15.08.2013 Views

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

significant digit, we follow the process of<br />

• adding the two digits with carry from the previous column<br />

• recording the sum bit as the result, and<br />

• passing the carry bit on to the next column<br />

until one of the numbers ends.<br />

The Carry Chain Adder<br />

The inductively designed circuit of the carry chain adder.<br />

n = 1: the CCA 1 consists of a full adder<br />

n > 1: the CCA n consists of an (n − 1)-bit carry chain adder CCA n−1 and a full adder<br />

that sums up the carry of CCA n−1 and the last two bits of a and b<br />

Definition 419 An n-bit carry chain adder CCA n is inductively defined as<br />

(f 1 CCA (a0, b0, c)) = (FA 1 (a0, b0, c))<br />

(f n CCA (〈an−1, . . . , a0〉, 〈bn−1, . . . , b0〉, c ′ )) = 〈c, sn−1, . . . , s0〉 with<br />

〈c, sn−1〉 = (FA n−1 (an−1, bn−1, cn−1))<br />

〈cn−1, . . . , cs〉0 = (f n−1<br />

CCA (〈an−2, . . . , a0〉, 〈bn−2, . . . , b0〉, c ′ ))<br />

Lemma 420 (Cost) C(CCA n ) ∈ O(n)<br />

Proof Sketch: C(CCA n ) = C(CCA n−1 ) + C(FA 1 ) = C(CCA n−1 ) + 5 = 5n<br />

Lemma 421 (Depth) dp(CCA n ) ∈ O(n)<br />

Proof Sketch: dp(CCA n ) ≤ dp(CCA n−1 ) + dp(FA 1 ) ≤ dp(CCA n−1 ) + 3 ≤ 3n<br />

The carry chain adder is simple, but cost and depth are high. (depth is critical (speed))<br />

Question: Can we do better?<br />

Problem: the carry ripples up the chain (upper parts wait for carries from lower part)<br />

c○: Michael Kohlhase 246<br />

A consequence of using the carry chain adder is that if we go from a 32-bit architecture to a 64-bit<br />

architecture, the speed of additions in the chips would not increase, but decrease (by 50%). Of<br />

course, we can carry out 64-bit additions now, a task that would have needed a special routine<br />

at the software level (these typically involve at least 4 32-bit additions so there is a speedup for<br />

such additions), but most addition problems in practice involve small (under 32-bit) numbers, so<br />

we will have an overall performance loss (not what we really want for all that cost).<br />

If we want to do better in terms of depth of an n-bit adder, we have to break the dependency<br />

on the carry, let us look at a decimal addition example to get the idea. Consider the following<br />

snapshot of an carry chain addition<br />

135

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!