In reply to uvmbee:
Here is a sample code :
module hello_kitty;
export "DPI-C" task random_data;
import "DPI-C" context task read_from_c();
task read();
read_from_c();
endtask
task random_data(output int rdata,int wdata);
rdata = $urandom_range(0,20);
wdata = $urandom_range(0,10);
$display ("Randomized rdata = %d and wdata = %d",rdata,wdata);
endtask
endmodule :hello_kitty
module test;
hello_kitty h1();
initial repeat(10)
begin
h1.read;
// this works too - no wrapper needed
#500; // read every
end
endmodule
#include "stdio.h"
#include "svdpi.h"
extern int random_data(int*, int*);
int read_from_c(void)
{
int hi;
int hello;
int x;
x = random_data(&hi,&hello);
printf ("rdata = %d, wdata = %d \n",hi,hello);
return 0;
}