不同的结构元素“由连续和过程性赋值写入”。

发布于 2025-01-11 05:36:01 字数 2567 浏览 0 评论 0原文

为什么我得到:

# ** 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 在每个 ij 迭代之间都是独立的。

为什么这是无效的?

无法使用结构来对信号进行分组实在是太烦人了......

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾城月光淡如水﹏ 2025-01-18 05:36:01

该错误消息是由于 IEEE 1800-2017 SystemVerilog LRM。基本上,由于 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

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 of ar[i] is ar 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.

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文