Add05 Arithmetic
Add05 Arithmetic
Chapter 5
Arithmetic Circuits
SKEE2263 Digital Systems
Mun’im/Ismahani/Izam
{[email protected],[email protected],[email protected]}
Table of Contents
1 Iterative Designs
2 Adders
3 High-Speed Adders
4 Subtractors
5 Condition Codes
6 Multipliers
7 High-Speed Multipliers
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
Iterative Designs
a7-0 b7-0
a7 b7 a1 b1 a0 b0
z c
y7 y1 y0
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
Half Adder
a b c s
0 0 0 0
a
0 1 0 1 s
b
1 0 0 1
1 1 1 0 c
s = a⊕b
c = ab
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
Full Adder
Boolean Expressions
ai bi ci ci+1 si
0 0 0 0 0
0 0 1 0 1
0 1 0 0 1
0 1 1 1 0 si = ai ⊕ bi ⊕ ci
1 0 0 0 1 ci+1 = ai bi + ai ci + bi ci
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
Full Adder
Two-Level Realization
ai
bi si
ci
c i+1
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
Full Adder
Multi-Level, Hierarchical Realization
Half adder
Half adder
ai
bi si
c i+1
ci
si = (ai ⊕ bi ) ⊕ ci
= ai ⊕ bi ⊕ ci
ci+1 = ai bi + (ai ⊕ bi )ci
= ai bi + (ai + bi )ci
= ai bi + ai ci + bi ci
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
Full Adder
Schematic for Cascadable Module
ai bi
ai bi
c i+1 FA c c i+1
ci
si
si
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
a3 b3 a2 b2 a1 b1 a0 b0
FA FA FA FA
c4 c3 c2 c1 c0
s3 s2 s1 s0
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
a
2τ
b
2τ s
cin
τ
τ cout
τ
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
Ai
Bi
Si
Ci
Ci+1
Ci →Ci+1 Ai →Ci+1
Ci →Si Ai →Si
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
8τ 6τ 4τ
c4 2τ
c0
c3 c2 c1
10τ
s3 s2 s1 s0
ai bi ci ci+1 Decision gi pi
0 0 0 0 “Carry 0 0
0
0 0 1 0 kill” 0 0
0 1 0 0 0 1
0 1 1 1 “Carry 0 1
ci
1 0 0 0 propagate” 0 1
1 0 1 1 0 1
1 1 0 1 “Carry 1 1
1
1 1 1 1 generate” 1 1
ci+1 = 1 :
when ai = bi = 1 (regardless of the carry in) or,
when ai 6= bi and the carry-in (from the previous stage) is 1
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
gi = ai bi
pi = ai + bi
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
ai bi ai bi
ai
bi si
p g ci
pi
gi
0
ci+1 ci
1
Partial Full Adder (PFA)
pi , gi w.r.t. carries
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
c1 = g0 + p0 c0
c2 = g1 + p1 c1
= g1 + p1 (g0 + p0 c0 )
= g1 + p1 g0 + p1 p0 c0
c3 = g2 + p2 c2
= g2 + p2 (g1 + p1 g0 + p1 p0 c0 )
= g2 + p2 g1 + p2 p1 g0 + p2 p1 p0 c0
c4 = g3 + p3 c3
= g3 + p3 (g2 + p2 g1 + p2 p1 g0 + p2 p1 p0 c0 )
= g3 + p3 g2 + p3 p2 g1 + p3 p2 p1 g0 + p3 p2 p1 p0 c0
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
p3 g3 p2 g2 p1 g1 p0 g0 c 0
c4 c3 c2 c1
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
s3 s2 s1 s0
g3 p3 c3 g2 p2 c2 g1 p1 c1 g0 p0
c4
Carry Lookahead Generator
4 4 4
s 11-8 s 7-4 s 3-0
4 4 4 4
s 15-12 s 11-8 s 7-4 s 3-0
P3 G3 P2 G2 P1 G1 P0 G0
Total delay = 10 τ .
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
c8,0 4-bit
0
c4 adder
a 7-4 b 7-4
4 4
c8,1 4-bit
1 a 3-0 b 3-0
adder
4 4
4 4
c4 4-bit
1 0 c0
adder
4 4
c8 s 7-4 s 3-0
A B C
n n n
A 0 0 1 0 1 1
B 0 1 0 1 0 1
CSA
+ C 1 1 1 1 0 1
S 0 1 0 0 0 1 1
n+1 n+1 C
P 0 1 1 1 0 1 0
Y X 1 0 1 1 1 0 1
(Carry vector) (Bitwise sum)
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
RCA
FA FA FA HA
c3 c2 c1 c0
CPA
HA FA FA FA HA
s5 s4 s3 s2 s1 s0
Delay 30τ
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
CSA
FA FA FA FA
CPA
HA FA FA HA
s5 s4 s3 s2 s1 s0
Delay 14τ
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
Source: http://www.slideshare.net/ankitgoel/cmos-arithmetic-circuits
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
Half Subtractor
Input Output
a b r (borrow) d (difference) d = a0 b + ab0
0 0 0 0 =a⊕b
0 1 1 1
r = a0 b
1 0 0 1
1 1 0 0
a
d
b
r
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
Full Subtractor
Input Output
a b rin rout d
0 0 0 0 0
d = a0 b0 c + a0 bc0 + ab0 c0 + abc
0 0 1 1 1
0 1 0 1 1 =a⊕b⊕c
0 1 1 1 0
cout = a0 b0 c + a0 bc0 + a0 bc + abc
1 0 0 0 1
1 0 1 0 0 = a0 c + a0 b + bc
1 1 0 0 0
1 1 1 1 1
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
Full Subtractor
Half subtractor
Half subtractor
ai
bi di
r i+1
ri
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
Ripple Subtractor
a3 b3 a2 b2 a1 b1 a0 b0
FS FS FS FS
r4 r3 r2 r1 r0
d3 d2 d1 d0
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
Subtraction by Adding
S =A+B+1
B
n
= A + B∗
A n
= A + (2n − B)
n
B* = A − B + 2n
X Y =A−B
Borrow cn n-bit adder c0 1
where:
n
B: Ones’
A-B complement of B
Difference
B ∗ : Two’s
complement of B
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
Adder/Subtractor
a3 b3 a2 b2 a1 b1 a0 b0
1 0 1 0 1 0 1 0
Sub
FA FA FA FA
c4 c3 c2 c1 c0
s3 s2 s1 s0
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
Flags
Z Flag
N Flag
The negative flag (N) is simply the sign bit. When it is high, the
result was less than zero.
N = sn−1
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
C Flag
C = cn
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
V Flag
True when a calculation produces a result that is greater than a
register can store
Method 1:
Method 2:
V = cn ⊕ cn−1
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
Flags Circuit
a 3 b3 a 2 b2 a 1 b1 a 0 b0
Sub
s0 c in
s1
s2 Z
s3 N
c3 c4 c3 c2 c1 c0
C FA FA FA FA
V
c4
C
s3 s2 s1 s0
V
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
Binary Multiplication
1 1 0 1 (13)10 Multiplicand M
× 1 0 1 1 (11)10 Multiplier Q
1 1 0 1
1 1 0 1 Partial
0 0 0 0 Products
1 1 0 1
1 0 0 0 1 1 1 1 (143) 10 Product P
2 × 2 Multiplication
b0
a1 a0
a1 a0 b1
a1 a0
× b1 b0
a1 b0 a0 b0
a1 b1 a0 b1
p3 p2 p1 p0 HA HA
p3 p2 p1 p0
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
HA FA FA HA
FA FA FA HA
FA FA FA HA
p7 p6 p5 p4 p3
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
Source: http://www.slideshare.net/ankitgoel/cmos-arithmetic-circuits
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
HA HA HA
FA FA FA
FA FA FA
p3
FA FA HA
p7 p6 p5 p4
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
Source: http://www.slideshare.net/ankitgoel/cmos-arithmetic-circuits
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
Source: http://www.slideshare.net/ankitgoel/cmos-arithmetic-circuits
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
2A 2A
<<1 <<1
8A 16A
A <<3 10A A <<4 14A
Iterative Designs Adders High-Speed Adders Subtractors Condition Codes Multipliers High-Speed Multipliers
16 x 4
Memory
Multiplicand A3 D3
x[1:0] A2 D2 Product
Multiplier A1 D1 z[3:0]
y[1:0] A0 D0
A1 A0
A3 A2 00 01 10 11
00 0000 0000 0000 0000
01 0000 0001 0010 0011
10 0000 0010 0100 0110
11 0000 0011 0110 1001