using C programs in SV, DPI

Status
Not open for further replies.

prashantsid

Newbie level 5
Joined
Apr 8, 2012
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Faridabad, INDIA
Activity points
1,365
I have been trying to use DPI to use some functions i've made in C, in SV.. but somehow m not able to do this thing.
and the other way around , i.e. exporting SV functions in C was also a waste of time for me..

This is what i have tried doing,

in C side i wrote a dummy program say,
int main(void) {
printf("MSG printed from C side.\n");
}
complied the above code using,
gcc -c -fPIC <c-file-name.c> -o <obj-name.so>
obtained a shared object file from the above process.

then on SV side,
-sv_lib <path>/<obj-name-without-extensions>
module...
import "DPI" int main();
...
..
main();
..
endmodule

This is what i have tried using but the console didnt print anything..
Also it would be really great if somebody can give me any idea of how to use SV functions in C side..
i know that i need to export the function, but how my C program will be able to recognize it, which files i need to include in C prgram..
also i have learned from some internet source that there are two include file; svdpi.h and svdpi.h.
so if anybody has links to these header files along with the source object file , it would be really great..
BTW the tool i am using is ncsim..
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…