Main Content

cgsl_0204: Vector and bus signals crossing into atomic subsystems or Model blocks

ID: Titlecgsl_0204: Vector and bus signals crossing into atomic subsystems or Model blocks
DescriptionWhen working with vector or bus signals and some of the signal elements are in an atomic subsystem or a referenced model, use the following information to determine how to select signal elements to minimize memory usage.
A

Bus or vector entering an atomic subsystem:

Function packaging: Non-reusable function

Function interface: void_void

 Signals selected outside subsystem results in...Signal selected inside subsystem results in...
Virtual BusNo data copies.No data copies.
Nonvirtual BusNo data copies.No data copies.
VectorA copy of the selected signals in global block I/O structure that is used in the function.No data copies.

Function packaging: Non-reusable function

Function interface: Allow arguments (Optimized)

 Signals selected outside subsystem results inSignal selected inside subsystem results in
Virtual BusNo data copies. Only the selected signals are passed to the function.No data copies. Only the selected signals are passed to the function.
Nonvirtual BusNo data copies. Only the selected signals are passed to the function.No data copies. The whole bus is passed to the function.
VectorA copy of the selected signals in a local variable that is passed to the function.No data copies. The whole vector is passed to the function.

Function packaging: Reusable function

 Signals selected outside subsystem results inSignal selected inside the subsystem results in
Virtual BusNo data copies. Only the selected signals are passed to the function.No data copies. Only the selected signals are passed to the function.
Nonvirtual BusNo data copies. Only the selected signals are passed to the function. See example 1. No data copies. The whole bus is passed to the function.
VectorA copy of the selected signals in a local variable that is passed to the function.No data copies. The whole vector is passed to the function.

 
B

Bus or vector entering a Model block:

 Signals selected outside Model block results in...Signal selected inside Model block results in...
Virtual BusNo data copies. Only selected signals are passed to the function.

If Inport block parameter Output as nonvirtual bus is selected, then there are no data copies. Only the selected signals are passed to the function.

If Inport block parameter Output as nonvirtual bus is cleared, then a copy of the whole bus is passed to the function.

Nonvirtual BusNo data copies. Only the selected signals are passed to the function.

If Inport block parameter Output as nonvirtual bus is selected, then there are no data copies. Only the selected signals are passed to the function.

If Inport block parameter Output as nonvirtual bus is cleared, then a copy of the whole bus is passed to the function. See example 2.

VectorA copy of the selected signals in a local variable that is passed to the function.No data copies. The whole vector is passed to the function.

Notes
  • Depending on Embedded Coder® settings (e.g. optimizations), predecessor blocks and signal storage classes, actual results might differ from the tables.

  • Virtual busses do not support global data.

  • If the subsystem is set to Inline, data copies do not occur.

RationaleA, BMinimize RAM, ROM, and stack usage
Last ChangedR2016a
Examples

Example 1: Nonvirtual bus entering an atomic subsystem

  • Function packaging: Reusable function

  • Selection: Subsignal selected outside the subsystem

Only the selected signals are passed to the function:

Example 2: Nonvirtual bus entering a model block

  • Total number of instances allowed per top model: Multiple

  • Selection: Subsignal selected inside the referenced model

There are no data copies in the code for the main model. The whole bus is passed to the model reference function.

Code for the model reference function: