C/C++ Interface

If your SystemVerilog project references C/C++ code via DPI/VPI, you can specify the C/C++ source files and compilation directives in the project’s Build Configurations. When simulation starts, the C/C++ sources are built into shared objects and automatically loaded into the simulation.

You can also specify pre-built shared objects using the standard -sv_lib, -sv_liblist and -sv_root run arguments, for example: -sv_lib /path/to/lib.so

If your project includes a UVM testbench, by default DVT IDE uses a built-in implementation of the UVM DPI-C methods, optimized for speed. Simply uncheck the corresponding box in the DVT Run Dashboard to compile and use the C implementations from the UVM library.

Note Currently C/C++ is only supported when running DVT IDE under Linux.

From the Project menu you can Generate DPI-C headers required for the C/C++ compilation. Header files are created in the dvt.data/native.bridge/headers directory located in the project root.

C/C++ compilation

  • C/C++ top files specified in build configuration file are compiled into shared objects, one shared object per invocation

  • compilation is done using a Makefile generated from the build config located at: dvt.data/native.bridge/bin/Makefile

  • compiled shared objects are stored inside: dvt.data/native.bridge/bin/objs. At runtime all shared objects located in this directory will be loaded

  • C/C++ flags collected at build are added to the Makefile. See C/C++ Support.

The following run directives are relevant for C/C++:

+dvtx_native_disable_compilation

Disables the compilation of C/C++ top files.

+dvtx_native_jimpl_uvm

Use the built-in library of UVM DPI-C implementations.

+dvtx_native_no_gen

Disable automatic generation of the C/C++ stubs and Makefile used for compilation. Useful if you want to hand-edit the files for debugging purposes.

+dvtx_native_trace

Enable native bridge trace info. Default value: false

+dvtx_native_verbosity

Enable native bridge verbose mode. Default value: false

Use the following build configuration directive to change the location of dvt.data:

+dvt_setenv+DVT_DATA=/path/to/dvt/data