Main Content

Tunable Parameters in Sequence Subsystem

When a Simulink® sequence subsystem includes tunable parameters, the uvmbuild function generates a sequence object that contains a SystemVerilog parameter for each tunable parameter. These parameters can be randomized, and their minimum, maximum, and default values are derived from the Simulink parameter.


This feature requires the ASIC Testbench for HDL Verifier add-on.

Prepare Sequence for UVM Generation With Tunable Parameters

To prepare the sequence subsystem for Universal Verification Methodology (UVM) generation with tunable parameters, take these steps.

  1. Set up your Simulink model for DPI and UVM generation. On the Modeling tab in Simulink, click Model Settings. In the Configuration Parameters dialog box, select Code Generation on the left pane. Then, set System target file to systemverilog_dpi_grt.tlc If you have the Embedded Coder® product you can alternatively set this value to systemverilog_dpi_ert.tlc.

  2. Create a data object for your parameter by using the Simulink.Parameter (Simulink) object. For example, to create a parameter named dataValue, enter this code at the MATLAB command prompt.

    dataValue = Simulink.Parameter
    open dataValue

    Define properties for the dataValue parameter. In the Simulink.Parameter window, set these values.

    • Value – Set the default value for the generated UVM parameter.

    • Minimum – Set the minimum value for generated UVM parameter.

    • Maximum – Set the maximum value for generated UVM parameter.

    • Data type – Set the data type for the generated UVM parameter. For the sequence subsystem, note the difference between using integer and floating point data types for constrained random parameters.

    • Storage class – Select Model default, SimulinkGlobal, or ExportedGlobal.

      Use Model default when your parameter is instance-specific. Use either SimulinkGlobal or ExportedGlobal to generate a global variable. Setting Storage class to Auto optimizes the parameter during code generation, and is not recommended.

  3. Use the parameter you created in the sequence subsystem of your Simulink model. For example, you can parameterize a Constant (Simulink) block to generate random values within a given range by setting its Constant value (Simulink) parameter to the Simulink parameter you previously defined.

Generate UVM Sequence

Use the uvmbuild function to generate a UVM test bench. In addition to the files regularly generated by uvmbuild, the function adds components to the file top_model_name_uvmbuild/uvm_testbench/sequence/

  • When you use integer data types, the sequence contains two added SystemVerilog random constraint code-blocks.

    • Default value

    • range

    The values for these constraints are derived from the value you set in the Simulink parameter.

  • When you use floating point data types, the sequence contains these two additional functions.

    • pre_randomize – This function sets the default value for the tunable parameter.

    • post_randomize – This function checks that the value set for the parameter is within the range defined in the Simulink parameter.

      When using integer data types, these functions are empty.

For more information about the files generated by the uvmbuild function, see Generated Files and Folder Structure.

Control Sequence Parameters in UVM Simulation

After generating UVM components for your system, you can control stimulus generation in one of these two ways.

If a tunable parameter is of integer data type, you can turn on or off the default value and range constraints. You can also add and set additional SystemVerilog constraints.

If a tunable parameter is of floating point data type, you can:

  • Write your own randomize function by using the pre_randomize function.

  • Change the default value of the parameter by extending the pre_randomize function.

The post_randomize function checks that the floating point tunable parameter is within the range defined in the Simulink model. If the Minimum and Maximum properties of the Simulink parameter are empty, this function is empty.

See Also

Related Topics