| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
| On this page… |
|---|
A bus signal can be virtual, meaning that it is just a graphical convenience that has no functional effect, or nonvirtual, meaning that the signal occupies its own storage. During simulation, a block connected to a virtual bus reads inputs and writes outputs by accessing the memory allocated to the component signals. These signals are typically noncontiguous, and no intermediate memory exists. Simulation results and generated code are exactly the same as if the bus did not exist, which functionally it does not.
By contrast, a block connected to a nonvirtual bus reads inputs and writes outputs by accessing copies of the component signals. The copies are maintained in a contiguous area of memory allocated to the bus. Such a bus is represented by a structure in generated code, which can be helpful when tracing the correspondence between the model and the code.
Compared with nonvirtual buses, virtual buses reduce memory requirements because they do not require a separate contiguous storage block, and execute faster because they do not require copying data to and from that block. Not all blocks can accept buses. See Bus-Capable Blocks for more about which blocks can handle which types of buses. Virtual buses are the default except where nonvirtual buses are explicitly required. See Connecting Buses to Inports and Outports for more information.
Bus signals do not specify whether they are virtual or nonvirtual; they inherit that specification from the block in which they originate. Every block that creates or requires a nonvirtual bus must have an associated bus object. Those blocks are:
To specify that a bus is nonvirtual:
Associate the block with a bus object, as described in Associating Bus Objects with Simulink Blocks.
Open the Block Parameters dialog of the Bus Creator, Inport, or Outport block.
Do one of the following, depending on the type of the block:
Bus Creator: Select Output as nonvirtual bus.
Inport: Select Signal Attributes > Output as nonvirtual bus.
Outport: Select Signal Attributes > Output as nonvirtual bus in parent model.
Click OK or Apply.
The Signal Attributes parameter is applicable only to root Inport and Outport blocks, and does not appear in the parameters of a subsystem Inport or Outport block. In a root Outport block, setting Signal Attributes > Output as nonvirtual bus in parent model specifies that the bus emerging in the parent model is nonvirtual. The bus that is input to the root Outport can be virtual or nonvirtual.
All signals in a nonvirtual bus must have the same sample time, even if the elements of the associated bus object specify inherited sample times. Any bus operation that would result in a nonvirtual bus that violates this requirement generates an error.
All buses and signals input to a Bus Creator block that outputs a nonvirtual bus must therefore have the same sample time. You can use a Rate Transition block to change the sample time of an individual signal, or of all signals in a bus, to allow the signal or bus to be included in a nonvirtual bus.
When updating a diagram prior to simulation or code generation, the Simulink software automatically converts virtual buses to nonvirtual buses where the conversion is possible and prevents an error. For example, referenced models and Stateflow charts require any bus connected to them to be nonvirtual.
The conversion consists of inserting hidden Signal Conversion blocks into the model where needed. You can eliminate the need for the automatic conversion by specifying a nonvirtual bus in the block where the bus originates, or by inserting explicit Signal Conversion blocks. The latter is generally unnecessary, but can be useful to clarify the model.
The source block of any virtual bus that is converted to a nonvirtual bus, whether explicitly or automatically, must specify a bus object, as described in Using Bus Objects. Conversion to a nonvirtual bus fails if no bus object is specified, and the Simulink software posts an error message describing the problem.
![]() | Using the Bus Object API | Connecting Buses to Inports and Outports | ![]() |

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 |