Nest Buses

You can nest buses to any depth. To create a nested bus, use a Bus Creator block. If one of the inputs to the Bus Creator block is a bus, then the output is a nested bus. To select a signal within a nested bus, use a Bus Selector block.

For example, in the next model, the Bus3 bus signal combines two signals, motor3 and motor4. The Bus2 signal combines the Bus3 bus signal and the motor1 and motor2 signals. The Bus1 signal combines the Bus2 bus signal and the motor5 signal.

All of the signals retain their separate identities, just as if no bus creation and selection occurred. You can use Bus Selector blocks to select individual signals from a nested bus.

The Simulink® software automatically handles most of the complexities involved. For example, you can specify to have Simulink repair broken selections in the Bus Selector and Bus Assignment block parameter dialog boxes due to upstream bus hierarchy changes. To enable these automatic repairs, in theConfiguration Parameters > Diagnostics > Connectivity pane, set the Repair bus selections diagnostic to Warn and repair. The repairs occur when you update a model. To save the repairs, save the model.

Circular Bus Definitions

The ability to nest a bus as an element of another bus creates the possibility of a loop of Bus Creator blocks, Bus Selector blocks, and bus-capable blocks that inadvertently includes a bus as an element of itself. The resulting circular definition cannot be resolved and therefore causes an error.

The error message that appears specifies the location at which the Simulink software determined that the circular structure exists. The error is not really at any one location: the structure as a whole is in error. Nonetheless, the location cited in the error message can be useful for beginning to trace the definition cycle; its structure may not be obvious on visual inspection.

  1. Begin by selecting a signal line associated with the location cited in the error message.

  2. Choose Highlight to Signal to Source or Highlight Signal to Destination from the signal's context menu. (See Display Signal Sources and Destinations for more information.)

  3. Continue choosing signals and highlighting their sources and destinations until the cycle becomes clear.

  4. Restructure the model as needed to eliminate the circular bus definition.

Because the problem is a circular definition rather than a circular computation, the cycle cannot be broken by inserting additional blocks, in the way that an algebraic loop can be broken by inserting a Unit Delay block. No alternative exists but to restructure the model to eliminate the circular bus definition.

See Also


Related Examples

More About

Was this topic helpful?