如何在系统verilog中返回关联数组



hello想知道关联数组是如何作为返回值传递的

代码:

function abc()
begin
int value[string][string];
value = def();
end
function int def()
begin
int new_value[string][string];
//logic to populate the array
return new_value;
end

我看到以下错误:目标的类型为int。而源的类型是int$[string][string]。

如何处理此问题并无缝传递关联数组?

对于返回聚合类型的函数,您需要首先声明一个typedef,然后将其用作返回值。

typedef int AA_t[string][string];
function AA_t def();
AA_t new_value; 
//logic to populate the array
return new_value;
endfunction

一旦你有了typedef,你不妨在任何地方都使用它。

最新更新