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.
To identify which composite interfaces to consider based on high-level guidelines and ideal use cases, see Explore Composite Interfaces.
Composite Interface Elements
Requirement | Virtual Buses | Nonvirtual Buses | Arrays of Buses | Arrays |
---|---|---|---|---|
Hierarchical elements | Supported Elements of virtual buses can have hierarchy. | Supported Elements of nonvirtual buses can have hierarchy. | Supported While an array of buses is flat, the nested buses can have hierarchy. | Not supported While you can concatenate signals in stages to create an array, the result is flat, as if you used a single block to concatenate the signals. |
Elements with different sample times | Supported Elements of virtual buses can have different sample times. For faster model compilation, use the same sample time for each element of a virtual bus. To change the sample time of an input element, use a Rate Transition block. | 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. | Not supported All elements of an array 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 | Not supported All elements of an array must have the same data type. |
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) | Supported Arrays can contain variable-size signals. |
Function-call signals | Supported A virtual bus can contain
function-call signals as long as the bus is not defined by a
| Not supported Nonvirtual buses do not support function-call signals. | Not supported Arrays of buses do not support function-call signals. | Not supported Arrays do not support function-call signals. To group function-call signals in a virtual vector, see Mux. |
Messages | Supported Virtual buses can have message elements as long as they do not also have signal elements. | Not supported Nonvirtual buses cannot contain message elements. | Not supported Arrays of buses cannot contain message elements. | Not supported Arrays cannot contain message elements. |
Physical conserving connections | Not supported Simulink® buses do not support physical conserving connections. To group physical conserving connections, use a Simscape Bus (Simscape) block. | Not supported Simulink buses do not support physical conserving connections. | Not supported Arrays of buses do not support physical conserving connections. | Supported Arrays support physical conserving connections. For more information, see Nonscalar Physical Signal Connections (Simscape). |
Composite Interface Modeling
Requirement | Virtual Buses | Nonvirtual Buses | Arrays of Buses | Arrays |
---|---|---|---|---|
Name-based element access | Supported You can access the elements of virtual buses by name. | Supported You can access the elements of nonvirtual buses by name. | Not supported You can access the top-level elements of arrays of buses only by index. | Not supported You can access the elements of an array only by index. |
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 an array of buses through the interface, but they cannot select the index-based elements of arrays of buses. | Not supported In Bus Element blocks can pass an array through the interface, but they cannot select the index-based elements of the array. |
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:
| Supported To define an input array
for a model component, specify the array with a |
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 an array of buses through the interface, but they cannot create an array of buses. | Not supported Out Bus Element blocks can pass an array through the interface, but they cannot create an array. |
Incremental interface changes using port blocks | Supported You can add, remove, and modify elements of a virtual bus at an interface with or without changing the block diagram by using In Bus Element and Out Bus Element blocks. | Not supported You cannot make incremental interface changes to nonvirtual buses using port blocks. To modify a nonvirtual bus, modify the
corresponding | Not supported While you can change the dimensions of an array of buses at an interface by using port blocks, you cannot change the elements at the interface. To modify the elements of an array of
buses, modify the corresponding | Not supported You cannot make incremental interface changes to arrays using port blocks. To modify an array, use Selector and Vector Concatenate blocks. |
Defined interfaces in simulation | Supported To define the properties
of a virtual bus, you can use a | Supported Nonvirtual buses require
| Supported To define the properties
of an array of buses, use a | Supported To define the properties
of an array, use a |
Iterative processing of subsystems | Not supported Virtual buses do not support iterative processing of subsystems. | Not supported Nonvirtual buses do not support iterative processing of subsystems. 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. | Supported Arrays let you iterate over a group of signals. Connect the array to a subsystem such as a for-each, while-iterator, or for-iterator subsystem. |
Composite Interface Code Generation
Requirement | Virtual Buses | Nonvirtual Buses | Arrays of Buses | Arrays |
---|---|---|---|---|
Structures in generated code | Not supported Virtual buses do not
appear as structures in the generated code. While you can
specify a | Supported Nonvirtual buses appear
as structures in the generated code. The corresponding
For more information, see Organize Data into Structures in Generated Code (Simulink Coder). | Supported Arrays of buses appear as
arrays of structures in the generated code. The corresponding
| Not supported Arrays appear as vectors in the generated code. For more information, see Code Generation of Matrices and Arrays (Simulink Coder). |
Individual data elements at interface | Supported For a virtual bus, the generated code appears as if the bus did not exist. The code generator is able to fully optimize the signals in a virtual bus. For more information, see Generate Efficient Code for Buses (Simulink Coder). | Not supported A nonvirtual bus is represented as a whole in the generated code. A nonvirtual bus can require data copies. | Not supported An array of buses is represented as a whole in the generated code. An array of buses can require data copies. | Not supported An array is represented as a whole in the generated code. An array can require data copies. |