Customize Generated SystemVerilog Code

Set Up Model for Customized Code Generation

  1. Open your model and select Simulation > Model Configuration Parameters.

  2. Select Code Generation from the left pane.

  3. 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).

  4. 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.

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

  6. Select Customize generated SystemVerilog code.

  7. 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.

  8. 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 your model, generate C code for subsystem.

    You can generate C code from the MATLAB® command line by using the command rtwbuild.

  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.