Specifying VHDL Generics and Verilog Parameters - 2024.2 English

Vitis Model Composer User Guide (UG1483)

Document ID
UG1483
Release Date
2024-11-13
Version
2024.2 English

You can specify a list of generics that get passed to the module when Vitis Model Composer compiles the model into HDL. Values assigned to these generics can be extracted from mask parameters and from propagated port information (for example, 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 (for example, 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 can be invoked before the data types (or rates) are 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 can 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 (for example, values that specify generic values) to the black box by doing the following:
  • Copy a black box into a Simulink library or model.
  • Break the link on the black box.
  • Add the desired parameters to the black box dialog box.