User guide

368 www.xilinx.com System Generator for DSP User Guide
UG640 (v 12.2) July 23, 2010
Chapter 4: Importing HDL Modules
4. Double click on the waveform scope black box. Notice a Number of Input Ports field is
included in the block dialog box and is unique to this black box instance. The dialog
box is shown below:
5. Change the number of input ports from 3 to 4 and apply the changes. The black box
now has an additional input port labeled sig4 and should look like the following:
Every black box has a standard list of mask parameters. The black box in this example
has an additional mask parameter nports that stores the number of input ports
selected by the user. To change a black box mask it is necessary to disable the link to the
library. When a black box is changed in this way, it is best to save the black box in a
library. (See the Simulink documentation on libraries for details.) The tutorial library
scope_lib.mdl contains the modified signal scope black box used in this example.
When a black box configuration M-function adds an HDL file, the path to the file can
be relative to the directory in which the library is saved. This eliminates the need to
copy the HDL into the same directory as the model.
The black box's configuration M-function is invoked whenever the block parameter
dialog box is modified. This allows the M-function to check the mask parameters and
configure the black box accordingly. In this example, the M-function adjusts the
number of block input ports based on the nports parameter specified in the mask.
6. Open the file scope_config.m that defines the configuration M-function for the
example black box. Locate the line:
simulink_block = this_block.blockName;
This obtains the Simulink name of the black box and assigns it to the variable
simulink_block. The name is useful because it is the handle that MATLAB
functions need to manipulate the block.
7. Locate the line:
nports = eval(get_param(simulink_block,'nports'));
The value of the nports mask parameter is obtained by the get_param command.
The get_param returns a string containing the number of ports. An eval encloses the
get_param and converts the string into an integer that is assigned to the nports
variable.