Main Content

Replace Values of Bus Elements

To assign the value of an input to a bus element, you can use aBus Assignment块。Use aBus Assignmentblock to change bus element values without addingBus SelectorandBus Creatorblocks that select bus elements and reassemble them into a bus.

Connect to theBus Assignmentblock ports:

  • 公共汽车去which you want to assign the values

  • The lines whose values you want to assign to specified bus elements

Connect the bus to the first input port of theBus Assignmentblock, and one or more lines with values to be assigned to the other ports. The Block Parameters dialog box lists the elements available for assignment in the bus. The bus can be virtual or nonvirtual. Select the elements to which you want to assign values. If you specify more than one element to assign values to, theBus Assignmentblock adds ports.

The elements that you assign values to can be nonbus or bus signals. The new values must match the attributes of the elements in the original bus.

Update a Bus Element

This simple example illustrates the mechanics of using theBus Assignment块。在更复杂的模型,使用Bus Assignmentblock simplifies updating a bus to reflect the processing that occurs in a separate component, such as a subsystem or referenced model. Here is the model after you simulate it.

Some key steps in constructing this model are:

  1. Connect twoConstantblocks to aBus Creator块。The value of signalais 1, and the value of signalbis 2.

  2. Connect theBus Creatoroutput busconst_busto the first port of aBus Assignment块。The bus elementsaandbare available to assign new values to them.

  3. Connect theConstantblock output signalcto the second port of theBus Assignment块。

  4. For theBus Assignmentblock, in the Block Parameters dialog boxElements in the buslist, select theasignal and clickSelect.

  5. Use aBus Selectorto select signalsaandbfrom theconst_busbus and connect those signals toDisplayblocks.

  6. Simulate the model. TheDisplayblocks show that the value of signala, which was 1 when theconst_busbus was created, is now 3, reflecting the assignment of thecsignal from theConst3块。

See Also

Blocks

Related Topics