SystemVerilog 级联赋值不正确

SystemVerilog concatenation assignment is incorrect

我正在阅读这个 website 中有关连接的内容。 program如下:

program main ;
bit [4:0] a;
reg b,c,d;
initial begin
b = 0;
c = 1;
d = 1;
a = {b,c,0,0,d};
{b,c,d} = 3'b111;
$display(" a %b b %b c %b d %b ",a,b,c,d);
end
endprogram

结果是:

a 00001 b 1 c 1 d 1

c 被赋值为 1 时,c 如何在串联中赋值给 a 时得到结果值 0?

在Verilog中,如果没有声明位宽和基数,则假定为32位十进制。因此,0 等同于 32'd0

你想要a = {b,c,1'b0,1'b0,d};。或者你可以用 a = {b,c,2'b0,d};

把它设为 2 位零

文字 01 没有确定大小,但它们实际上是隐式的 32 位。根据 1800-2017 LRM,由于这个常见错误,将未确定大小的数字字面量放在串联中是非法的。您使用的工具没有捕捉到这个。

你应该用明确大小的文字来写这个

a = {b,c,1'b0,1'b0,d};