Compare Capabilities of Composite Interfaces
Before you implement a piece of your system using a specific type of composite interface, consider whether the type satisfies your requirements for composite interface elements, modeling, and code generation.
Tip
To identify which composite interfaces to consider based on high-level guidelines and ideal use cases, see Choose Among Composite Interfaces.
For physical conserving connections, see Simscape Bus (Simscape).
Based on best practices for composite interfaces, these comparison tables focus on buses.
Composite Interface Elements
Composite Interface Elements Requirement | Virtual Buses | Nonvirtual Buses | Arrays of Buses |
---|---|---|---|
Hierarchical elements | Supported Elements of virtual buses can have hierarchy. | Supported Elements of nonvirtual buses can have hierarchy. | Supported While the array of buses is flat, the nested buses can have hierarchy. |
Elements with different sample times | Supported Elements of virtual buses can have different sample times. | Not supported All elements of a nonvirtual bus must use the same sample time. Use a Rate Transition block to change the sample time of signals in a bus. For more information, see Modify Sample Times for Nonvirtual Buses. | Not supported All elements of an array of buses must use the same sample time. |
Elements with different data types | Supported Elements of virtual buses can have different data types. | Supported Elements of nonvirtual buses can have different data types. | Supported Top-level elements
of arrays of buses must specify the same |
Variable-size signals | Supported Virtual buses can contain variable-size signals as long as they are not used as inputs to or outputs from a referenced model. | Supported Nonvirtual buses can contain variable-size signals. Signal logging is supported for nonvirtual buses with variable-size signals when running a simulation in normal or accelerator mode. (since R2023a) | Supported Arrays of buses can contain variable-size signals only for simulations in normal mode. Signal logging is supported for arrays of buses with variable-size signals only when running a simulation in normal mode. (since R2023a) |
Function-call signals | Supported Virtual buses can
contain function-call signals. The virtual bus must not be defined by a
| Not supported Nonvirtual buses cannot contain function-call signals. | Not supported Arrays of buses cannot contain function-call signals. |
Messages | Supported Virtual buses can have message elements as long as they do not also have signal elements. | Not supported Nonvirtual buses can contain only signal elements. Messages can have nonvirtual bus payloads. | Not supported The nested nonvirtual buses in arrays of buses cannot have message elements. |
Composite Interface Modeling
Composite Interface Modeling Requirement | Virtual Buses | Nonvirtual Buses | Arrays of Buses |
---|---|---|---|
Name-based element access | Supported Access elements of virtual buses by name. | Supported Access elements of nonvirtual buses by name. | Supported Access top-level elements of arrays of buses by index. Then, access elements of the nested buses by name. |
Element access at component input ports | Supported To select elements of a virtual bus at an input port, use In Bus Element blocks. | Supported To select elements of a nonvirtual bus at an input port, use In Bus Element blocks. | Not supported In Bus Element blocks can pass arrays of buses through the interface, but they cannot select the index-based elements of arrays of buses. |
Composite interface definition at component input ports | Supported To define an input virtual bus for a model component, specify the virtual bus and its elements with one or more In Bus Element blocks. | Supported To define an input nonvirtual bus for a model component, specify the nonvirtual bus with one or more In Bus Element blocks. For the element that you want to be a nonvirtual bus:
| Supported To define an input array of buses for a model component, specify the array of buses with an In Bus Element block. For the element that you want to be an array of buses:
|
Composite interface creation at component output ports | Supported To create a virtual bus at an output port, connect the desired elements of the virtual bus to Out Bus Element blocks that correspond to the same output port. | Supported To create a nonvirtual bus at an output port, connect the desired elements of the nonvirtual bus to Out Bus Element blocks that correspond to the same output port. Then, edit the signal attributes of the bus.
| Not supported Out Bus Element blocks can pass arrays of buses through the interface, but they cannot create arrays of buses. |
Incremental interface changes | Supported Virtual buses support incremental interface changes. Use In Bus Element and Out Bus Element blocks to modify the bus at the interface. | Not supported Nonvirtual
buses are defined by | Not supported You can change the dimensions of an array of buses at an interface. The nested buses
are defined by a |
Defined interfaces in simulation | Supported To define the
properties of a virtual bus, you can specify a | Supported Nonvirtual buses
specify the properties of their elements with | Supported Arrays of buses
specify the properties of their elements with |
Iterative processing of subsystems | Not supported Virtual buses do not support iterative processing of subsystems. | Supported Group nonvirtual buses in arrays of buses to iteratively process them in a subsystem such as a for-each, while-iterator, or for-iterator subsystem. | Supported Arrays of buses let you iterate over a group of nonvirtual buses. Connect the array of buses to a subsystem such as a for-each, while-iterator, or for-iterator subsystem. |
Composite Interface Code Generation
Composite Interface Code Requirement | Virtual Buses | Nonvirtual Buses | Arrays of Buses |
---|---|---|---|
Data structures in generated code | Not supported While you can
specify a | Supported Nonvirtual buses
specify the properties of their elements with | Supported Arrays of buses
specify the properties of their elements with |
Partial data use | Supported Model components
use only the data of selected elements of a virtual bus that is not defined by a
When a
| Not supported Model components use all the data of a nonvirtual bus. | Not supported Model components use all the data of an array of buses. |
Partial signal copies | Supported When model compilation requires signal copies for a virtual bus, Simulink® can copy elements of the bus instead of the entire bus. If a | Not supported When model compilation requires signal copies for a nonvirtual bus, Simulink copies the entire bus. | Not supported When model compilation requires signal copies for an array of buses, Simulink copies the entire array of buses. |
Note
For additional code generation considerations, see:
Generate Efficient Code for Bus Signals (Simulink Coder)
Organize Data into Structures in Generated Code (Simulink Coder)
Code Generation of Matrices and Arrays (Simulink Coder)