1.Verilog中如果wire連接到常量,而常量沒有說明他的位寬,那么將會默認為32位
如:
input [3:0] x ; wire [3:0] a; assign a = 3 + x;
上述代碼在綜合的時候,會將a擴展成32位進行操作,而事先聲明常量位寬將不會出現,如下:
1 input [3:0] x ; 2 wire [3:0] a; 3 assign a = 4d’3 + x;
這一點看起來沒什么大不了的,但是有時候卻會出現我們想的不一樣的結果,請看下面的代碼:
1 input [63 : 0] x; 2 output [63 : 0] y; 3 assign y = x + ('d122<<32);
本來想把低32位加到高32位,然而由於沒有說明常量的位寬,系統綜合默認常量為32位,當移位后其實為32'd0,因此上面的代碼實際還是那個相當於實現 y = x + 32'd0 ,如果要得到正常的結果需要說明位寬,如下:
1 input [63 : 0] x; 2 output [63 : 0] y; 3 assign y = x + (64'd122<<32);
考慮到為了避免這樣的情況出現,我們盡量不要省略常量的位寬。
2.在QuartusII默認的是線型
Quartus II中有些線可以不聲明就使用,系統綜合會默認添加相應的wire型,如下:
1 //已有模塊 2 module A 3 ( 4 input a, 5 output b; 6 ); 7 ............ 8 endmodule 9 10 module B( 11 input a, 12 output y, 13 ); 14 ............ 15 endmodule 16 17 module C( 18 19 ); 20 21 A A1( 22 .a(net1) 23 .b(netout) 24 ); 25 26 B B1( 27 .a(net1), 28 .y(netout1) 29 ); 30 endmodule
上面的框架綜合后自動生成沒有聲明的wire的線。