主要内容

DPICustomTemplateConfiguration

R2026b

Configure custom template for Simulink DPI component generation

Since R2026b

Description

Add-On Required: This feature requires the ASIC Testbench for HDL Verifier add-on.

Use DPICustomTemplateConfiguration objects to configure a custom template for generating SystemVerilog DPI or a UVM component from a Simulink® model.

After you configure the object, save it to a MAT file and specify the MAT file path in the Simulink configuration parameters. When you set the DPI component template type to Custom, the code generator uses the settings stored in the object.

If you generate DPI components from MATLAB® functions rather than Simulink models, use the svdpiConfiguration object with the dpigen function instead.

Creation

Description

cfg = DPICustomTemplateConfiguration() creates a DPICustomTemplateConfiguration object with default settings.

example

cfg = DPICustomTemplateConfiguration(Name=Value) creates a DPICustomTemplateConfiguration object with additional options specified by one or more name-value pair arguments.

example

Properties

expand all

Template Files

Component template files for DPI code generation, specified as a string scalar, string array, character vector, or cell array of character vectors containing paths to .tlc files.

You must set this property before generating code. Each path must reference an existing .tlc file. You can specify absolute paths, relative paths (resolved relative to the current working directory), or filenames on the MATLAB path.

Example: "my_component.tlc"

Example: {"my_component.tlc", "my_package.tlc"}

Data Types: string | char | cell

Testbench template files for DPI testbench generation, specified as a string scalar, string array, character vector, or cell array of character vectors containing paths to .tlc files.

This property is required when testbench generation is enabled in the Simulink configuration parameters. Each path must reference an existing .tlc file. You can specify absolute paths, relative paths (resolved relative to the current working directory), or filenames on the MATLAB path.

Example: "my_testbench.tlc"

Data Types: string | char | cell

Template Data

This property is read-only.

Custom port groups for TLC template variables, represented as a struct. Each field name is a port group name, and the corresponding value is the list of port names in that group. In TLC templates, access port group data using ptd.* variables.

To add or remove port groups, use the addPortGroup and removePortGroup functions.

Data Types: struct

Custom key-value pairs that populate global template dictionary (gtd.*) variables in TLC templates, specified as a cell array. The first column contains variable names and the second column contains variable values. Names and values must be character vectors.

Example: cfg.TemplateDictionary = {'CopyrightOwner', 'Acme Corp'; 'ToolVersion', '2.1'}

Generation Options

Indicator for sequential module, specified as a logical scalar. The template adds ports for clock, clock enable, and reset signals. Use it when you have state in your model (such as persistent variables) to create a sequential, registered SystemVerilog module.

Set this property to false when your template targets a combinational (unclocked) component.

Data Types: logical

Indicator for UVM template, specified as a logical scalar. This property affects the generated testbench, including termination of simulation.

When creating a custom UVM component, you must explicitly configure the required template variables using TemplateDictionary and the required port groups using addPortGroup that the UVM predictor expects.

Data Types: logical

Object Functions

addPortGroupAdd port group mapping to svdpiConfiguration or DPICustomTemplateConfiguration object
removePortGroupRemove port group mapping from svdpiConfiguration or DPICustomTemplateConfiguration object

Examples

collapse all

Create a custom template configuration object and set it to use a custom template named MyTemplate.tlc. Assign values to template directive using the TemplateDictionary property.

cfg = DPICustomTemplateConfiguration;
cfg.ComponentTemplateFiles = "MyTemplate.tlc";
cfg.TestBenchTemplateFiles = "MyTBTemplate.tlc";
cfg.TemplateDictionary = {'author','Jane Doe';'comment','This is a great demo!'}
cfg = 
  DPICustomTemplateConfiguration with properties:

    ComponentTemplateFiles: {'C:\Users\user\hdlverifier-ex86814857\MyTemplate.tlc'}
    TestBenchTemplateFiles: {'C:\Users\user\hdlverifier-ex86814857\MyTBTemplate.tlc'}
        TemplateDictionary: {2×2 cell}
                PortGroups: []
      IsSequentialTemplate: 1
             IsUVMTemplate: 0

To see the full example, see Use Custom Template to Generate DPI Component.

Limitations

  • When testbench generation is enabled in the configuration parameters, you must set Connection to Port list. The option of Interface is not supported.

  • When testbench generation is enabled in the configuration parameters, you must set Generate access function to test point to one of these options:

    • One function for all test points

    • None

    The option for One function per Test Point is not supported.

Version History

Introduced in R2026b