To assign the values of a signal to bus element, you can use a Bus Assignment block. Use a Bus Assignment block to change bus element values without adding Bus Selector and Bus Creator blocks that select bus elements and reassemble them into a bus.
Connect to the Bus Assignment block ports:
The bus to which you want to assign the signal values
The signals whose values you want to assign to specified bus elements
Connect the bus to the first input port of the Bus Assignment block, and one or more signals to be assigned to the other ports. The Block Parameters dialog box lists the signals available for assignment in the bus. The bus can be virtual or nonvirtual. Select the elements to which you want to assign signal values. If you specify more than one signal to assign values to, the Bus Assignment block adds ports.
The signals that you assign values to can be nonbus or bus signals. The signals must match the attributes of the signals in the original bus.
This simple example illustrates the mechanics of using the Bus Assignment block. In more complex models, using a Bus Assignment block 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:
Connect two Constant blocks to a Bus Creator
block. The value of signal
a is 1, and the value of
b is 2.
Connect the Bus Creator output signal
const_bus to the first port of a Bus
Assignment block. The bus elements
b are available to assign new values to them.
Connect the Constant block output signal
c to the second port of the Bus
For the Bus Assignment block, in the Block Parameters
dialog box Signals in the bus list, select the
a signal and click
Use a Bus Selector to select signals
b from the
const_bus signal and
connect those signals to Display blocks.
Simulate the model. The Display blocks show that the value
a, which was 1 when the
const_bus bus was created, is now 3, reflecting the
assignment of the
c signal from the