2013-07-30 54 views
1

的常量我寫了這樣的代碼下面進行連結,但它顯示了一個錯誤:串聯SystemVerilog中

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 

這裏的錯誤是表明constants cannot be concatenated

它不能連接這裏的零和一個。任何人都可以幫我解決這個問題嗎?

+0

這條線是什麼說的 - {b,c,d} = 3'b111? –

+0

'{b,c,d} = 3'b111; '這條線意味着b,c&d將分別指定爲1'b1,1'b1&1'b1。 –

回答

3

當前代碼連接32位(或整數)寬度0。你真正想要的是:

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

NB:通過節奏把這個工具,我得到:

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)]. 
+1

甚至'a = {b,c,2'b00,d};' – toolic

2

請參閱IEEE 1800-2012 LRM,在11.4.12連接操作

Unsized constant numbers shall not be allowed in concatenations. This is because the size of each operand in the concatenation is needed to calculate the complete size of the concatenation.

所以它非法使用。您必須明確指定常數的位大小。

0

由於錯誤說常量不能連接,所以在這裏你試圖串接常量值,這是非法的。明確提及每個值的位大小將解決您的問題。以下是代碼:

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