User guide
24-253
SystemVerilog Testbench Constructs
Example:
import "DPI" task c_test(int addr);
initial c_task(1000);
export "DPI" task sv_add;
function int sv_add(input int a, input int b);
sv_add = a+b;
endtask
#include <svdpi.h>
extern void sv_add(int, int);
void c_task(int addr) {
...
sv_add(addr, 10);
...
}
vcs -sverilog top.sv c_task.c
Note:
You can export all SystemVerilog functions except class member
functions.
Limitations
In the current implementation of the DPI, import and export functions
are supported with some restrictions on the following data types:
• Unpacked structs/unions, byte, shortint, longint, and shortreal.
• Unpacked arrays of the above types
Include Files
The SystemVerilog 3.1a LRM defines the C layer for the DPI. The
C-layer of the DPI provides two include files: