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
signal combines two signals,
Bus2 signal combines the
signal and the
Bus1 signal combines the
signal and the
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
Warn and repair. The repairs occur when you
update a model. To save the repairs, save the model.
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.
Begin by selecting a signal line associated with the location cited in the error message.
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.)
Continue choosing signals and highlighting their sources and destinations until the cycle becomes clear.
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.