You need to perform some special configuration steps to have a model:
Produce a bus signal as an output of a root-level Inport block
Accept a virtual bus as an input to a root-level Outport block
Accept a bus as an input to a nonvirtual Inport block in an atomic subsystem
To produce a bus signal as an output of a root-level Inport block, in the Block Parameters dialog box of the Inport block:
Set the Data type parameter to
<object name> with the name of the bus
object name that defines the bus that the Inport
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.
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
<object name> with the name of the
bus object name that defines the bus that the Outport
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.
In a model reference hierarchy, if the bus signal in a top-level 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.
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.
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 the first condition is violated (that is, the bus elements have different data types), attempting to simulate the model halts the simulation and produces an error message. To avoid this problem without changing the semantics of your model, insert a Signal Conversion block between the Inport block and the Outport block to which it was originally connected.
For example, the following model, which includes an atomic subsystem, does not simulate.
Starting the simulation generates the following error messages:
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) is directly
connected to one of the subsystem outputs. 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
Signal copy. Inserting the Signal
Conversion block enables you to simulate the model.