Virtual and Nonvirtual Buses

Introduction

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.

Virtual buses are the default except where nonvirtual buses are explicitly required. A nonvirtual subsystem needs bus objects on all bus inports and outports, as described in Using Bus Objects and this section. Some nonvirtual subsystems impose additional requirements on buses.

Some buses that are not directly connected to nonvirtual subsystems must be nonvirtual also, as described in Connecting Buses to Nonvirtual Subsystems and Connecting Buses to Root Level Inports. Not all blocks can accept buses. See Bus-Capable Blocks for more about which blocks can handle which types of buses. You can use a Signal Conversion block to convert a nonvirtual bus to a virtual bus, and vice versa.

When updating a diagram prior to simulation or code generation, the Simulink® software automatically upgrades virtual to nonvirtual buses where the upgrade prevents an error and does not cause any errors. The upgrade consists of inserting hidden Signal Conversion blocks into the model where needed. You can eliminate the need for the upgrade by specifying a nonvirtual bus in the block where the bus originates, or by manually inserting appropriate conversion blocks. The latter is generally unnecessary, but can be useful to clarify the model.

Creating Nonvirtual Buses

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:

  1. Associate the block with a bus object, as described in Associating Bus Objects with Model Blocks.

  2. Open the Block Parameters dialog of the Bus Creator, Inport, or Outport block.

  3. Do one of the following, depending on the type of the block:

  4. Click OK or Apply.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS