Bus Assignment

Replace specified bus elements


Signal Routing


The Bus Assignment block assigns signals (including buses and arrays of buses) connected to its Assignment input ports (:=) to specified elements of the bus connected to its Bus input port, replacing the signals previously assigned to those elements. The change does not affect the signals themselves, it affects only the composition of the bus. Signals not replaced are unaffected by the replacement of other signals. You cannot use the Bus Assignment block to replace a bus that is nested within an array of buses.

For information about buses, see:

Connect the bus to be changed to the first input port. Use the block parameters dialog box to specify the bus elements to be replaced. The block displays an assignment input port for each such element. The signal connected to the assignment port must have the same structure, data type, and numeric type as the bus element to which it corresponds.

All signals in a nonvirtual bus must have the same sample time, even if the elements of the associated bus object specify inherited sample times. Any bus operation that would result in a nonvirtual bus that violates this requirement generates an error. All buses and signals input to a Bus Assignment block that modifies a nonvirtual bus must therefore have the same sample time. You can use a Rate Transition block to change the sample time of an individual signal, or of all signals in a bus, to allow the signal or bus to be included in a nonvirtual bus. See Virtual and Nonvirtual Buses for more information.

By default, Simulink® implicitly converts a non-bus signal to a bus signal to support connecting the signal to a Bus Assignment or Bus Selector block. To prevent Simulink from performing that conversion, in the Model Configuration Parameters > Diagnostics > Connectivity pane, set the Non-bus signals treated as bus signals diagnostic to warning or error.

By default, Simulink repairs broken selections in the Bus Assignment and Bus Selector block parameters dialog boxes that are due to upstream bus hierarchy changes. Simulink generates a warning to highlight that it made changes. To prevent Simulink from making these repairs automatically, in the Model Configuration Parameters > Diagnostics > Connectivity pane, set the Repair bus selections diagnostic to Error without repair.

For information about using this block in a library block, see Buses and Libraries.

The following limitations apply to working with arrays of buses, when using the Bus Assignment block. For details about defining and using an array of buses, see Combine Buses into an Array of Buses.

  • You can assign or replace a sub-bus that is an array of buses. However, the nested bus cannot be nested inside of an array of buses.

  • To replace a signal in an array of buses, use a Selector block to select the index for the bus element that you want to use with the Bus Assignment block. Then use that selected bus element with the Bus Assignment block.

Data Type Support

The bus input port of the Bus Assignment block accepts and outputs real or complex values of any data type that Simulink supports, including fixed-point and enumerated data types. The assignment input ports accept the same data types as the bus elements to which they correspond.

For more information, see Data Types Supported by Simulink in the Simulink documentation.

Parameters and Dialog Box

The Bus Assignment dialog box appears as follows:

Signals in the bus

Displays the names of the signals contained by the bus at the block's Bus input port. Click any item in the list to select it. To find the source of the selected signal, click the adjacent Find button. Simulink opens the subsystem containing the signal source and highlights the source's icon. Use the Select>> button to move the currently selected signal into the adjacent list of signals to be assigned values (see Signals that are being assigned below). To refresh the display (e.g., to reflect modifications to the bus connected to the block), click the adjacent Refresh button.

Signals that are being assigned

Lists the names of bus elements to be assigned values. This block displays an assignment input port for each bus element in this list. The label of the corresponding input port contains the name of the element. You can order the signals by using the Up, Down, and Remove buttons. Port connectivity is maintained when the signal order is changed.

Three question marks (???) before the name of a bus element indicate that the input bus no longer contains an element of that name, for example, because the bus has changed since the last time you refreshed the Bus Assignment block's input and bus element assignment lists. You can fix the problem either by modifying the bus to include a signal of the specified name or by removing the name from the list of bus elements to be assigned values.

Enable regular expression

To display this parameter, select the Options button on the right-hand side of the Filter by name edit box ( ).

Enables the use of MATLAB® regular expressions for filtering signal names. For example, entering t$ in the Filter by name edit box displays all signals whose names end with a lowercase t (and their immediate parents). For details, see Regular Expressions.

The default is On. If you disable use of MATLAB regular expressions for filtering signal names, filtering treats the text you enter in the Filter by name edit box as a literal string.

Show filtered results as a flat list

To display this parameter, select the Options button on the right-hand side of the Filter by name edit box ( ).

Uses a flat list format to display the list of filtered signals, based on the search text in the Filter by name edit box. The flat list format uses dot notation to reflect the hierarchy of bus signals. The following is an example of a flat list format for a filtered set of nested bus signals.

The default is Off, which displays the filtered list using a tree format.


Data Types

Double | Single | Boolean | Base Integer | Fixed-Point | Enumerated | Bus

Multidimensional Signals


Variable-Size Signals


Code Generation


Introduced before R2006a

Was this topic helpful?