Bus Data Crossing Model Reference Boundaries

A model reference boundary refers to the boundary between a model that contains a Model block and the referenced model. If you have bus data in a model that is passed to a Model block, then that data crosses the boundary to the referenced model. You need to set up your model so that the bus data input to the Model block is consistent with the bus data that the referenced model requires.

For bus data that crosses model reference boundaries:

  1. Use a bus object (Simulink.Bus) to define the bus. For details, see When to Use Bus Objects and Create Bus Objects.

    You can use a nonvirtual or a virtual bus as an input to a referenced model.

  2. Decide whether to use a virtual or nonvirtual bus. Using a nonvirtual bus provides a well-defined data interface for code generation. See Virtual and Nonvirtual Buses.

To use a multi-rate bus signal across a model referenced boundary requires a specific configuration of parameters in the parent and referenced models.

Connect Multi-Rate Buses to Referenced Models

You can input a single-rate bus to a referenced model. To input the signals in a multi-rate bus to a referenced model, insert blocks into the parent and referenced model as follows:

  1. In the parent model: To convert the multi-rate bus to a single-rate bus, insert a Rate Transition block. 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 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.

Limitations for Virtual Buses

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

  • The bus cannot contain a variable-size signal element.

    As a workaround, use a nonvirtual bus instead.

  • For code generation, you cannot configure the I/O arguments step method style of C++ class interface for the referenced model.

    As a workaround, use a nonvirtual bus instead. Alternatively, use the Default style of C++ class interface.

  • For code generation, you cannot configure function prototype control for the referenced model.

    As a workaround, use a nonvirtual bus instead.

Use the Upgrade Advisor to fix models saved before R2016a that engage these limitations. See Update Models Saved Before R2016a.

Update Models Saved Before R2016a

The behavior of models that meet these criteria is different than it is in R2016a and later releases:

  • The model was saved in a release earlier than R2016a.

  • The model has referenced models with bus inputs and outputs configured to be treated as virtual buses.

Use the Upgrade Advisor Check for virtual bus across model reference boundaries check to avoid errors that the behavior differences can trigger. Run the Analyze model hierarchy and continue upgrade sequence check on the top-level model and then down through the model reference hierarchy.

See Also



Related Examples

More About

Was this topic helpful?