Explore Composite Interfaces
To reduce visual complexity in a model, you can group multiple signals, messages, or conserving connections into a composite interface for a block or model component. The grouped elements retain their separate identities, and you can extract them.
As you create composite interfaces, consider these potential requirements:
Name-based element access — Meaningful element names and hierarchy can simplify element selection and mapping.
Reusability — Bus objects provide a reusable interface definition that you can apply as long as the definition is available to the model.
Code generation — The type of composite interface can make a significant difference in the efficiency, size, and readability of the generated code. For a bus structure to appear in the generated code, the bus must be nonvirtual. When a bus is virtual, only the elements of the bus appear in the generated code.
Composite Interfaces
The different types of composite interfaces serve a variety of modeling requirements.
Modeling Requirement | Type of Composite Interface | Appearance in Model | More Information |
---|---|---|---|
Flexible interfaces and incremental changes | Virtual bus A virtual bus is a flexible group of named elements. A virtual bus is analogous to a bundle of wires held together by tie wraps. | Group Signals or Messages into Virtual Buses | |
Defined interfaces in code generation | Nonvirtual bus A nonvirtual bus is a defined group of named elements. A nonvirtual bus is analogous to a structure in C code. | Create Nonvirtual Buses | |
Iterative processing of multiple elements | Array of buses An array of buses is an array of nonvirtual buses that have the same interface definition. | Group Nonvirtual Buses in Arrays of Buses | |
Iterative processing of individual elements | Array An array is a nonscalar signal with one or more dimensions. | (default) (Wide nonscalar lines information overlay enabled) |
Models can use a combination of these interfaces.
You can identify composite interfaces by their line style after you compile a model. When you create a composite interface or open a model that contains composite interfaces, the composite interfaces have the same line style as scalar signals. To compile a model, in the Simulink® Toolstrip, on the Modeling tab, select Update Model.
High-Level Composite Interface Selection Guidelines
This flow chart helps you choose among virtual buses, nonvirtual buses, arrays of buses, and arrays.
The flow chart identifies whether you have one of these specialized use cases for a composite interface:
If the interface will provide multiple signals for a subsystem to iteratively process, consider using an array of buses.
If the interface will provide one signal for a subsystem to iteratively process or a composite signal for matrix or vector operations, consider using an array.
If you will require the generated code to use a structure to represent the interface, consider using a nonvirtual bus.
For other use cases, consider using a virtual bus.
Note
To group function-call signals in a virtual vector, see Mux.
Modeling Requirement Considerations
Before implementing a composite interface based on the high-level guidelines, consider additional modeling requirements. For example, if you want to group messages, you must use a virtual bus.
To determine what composite interfaces meet your modeling requirements, see Compare Capabilities of Composite Interfaces.