Verilog整理

1.两种实例化

2.运算符//逻辑运算+按位运算//拼接运算符

3.reg默认为1位

4.{16{1}}与{16{1'b1}}不同

5.[1023:0] in

  ha[3:0]=(in>>(4*sel))

6.三位全加器

 1  module add( 
 2 
 3                 input a, b, cin,
 4 
 5                 output cout, sum 
 6 
 7         );
 8  assign cout=a&b|a&cin|b&cin,sum=a^b^cin;
 9  endmodule
10  module top_module( 
11 
12                 input [2:0] a, b,
13 
14                 input cin,
15 
16                 output [2:0] cout,
17 
18                 output [2:0] sum );
19     add a0(a[0],b[0],cin,cout[0],sum[0]);
20     add a1(a[1],b[1],cout[0],cout[1],sum[1]);
21     add a2(a[2],b[2],cout[1],cout[2],sum[2]);
22 endmodule

猜你喜欢

转载自www.cnblogs.com/xxmlala-fff/p/11846846.html
今日推荐