Main Content

Generate DUT Ports for Tunable Parameters

Tunable parameters that you use to adjust your model behavior during simulation can map to top-level DUT ports in your generated HDL code. HDL Coder™ generates one DUT port per tunable parameter.

You can generate a DUT port for a tunable parameter by using it in one of these blocks:

  • Gain

  • Constant

  • MATLAB Function

  • MATLAB System

  • Chart

  • Truth Table

  • State Transition Table

These blocks with the tunable parameter can be at any level of the DUT hierarchy, including within a model reference.

You cannot use HDL cosimulation with a DUT that uses tunable parameters in any of these blocks. If you use a tunable parameter in a block other than these blocks, code is generated inline and does not map to DUT ports. To use the value of a tunable parameter in a Chart or Truth Table block, see Use Tunable Parameter in Other Blocks.

You can define and store the tunable parameters in the base workspace or a Simulink® data dictionary. However, a Simulink data dictionary provides more capabilities. For details, see What Is a Data Dictionary?.


  • The Simulink compiled data type for all instances of a tunable parameter must be the same.

  • Simulink blocks that use tunable parameters with the same name must operate at the same data rate.

To learn more about Simulink compiled data types, see Control Block Parameter Data Types.

Create and Add Tunable Parameter That Maps to DUT Ports

To generate a DUT port for a tunable parameter:

  1. Create a tunable parameter with StorageClass set to ExportedGlobal.

    For example, to create a tunable parameter, myParam, and initialize it to 5, at the command line, enter:

    myParam = Simulink.Parameter;
    myParam.Value = 5;
    myParam.CoderInfo.StorageClass = 'ExportedGlobal';

    Alternatively, using the Model Explorer, create a tunable parameter and:

    • In the Storage Class column of the Contents pane, click the configure link.

    • In the Dialog pane, click Configure in Coder App. Set Storage Class to ExportedGlobal.

    See Create Data Objects from Built-In Data Class Package Simulink.

  2. In your Simulink design, use the tunable parameter as the:

    • Constant value in a Constant block.

    • Gain parameter in a Gain block.

    • MATLAB® function argument in a MATLAB Function block.

Generated Code

The following VHDL® code is an example of code that HDL Coder generates for a Gain block with its Gain field set to a tunable parameter, myParam. You see that the code generator creates a DUT port and adds a comment to indicate that the port corresponds to a tunable parameter.

  PORT( In1      : IN   std_logic_vector(15 DOWNTO 0); -- sfix16_En5
        myParam  : IN   std_logic_vector(15 DOWNTO 0); -- sfix16_En5 Tunable port
        Out1     : OUT  std_logic_vector(31 DOWNTO 0) -- sfix32_En10
END s;


  -- Signals
  SIGNAL myParam_signed  : signed(15 DOWNTO 0); -- sfix16_En5
  SIGNAL In1_signed      : signed(15 DOWNTO 0); -- sfix16_En5
  SIGNAL Gain_out1       : signed(31 DOWNTO 0); -- sfix32_En10

  myParam_signed <= signed(myParam);

  In1_signed <= signed(In1);

  Gain_out1 <= myParam_signed * In1_signed;

  Out1 <= std_logic_vector(Gain_out1);

END rtl;


Make sure that the Use trigger signal as clock check box is left cleared by default. When you use test point or tunable parameters in the IP core workflow, the DUT must be a subsystem level DUT and not the top-level model or model reference DUT.

Use Tunable Parameter in Other Blocks

To use the value of a tunable parameter in a Chart or Truth Table block:

  1. Create the tunable parameter and use it in a Constant block.

  2. Add an input port to the block where you want to use the tunable parameter.

  3. Connect the output of the Constant block to the new input port.

Related Topics