I have a question about the DPI connection between SystemVerilog and C. Specifically, I have a C function that looks like:
unsigned short C_FUN(unsigned char* data)
and what I want to pass to it is a bit[7:0] my_darray[];
Which is the best way to do it? Thanks in advance.
A mixed packed/unpacked dynamic array is handled as an
svOpenArrayHandle
in the C layer of the DPI. You're going to have to create a wrapper function that converts from the SystemVerilog type to your type:For more info on how to convert from have a look at the IEEE 1800-2012 standard, section 35 and annex H.
What you basically have are some nice functions that you can use to operate on the array (defined in the
svdpi.h
file):You can use these functions to loop over all elements and fill an array of
char
that will be pointed to bydata
.