Main Content

Display Bus Information

You can display bus information using multiple approaches.

Display Bus Hierarchy

To interactively display bus hierarchy:

  1. Click a signal line.

  2. On theSignaltab, select信号层次结构.

    A Signal Hierarchy Viewer opens, showing the signal hierarchy for the selected signal.

For example, this Signal Hierarchy Viewer shows the signal hierarchy for a bus namedmain_bus.

The Signal Hierarchy Viewer shows the hierarchy for a bus with two nested buses that contain two and three elements respectively.

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.

Note

To produce accurate results at edit time in the Signal Hierarchy Viewer, your model must compile successfully.

To filter the displayed signals, click theOptionsbuttonon the right side of theFilter by nameedit box.

  • To use MATLAB®regular expressions for filtering signal names, select使正则表达式. For example, to display all signals whose names end with a lowercaser(and their immediate parents), enterr $在里面Filter by nameedit box. For more information, seeRegular Expressions.

  • To display a flat list of the filtered results, selectShow filtered results as a flat list. The flat list uses dot notation to indicate the hierarchy of buses. This example shows a filtered set of nested buses.

    匹配过滤器的嵌套的公共汽车使用点符号表示其层次结构

Display Value of Bus Elements

To interactively display the values of bus elements at a port:

  1. Click a signal line.

  2. On theSignaltab, selectOutput Value Label.

  3. Click the port value label, and select the signals you want to display.

    For example, in this model, you can select which signals to display from the signals that are contained inModelBus.

For more information, seeDisplay Value for a Specific Port.

以编程方式获得总线层次结构和虚拟性

To programmatically get the hierarchy and virtuality of a bus in a compiled model, query these parameters with theget_paramcommand:

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

  • “编译”- 对于一个模型“编译”phase, returns information about whether the signal connected to a port is a bus and whether the signal is a virtual or nonvirtual bus. Before you query the汇编的布斯特型parameter value, use themodelfunction to put the model in the“编译”phase.

For example, open and simulate thebusdemomodel.

open_system('busdemo') sim('busdemo');

获取所需的公交信息的端口的手柄。

ph = get_param(['busdemo/Bus Creator'],“ Porthandles”);

Get the signal hierarchy at the port.

sh = get_param(ph.Outport,'SignalHierarchy')
sh =带字段的结构:信号名称:'main_bus'busObject:''儿童:[2×1 struct]

Get the compiled bus type at the port while the model is compiling.

busdemo([],[],[],,“编译”); bt = get_param(ph.Outport,“编译”)
bt ='virtual_bus'

Terminate compilation.

busdemo([],[],[],,'term');

相关话题