Yes you can certainly nest buses to any depth. So you can build a 4-level hierarchy by defining each “leaf” bus first and then using it as an element in the next‐higher‐level bus, and so on.
You can follow the following :
- Define the innermost (Level 4) bus with normal signal elements.
- Define Level 3, including one BusElement whose DataType is 'Bus: Bus_L4'.
- Define Level 2, including one element 'Bus: Bus_L3'.
- Define Level 1, including one element 'Bus: Bus_L2'.
As a result you are gonna see a top-level bus (Bus_L1) containing nested subbuses down four levels. Once you’ve assigned all four bus definitions (Bus_L1 through Bus_L4) into the workspace, you can simply set your Inport, Outport, or Data Store’s type to Bus: Bus_L1 in Simulink and get the full nested hierarchy in your model.
Some things to keep in mind:
- Each bus object must have a unique Name property.
- You must create Level 4 first, then Level 3 (which references Level 4), then Level 2, then Level 1. Otherwise Simulink won’t know about the referenced bus.
- If you pull this bus into a block (e.g., Inport), be sure to set that Inport’s “Port data type” to Bus: Bus_L1.
- If you build a bus directly by connecting a Bus Creator with multiple inputs, Simulink can create a “virtual bus.” But for nested (hierarchical) buses, you can choose explicit Simulink.Bus definitions so you can control names and data types.
Please refer these pages to know more:
- https://www.mathworks.com/help/simulink/slref/buscreator.html?searchHighlight=nested+bus+heirarchy&s_tid=srchtitle_support_results_2_nested+bus+heirarchy
- https://www.mathworks.com/help/simulink/slref/simulink.bus.html
- https://www.mathworks.com/help/simulink/ug/create-bus-objects-programmatically.html
Hope this helps!