DPI-C Mapping data types

Currently working on verification IP for SPARC V8 using UVM

I have developed a reference model in C it calculates the result and destination register address based on instruction send from SV which is 32-bit length. so, if I declare in SV as
bit [31:0]inst;

and used
import “DPI-C” function void ref_model(input bit [31:0]inst,output bit [31:0]reg_data,output bit [4:0]reg_add);

what should the corresponding data type in C, I have tried like this in C
void ref_model(svBitVecVal* inst,svBitVecVal* reg_data,svBitVecVal* reg_add) // included svdpi.h
{
printf(“inst=%s\n”,inst);

}

when I tried to print inst in C some garbage gets printing also not getting outputs reg_data & reg_add.

appreciate if any experts help me, thank you.

If you are using Questa, then add -dpiheader filename.h" to the vlog command line. This generates the actual prototype needed in C. You should include that file in your C source code so that checks for errors can be made at compile time.

Your print statement should be

printf("inst=%x\n",inst);

you are not printing a string. I would need to see the code that is writing to the outputs to tell you what is wrong.

I would also suggest that you use C compatible types (int unsigned) if you can rather than packed arrays of bits. It will be more efficient.

yes sir,
printf(“inst=%x\n”,*inst);
works…