User guide
22-53
SystemVerilog Design Constructs
Notice that there is a delay in this user-defined task. This is a blocking
task for the C or C++ function that calls it. The argument for this
user-defined task has the inout direction.
Next comes the declaration that the user-defined task can be called
by a C or C++ function:
export "DPI" task task_in_SV;
The module ends with procedural code that calls the C or C++
function:
initial
func_in_C(4);
The C or C++ source code is as follows:
#include <svdpi.h>
extern int task_in_SV(int *i);
void func_in_C(int i)
{
printf("before export, i=%d\n",i);
task_in_SV(&i);
printf("after export, i=%d\n",i);
}
The #include preprocessor statement:
#include <svdpi.h>
Specifies declarations and prototypes of SystemVerilog DPI library
functions and tasks. Synopsys recommends including this line before
calls to DPI functions and tasks.