This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Logic Analyzer

Visualize, measure, and analyze transitions and states over time

Description

The Logic Analyzer is a tool for visualizing and inspecting signals 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+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

Open the Logic Analyzer

Simulink Toolbar: Click the Logic Analyzer button . If the button is not displayed, click the Simulation Data Inspector button arrow and select Logic Analyzer from the menu.

Your most recent choice for data visualization is saved across Simulink sessions.

Examples

Select Signals to Analyze

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 click the Logic Analyzer button arrow and select Log Selected Signals.

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.

Modify Global Settings

Open the Logic Analyzer and select Settings from the toolstrip. A global settings dialog box opens. Any setting you change for an individual signal supersedes the global setting.

Set the display Radix of your signals as one of the following:

  • Hexadecimal — Displays values as symbols from zero to nine and A to F

  • Octal — Displays values as numbers from zero to seven

  • Binary — Displays values as zeros and ones

  • Signed decimal — Displays the signed, stored integer value

  • Unsigned decimal — Displays the stored integer value

Set the display Format as one of the following:

  • Automatic — Displays floating point signals in Analog format and integer and fixed-point signals in Digital format. Boolean signals are displayed as zero or one.

  • Analog — Displays values as an analog plot

  • Digital — Displays values as digital transitions

Set the display Time Units to one of the following:

  • Automatic — Uses a time scale appropriate to the time range shown in the current plot

  • seconds

  • milliseconds

  • microseconds

  • nanoseconds

  • picoseconds

  • femtoseconds

Set the Boolean Highlighting to one of the following:

  • None

  • Rows — Adds a highlighted background for the entire Boolean signal row.

    Select Highlight boolean values to add highlighting to Boolean signals.

  • Gradient— Adds color highlighting to Boolean signals based on value. If the signal value is true, the highlight fades out below. If the signal value is false, the signal fades out above. With this option, you can visually deduce the value of the signal.

Inspect the graphic for an explanation of the global settings: Wave Color, Axes Color, Height, Font Size, and Spacing. Font Size applies only to the text within the axes.

By default, when your simulation stops, the Logic Analyzer shows all the data for the simulation time on one screen. If you do not want this behavior, clear Fit to view at Stop. This option is disabled for long simulation times.

To display the short names of waves without path information, select Display short wave names.

You can expand fixed-point and integer signals and view individual bits. The Display Least Significant bit first option enables you to reverse the order of the displayed bits.

If you stream bus signals to the Logic Analyzer, you can display the names of the signals inside the bus using the Display bus element names option. To show bus element names:

  1. Add the bus signal for streaming.

  2. In the Logic Analyzer settings, select the Display bus element names check box.

  3. Run the simulation.

When you expand the bus signals, you will see the bus signal names.

Some special situations:

  • If the signal has no name, the Logic Analyzer shows the block name instead.

  • If the bus is a bus object, the Logic Analyzer shows the bus element names specified in the Bus Object Editor.

  • If one of the bus elements contains an array, each element of the array is appended with the element index.

  • If a bus element contains an array with complex elements, the real and complex values (i) are split.

  • Bus signals passed through a Gain block are labeled Gain(1), Gain(2),...Gain(n).

  • If the bus contains an array of buses, the Logic Analyzer prepends the element name with the bus array index.

Modify Individual Wave Settings

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.

Delete and Restore Waves

  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.

Add Trigger

The Logic Analyzer trigger allows you to find data points based on certain conditions. This feature is useful for debugging or testing when you need to find a specific signal change.

  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.

Choose Visible Instance of Multi-Instance Model Block

The Logic Analyzer can stream only a single instance of a multi-instance Model block. This example shows how to select an instance of a multi-instance Model block for streaming on the Logic Analyzer.

  1. Open the multipleModelInstances model:

    open_system(fullfile(matlabroot,'examples','dsp','multipleModelInstances.slx'))

    The model contains three instances of the referencedModel model.

  2. Double-click any of the Model blocks to open the model referenced by all three Model blocks.

  3. Open the Logic Analyzer in the referenced model.

  4. From the multipleModelInstances model, run the model. The Logic Analyzer displays a single instance of a multi-instant Model block.

  5. To switch between instances, from the Simulink Editor menu, select Diagram > Subsystem & Model Reference > Model Block Normal Mode Visibility. Select Model Instance 3 and then click OK.

  6. Run the multipleModelInstances model again. The Logic Analyzer displays Model Instance 3 data.

View Bit-Expanded Wave and Reverse Display Order of Bits

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.

Add Triggers to Verify Write Operation

This example shows how to use a trigger to verify that the signals are matching the design.

  1. Open the Programmable FIR Filter model (dspprogfirhdl).

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

  3. To add a trigger, in the toolstrip, select Attach Signals and attach the write enable Write En signal. An icon appears in front of the signal name to indicate it is attached to a trigger. The icon changes depending on the type of trigger.

  4. Select Set Conditions and change the trigger condition for the Write En signal to Falling Edge. The trigger will show when the write enable signal was sent.

  5. Attach the Write Done signal to the trigger. Keep the trigger condition for this signal as the default, Rising Edge. Now, the trigger will also show when the write was completed.

    If you open the Set Conditions drop down, you see an Operator field. This field appears when multiple signals are attached to the trigger. Change the operator to OR so that the trigger will show instances where a write was started or completed.

  6. Set the Display Mode to Auto. With this setting, the Logic Analyzer marks all locations where the trigger conditions are met.

  7. Select Enable Trigger and run the simulation.

    Each time the trigger conditions are met, the Logic Analyzer marks the time with a locked blue cursor. At each marked location, Write En is 0 and Write Done is 1. If you examine each location marked by a trigger, you can verify that each time a write is sent, it is also completed.

Related Examples

Limitations

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

  • If you enable the configuration parameter Log Dataset data to file, you cannot stream logged data to the Logic Analyzer.

  • While the simulation is running, the following features are disabled: zoom and pan and modifying the trigger.

  • For large simulations, fit to view zooming is disabled.

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

  • Constants marked for streaming are visualized as a straight line.

  • Signals marked for streaming using Simulink.sdi.markSignalForStreaming or Dashboard Scope do not appear on the Logic Analyzer.

  • Integers are supported up to 64 bits and fixed-point signals are supported up to 128 bits.

  • You can use the Logic Analyzer in models running the following supported simulation modes.

    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, then the following signals cannot be streamed into 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 (Simulink).

See Also

System Objects

Introduced in R2016b