不同的结构元素 "written by continuous and procedural assignments"
Different struct elements "written by continuous and procedural assignments"
为什么我得到:
# ** 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 游乐场:https://www.edaplayground.com/x/qYZ9
将 generate/assign 替换为 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
块替换带有 assign
的生成器会给出不同的结果,因为所有 *.seq
信号都是 X
.
每个assig = seq
在每个i
和j
迭代之间都是独立的。
为什么这个无效?
无法使用结构对信号进行分组实在是太烦人了...
错误信息是由于 IEEE 1800-2017 SystemVerilog LRM 的第 11.5.3 节中对 最长静态前缀 的相当悲观的定义。基本上,由于 i
是一个变量索引,因此 ar[i]
的长静态前缀是 ar
并且任何数组或结构选择不相关的后继。工具一直在更乐观地对待这个问题,但这是一个渐进的过程。
您可以全局抑制错误,或重写代码,将 for
循环移出块,进入生成-for
循环。
module tb;
logic clk;
struct {
struct {
logic seq;
logic assig;
logic seq2;
} subar [4];
} ar [2];
for (genvar i=0; i<2; i++) begin
for (genvar j=0; j<4; j++) begin
always_ff @(posedge clk) begin
ar[i].subar[j].seq <= '1;
end
end
end
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
for (genvar i=0; i<2; i++) begin
for (genvar j=0; j<4; j++) begin
always_ff @(posedge clk) begin
ar[i].subar[j].seq2 <= '1;
end
end
end
endmodule
为什么我得到:
# ** 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 游乐场:https://www.edaplayground.com/x/qYZ9
将 generate/assign 替换为 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
块替换带有 assign
的生成器会给出不同的结果,因为所有 *.seq
信号都是 X
.
每个assig = seq
在每个i
和j
迭代之间都是独立的。
为什么这个无效?
无法使用结构对信号进行分组实在是太烦人了...
错误信息是由于 IEEE 1800-2017 SystemVerilog LRM 的第 11.5.3 节中对 最长静态前缀 的相当悲观的定义。基本上,由于 i
是一个变量索引,因此 ar[i]
的长静态前缀是 ar
并且任何数组或结构选择不相关的后继。工具一直在更乐观地对待这个问题,但这是一个渐进的过程。
您可以全局抑制错误,或重写代码,将 for
循环移出块,进入生成-for
循环。
module tb;
logic clk;
struct {
struct {
logic seq;
logic assig;
logic seq2;
} subar [4];
} ar [2];
for (genvar i=0; i<2; i++) begin
for (genvar j=0; j<4; j++) begin
always_ff @(posedge clk) begin
ar[i].subar[j].seq <= '1;
end
end
end
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
for (genvar i=0; i<2; i++) begin
for (genvar j=0; j<4; j++) begin
always_ff @(posedge clk) begin
ar[i].subar[j].seq2 <= '1;
end
end
end
endmodule