-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhalf_adder.v
More file actions
33 lines (31 loc) · 755 Bytes
/
half_adder.v
File metadata and controls
33 lines (31 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
`timescale 1ns/10ps
module half_adder(cout,sum,a,b);
output sum,cout ;
input a,b ;
wire w1,w2,w3 ;
parameter delay = 0 ;
nand #delay n1(w1,a,b);
nand #delay n2(cout,w1,w1);
nand #delay n3(w2,a,w1);
nand #delay n4(w3,b,w1);
nand #delay n5(sum,w2,w3);
endmodule
module tb_half_adder();
wire tsum,tcout ;
reg ta,tb ;
half_adder uut(tcout,tsum,ta,tb);
initial $monitor("t=%3d, cout=%b, sum=%b, a=%b, b=%b",$time,tcout,tsum,ta,tb);
initial
begin
$dumpfile("half_adder.vcd");
$dumpvars;
end
initial
begin
#00 ta=1'b0 ; tb=1'b0 ;
#50 ta=1'b0 ; tb=1'b1 ;
#50 ta=1'b1 ; tb=1'b0 ;
#50 ta=1'b1 ; tb=1'b1 ;
#50 $stop ;
end
endmodule