Define Bus Properties for Reuse
Buses reduce line complexity and clutter in a block diagram and make incrementally changing an interface easier. A virtual bus is analogous to a bundle of wires held together by tie wraps. A nonvirtual bus is analogous to a structure in C code. To create a reusable specification for a bus, use a bus object. The software uses a bus object to validate the properties of a bus and its elements. Multiple blocks, objects, and model components can specify the same bus object.
A bus object specifies only the architectural properties of a bus, distinct from the values of the signals it contains. For example, a bus object can specify the number of elements in a bus, the order of those elements, whether and how elements are nested, and the data types of constituent signals, but not the signal values.
A bus object is analogous to a structure definition in C: the bus object defines the members of the bus but does not create the bus. A bus object is also like a cable connector. The connector defines the pins and their configuration and controls what types of wires can connect to it. Similarly, a bus object defines the configuration and properties of the signals that the associated bus must have.
Bus objects are optional for virtual buses but required for nonvirtual buses. For more information about virtual and nonvirtual buses, see Composite Interface Guidelines.
To define bus properties at the interface of a reusable component, such as a referenced subsystem or model, use In Bus Element and Out Bus Element blocks. For more information, see Define Bus Properties at Component Interfaces.
Determine Whether to Use Bus Objects
You can specify bus properties individually or with bus objects. To simulate a model that uses bus objects, you must load the bus objects by using projects, data dictionaries, model callbacks, or other strategies.
Depending on your modeling requirements, how you define the bus properties can differ.
| Modeling Requirement | Specification Source |
|---|---|
| Assign or validate the hierarchy and properties of a bus at a subsystem or model interface. | Use one or more In Bus Element or Out Bus Element
blocks. Optionally, use a Inport and
Outport blocks at the top level of a model
require |
| Assign or validate the hierarchy and properties of a bus across multiple blocks, subsystems, or models. | Use a |
| Enforce consistency at the interface between components, such as subsystems or models. | Use a When the ports of model components directly connect to each other, specify the same or an equivalent bus object for those ports. By specifying a bus object with the same hierarchy and properties at both sides of the interface, you enforce consistency at the interface between the components. For more information about interface design, see Define Interfaces and Manage Data of Simulink Components. |
| Enforce strong data typing when you create a bus with a Bus Creator block. | Use a
|
| Enforce the output bus of a Switch or Multiport Switch block to use consistent element names regardless of which input bus the block propagates. | Use a
|
Use any of these modeling configurations:
| Use a |
| Trace the correspondence between the model and generated code for a bus. | Use a nonvirtual bus defined by a The generated code for a nonvirtual bus produces a structure. Nonvirtual buses can result in multiple copies of some buses. Bus objects appear in the generated code only when they define nonvirtual buses. For bus objects that define virtual buses, the properties that the bus objects specify appear in the generated code instead of the bus object. For more information, see Create Nonvirtual Buses. |
| Design rigid interface specifications for Simscape™ conserving connections and lock down connection names and types. | Use a For more information, see Design Rigid Interface Specifications for Conserving Connections (Simscape). |
Next Steps
When bus objects address your modeling requirements, follow these next steps:
When In Bus Element or Out Bus Element blocks address your modeling requirements, see Define Bus Properties at Component Interfaces.