User guide

22-51
SystemVerilog Design Constructs
Exporting time-consuming user-defined tasks is an LCA feature
requiring a special license.
Time-consuming user-defined tasks are also called blocking tasks,
they suspend, for some simulation time, the C or C++ function that
calls it.
The following is an example of a module definition containing such a
user-defined task:
`timescale 1 ns/1 ns
module test;
import "DPI" context task func_in_C(int i);
task task_in_SV(inout int i);
#5 i = i/2;
endtask
export "DPI" task task_in_SV;
initial
func_in_C(4);
endmodule
One of the first lines in the module declares the use of a C language
function later in the code:
import "DPI" context task func_in_C(int i);
This line says that we are importing (calling) a function in the C or
C++ language using the DPI. There is the following required
information in this declaration: