In reply to mehul.gor:
In Verilog/SystemVerilog, a potentially time consuming routine must be written as a task.
task READ_DPI(input int address, output int data);
#100 data = MEM[address];
endtask
export "DPI-C" task READ_DPI;
If you compile this code generating a DPI header file, it will produce this prototype:
DPI_LINK_DECL int
READ_DPI(
int address,
int* data);
An output argument is passed by reference in C. Note that the int return value of a DPI exported task is used for disables, and can be ignored if not used.
Your code can call this routine as:
#include "dpi.h"
...
READ_DPI(address,&data);
...
If you really need the READ routine to be a function in C, you can put a wrapper around it:
int READ(
int address) {
int data;
READ_DPI(address &data);
return data;
}