如何将SV中的reg转换为C中的等效值(DPI)

问题描述 投票:0回答:1

我看到以下编译问题。

错误-[ICTTFC] 不兼容的复杂类型使用

  $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)

我将所需的 c 函数导入到 sv 中,如下所示: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

来自以下CC文件的函数在Memory.cc文件中定义如下:

 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;
   }

请在这里帮助我。 谢谢,

system-verilog system-verilog-dpi
1个回答
0
投票

形式/实际类型不兼容意味着您使用与原型不匹配的参数调用 write_dword。

看起来就像在

write_dword
的第二个函数参数中,您试图将 8 个 8 位字节的未打包数组传递给需要 8 位打包数组的函数参数。

在没有看到所有声明的情况下,我猜您需要将参数类型更改为

input logic [7:0] data[]
,添加
[]

© www.soinside.com 2019 - 2024. All rights reserved.