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的线。