Logic Analyzer
Visualize, measure, and analyze transitions and states over time
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
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, on the Signal tab, select the 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.
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
Open the Logic Analyzer and select a wave by clicking the wave name.
From the Logic Analyzer toolstrip, click
. The wave is removed from the Logic Analyzer.
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.
Save and Restore Views
You can save the current Logic Analyzer view as an 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.
This example model contains Sine Wave and Constant blocks, whose outputs are connected to an Add block.
Save Logic Analyzer View
To save the current view, follow these steps:
In your model, select the signals that you want to visualize in the Logic Analyzer.
Log selected signals and open the Logic Analyzer app.
This example logs the output signals from the Sine Wave, Constant, and Add blocks.
From the Logic Analyzer toolstrip, click Save View or press Ctrl+S.
In the window that opens, browse for the folder where you want to save the file. Then, name the file and click Save.
Open Logic Analyzer View
To open a saved view file, follow these steps:
Open the Logic Analyzer app.
From the Logic Analyzer toolstrip, click Open View or press Ctrl+O.
In the window that opens, browse for the folder where you saved the view file. Then, select the file and click Open. Logic Analyzer adds a divider named after the view file and the signals from the view file to the current view.
If you change a block or subsystem name in your Simulink model and open a saved Logic Analyzer view file, the file shows the updated signal names. For example, in the model in this example:
Change the name of the Sine Wave block to
Sine Signal
and Constant block toConstant Signal
.Compile or simulate your model and then open the saved view file. It shows the updated signal names.
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.
Open the Logic Analyzer and select the Trigger tab.
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.
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.
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.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.
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-Reference Model Block
The Logic Analyzer can stream only a single instance of a multi-instance Model block. If the same model is opened across different windows, those models will share the same Logic Analyzer. This example shows how to select an instance of a multi-instance Model block for logging on the Logic Analyzer.
Open the multipleModelInstances
model.
open_system('multipleModelInstances')
The model contains three instances of the referencedModel
model.
Double-click any of the Model blocks to open the model referenced by all three Model blocks.
open_system('referencedModel')
In the referenced model, open Logic Analyzer by expanding Review Results gallery under Simulation tab in the Simulink Editor menu. You should see referencedModel - [multipleModelInstances]
in the toolbar of Logic Analyzer.
From the Logic Analyzer window, run the model. By running the simulation from a referenced version of referencedModel
, Simulink runs the top model (multipleModelInstances
) and referenced models (referencedModel
). The Logic Analyzer displays a single instance of a multi-instance Model block.
When you run a simulation, the logic analyzer runs the model listed in the Logic Analyzer toolbar. If this model is a referenced model, the toolbar also lists the top model and you will see results from running the top model. To view results from the referenced model in isolation, you must open the referenced model as a top model.
To switch between instances, expand the Prepare gallery from the Simulation tab in the Simulink Editor menu. Select Normal Mode Visibility under Signal Monitoring to open Model Block Normal Mode Visibility. Expand multipleModelInstances
, select Model Instance 3 and click OK.
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.
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.
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.
Open the Programmable FIR Filter model (
dspprogfirhdl
).Open the Logic Analyzer and select the Trigger tab.
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.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.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.Set the Display Mode to
Auto
. With this setting, the Logic Analyzer marks all locations where the trigger conditions are met.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
is0
andWrite Done
is1
. If you examine each location marked by a trigger, you can verify that each time a write is sent, it is also completed.
View Stateflow States in Logic Analyzer
Use the Logic Analyzer to visualize and measure transitions and states over time. With the Logic Analyzer, you can visualize:
Output data from your chart
Child and leaf state activity for your chart
Self, child, and leaf state activity for your states
You can measure the output over time and add triggers to identify the output values at specified events.
Add Signals and States for Logging
In this example, you use the Logic Analyzer to visualize the
behavior of the engine RPM, the transmission and vehicle speed, and the gear
state in the model sf_car
.
Open the model
sf_car
.openExample("sf_car")
In the Simulink Editor, click the
engine RPM
signal. Then, in the Simulation tab, select Log Signals.The logging badge
appears above the signal to indicate that the data from the signal is logged when you run the model.
Repeat the previous step for the
transmission speed
andvehicle speed
signals.Open the
shift_logic
chart by clicking the arrow in the bottom-left corner of the block.Select the state
gear_state
. Then, in the Simulation tab, click Log Child Activity. The logging badgeappears in the corner of the state.
View Logged Output in Logic Analyzer
Simulate the model.
In the Simulation tab, under Review Results, select Logic Analyzer
. When you simulate the model, the icon is highlighted to indicate that the Logic Analyzer has new simulation data.
In the Logic Analyzer window, drag the yellow cursor to see the signal values at different points in the simulation. For example, you can see the reaction of the engine RPM as the car gears change. For more information, see Inspect and Measure Transitions Using the Logic Analyzer.
Related Examples
- Inspect and Measure Transitions Using the Logic Analyzer
- Visualize Multiple Signals Using Logic Analyzer
- Partly Serial Systolic FIR Filter Implementation (DSP HDL Toolbox)
- Fully Parallel Systolic FIR Filter Implementation (DSP HDL Toolbox)
- Configure Logic Analyzer
- Programmable FIR Filter for FPGA (HDL Coder)
- Log Simulation Output for States and Data (Stateflow)
Limitations
Logging Settings
If you enable the configuration parameter Log data to file (Simulink), you cannot stream logged data to the Logic Analyzer.
Signals marked for logging using
Simulink.sdi.markSignalForStreaming
(Simulink) or visualized with a Dashboard Scope (Simulink) do not appear on the Logic Analyzer.You cannot visualize Data Store Memory (Simulink) block signals in the Logic Analyzer if you set the Log data store data parameter to on.
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. To verify results, enable signal logging, or use a Display block.
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 display any waveform for
Inf
andNaN
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.
Mode | Supported | Notes and Limitations |
---|---|---|
Normal | Yes | |
Accelerator | Yes | You cannot use the Logic Analyzer to visualize
signals in Model (Simulink) blocks
with Simulation mode set to
|
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:
|
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).
Version History
Introduced in R2016b