Concatenation systemverilog中常量的串联

Concatenation systemverilog中常量的串联,concatenation,system-verilog,Concatenation,System Verilog,我为串联编写了如下代码,但显示了一个错误: module 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 endmodule 这里的错误显示

我为串联编写了如下代码,但显示了一个错误:

module 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  
endmodule  
这里的错误显示,
常量不能被串联


这里不能连接0和1。有人能帮我解决这个问题吗?

当前代码正在连接32位(或整数)宽度0。你真正想要的是:

a = {b, c, 1'b0, 1'b0, d};  
注:通过cadence工具,我得到:

file: main.sv
    a = {b,c,0,0,d};  
             |
ncvlog: *E,NONOWD (main.sv,11|13): Illegal use of a constant without an explicit width specification [4.1.14(IEEE)].
    a = {b,c,0,0,d};  
               |
ncvlog: *E,NONOWD (main.sv,11|15): Illegal use of a constant without an explicit width specification [4.1.14(IEEE)].
请参见11.4.12中的串联运算符

串联中不允许使用无大小的常量。这 是因为串联中每个操作数的大小需要 计算连接的完整大小


所以这是非法使用。您必须明确指定常量数字的位大小。

由于错误表明无法串联常量,因此您尝试串联常量值,这是非法的。明确提及每个值的位大小将解决您的问题。代码如下:

module concat;
  bit [4:0] a;
  reg b,c,d;
  initial
  begin
    b=1'b0;
    c=1'b1;
    d=1'b1;
    a={b,c,1'b0,1'b0,d};
    {b,c,d}=3'b111;
    $display("a: %b, b: %b, c: %b, d: %b",a,b,c,d);
  end
endmodule

这行写的是什么-{b,c,d}=3'b111?{b,c,d}=3'b111;`该行表示b、c和d将分别指定为1'b1、1'b1和1'b1。