The same scoping and parameter passing rules that apply to ordinary Simulink blocks apply to System Generator blocks. Consequently, blocks in the Xilinx 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.
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 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.
As shown below, in the parameter editing dialog for the accumulator and multiplier blocks, there are radio buttons that allow either the truncate or round option to be selected.
In order to use a parameter rather than the radio button selection, right-click the radio button and select Define With Expression. A MATLAB expression can then be used as the parameter setting. In the example below, the trunc_round parameter from the Subsystem mask can be used in both the accumulator and multiply blocks so that each block will use the same setting from the mask variable on the Subsystem.