Buses at Model Reference Interfaces

To select virtual bus element inputs, you can use In Bus Element blocks. To create virtual bus outputs, you can use Out Bus Element blocks.

For nonvirtual buses, you must use Inport and Outport blocks.

Use Buses with Root-Level Inport Blocks

To pass a bus from an Inport block into a referenced model, in the Block Parameters dialog box of the Inport block:

  • Set the Data type parameter to Bus: <object name>

  • Replace <object name> with the name of the bus object name that defines the bus that the Inport block produces.

Root-level Inport blocks convert virtual buses to nonvirtual buses. All signals in a nonvirtual bus must have the same sample time. For details, see Specify Bus Signal Sample Times.

For information about importing data to root-level Inport blocks, see Load Bus Data to Root-Level Input Ports.

Use Buses with Root-Level Outport Blocks

Root-level Outport blocks convert virtual buses to nonvirtual buses. All signals in a nonvirtual bus must have the same sample time. For details, see Specify Bus Signal Sample Times.

A root level Outport block of a model can accept a virtual bus only if all elements of the bus have the same data type. The Outport block automatically converts the bus to a vector having the same number of elements as the bus, and outputs that vector.

To use a bus signal that contains mixed data types as an input to a root-level Outport block, in the Block Parameters dialog box of the Outport block:

  • Set Data type to Bus: <object name>.

  • Replace <object name> with the name of the bus object name that defines the bus that the Outport block produces.

In a model hierarchy, if the bus signal in a top model is virtual, the signal is converted to nonvirtual (see Bus Conversion). For information about using buses as inputs to or outputs from a referenced model, see Bus Data Crossing Model Reference Boundaries.

Use Buses with Atomic Subsystem Nonvirtual Inport Blocks

By default, an Inport block is a virtual block and accepts a bus as input. However, an Inport block is nonvirtual if both of these conditions exist:

  • The Inport block is in an atomic subsystem.

  • The signal or any of its elements (if the signal is a bus) are directly connected to the output of the subsystem.

For information about the difference between virtual and nonvirtual blocks, see Nonvirtual and Virtual Blocks.

The Inport block can accept a bus when either of these conditions is true:

  • All elements of the bus can be converted to a vector (all the elements must have the same data type).

  • The bus is a nonvirtual bus.

If bus elements have different data types, attempting to simulate the model halts the simulation and produces an error message. You can avoid violating this condition without changing the semantics of your model by inserting a Signal Conversion block between the Inport and Outport blocks.

For example, the following model, which includes an atomic subsystem, does not simulate.

In the subsystem, the Inport block labeled nonvirtual is nonvirtual because it resides in an atomic subsystem and one of its bus elements (labeled a) directly connects to a subsystem output.

Further, the bus (bus1) connected to the subsystem inputs has elements of differing data types. As a result, you cannot simulate this model.

To break the direct connection to the subsystem output, after the nonvirtual Inport block, insert a Signal Conversion block. Set the Signal Conversion block Output parameter to Signal copy. Inserting the Signal Conversion block enables you to simulate the model.

See Also

Blocks

Related Topics