Skip to Main Content Skip to Search
Product Documentation

About Composite Signals

Composite Signal Terminology

A composite signal is a signal that is composed of other signals. The constituent signals originate separately and join to form the composite signal. They can then be extracted from the composite signal downstream and used as if they had never been joined. Composite signals can reduce visual complexity in models by grouping signals that run in parallel over some or all of their courses, and can serve various other purposes.

A Simulink composite signal is called a bus signal, or just a bus. A Simulink bus is analogous to a bundle of wires held together by tie wraps. Simulink implements a bus as a name-based hierarchical structure. A Simulink bus should not be confused with a hardware bus, like the bus in the backplane of many computers. It is more like a programmatic structure defined in a language like C.

The signals that constitute a bus are called elements. The constituent signals retain their separate identities within the bus and can be of any type or types, including other buses nested to any level. The elements of a bus can be any of the following:

Some requirements and limitations apply when you connect buses to blocks or to nonvirtual subsystems. See Bus-Capable Blocks, Connecting Buses to Inports and Outports, and Composite Signal Limitations for more information.

Types of Simulink Buses

A bus can be either virtual or nonvirtual. Both virtual and nonvirtual buses provide the same visual simplification, but their implementations are different.

The two types of buses are interchangeable for many purposes, but some situations require a nonvirtual bus. See Virtual and Nonvirtual Buses for more information.

View Information about Buses

To view information about buses, use one of the following approaches:

Signal Hierarchy Viewer

Use the Signal Hierarchy Viewer to interactively display information about a signal. For a bus signal, the Signal Hierarchy Viewer displays the bus hierarchy.

  1. Right-click a signal line.

  2. Select the Signal Hierarchy option. The Signal Hierarchy Viewer dialog box appears.

For example, open the busdemo demo.

Right-click the main_bus signal (output signal for the Bus Creator block), and select Signal Hierarchy. The following information appears:

Each Signal Hierarchy Viewer is associated with a specific model. If you edit a model while the associated Signal Hierarchy Viewer is open, the Signal Hierarchy Viewer reflects those updates.

You can also open the Signal Hierarchy Viewer in the Simulink Model Editor.

  1. Select View > Signal Hierarchy.

  2. Select a signal

To filter the displayed signals, click the Options button on the right-hand side of the Filter by name edit box ( ).

CompiledBusType and SignalHierarchy Parameters

To get information about the type and hierarchy of a bus signal in a compiled model, use these parameters with the get_param command:

Before you use these commands:

  1. In the Configuration Parameters > Diagnostics > Connectivity pane, set the Mux blocks used to create bus signals diagnostic to error.

  2. Update the diagram or simulate the model.

For example, if you open and simulate the busdemo demo, the model looks as shown below:

The following code illustrates how you can use the SignalHierarchy and CompiledBusType parameters:

mdl = 'busdemo'; 
open_system(mdl)
% Obtain the handle a port
ph = get_param([mdl '/Bus Creator'], 'PortHandles');
% SignalHierarchy is available at edit time
sh = get_param(ph.Outport, 'SignalHierarchy')
% Compile the model
busdemo([],[],[],'compile');
bt = get_param(ph.Outport, 'CompiledBusType')
% Terminate the model
busdemo([],[],[],'term');

Buses and Muxes

If all signals in a bus are the same type, you may be able to use a contiguous vector or a virtual vector (mux) instead of a bus. For more information, see Mux Signals. In some cases, muxes and virtual buses can be treated interchangeably; implicit type conversion occurs when needed.

Do not mix muxes and buses in new applications.

One way that such a mux/bus mixture occurs is when you use a Mux block to create a virtual bus, such as a Mux block that outputs to a Bus Selector. This kind of mixture does not support strong type checking and increases the likelihood of run-time errors. MathWorks discourages treating muxes and buses interchangeably. Mux/bus mixtures may become unsupported in the future. Simulink generates a warning for this kind of mux/bus mixture when you load a model created in a release prior to R2010a. For new models, Simulink generates an error. Do not create such mux/bus mixtures in new applications, and consider upgrading existing applications to avoid such mixtures. The Configuration Parameters > Diagnostics > Connectivity pane provides diagnostics that report cases where muxes and virtual buses are used interchangeably, and includes capabilities that you can use to upgrade a model to eliminate such mixtures. See Avoiding Mux/Bus Mixtures for details.

Another way for a mux/bus mixture to occur is when a virtual bus signal is treated as a mux, such as a bus signal that inputs directly to a Gain block. To detect such mixtures, in the Configuration Parameters > Diagnostics > Connectivity pane, set the Bus signal treated as vector diagnostic to warning or error.

Bus Objects

A bus can have an associated bus object, which can both provide and validate bus properties. A bus object is an instance of class Simulink.Bus that is defined in the base workspace. The object defines the structure of the bus and the properties of its elements, such as nesting, data type, and size. Bus objects are optional for virtual buses and required for nonvirtual buses. See Using Bus Objects for more information. You can create bus objects programmatically or by using the Simulink Bus Editor, which facilitates bus object creation and management. See Using the Bus Editor for more information.

Bus Code

The various techniques for defining buses are essentially equivalent for simulation, but the techniques used can make a significant difference in the efficiency, size, and readability of generated code. If you intend to generate production code for a model that uses buses, see Buses for information about the best techniques to use.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS