Display Information About Buses

Viewing information about bus signals can help you during model creation, debugging, and analysis. To view information about buses, you can use different approaches, depending on your modeling task:

  • To display bus signals in a bus hierarchy interactively, use the Signal Hierarchy Viewer.

  • To display the value of a specific port or port values for a block before simulation, right click on the signal and select Show Value Label of Selected Port. For details, see Port Value Display.

  • To display at the MATLAB® command line the type and hierarchy of a bus signal use the CompiledType and SignalHierarchy parameters. For details, see CompiledBusType and SignalHierarchy Parameters.

Signal Hierarchy Viewer

You can use the Signal Hierarchy Viewer to display information about a signal. To display the bus hierarchy:

  1. Right-click a signal line.

  2. Select the Signal Hierarchy option. The Signal Hierarchy Viewer dialog box appears.

For example, open the busdemo model.

Right-click the main_bus signal (output signal for the Bus Creator block), and select Signal Hierarchy.

Each Signal Hierarchy Viewer is associated with a specific model. If you edit a model while the associated Signal Hierarchy Viewer is open, the Signal Hierarchy Viewer reflects those updates.

You can also open the Signal Hierarchy Viewer in the Simulink® Editor.

  1. Select a signal.

  2. On the Signal tab, in the Hierarchy section, click the Signal Hierarchy button.

Note

To produce accurate results at edit time, the Signal Hierarchy Viewer requires that the model compiles successfully.

To filter the displayed signals, click the Options button on the right-hand side of the Filter by name edit box ().

  • To use MATLAB regular expressions for filtering signal names, select Enable regular expression. For example, to display all signals whose names end with a lowercase r (and their immediate parents), enter r$ in the Filter by name edit box. For details, see Regular Expressions (MATLAB).

  • To use a flat list format to display the list of filtered signals, based on the search text in the Filter by name edit box, select Show filtered results as a flat list. The flat list format uses dot notation to reflect the hierarchy of bus signals. This example shows a flat list format for a filtered set of nested bus signals.

Port Value Display

To display the value of a specific port or port values for a block before simulation, right click on the signal and select Show Value Label of Selected Port.

For bus signals, the Show Value Label of Selected Port option opens a dialog box where you can select from all signals in the bus. For example, in this model, you can see the dialog box for all signals that are contained in ModelBus.

For more information about port value display, see Display Value for a Specific Port.

CompiledBusType and SignalHierarchy Parameters

To get information about the type and hierarchy of a bus signal in a compiled model, use these parameters with the get_param command:

  • CompiledBusType — For a compiled model, returns information about whether the signal connected to a port is a bus and whether the signal is a virtual or nonvirtual bus.

  • SignalHierarchy — If the signal is a bus, returns the name and hierarchy of the signals in the bus.

Before you use these commands, for CompiledBusType, update the diagram or simulate the model.

For example, open and simulate the busdemo model.

This code illustrates how you can use the SignalHierarchy and CompiledBusType parameters:

mdl = 'busdemo'; 
open_system(mdl)
% Obtain the handle a port
ph = get_param([mdl '/Bus Creator'], 'PortHandles');
% SignalHierarchy is available at edit time
sh = get_param(ph.Outport, 'SignalHierarchy')
% Compile the model
busdemo([],[],[],'compile');
bt = get_param(ph.Outport, 'CompiledBusType')
% Terminate the model
busdemo([],[],[],'term');

Related Topics