ECECS 552 Carry Lookahead Prof Mikko Lipasti Lecture

  • Slides: 16
Download presentation
ECE/CS 552: Carry Lookahead © Prof. Mikko Lipasti Lecture notes based in part on

ECE/CS 552: Carry Lookahead © Prof. Mikko Lipasti Lecture notes based in part on slides created by Mark Hill, David Wood, Guri Sohi, John Shen and Jim Smith

Combined Ripple-carry Adder/Subtractor Full Add er a 0 b 0 Full Add er a

Combined Ripple-carry Adder/Subtractor Full Add er a 0 b 0 Full Add er a 1 b 1 Full Add er a 2 b 2 Full Add er Cout operation b a 31 31 • The above ALU is too slow – Gate delays for add = 32 x FA + XOR ~= 64 2

Carry Lookahead • Theoretically, in parallel – Sum 0 = f(cin, a 0, b

Carry Lookahead • Theoretically, in parallel – Sum 0 = f(cin, a 0, b 0) – Sumi = f(cin, ai…a 0, , bi…b 0) – Sum 31 = f(cin, a 31…a 0, b 31…b 0) • Any boolean function in two levels, right? – Wrong! Too much fan-in! 3

Carry Lookahead • Need compromise – Build tree so delay is O(log 2 n)

Carry Lookahead • Need compromise – Build tree so delay is O(log 2 n) for n bits – E. g. 2 x 5 gate delays for 32 bits • We will consider basic concept with – 4 bits – 16 bits • Warning: a little convoluted 4

Carry Lookahead 0101 0100 0011 0110 Need: both 1 to generate carry one or

Carry Lookahead 0101 0100 0011 0110 Need: both 1 to generate carry one or both 1 s to propagate carry Define: gi = ai * bi ## carry generate pi = ai + bi ## carry propagate Recall: ci+1 = ai * bi + ai * ci + bi * ci = ai * bi + (ai + bi) * ci = g i + pi * c i 5

Carry Lookahead • Therefore c 1 = g 0 + p 0 * c

Carry Lookahead • Therefore c 1 = g 0 + p 0 * c 0 c 2 = g 1 + p 1 * c 1 = g 1 + p 1 * (g 0 + p 0 * c 0) = g 1 + p 1 * g 0 + p 1 * p 0 * c 0 c 3 = g 2 + p 2 * g 1 + p 2 * p 1 * g 0 + p 2 * p 1 * p 0 * c 0 c 4 = g 3 + p 3*g 2 + p 3*p 2*g 1 + p 3*p 2*p 1*g 0 + p 3*p 2*p 1*p 0*c 0 • Uses one level to form pi and gi, two levels for carry • But, this needs n+1 fanin at the OR and the rightmost AND 6

4 -bit Carry Lookahead Adder c 4 c 0 Carry Lookahead Block g 3

4 -bit Carry Lookahead Adder c 4 c 0 Carry Lookahead Block g 3 p 3 a 3 b 3 g 2 p 2 a 2 b 2 c 3 s 3 g 1 p 1 a 1 b 1 c 2 s 2 g 0 p 0 a 0 b 0 c 1 s 0 7

Hierarchical Carry Lookahead for 16 bits c 15 c 0 Carry Lookahead Block G

Hierarchical Carry Lookahead for 16 bits c 15 c 0 Carry Lookahead Block G P a, b 12 -15 G P a, b 8 -11 G P a 4 -7 b 4 -7 G P a 0 -3 b 0 -3 c 12 c 8 c 4 c 0 s 12 -15 s 8 -11 s 4 -7 s 0 -3 8

Hierarchical CLA for 16 bits Build 16 -bit adder from four 4 -bit adders

Hierarchical CLA for 16 bits Build 16 -bit adder from four 4 -bit adders Figure out G and P for 4 bits together G 0, 3 = g 3 + p 3 * g 2 + p 3 * p 2 * g 1 + p 3 * p 2 * p 1 * g 0 P 0, 3 = p 3 * p 2 * p 1 * p 0 (Notation a little different from the book) G 4, 7 = g 7 + p 7 * g 6 + p 7 * p 6 * g 5 + p 7 * p 6 * p 5 * g 4 P 4, 7 = p 7 * p 6* p 5 * p 4 G 12, 15 = g 15 + p 15 * g 14 + p 15* p 14 * g 13 + p 15 * p 14 * p 13 * g 12 P 12, 15 = p 15 * p 14 * p 13 * p 12 9

Carry Lookahead Basics Fill in the holes in the G’s and P’s Gi, k

Carry Lookahead Basics Fill in the holes in the G’s and P’s Gi, k = Gj+1, k + Pj+1, k * Gi, j (assume i < j +1 < k ) Pi, k = Pi, j * Pj+1, k G 0, 7 = G 4, 7 + P 4, 7 * G 0, 3 P 0, 7 = P 0, 3* P 4, 7 G 8, 15 = G 12, 15 + P 12, 15 * G 8, 11 P 8, 15 = P 8, 11 * P 12, 15 G 0, 15 = G 8, 15 + P 8, 15 * G 0, 7 P 0, 15 = P 0, 7 * P 8, 15 10

CLA: Compute G’s and P’s G 12, 15 P 12, 15 G 8, 11

CLA: Compute G’s and P’s G 12, 15 P 12, 15 G 8, 11 P 8, 11 G 4, 7 P 4, 7 G 8, 15 P 8, 15 G 0, 3 P 0, 3 G 0, 7 P 0, 7 G 0, 15 P 0, 15 11

CLA: Compute Carries g 12 - g 15 p 12 - p 15 c

CLA: Compute Carries g 12 - g 15 p 12 - p 15 c 12 g 8 - g 11 g 4 - g 7 p 8 - p 11 p 4 - p 7 c 0 c 4 c 8 g 0 - g 3 p 0 - p 3 G 8, 11 P 8, 11 G 0, 3 P 0, 3 c 8 c 0 G 0, 7 P 0, 7 c 0 12

Other Adders: Carry Select • Two adds in parallel; with and without cin –

Other Adders: Carry Select • Two adds in parallel; with and without cin – When Cin is done, select correct result Full Adder 0 c 0 Full Adder next select Full Adder 1 2 -1 Mux select 13

Other Adders: Carry Save + 7 9 1 8 A + B => S

Other Adders: Carry Save + 7 9 1 8 A + B => S C, S 0, 8 Final 8+1=9 Save carries A + B => S, Cout Use Cin A + B + C => S 1, S 2 (3# to 2# in parallel) Used in combinational multipliers by building a Wallace Tree c 1, 7 7 a b CSA c s 14

Adding Up Many Bits f e d c CSA b a CSA S 0

Adding Up Many Bits f e d c CSA b a CSA S 0 CSA S 2 S 1 15

Summary • Carry lookahead • Carry-select, Carry-save • State of the art: parallel prefix

Summary • Carry lookahead • Carry-select, Carry-save • State of the art: parallel prefix adders – aka. Brent-Kung, Kogge-Stone, … – Generalization of CLA – Physical design (e. g. wiring) of primary concern – Covered in ECE 555 16