User guide

24-255
SystemVerilog Testbench Constructs
Time Consuming Blocking Tasks
When SystemVerilog calls a C import task, this task can then call
blocking (context) SystemVerilog tasks. This is particularly useful if
the C code must call a read/write task in a SystemVerilog BFM
model.
Note that the C task must be initially called from SystemVerilog using
an import task call. For example, the following C code contains a test
that calls the SystemVerilog apb_write task as needed to issue
writes on an APB bus.
#include<svdpi.h>
extern void abp_write(int, int);
void c_test(int base) {
int addr, data;
for(addr=base; addr<base+5; addr++) {
data = addr * 100;
apb_write(addr, data);
printf("C_TEST: APB_Write : addr = 0x%8x, data = 0x%8x\n",
addr, data);
}
}