Main Content

Logic Analyzer

Visualize, measure, and analyze transitions and states over time

Description

The Logic Analyzer is a tool for visualizing and inspecting signals and states in your Simulink® model. Using the Logic Analyzer, you can:

  • Debug and analyze models

  • Trace and correlate many signals simultaneously

  • Detect and analyze timing violations

  • Trace system execution

  • Detect signal changes using triggers

For keyboard shortcuts, click More.

Keyboard Shortcuts

ActionsDescriptionApplicable When
Ctrl+SSave viewAlways
Ctrl+OOpen viewAlways
Ctrl+XCutWave is selected
Ctrl+CCopyWave is selected
Ctrl+VPasteWave is selected
DeleteDeleteWave is selected
Ctrl+-Zoom outAlways
Shift+Ctrl+-Zoom out around active cursorAlways
Ctrl++Zoom inAlways
Shift+Ctrl++Zoom out around active cursorAlways
Shift+Ctrl+CMove display to active cursorWhen cursor is not in the display range
SpaceZoom out fullAlways
Tab, Right ArrowNext transitionDigital format wave is selected
Shift+Tab, Left ArrowPrevious transitionDigital format wave is selected
Ctrl+ASelect all wavesAlways
Up ArrowSelect wave above selectedWave is selected
Down ArrowSelect wave below selectionWave is selected
Ctrl+Up ArrowMove selected waves upWave is selected
Ctrl+Down ArrowMove selected waves downWave is selected
EscapeUnselect all signalsWave is selected
Page UpScroll upAlways
Page DownScroll downAlways
Logic Analyzer app

Open the Logic Analyzer App

On the Simulation tab in the Simulink Editor menu, click the Logic Analyzer app button. If the button is not displayed, expand the Review Results gallery and you will find the Logic Analyzer app under Signal Logging Results. Your most recent choice for data visualization is saved across Simulink sessions.

To visualize referenced models, you must open the Logic Analyzer from the referenced model. You should see the name of the referenced model in the Logic Analyzer toolbar.

Examples

expand all

The Logic Analyzer supports several methods for selecting data to visualize.

  • Select a signal in your model. When you select a signal, an ellipsis appears above the signal line. Hover over the ellipsis to view options and then select the Enable Data Logging option.

  • Right-click a signal in your model to open an options dialog box. Select the Log Selected Signals option.

  • Use any method to select multiple signal lines in your model. For example, use Shift+click to select multiple lines individually or CTRL+A to select all lines at once. Then, on the Signal tab, select the Log Signals button.

    Log signals button

To visualize data in the Logic Analyzer, you must enable signal logging for the model. (Logging is on by default.) To enable signal logging, open Model Settings from the toolstrip, navigate to the Data Import/Export pane, and select Signal logging.

When you open the Logic Analyzer, all signals marked for logging are listed. You can add and delete waves from your Logic Analyzer while it is open. Adding and deleting signals does not disable logging, only removes the signal from the Logic Analyzer.

Open the Logic Analyzer and select a wave by double-clicking the wave name. Then from the Wave tab, set parameters specific to the individual wave you selected. Any setting made on individual signals supersedes the global setting. To return individual wave parameters to the global settings, click Reset.

  1. Open the Logic Analyzer and select a wave by clicking the wave name.

  2. From the Logic Analyzer toolstrip, click . The wave is removed from the Logic Analyzer.

  3. To restore the wave, from the Logic Analyzer toolstrip, click .

    A divider named Restored Waves is added to the bottom of your channels, with all deleted waves placed below it.

You can save the current Logic Analyzer view as MLDATX file and open it later. A Logic Analyzer view saves the signal layout and appearance characteristics without saving the data. Specifically, a view saves the signal names, signal groups, dividers, and their respective settings, including their order.

Note

Saving of Stateflow® signals is not supported.

To save the current view, follow these steps:

  1. In your model, select the signals that you want to visualize in the Logic Analyzer.

  2. Log selected signals and open the Logic Analyzer app.

  3. From the Logic Analyzer toolstrip, click Save View or press Ctrl+S.

    Logic Analyzer toolstrip highlighted on Save View button

  4. In the window that opens, browse for the folder where you want to save the file. Then, name the file and click Save.

To open a saved view file, follow these steps:

  1. Open the Logic Analyzer app.

  2. From the Logic Analyzer toolstrip, click Open View or press Ctrl+O.

    Logic Analyzer toolstrip highlighted on Open View button

  3. In the window that opens, browse for the folder where you saved the view file. Then, select the file and click Open. It adds a divider named after the view file and the signals from the view file to the current view.

    Logic Analyzer view with a divider named after the view file and signals from the view file

  1. Open the Logic Analyzer and select the Trigger tab.

  2. To attach a signal to the trigger, select Attach Signals, then select the signal you want to trigger on. You can attach up to 20 signals to the trigger. Each signal can have only one triggering condition.

  3. By default, the trigger looks for rising edges in the attached signals. You can set the trigger to look for rising or falling edges, bit sequences, or a comparison value. To change the triggering conditions, select Set Conditions.

    If you add multiple signals to the trigger, control the trigger logic using the Operator option:

    • AND - match all conditions.

    • OR - match any condition.

  4. To control how many samples you see before triggering, set the Display Samples option. For example, if you set this option to 500, the Logic Analyzer tries to give you 500 samples before the trigger. Depending on the simulation, the Logic Analyzer may show more or fewer than 500 samples before the trigger. However, if the trigger is found before the 500th sample, the Logic Analyzer still shows the trigger.

  5. Control the trigger mode using Display Mode.

    • Once - The Logic Analyzer marks only the first location matching the trigger conditions and stops showing updates to the Logic Analyzer. If you want to reset the trigger, select Rearm Trigger. Relative to the current simulation time, the Logic Analyzer shows the next matching trigger event.

    • Auto - The Logic Analyzer marks every location matching the trigger conditions.

  6. Before running the simulation, select Enable Trigger. A blue cursor appears as time 0. Then, run the simulation. When a trigger is found, the Logic Analyzer marks the location with a locked blue cursor.

The Logic Analyzer enables you to bit-expand fixed-point and integer waves.

  1. In the Logic Analyzer, click the arrow next to a fixed-point or integer wave to view the bits.

    The least significant bit and the most significant bit are marked with lsb and msb next to the wave names.

  2. Click Settings, and then select Display Least Significant bit first to reverse the order of the displayed bits.

Related Examples

Limitations

Logging Settings

Input Signal Limitations

  • Signals marked for logging for the Logic Analyzer must have fewer than 8000 samples per simulation step.

  • The Logic Analyzer does not support frame-based processing.

  • For 64-bit integers and fixed-point numbers greater than 53 bits, if the numbers are greater than the maximum value of double precision, the transitions between numbers might not display correctly.

  • You may see performance degradation in the Logic Analyzer for large matrices (greater than 500 elements) and buses with more than 1000 signals.

  • The Logic Analyzer app does not support Stateflow data output.

  • The Logic Analyzer app does not save Stateflow signals when you save the current Logic Analyzer view.

  • The Logic Analyzer app does not display any waveform for Inf and NaN values.

Graphical Settings

  • While the simulation is running, you cannot zoom, pan, or modify the trigger.

  • To visualize constant signals, in the settings, you must set the Format to Digital. Constants marked for logging are visualized as a continuous transition.

ModeSupportedNotes and Limitations

Normal

Yes

 

Accelerator

Yes

You cannot use the Logic Analyzer to visualize signals in Model blocks with Simulation mode set to Accelerator.

Rapid Accelerator

Yes

Data is not available in the Logic Analyzer during simulation.

If you simulate a model with the simulation mode set to rapid accelerator, after simulation the following signals cannot be visualized in the Logic Analyzer:

  • Multi-instance model reference signals

  • Nonvirtual bus signals

Processor-in-the-loop (PIL)

No

 

Software-in-the-loop (SIL)

No

 

External

No

 

For more information about these modes, see How Acceleration Modes Work.

Version History

Introduced in R2016b