Help Center
- Documentation
- Trial software
- Product updates
Bus Assignment
Assign new values to specified bus elements
Libraries: Simulink / Signal Routing HDL Coder / Signal Routing
Description
The Bus Assignment block assigns the values of input signals to selected bus elements. Use a Bus Assignment block to change bus element values without extracting bus elements and reassembling the bus with the desired elements. 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.
The Bus Assignment block assigns elements connected to its assignment input ports to specified elements of the bus connected to its bus input port. The block replaces the elements previously assigned to those elements. The change does not affect the composition of the bus. The change affects only the values of the elements. Signals not replaced are unaffected by the replacement of other elements.
The elements to which you assign values can be nonbus signals or buses, including arrays of buses, as long as they are elements of the input bus. The new values must match the attributes of the elements in the original bus.
By default, the software repairs broken selections for a Bus Assignment block that are due to upstream bus hierarchy changes. A warning notifies you when a repair modifies the model. To prevent the software from making these repairs automatically, set the Repair bus selections configuration parameter to Error without repair .
Assign Signal Values to Bus Elements
To replace the value of a bus element, use a Bus Assignment block. You do not need to use Bus Selector and Bus Creator blocks to change the value of a bus element.
Open and compile the example model named BusAssignment . To compile the model, on the Modeling tab of the Simulink® Toolstrip, click Update Model or Run . Compiling the model updates the line styles, which you can use to visually identify buses.
The Bus Assignment block has two input ports. The first input port receives the bus that contains an element to which you want to assign a new value. The bus can be virtual or nonvirtual. The second input port receives the signal whose value you want to assign to the bus element.
Double-click the Bus Assignment block to open a dialog box with assignment options. The Block Parameters dialog box lists the elements available for assignment in the Elements in the bus list.
In this model, bus elements a and b are available for assignment.
Element a also appears in the Elements that are being assigned list, which indicates that the element is selected for assignment.
The port label on the block indicates the corresponding element. For element a , the port label is :=a .
To assign a new value to the bus element, connect the signal that provides the new value to the corresponding port on the Bus Assignment block. The elements to which you assign values can be buses or nonbus signals. The new values must match the attributes of the elements in the original bus.
In this model, signal c connects to the port that assigns a new value to element a . The Bus Assignment block replaces the value of bus element a , which is 1, with the value of signal c , which is 3.
To display the new value of element a and the unchanged value of element b , the Bus Selector block selects elements a and b and connects them to Display blocks. The Display blocks show the value of these elements after assignment.
Element a has a value of 3, which is its new value from the Bus Assignment block.
Element b has a value of 2, which is its original value.
You can select additional elements for assignment by selecting an element under Elements in the bus then clicking Select . The Bus Assignment block adds an input port for each additional element to which you want to assign a new value. The new input ports let you connect the signals that you want to assign to the additional bus elements.
Extended Examples
Simulink Bus Capabilities
Work with buses in components, simplify component interfaces, and streamline common bus workflows.
- Open Live Script
Limitations
The Bus Assignment block does not support messages.
Bus — Input bus with elements to reassign bus
The input virtual or nonvirtual bus can have elements with real or complex values of any data type supported by Simulink ® software, including bus objects, fixed-point data types, and enumerated data types. The bus can also contain arrays of buses.
Data Types: single | double | half | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | enumerated | bus | string Complex Number Support: Yes
:= — New value to assign to bus element scalar | vector | matrix | array | bus
Each element in the Elements that are being assigned list receives an assignment port. The port label indicates the bus element that corresponds to the port. For an element named signal1 , the port label is := signal1 .
Connect the signal that you want to assign to the bus element to its corresponding assignment port. The signal connected to the assignment port must have the same structure, data type, and sample time as the corresponding bus element. To change the sample time of one or more elements, use a Rate Transition block. For more information, see Modify Sample Times for Nonvirtual Buses .
Bus — Output bus bus
The output virtual or nonvirtual bus includes the assigned bus element values for the selected elements and the unmodified bus element values for the other elements.
To edit Bus Assignment block parameters interactively, double-click the block.
Elements in the bus — Elements of input bus list of element names
This parameter is read-only.
Select elements in the input bus to operate on them.
An arrow next to an element name indicates that an element is a nested bus. To display the elements in a nested bus, click the arrow.
With one or more elements selected, click:
Find — Find the source of the selected elements. The software opens and highlights the system containing the element source.
Select — Add the selected elements to the list of elements to be assigned values. For more information, see Elements that are being assigned .
To refresh the list to reflect modifications to the input bus, click Refresh .
Programmatic Use
To get the block parameter value programmatically, use the get_param function.
Example: get_param(gcb,'InputSignals')
Filter by name — Filter for input elements text
Specify a search term to use for filtering a long list of input elements. Do not enclose the search term in quotation marks. The filter does a partial string search.
Enable regular expression — Option to filter input elements with regular expressions off (default) | on
Enable the use of MATLAB ® regular expressions for filtering element names. For example, enter t$ in the Filter by name box to display all elements whose names end with a lowercase t and their immediate parents. For more information, see Regular Expressions .
Dependencies
Show filtered results as a flat list — option to display filtered input elements in flat list off (default) | on.
By default, the list of input elements displays elements in a hierarchical tree. To display filtered elements in a flat list that uses dot notation to reflect the bus hierarchy, select this parameter.
Elements that are being assigned — Bus elements to be assigned new values list of element names
For each element in this list, the block has an assignment port. The port label contains the name of the corresponding element.
To add assignment ports for elements:
Select one or more elements from the Elements in the bus list.
If you select multiple elements from the Elements in the bus list, the order in which you select them sets their order in the Elements that are being assigned list.
Optionally, specify where you want the elements to appear in the Elements that are being assigned list. Select the element below which you want the added elements to appear. If you do not select an element, added elements appear at the end of the list.
Click Select .
To change the order of the assignment ports, select an element or multiple contiguous elements in the list, then click Up or Down . Port connectivity is maintained when you change the element order.
To remove assignment ports, select the corresponding elements in the list, then click Remove .
If an element in the list is not in the input bus, the element name starts with three question marks ( ??? ). Modify the input bus to include an element of the specified name, or remove the element from the list.
To set the block parameter value programmatically, use the set_param function.
Example: set_param(gcb,'AssignedSignals','sine,chirp')
Block Characteristics
To replace a bus in an array of buses. Use an Assignment block instead. For an example, see Model Arrays of Buses .
To replace an element of a bus in an array of buses, select the index of the bus that you want to modify by using a Selector block. Then, use the selected bus as input to the Bus Assignment block.
Extended Capabilities
C/c++ code generation generate c and c++ code using simulink® coder™..
Actual data type or capability support depends on block implementation.
HDL Code Generation Generate VHDL, Verilog and SystemVerilog code for FPGA and ASIC designs using HDL Coder™.
HDL Coder™ provides additional configuration options that affect HDL implementation and synthesized logic.
To learn more about using buses for HDL code generation, see Buses (HDL Coder) and Use Buses to Improve Readability of Model and Generate HDL Code (HDL Coder) .
This block has one default HDL architecture.
This block supports these data types for HDL code generation:
PLC Code Generation Generate Structured Text code using Simulink® PLC Coder™.
Fixed-point conversion design and simulate fixed-point systems using fixed-point designer™., version history.
Introduced before R2006a
Bus Creator | Bus Selector
- Composite Interface Guidelines
- Group Signals or Messages into Virtual Buses
- Create Nonvirtual Buses
- Group Nonvirtual Buses in Arrays of Buses
- Share and Reuse Bus-Routing Blocks
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
- América Latina (Español)
- Canada (English)
- United States (English)
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 简体中文 Chinese
- 日本 Japanese (日本語)
- 한국 Korean (한국어)
Contact your local office
Help Center
- Documentation
- Trial software
- Product updates
Iterated Assignment with the Assignment Block
The iterator generates indices for the Assignment block. On the first iteration, the Assignment block copies the first input (Y0) to the output (Y) and assigns the second input (U) to the output Y(E1). On successive iterations, the Assignment block assigns the current value of U to Y(Ei), that is, without first copying Y0 to Y. These actions occur in a single time step.
- For Iterator Subsystem | For Iterator | Assignment
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
- América Latina (Español)
- Canada (English)
- United States (English)
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 简体中文 Chinese
- 日本 Japanese (日本語)
- 한국 Korean (한국어)
Contact your local office
IMAGES
VIDEO