Block Masks and Parameter Passing - 2022.2 English

Vitis Model Composer User Guide (UG1483)

Document ID
UG1483
Release Date
2023-01-13
Version
2022.2 English

The same scoping and parameter passing rules that apply to ordinary Simulink blocks apply to HDL blocks. Consequently, blocks in the Xilinx HDL Blockset can be parameterized using MATLAB variables and expressions. This capability makes possible highly parametric designs that take advantage of the expressive and computational power of the MATLAB language.

Block Masks

In Simulink, blocks are parameterized through a mechanism called masking. In essence, a block can be assigned mask variables whose values can be specified by a user through dialog box prompts or can be calculated in mask initialization commands. Variables are stored in a mask workspace. A mask workspace is local to the blocks under the mask and cannot be accessed by external blocks.

Note: It is possible for a mask to access global variables and variables in the base workspace. To access a base workspace variable, use the MATLAB evalin function. For more information on the MATLAB and Simulink scoping rules, refer to the manuals titled Using MATLAB and Using Simulink from The MathWorks, Inc.

Parameter Passing

It is often desirable to pass variables to blocks inside a masked Subsystem. Doing so allows the block’s configuration to be determined by parameters on the enclosing Subsystem. This technique can be applied to parameters on blocks in the Xilinx HDL blockset whose values are set using a listbox, radio button, or checkbox. For example, when building a Subsystem that consists of a multiply and accumulate block, you can create a parameter on the Subsystem that allows you to specify whether to truncate or round the result. This parameter will be called trunc_round as shown in the figure below.

Figure 1. Creating a Parameter

As shown in the following figure, in the Block Parameters dialog for the accumulator and multiplier blocks, there are radio buttons that allow either the Truncate or Round option to be selected.

Figure 2. Editing a Parameter