【发布时间】:2021-06-20 04:35:01
【问题描述】:
我希望 SystemVerilog 中的数据数组具有 C/C++ 端数组中数据的完整副本:
C/C++ 代码:
void myCfunc(svOpenArrayHandle results) {
int randomsize;
...
uint32_t myArray[randomsize];
...
svPutBitArrElemVecVal(results, myArray, 1); // copies only the first element
//svPutBitArrElemVecVal(results, myArray, 1, 2, 3); // still only copies the first element for some reason
// svCopyArr(results, myArray); // this isn't a DPI function, but I would like do to something like this.
// Copy the whole array, not just the an element
}
SV 代码:
module tb_top;
int results[100];
import "DPI-C" function myCfunc(output int results[]);
...
initial begin
myCfunc(results);
end
endmodule : tb_top
我的问题是我每次都不知道源数组的确切大小。此外,即使每次都是固定大小,我会想象对于大型数组来说,拥有一长串索引参数将是多余的。其他 SV-DPI 处理程序函数似乎不适用于我的案例,或者我一定误解了它们的使用方式。
【问题讨论】:
-
如何将数组大小作为单独的参数传递?
-
@Serge 实际上我已经这样做了。我的问题不在于 SV 方知道大小,而在于数组元素的实际分配。我使用的函数似乎只分配源数组的第一个元素
-
为此,您需要提供一个小型复制器示例并展示您的坏/好结果。
标签: c++ arrays system-verilog system-verilog-dpi