Documentation

Use Arrays of Buses in Models

Array of Buses Requirements and Limitations

Bus Requirements

All buses combined into an array of buses must:

  • Be nonvirtual

  • Have the same bus type (that is, same name, hierarchies, and attributes for the bus elements)

  • Have no variable-size signals or frame-based signals

Supported Blocks

You can use arrays of buses with these blocks:

  • Virtual blocks

  • Several nonvirtual blocks, such as:

    • Some signal routing blocks (for example, Data Store Memory, Merge, and Switch)

    • Rate Transition and Zero-Order Hold blocks

  • Several additional blocks, such as Assignment, MATLAB Function, and Signal Conversion

For a complete list, see Blocks That Support Arrays of Buses. That section describes requirements for using the supported blocks.

Structure Parameter Requirements

To initialize an array of buses with structure parameters, you can use:

  • The number 0. In this case, all the individual signals in the array of buses use the initial value 0.

  • A scalar struct that represents the same hierarchy of fields and field names as the bus type. In this case, the scalar structure expands to initialize each of the individual signals in the array of buses.

  • An array of structures that specifies an initial value for each of the individual signals in the array of buses.

    If you use an array of structures, all the structures in the array must have the same hierarchy of fields. Each field in the hierarchy must have the same characteristics across the array:

    • Field name

    • Numeric data type, such as single or int32

    • Complexity

    • Dimensions

You cannot use partial structures.

For more information about specifying initial conditions for bus signals, see Initialize Arrays of Buses.

Signal Logging Limitation

Simulink® does not log array of buses signals inside referenced models in rapid accelerator mode.

Stateflow Limitations

Stateflow® action language does not support arrays of buses.

Blocks That Support Arrays of Buses

The following blocks support arrays of buses:

Block Parameter Settings

Using an array of buses signal with some blocks requires specific block parameter settings.

This information is also in the reference pages for each of these blocks. For usage information for bus-related blocks, see Work with Array of Buses Signals.

BlockBlock Parameters Settings
Memory

Initial condition — You can specify this parameter with:

  • The value 0. In this case, all the individual signals in the array of buses use the initial value 0.

  • An array of structures that specifies an initial condition for each of the individual signals in the array of buses.

  • A single scalar structure that specifies an initial condition for each of the elements that the bus type defines. Use this technique to specify the same initial conditions for each of the buses in the array.

Merge
  • Allow unequal port widths — Clear this parameter.

  • Number of inputs — Set to a value of 2 or greater.

  • Initial condition — You can specify this parameter with:

    • The value 0. In this case, all the individual signals in the array of buses use the initial value 0.

    • An array of structures that specifies an initial condition for each of the individual signals in the array of buses.

    • A single scalar structure that specifies an initial condition for each of the elements that the bus type defines. Use this technique to specify the same initial conditions for each of the bus signals in the array.

Multiport Switch

Number of data ports — Set to a value of 2 or greater.

Signal Conversion

Output — Set to Signal copy.

Switch

Threshold — Specify a scalar threshold.

Set Diagnostic

Before you run a simulation on a model that uses an array of buses, in the Configuration Parameters > Diagnostics > Connectivity pane, check that the Mux blocks used to create bus signals parameter uses the default setting of error.

Signal Line Style

After model simulation, the line style for the array of buses signal is a thicker version of the signal line style for a nonvirtual bus signal.

For example, in the sldemo_bus_arrays model, the Scalar Bus signal is a nonvirtual bus signal, and the Bus Array output signal of the Concatenate block is an array of buses signal.

Related Examples

Was this topic helpful?