Use HDL Parameters in Cosimulation
You can configure Verilog or VHDL parameters in a cosimulation. When you use the Cosimulation Wizard to generate an HDL
Cosimulation block or an
System object™, the Simulation Options step creates a configuration
DUT is the name of your HDL DUT. The configuration file
includes a line for each HDL parameter, with a default value assigned. Uncomment the
line for the parameter you want to configure and assign a value to override the default
For example, consider this generated configuration file, generated for ModelSim® cosimulation.
# Uncomment lines below for any parameter whose default value you want to change. # For parameters marked "N/A" (not available) the default value could not be # determined, but you can override in the same way. #-G/design_top/coeff1=0 #-G/design_top/coeff2=18 #-G/design_top/coeff3=74
To change the value of
coeff1 to 32, uncomment that line and assign
a value of 32.
-G/design_top/coeff1=32 #-G/design_top/coeff2=18 #-G/design_top/coeff3=74
Similarly, when you cosimulate with Xcelium™, the parameters in the configuration file are created with the
-gpg directive to force value assignment for generics and
-gpg "design_top.coeff1=120 #-gpg "design_top.coeff2=18 #-gpg "design_top.coeff3=74
This feature is not supported for Vivado® cosimulation
Supported Data Types
Supported Verilog data types
Integer — Up to 32 bit
String — Up to 256 byte
Supported VHDL data types
String — Up to 256 byte
Cosimulation with Parameterized Port Size
In a Simulink® cosimulation, if your HDL design includes a parameter that configures the width of an input or an output port, the Cosimulation Wizard creates an HDL Cosimulation block with the default value for that port width. After generating the block, if you override the default value and assign another value to that parameter, you must follow these steps:
parameter_file and override the parameter value to reflect the desired port width. For example, change the
Make sure that the HDL simulator is not open. In the Simulink canvas that opens after generating the HDL Cosimulation block, double-click the block labeled Compile HDL Design to recompile the HDL design. Then, double-click the block labeled Launch HDL Simulator to start the HDL simulator.
After the HDL simulator opens and loads the design, open the HDL Cosimulation block mask. On the Ports tab, select each port and click Delete until the table is empty.
Click Auto Fill and, in the Auto Fill pane that opens, enter the path to the DUT.
Click Fill. The port list reflects the new parameter value.
This port list includes the HDL ports with the modified port widths, as well as ports for clock and reset. Since Simulink has an implicit clock and reset, you can select and remove those two ports from the list.
Continue cosimulation activities. Do not regenerate the block.