Main Content

Generate Cross-Platform DPI Components

Use DPI component generation to export a Simulink® subsystem to a C language component with a digital programming interface (DPI) for use in a Verilog® or SystemVerilog simulation. You can customize DPI generation for ModelSim® or Xcelium™ (Linux® only), or you can generate a generic DLL.

When you generate the component from a Windows® 64 host machine, you can also build the component libraries and run the simulation on a different operating system. If your target and host are not the same, you must port and build the shared libraries or HDL simulator projects manually. You cannot port a DPI component generated on a Linux machine to any other operating system.

Select Target Toolchain

When your target machine uses the same operating system as your host, you can select an installed compiler or request that the tools find a compiler automatically. If you want to generate a simulator project, or if you have no other compilers installed, select an HDL simulator for the same operating system as the host. However, if your target operating system is different from the host, you must select a target simulator and operating system.

Open your model, and on the Apps tab, click HDL Verifier. Select DPI Component Generation on the left pane, and on the HDL Verifier tab, click C Code Settings. The Configuration Parameters dialog opens on the Code Generation pane. The, under Toolchain settings, select a target Toolchain. This option specifies the target simulator and operating system where you run simulations. The supported cross-product toolchains are:

  • Mentor Graphics ModelSim/QuestaSim (64-bit Windows) (available from Windows host only)

  • Mentor Graphics ModelSim/QuestaSim (32-bit Windows) (available from Windows host only)

  • Cadence Xcelium (64-bit Linux)

  • Mentor Graphics ModelSim/QuestaSim (64-bit Linux)

To build a shared library for a different operating system, you must select one of the simulator options. You can then build the library on your target machine.

Generate Component

On the configuration parameters, under Target Selection, for System target file click Browse. Select systemverilog_dpi_ert.tlc from the list.

To generate your component and an optional test bench, follow Generate SystemVerilog DPI Component from step 3 and on.

Package Files for Transfer

After generating the component, use the packNGo (MATLAB Coder) function to package the generated files and any required dependencies before copying them to the target machine.

load('subsystem_build/buildInfo.mat')
packNGo(buildInfo, 'minimalHeaders', false)
Where subsystem is the name of the Simulink subsystem used for DPI generation. The result is a zip file named subsystem.zip.

Copy to Target Machine

To use your generated component on a different operating system, you must copy the generated package file to the target machine, unzip it, and build the libraries there.

  1. Copy the generated subsystem.zip file from the host machine to the target machine. The .zip file is located in the same folder as your model. The ModelSim .do file or Xcelium .sh file is included in the .zip file.

  2. Unzip the file into a folder of your choice.

Build Libraries

When you generate the component on the host machine, the libraries are built for that operating system. To port the component to a different operating system, you must build the components manually on the target machine. To build your simulator project or generic shared library, find your target operating system and HDL simulator in the table and follow the instructions.

Target Operating SystemHDL SimulatorBuild Instructions
Windows 32 ModelSim
  • Check that the gcc_ver_mingw32 library is installed in your ModelSim installation folder. This compiler is available when you install ModelSim. Install the compiler before building the component.

  • Start the ModelSim HDL simulator.

  • In the command window, change to the folder where you unzipped the generated files.

  • Build the project with this command:

    do subsystem.do

    Where subsystem is the name of the Simulink subsystem used for DPI generation.

LinuxModelSim
  • Start the ModelSim HDL simulator.

  • In the command window, change to the folder where you unzipped the generated files.

  • Build the project with this command:

    do subsystem.do

    Where subsystem is the name of the Simulink subsystem used for DPI generation.

Xcelium
  • In a terminal shell with Xcelium on the path, build the project with this command:

    sh subsystem.sh

    Where subsystem is the name of the Simulink subsystem used for DPI generation.

See Also

(MATLAB Coder)

Related Topics