L29 Adder
L29 Adder
L29 Adder
Digital Circuits
Vipul Arora
Dept. of Electrical Engineering
IIT Kanpur
April 6, 2022
1
Comparator
A = A3 A2 A1 A0
𝐴𝒊 𝐵𝒊 𝒙 𝒚
B = B3 B2 B1 B0 0
0
0
1
1 0
( A = B ) = x3 x2 x1 x0 1 1
( A B ) = A3 B3 + x3 A2 B2 + x3 x2 A1 B1 + x3 x2 x1 A0 B0
( A B ) = A3 B3 + x3 A2 B2 + x3 x2 A1B1 + x3 x2 x1 A0 B0
2
Comparator
( A B ) = A3 B3 + x3 A2 B2 + x3 x2 A1 B1 + x3 x2 x1 A0 B0
( A B ) = A3 B3 + x3 A2 B2 + x3 x2 A1B1 + x3 x2 x1 A0 B0
3
( A B ) = A3 B3 + x3 A2 B2
+ x3 x2 A1 B1 + x3 x2 x1 A0 B0
( A B ) = A3 B3 + x3 A2 B2
+ x3 x2 A1 B1 + x3 x2 x1 A0 B0
( A = B ) = x3 x2 x1 x0 4
Adder
a
S a b S C S
b
0 0 0 0
0 1 1 0
C Half Adder C
1 0 1 0
1 1 0 1
S = a.b + a.b ; C = a.b
a b
a b Cin S Cout
S 0 0 0 0 0
1
0 0 1 1 0
111 0 1 0 1 0
110 Cout Full Adder Cin 0 1 1 0 1
--------- 1 0 0 1 0
1101 1 0 1 0 1
a b 1 1 0 0 1
1 1 1 1 1
b S 1 0 0 1 0
1 0 1 0 1
Cin .(a b) 1 1 0 0 1
a.b 1 1 1 1 1
Cout
Cin
6
4-bit Adder
S(0:3) A 3 A 2 A 1 A 0 B 3 B 2 B 1 B 0 S 3 S 2 S 1S 0 Cout C3 C2 C1
0000 0000 0000 0
1 A 3 A 2 A 1A 0
0000 0001 0001 0
0001 0000 0001 0
B 3 B 2 B 1B 0
Cout 4-bit adder
C 4 S 3 S 2 S 1S 0
A(0:3) B(0:3)
S3 S1 S0
S2
C3 C2 C1 0
C4
FA FA FA FA
A3 B3 A2 B2 A1 B1 A0 B0
FA = Full Adder
7
Subtraction
A - B = A + 2’s complement of B
A − B = A + B +1
A - B = A + 1’s complement of B+1
FA FA FA FA 1
B3 B2 B1 B0
A3 A2 A1 A0
B3 B2 B1 B0
B0 1 = B0 .1 + B0 .1 = B0
8
Adder/Subtractor
FA FA FA FA 1
FA FA FA FA 01 A3 A2 A1 A0
A3 B3 A2 B2 A1 B1 A0 B0 1
B3 B2 B1 B0
FA FA FA FA
A3 A2 A1 A0
M=1
B3 B2 B1 B0
B0 0 = B0 .0 + B0 .0 = B0 M = 0 for Adder
B0 1 = B0 .1 + B0 .1 = B0 M=1 for Subtractor
9