User guide
330 www.xilinx.com System Generator for DSP User Guide
UG640 (v 12.2) July 23, 2010
Chapter 4: Importing HDL Modules
When System Generator compiles a black box into hardware, it produces the appropriate
clock enable signals for your module, and automatically wires them up to the appropriate
clock enable ports.
Combinational Paths
If the module you are importing has at least one combinational path (i.e., a change on any
input can effect an output port without a clock event), you must indicate this in the
configuration M-function. SysgenBlockDescriptor object provides a
tagAsCombinational method that indicates your module has a combinational path. It
should be invoked as follows in the configuration M-function:
this_block.tagAsCombinational;
Specifying VHDL Generics and Verilog Parameters
You may specify a list of generics that get passed to the module when System Generator
compiles the model into HDL. Values assigned to these generics can be extracted from
mask parameters and from propagated port information (e.g., port width, type, and rate).
This flexible means of generic assignment allows you to support highly parametric
modules that are customized based on the Simulink environment surrounding the black
box.
The addGeneric method allows you to define the generics that should be passed to your
module when the design is compiled into hardware. The following code shows how to set
a VHDL Integer generic, dout_width, to a value of 12.
addGeneric('dout_width','Integer','12');
It is also possible to set generic values based on port on propagated input port information
(e.g., a generic specifying the width of a dynamic output port).
Because a black box's configuration M-function is invoked at several different times when
a model is compiled, the configuration function may be invoked before the data types (or
rates) have been propagated to the black box. If you are setting generic values based on
input port types or rates, the addGeneric calls should be nested inside a conditional
statement that checks the value of the inputTypesKnown or inputRatesKnown
variables. For example, the width of the dout port can be set based on the value of din as
follows:
if (this_block.inputTypesKnown)
% set generics that depend on input port types
this_block.addGeneric('dout_width', ...
this_block.port('din').width);
end
Generic values can be configured based on mask parameters associated with a block box.
SysgenBlockDescriptor provides a member variable, blockName, which is a string
representation of the black box's name in Simulink. You may use this variable to gain
access the black box associated with the particular configuration M-function. For example,
assume a black box defines a parameter named init_value. A generic with name
init_value can be set as follows:
simulink_block = this_block.blockName;
init_value = get_param(simulink_block,'init_value');
this_block.addGeneric('init_value', 'String', init_value);
Note: You can add your own parameters (e.g., values that specify generic values) to the black box
by doing the following: