| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Real-Time Workshop Embedded Coder |
| Contents | Index |
| Learn more about Real-Time Workshop Embedded Coder |
| On this page… |
|---|
Virtual buses are graphical conveniences that do not affect generated code. As a result, the code generation engine is able to fully optimize the signals in the bus. You should therefore use virtual rather than nonvirtual buses wherever possible. You can convert between virtual and nonvirtual buses as needed using Signal Conversion blocks. In many cases, Simulink automatically converts a virtual bus to a nonvirtual bus when required. For example, a virtual bus input to a Model block becomes a nonvirtual bus with no need for explicit conversion. See for more information.
In some cases, Simulink requires the use of nonvirtual buses:
For non-auto storage classes
Inports and Outports of Model blocks
To generate a specific structure from the bus
Root level Inport or Outport blocks when the bus has mixed data types
In one case, Simulink requires the use of virtual buses:
Only virtual buses can be used for bundling function call signals.
Buses can contain subordinate buses. The storage class of any subordinate bus should be auto, which results in a local signal. Setting a subordinate bus to a non-auto storage class has two undesirable results:
Allocation of redundant memory (memory for the subordinate bus object and memory for the final bus object)
Additional copy operations (first copying to the subordinate bus and then copying from the subordinate bus to the final bus)
In the following example, the final bus is created from local scoped subordinate elements. The resulting assignment operations are relatively efficient:


By contrast in the next example the subordinate elements sub_bus_1 and sub_bus_2 are global in scope. First the assignment to the subordinate bus occurs (lines 54 – 59) then the copy of the subordinate bus to the main bus (lines 60 – 61). In most cases, this is not an efficient implementation:


![]() | Setting Bus Diagnostics | Using Single-Rate and Multi-Rate Buses | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |