Main Content

Customize Generated SystemVerilog Code

Set Up Model for Customized Code Generation

  1. Open your model, and on the Apps tab, click HDL Verifier. Then, on the HDL Verifier tab, click C Code Settings. The Configuration Parameters dialog opens on the Code Generation pane.

  2. For System target file, click Browse and select systemverilog_dpi_grt.tlc.

    If you have a license for Embedded Coder®, you can select target systemverilog_dpi_ert.tlc. This target enables you to access its additional code generation options (on the Code Generation pane in Model Configuration Parameters).

  3. For Toolchain, in the Build process section, select the toolchain you want to use from the list. See Generate Cross-Platform DPI Components for guidance on selecting a toolchain.

    You can optionally select flags for compilation. For Build configuration, select Specify. Click Show Settings to display the current flags.

  4. In the left pane, expand Code Generation and select SystemVerilog DPI.

  5. Select Customize generated SystemVerilog code.

  6. Specify the SystemVerilog template you want to use by setting Source file template.

    Select Edit to see the contents of the specified Source file template. This example shows the content of the template file provided with HDL Verifier™, svdpi_grt_template.vgt:

    For more about the customized template, see Customization.

  7. Click OK to accept these options and close the Configuration Parameters dialog box. Next, go to Generate Customized SystemVerilog DPI Component.

Generate Customized SystemVerilog DPI Component

  1. In the HDL Verifier tab on the Simulink® toolstrip, select Generate DPI Component.

    You can alternatively use the slbuild (Simulink) function from the MATLAB® command line.

  2. If you built the component for the host machine, you can now use the component. If you intend to port the component to another machine with a different operating system, see Generate Cross-Platform DPI Components.