how to convert reg in SV to equivalent in C (DPI)

94 Views Asked by At

I am seeing following compilation issue.

Error-[ICTTFC] Incompatible complex type usage

  $STEM/MemInstance.sv, 88
  Incompatible complex type usage in task or function call.
  The following expression is incompatible with the formal parameter of the 
  function. The type of the actual is 'reg[7:0]$[]', while the type of the 
  formal is 'logic[7:0]'. Expression: trans.Data[0:7]
  Source info: cdnDdr5dimmUvmUser::write_dword(trans.Address, 
  trans.Data[0:7], 4'hf, 'b1)

I am importing the required c function into sv as follows:from MemInstance.sv ::

   import "DPI-C" function void write_dword(input logic [63:0] addr, input logic [7:0] data, int byteEn, int io);
   virtual function void writeSysMem(reg [63:0] addr, reg [7:0] data []);
      Memeorycompnent trans;
      trans = new();
      trans.Address = addr;
      trans.Data = data;
      void'(write_dword(trans.Address,trans.Data[0:7],4'hf,'b1));
   endfunction : writeSysMem

from the following CC file function is defined as follows in Memory.cc file:

 void write_dword(const svLogicVecVal* addr, const svLogicVecVal* data, uint32 byteEn, uint8 io=1)
   {
     uint64 my_addr0 = addr[0].aval;
     uint64 my_addr1 = addr[1].aval;
   }

Please help me here. Thanks,

1

There are 1 best solutions below

0
dave_59 On

Formal/actual type incompatibility means you are calling write_dword with arguments that don't match the prototype.

It looks in like in your second function argument to write_dword you are trying to pass an unpacked array of 8 8-bit bytes to a function argument that expects a packed array of 8-bits.

Without seeing all your declarations, I'm guessing you need to change the argument type to input logic [7:0] data[], adding the [].