不同的结构元素“由连续和过程性赋值写入”。
为什么我得到:
# ** Error (suppressible): testbench.sv(27): (vopt-12003) Variable 'ar[0].subar[0]' written by continuous and procedural assignments. See testbench.sv(19).
# ** Error (suppressible): testbench.sv(27): (vopt-12003) Variable 'ar[0].subar[1]' written by continuous and procedural assignments. See testbench.sv(19).
# ** Error (suppressible): testbench.sv(27): (vopt-12003) Variable 'ar[0].subar[2]' written by continuous and procedural assignments. See testbench.sv(19).
# ** Error (suppressible): testbench.sv(27): (vopt-12003) Variable 'ar[0].subar[3]' written by continuous and procedural assignments. See testbench.sv(19).
# ** Error (suppressible): testbench.sv(27): (vopt-12003) Variable 'ar[1].subar[0]' written by continuous and procedural assignments. See testbench.sv(19).
# ** Error (suppressible): testbench.sv(27): (vopt-12003) Variable 'ar[1].subar[1]' written by continuous and procedural assignments. See testbench.sv(19).
# ** Error (suppressible): testbench.sv(27): (vopt-12003) Variable 'ar[1].subar[2]' written by continuous and procedural assignments. See testbench.sv(19).
# ** Error (suppressible): testbench.sv(27): (vopt-12003) Variable 'ar[1].subar[3]' written by continuous and procedural assignments. See testbench.sv(19).
对于这段代码:
module tb;
logic clk;
struct {
struct {
logic seq;
logic assig;
logic seq2;
} subar [4];
} ar [2];
always_ff @(posedge clk) begin
for (int i=0; i<2; i++) begin
for (int j=0; j<4; j++) begin
ar[i].subar[j].seq <= '1;
end
end
end
generate
for (genvar i=0; i<2; i++) begin
for (genvar j=0; j<4; j++) begin
assign ar[i].subar[j].assig = '1;
end
end
endgenerate
always_ff @(posedge clk) begin
for (int i=0; i<2; i++) begin
for (int j=0; j<4; j++) begin
ar[i].subar[j].seq2 <= '1;
end
end
end
endmodule
所有三个逻辑在结构内部都是独立的,并且它们没有分配在两个不同的块中。
EDA Playground:https://www.edaplayground.com/x/qYZ9
替换generate/分配与always_comb
always_comb begin
for (int i=0; i<2; i++) begin
for (int j=0; j<4; j++) begin
ar[i].subar[j].assig = ar[i].subar[j].seq;
end
end
end
将生成与分配
替换为always_comb
块给出了不同的结果,因为所有*.seq
信号是X
。
每个 assig = seq
在每个 i
和 j
迭代之间都是独立的。
为什么这是无效的?
无法使用结构来对信号进行分组实在是太烦人了......
Why do I get :
# ** Error (suppressible): testbench.sv(27): (vopt-12003) Variable 'ar[0].subar[0]' written by continuous and procedural assignments. See testbench.sv(19).
# ** Error (suppressible): testbench.sv(27): (vopt-12003) Variable 'ar[0].subar[1]' written by continuous and procedural assignments. See testbench.sv(19).
# ** Error (suppressible): testbench.sv(27): (vopt-12003) Variable 'ar[0].subar[2]' written by continuous and procedural assignments. See testbench.sv(19).
# ** Error (suppressible): testbench.sv(27): (vopt-12003) Variable 'ar[0].subar[3]' written by continuous and procedural assignments. See testbench.sv(19).
# ** Error (suppressible): testbench.sv(27): (vopt-12003) Variable 'ar[1].subar[0]' written by continuous and procedural assignments. See testbench.sv(19).
# ** Error (suppressible): testbench.sv(27): (vopt-12003) Variable 'ar[1].subar[1]' written by continuous and procedural assignments. See testbench.sv(19).
# ** Error (suppressible): testbench.sv(27): (vopt-12003) Variable 'ar[1].subar[2]' written by continuous and procedural assignments. See testbench.sv(19).
# ** Error (suppressible): testbench.sv(27): (vopt-12003) Variable 'ar[1].subar[3]' written by continuous and procedural assignments. See testbench.sv(19).
for this code:
module tb;
logic clk;
struct {
struct {
logic seq;
logic assig;
logic seq2;
} subar [4];
} ar [2];
always_ff @(posedge clk) begin
for (int i=0; i<2; i++) begin
for (int j=0; j<4; j++) begin
ar[i].subar[j].seq <= '1;
end
end
end
generate
for (genvar i=0; i<2; i++) begin
for (genvar j=0; j<4; j++) begin
assign ar[i].subar[j].assig = '1;
end
end
endgenerate
always_ff @(posedge clk) begin
for (int i=0; i<2; i++) begin
for (int j=0; j<4; j++) begin
ar[i].subar[j].seq2 <= '1;
end
end
end
endmodule
All the three logics are independent inside the structure and they aren't assigned in two different blocs.
EDA Playground: https://www.edaplayground.com/x/qYZ9
Replacing the generate/assign with always_comb
always_comb begin
for (int i=0; i<2; i++) begin
for (int j=0; j<4; j++) begin
ar[i].subar[j].assig = ar[i].subar[j].seq;
end
end
end
Replacing the generate with assign
with an always_comb
bloc gives a different result because all the *.seq
signals are X
.
Each assig = seq
are all independent between each i
and j
iteration.
Why is this invalid?
Not being able to use a structure to group signals is excessively annoying...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该错误消息是由于 IEEE 1800-2017 SystemVerilog LRM。基本上,由于
i
是一个变量索引,因此ar[i]
的长静态前缀是ar
并且任何数组或结构选择后续的无关紧要。工具已经更加乐观地对待这个问题,但这是一个渐进的过程。您可以全局抑制错误,也可以重写代码,将
for
循环从块移出到生成for
循环中。The error message is because of the rather pessimistic definition of Longest static prefix in section 11.5.3 of the IEEE 1800-2017 SystemVerilog LRM. Basically, since
i
is a variable index, the long static prefix ofar[i]
isar
and any array or struct selects succeeding that are irrelevant. Tools have been treating this more optimistically, but that has been a gradual process.You can either suppress the error globally, or rewrite the code moving the
for
loop out of the block into a generate-for
loop.