Download presentation
Presentation is loading. Please wait.
Published byMegan McCoy Modified over 9 years ago
1
Spring 200622C:160/55:132 Page 1 Lecture 19 - Computer Arithmetic March 30, 2004 Sukumar Ghosh
2
Spring 200622C:160/55:132 Page 2 Carry-ripple Adder Each cell: r i = a i XOR b i XOR c in c out = a i c in + a i b i + b i c in = c in (a i + b i ) + a i b i 4-bit adder: “Full adder cell”
3
Spring 200622C:160/55:132 Page 3 Adders (cont.) Ripple Adder Ripple adder is inherently slow because, in general s7 must wait for c7 which must wait for c6 … T n, Cost n How do we make it faster, perhaps with more cost?
4
Spring 200622C:160/55:132 Page 4 Carry Select Adder T = T ripple_adder / 2 + T MUX
5
Spring 200622C:160/55:132 Page 5 Carry Select Adder Extending Carry-select to multiple blocks What is the optimal # of blocks and # of bits/block? –If # blocks too large delay dominated by total mux delay –If # blocks too small delay dominated by adder delay T sqrt(N), Cost 2*ripple + muxes
6
Spring 200622C:160/55:132 Page 6 Carry Select Adder T total = sqrt(N) T FA –assuming T FA = T MUX For ripple adder T total = N T FA Is sqrt(N) really the optimum? –From right to left increase size of each block to better match delays –Ex: 64-bit adder, use block sizes [13 12 11 10 9 8 7] How about recursively defined carry select?
7
Spring 200622C:160/55:132 Page 7 Carry Look-ahead Adders For n-bit addition best we can achieve is delay log(n) How do we arrange this? (think trees) First, reformulate basic adder stage: carry “propagate” p i = a i b i carry “generate” g i = a i b i c i+1 = g i + p i c i s i = p i c i a b c i c i+1 s
8
Spring 200622C:160/55:132 Page 8 Carry Look-ahead Adders Ripple adder using p and g signals: So far, no advantage over ripple adder: T N p0p0 g0g0 s 0 = p 0 c 0 c 1 = g 0 + p 0 c 0 s0s0 a0a0 b0b0 p1p1 g1g1 s 0 = p 1 c 1 c 2 = g 1 + p 1 c 1 s1s1 a1a1 b1b1 p2p2 g2g2 s 2 = p 2 c 2 c 3 = g 2 + p 2 c 2 s2s2 a2a2 b2b2 p3p3 g3g3 s 3 = p 3 c 3 c 4 = g 3 + p 3 c 3 s3s3 a3a3 b3b3 c0c0 c4c4
9
Spring 200622C:160/55:132 Page 9 Carry Look-ahead Adders Expand carries: c 0 c 1 = g 0 + p 0 c 0 c 2 = g 1 + p 1 c 1 = g 1 + p 1 g 0 + p 1 p 0 c 0 c 3 = g 2 + p 2 c 2 = g 2 + p 2 g 1 + p 1 p 2 g 0 + p 2 p 1 p 0 c 0 c 4 = g 3 + p 3 c 3 = g 3 + p 3 g 2 + p 3 p 2 g 1 +.... Why not implement these equations directly to avoid ripple delay? –Lots of gates. Redundancies (full tree for each). –Gate with high # of inputs. Let’s reorganize the equations.
10
Spring 200622C:160/55:132 Page 10 Carry Look-ahead Adders “Group” propagate and generate signals: P true if the group as a whole propagates a carry to c out G true if the group as a whole generates a carry Group P and G can be generated hierarchically. pipi gigi p i+1 g i+1 p i+k g i+k P = p i p i+1 … p i+k G = g i+k + p i+k g i+k-1 + … + (p i+1 p i+2 … p i+k )g i c in c out C out = G + PC in
11
Spring 200622C:160/55:132 Page 11 Carry Look-ahead Adders a0a0 b0b0 a1a1 b1b1 a2a2 b2b2 a a3a3 b3b3 a4a4 b4b4 a5a5 b5b5 b c 3 = G a + P a c 0 PaPa GaGa PbPb GbGb a6a6 b6b6 a7a7 b7b7 a8a8 b8b8 c c 6 = G b + P b c 3 PcPc GcGc P = P a P b P c G = G c + P c G b + P b P c G a c 9 = G + Pc 0 c0c0 9-bit Example of hierarchically generated P and G signals:
12
Spring 200622C:160/55:132 Page 12 p0p0 g0g0 s0s0 p1p1 g1g1 s1s1 c 1 = g 0 +p 0 c 0 p1p1 g2g2 s2s2 c2c2 p3p3 g3g3 s3s3 c 3 = g 2 +p 2 c 2 p4p4 g4g4 s4s4 p5p5 g5g5 s5s5 p6p6 g6g6 s6s6 c6c6 p7p7 g7g7 s7s7 c0c0 c 5 = g 4 +p 4 c 4 c 7 = g 6 +p 6 c 6 c4c4 c 2 =G 8 +P 8 c 0 P 8 =p 0 p 1 G 8 =g 1 +p 1 g 0 P 9 =p 2 p 3 c 6 =G a +P a c 4 P a =p 4 p 5 G a =g 5 +p 5 g 4 P b =p 6 p 7 G 9 =g 3 +p 3 g 2 G b =g 7 +p 7 g 6 c 4 =G c +P c c 0 P c =P 8 P 9 G c =G 9 +P 9 G 8 P d =P a P b G d =G b +P b G a c 8 =G e +P e c 0 P e =P c P d G e =G d +P d G c c0c0 c4c4 c8c8 8-bit Carry Look-ahead Adder with 2-input gates.
13
Spring 200622C:160/55:132 Page 13 Multiplication A = a7 a6 a5 a4 a3 a2 a1 B = b7 b6 b5 b4 b3 b2 b1 A x B = 2 6. b7.A + 2 5. b7.A + 2 4. b7.A + 2 3. b7.A + … + b7.A Use Carry Save Adders What is CSA?
14
Spring 200622C:160/55:132 Page 14 Carry Save Adder 1 1 0 0 1 1 0 1 1 1 0 1 0 1 1 0 0 1 1 1 0 1 1 1 1 1 0 0 1 0 Sum Carry computed in parallel 1 1 0 1 0 0 1 Ordinary addition CSA
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.