Main Content

Nonvirtual Buses at Model Interfaces

A model reference boundary is the boundary between a model that contains a Model block and the referenced model. If bus data passes to a Model block, then that data crosses the boundary to the referenced model. Bus data input for the Model block must be consistent with the bus data that the referenced model requires.

For bus data that crosses model reference boundaries, decide whether to use a virtual or nonvirtual bus. Using a virtual bus can be simpler than using a nonvirtual bus. However, using a nonvirtual bus provides a well-defined data interface for code generation. To learn the differences between virtual and nonvirtual buses, see Types of Composite Signals.

Tip

For virtual buses at interfaces, use In Bus Element and Out Bus Element blocks. These blocks support multirate virtual buses and do not require Simulink.Bus objects.

For nonvirtual buses at interfaces, use Inport and Outport blocks.

Model Reference Requirements for Nonvirtual Buses

If you use a bus as an input to or an output from a referenced model:

  • Only a nonvirtual bus can contain variable-size signal elements.

  • For code generation, you can only configure the I/O arguments step method style of C++ class interface for the referenced model when using a nonvirtual bus or when using the Default style of C++ class interface.

  • For code generation, you can only configure function prototype control for the referenced model when using a nonvirtual bus.

Nonvirtual Buses with Root-Level Inport Blocks

To pass a bus from a root-level 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 that defines the bus the Inport block produces.

To output a nonvirtual bus from the root-level Inport block, select Output as nonvirtual bus in the Block Parameters dialog box of the Inport block.

All signals in a nonvirtual bus must have the same sample time. For details, see Modify Sample Times for Nonvirtual Buses.

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

Nonvirtual Buses with Root-Level Outport Blocks

To pass a bus through a root-level Outport block of a referenced model, 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 that defines the bus the Outport block produces.

To output a nonvirtual bus from the port that corresponds to the root-level Outport block, select Output as nonvirtual bus in parent model in the Block Parameters dialog box of the Outport block.

All signals in a nonvirtual bus must have the same sample time. For details, see Modify Sample Times for Nonvirtual Buses.

Rate Transitions for Nonvirtual Buses

To pass a multirate bus as a nonvirtual bus into a referenced model, use an Inport block. Add blocks in the parent and referenced model as follows:

  1. In the parent model, convert the multirate bus to a single-rate bus by inserting a Rate Transition block. Inport blocks can only pass single-rate nonvirtual buses into referenced models. The Rate Transition block must specify a rate in its Block Parameters > Output port sample time field unless one of the following is true:

    • The Configuration Parameters > Solver pane specifies a rate with these settings:

      • The Periodic sample time constraint parameter is set to Specified.

      • The Sample time properties parameter contains the specified rate.

    • The Inport block that accepts the nonvirtual bus in the referenced model specifies a rate in its Block Properties > Signal Attributes > Sample time field.

  2. In the referenced model, use a Bus Selector block to pick out signals of interest, and use Rate Transition blocks to convert the signals to the desired rates.

See Also

Blocks

Related Topics