简体   繁体   English

localparam / 带有解包数组的参数:icarus

[英]localparam / parameter with unpack array : icarus

I am trying to initilize unpack parameter.我正在尝试初始化解包参数。

module dut #(parameter int arr[3]) 
(
input logic clk
);
endmodule

module main;
int t[3];
initial begin
t[0] = 0;
t[1] = 1;
t[2] = 2;
end
localparam int arr1[3] = t; //'{1,2,3};

localparam int A0 = 1;
localparam int A1 = 1;
localparam int A2 = 1;

localparam int [3] arr = '{A0, A1, A2};
logic clk;
                   
dut
# (.arr (arr)) 
dut_inst1
(.clk(clk));

dut
# (.arr (arr1)) 
dut_inst1
(.clk(clk));

endmodule

Icarus does not like any unpack initilization I tried. Icarus 不喜欢我尝试过的任何解包初始化。

I would have used pack initilization but then I have problem using it when generating based on it.我本来可以使用 pack initilization,但是基于它生成时我在使用它时遇到了问题。

Icarus is not a system verilog compiler. Icarus 不是系统verilog 编译器。 it implements some features but not all of them.它实现了一些功能,但不是全部。 The following example is a legal system verilog, but not an icarus one.以下示例是一个法律系统 verilog,但不是 icarus。

It looks like icarus 0.10 (from eda playground) does not understand parameter arrays and assignment patterns.看起来 icarus 0.10(来自 eda playground)不理解参数 arrays 和分配模式。 So, most likely there is no good way to do it without using separate parameter per array element.因此,如果不为每个数组元素使用单独的参数,很可能没有好的方法可以做到这一点。 I do not have newer versions though.我没有更新的版本。 Talk to icarus community.与伊卡洛斯社区交谈。

As for correct system verilog syntax, in the following example I fixes your t by using the previously commented aggregate assignment and fixes your declaration of parameters in dut and localparam in main.至于正确的系统 verilog 语法,在下面的示例中,我通过使用先前评论的聚合赋值修复了你的t ,并修复了你在 main 中的 dut 和 localparam 中的参数声明。 It is compilable with a commercial simulators but not with icarus.它可以用商业模拟器编译,但不能用 icarus 编译。

module dut #(parameter int arr[3] = '{0,0,0}) 
(
input logic clk
);
endmodule

module main;
/*
int t[3];
initial begin
t[0] = 0;
t[1] = 1;
t[2] = 2;
end
*/
  
  localparam int arr1[3] = '{1,2,3};

localparam int A0 = 1;
localparam int A1 = 1;
localparam int A2 = 1;

  localparam int arr [3] = '{A0, A1, A2};
logic clk;

 
dut
# (.arr (arr)) 
dut_inst1
(.clk(clk));

dut
# (.arr (arr1)) 
dut_inst2
(.clk(clk));

  
endmodule

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM