Hi Expert,
Now I am implementing C + SV DPI.
In C function, there is “unsigned char * abuf” which has some size of data and I’d like to pass this to SV by calling SV tasks with this pointer as argument.
Could you guide how to do this ?
Regards,
Rim.
In reply to babyworm7:
Hi Babyworm1,
Thanks for your reply.
Yes. I saw that before. But I’m lookin for a way how to handle that in SV side after getting that “chandle”. In SV side, if I get a chandle(which is unsigned char array) from C side, how can I access the elements with this chandle ?
Regards,
Rim.
In reply to orgjhrim1:
SystemVerilog has no pointers and therefore there’s no way reference a pointer that C understands from SystemVerilog.
However, the DPI will convert an SystemVerilog function/task argument to a pointer in C that you can access depending on the argument direction. However, each language domain is responsible it own memory allocation, so you can’t pass a variable sized data structure from C to SV without allocating the space to hold it on the SystemVerilog side first. For smaller data structures you could define a fixed sized array, copy the needed data and also pass the size of the data as another argument.