Fall 2009
What is Computer Arithmetic?
Programmable Logic Circuits
ELECT 90X
A Motivating Example
Using a calculator with √, x2, and xy functions, compute:
u = √√ … √ 2 = 1.000 677 131 “1024th root of 2”
Programmable Logic Circuits
ELECT 90X
Finite Range Can Lead to Disaster
Programmable Logic Circuits
ELECT 90X
Encoding Numbers in 4 Bits
16 14 12 10 8 6 4 2 0 2 4 6 8 10 12 14 16
Number
format
Programmable Logic Circuits
Unsigned integers
Signed-magnitude
3 + 1 fixed-point, xxx.x
2 + 2 floating-point, s 2 e e s
e in [2, 1], s in [0, 3]
Dr. Amr Talaat
equences of digits
➢ Lower case letters, usually indexed, represent indi
vidual digits
ELECT 90X
Radix of a Number System
Programmable Logic Circuits
ELECT 90X
Range of Representations
➢ Operands and results are stored in registers of
Programmable Logic Circuits
1 00011 3 = 35 mod 32
➢ Result has to be stored in a 5-bit register - the most signif
icant bit (with weight 2 =32)
5 is discarded
ELECT 90X
Fixed Radix Systems
➢ r - the radix of the number system
Programmable Logic Circuits
ELECT 90X
Representation of Mixed Numbers
➢ A sequence of n digits in a register - not necessa
Programmable Logic Circuits
➢ is
ELECT 90X
Fixed Point Representations
➢ Radix point not stored in register - understood to be in a fix
Programmable Logic Circuits
ELECT 90X
ULP - Unit in Last Position
➢ Given the length n of the operands, the weigh
Programmable Logic Circuits
t -m
r of the least significant digit indicates the
position of the radix point
➢ Unit in the last position (ulp) - the weight of t
he least significant digit
➢ ulp = r-m
➢ This notation simplifies the discussion
➢ No need to distinguish between the different p
artitions of numbers into fractional and integr
al parts
Dr. Amr Talaat
ELECT 90X
Representation of Negative Numbers
Programmable Logic Circuits
ELECT 90X
Signed-Magnitude Representation
➢ Sign and magnitude are represented separately
Programmable Logic Circuits
ELECT 90X
Disadvantage of the Signed-Magnitude
Representation
Programmable Logic Circuits
ELECT 90X
Complement Representations of Negative
Numbers
Programmable Logic Circuits
➢ Two alternatives -
➢ Radix complement (called two's complemen
t in the binary system)
➢ Diminished-radix complement (called one's c
omplement in the binary system)
➢ In both complement methods - positive numbe
rs represented as in the signed-magnitude met
hod
➢ A negative number -Y is represented by R-Y w
Dr. Amr Talaat
here R is a constant
➢ This representation satisfies -(-Y )=Y since R
-(R-Y)=Y
ELECT 90X
Advantage of Complement Representation
Programmable Logic Circuits
ELECT 90X
Two’s Complement
0
➢ r=2, k=n=4, m=0, ulp=2 =1
Programmable Logic Circuits
ELECT 90X
The Two’s Complement Representation
Programmable Logic Circuits
Dr. Amr Talaat
ELECT 90X
Example - Addition in Two’s complement
➢ Calculating X+(-Y) with Y>X - 3+(-5)
Programmable Logic Circuits
0011 3
+ 1011 -5
1110 -2
➢ Correct result represented in the two's comple
ment method - no need for preliminary decision
s or post corrections
➢ Calculating X+(-Y) with X>Y - 5+(-3)
0101 5
+ 1101 -3
1 0010 2
Dr. Amr Talaat
ELECT 90X
One’s Complement in Binary System
➢ r=2, k=n=4, m=0, ulp=2 =1
Programmable Logic Circuits
0
➢ Diminished-radix complement (called one's com
plement in the binary case) of a number X =
(2 - 1) - X = X-
4
resentations of zero
➢ Range of representable numbers is -7 X 7
ELECT 90X
Comparing the Three Representations in a
Binary System
Programmable Logic Circuits
Dr. Amr Talaat
ELECT 90X
5.1 Bit-Serial and Ripple-Carry Adders
Programmable Logic Circuits
Inputs Outputs
x y
x y c s
---------------- c
0 0 0 0 HA
0 1 0 1
1 0 0 1
1 1 1 0 s
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1 s
ELECT 90X
Half-Adder Implementations
Programmable Logic Circuits
_
x x
c c _
y y
x
x
y
s s y
s y
(c) NAND-gate half-adder with complemented carry.
ELECT 90X
Full-Adder Implementations
y x y x
Programmable Logic Circuits
cout HA
cout
HA cin
cin
s
(a) Built o f half -adders.
y x
Mux
0 0
cout 1
2
3 1
s
Dr. Amr Talaat
0
1 (b) Built as an AND- OR circuit.
cin
2
3
s Possible designs for a full-adder in terms
of half-adders, logic gates, and CMOS
(c) Suitable fo r CMOS r ealizatio n.
transmission gates.
ELECT 90X
Full-Adder Details
Programmable Logic Circuits
x0 TG
TG x1
N TG
Dr. Amr Talaat
ELECT 90X
Simple Adders Built of Full-Adders
y
Using full-adders in building
Programmable Logic Circuits
Clock si s
c32 c31 c2 c1 c0
FA . . . FA FA
Dr. Amr Talaat
cout cin
s32 s31 s1 s0
(b) Ripple-carry adder.
ELECT 90X
Critical Path Through a Ripple-Carry Adder
Programmable Logic Circuits
ck ck–1 ck–2 c2 c1 c0
FA FA . . . FA FA
cout cin
Dr. Amr Talaat
sk sk–1 sk–2 s1 s0
ELECT 90X
Inputs Outputs
Binary Adders as
x
Versatile
y c
Building
c s
Blocks
in out x y
----------------------
Programmable Logic Circuits
0 0 0 0 0
Set one input to 0: 0 c out =
0 AND
1 of other
0 inputs
1
0 1 0 0 1
Set one input to 1: c
0 out 1 = OR1of other
1 inputs
0 FA
cout cin
1 0 0 0 1
Set one input to 0 1 0 1 1 0
and another to 1: 1 s 1= NOT 0 of third
1 input0
1 1 1 1 1 s
c4 c3 c2 c1 c0
w xyz
w xyz xyz xy 0
Dr. Amr Talaat
(w xyz)
Four-bit binary adder used to realize the logic function
f = w + xyz and its complement.
ELECT 90X
Conditions and Exceptions
yk–1 xk–1 yk–2 xk–2 y1 x1 y0 x0
Programmable Logic Circuits
c k–1
ck c k–2 c2 c1 c0
cout FA ... FA FA
FA cin
Overflow
Negative
Zero
s k–1 s k–2 s1 s0
Two’s-complement adder with provisions for
detecting conditions and exceptions.
Dr. Amr Talaat
ELECT 90X
Manchester Carry Chains and Adders
Programmable Logic Circuits
ELECT 90X
Carry Network is the Essence of a Fast Adder
Programmable Logic Circuits
gi pi Carry is: xi yi
0 0 annihilated or killed gi = x i y i
0 1 propagated
1 0 generated pi = x i y i
1 1 (impossible)
Carry network
ck
Ripple; Skip;
c k1
... ci ... c0 Lookahead;
c k2 c1
c i+1 Parallel-prefix
Dr. Amr Talaat
si
The main part of an adder is the carry network. The rest is just a set of
gates to produce the g and p signals and the sum bits.
ELECT 90X
Ripple-Carry Adder Revisited
Programmable Logic Circuits
...
ck ck1 ck2 c2 c1 c0
Dr. Amr Talaat
ELECT 90X
The Complete Design of a Ripple-Carry Adder
Programmable Logic Circuits
gi pi Carry is: xi yi
0 0 annihilated or killed gi = x i y i
0 1 propagated
1 0 generated pi = x i y i
1 1 (impossible)
... ...
ck ck1 ck2 c2 Carry network
c1 ck c
c c
0
k1 k2 c2 c1 c0
ck
c k1
... ci ... c0
c k2 c1
c i+1
Dr. Amr Talaat
si
ELECT 90X
Unrolling the Carry Recurrence
Recall the generate, propagate, annihilate (absorb), and transfer signals:
Programmable Logic Circuits
ELECT 90X
Full Carry Lookahead
x3 y3 x2 y2 x1 y1 x0 y0
Programmable Logic Circuits
cin
...
s3 s2 s1 s0
ELECT 90X
Four-Bit Carry-Lookahead Adder
c4
Complexity
Programmable Logic Circuits
p3
reduced by g3
deriving the
carry-out
indirectly c3
p2
g2
Full carry lookahead is quite practical
for a 4-bit adder
c2 p1
c1 = g0 c 0 p0
c2 = g1 g0 p1 c 0 p 0 p1 g1
p0
g2 g1 p2 g0 p 1 p2 c 0 p0 p1 p2
Dr. Amr Talaat
c3 =
c
c4 = g3 g2 p3 g1 p 2 p3 g0 p1 p2 p3 1 g0
c 0 p0 p1 p2 p 3 c0
Four-bit carry network with
full lookahead.
ELECT 90X
Carry Lookahead Beyond 4 Bits
Programmable Logic Circuits
ELECT 90X
Solutions to the Fan-in Problem
Programmable Logic Circuits
• Multilevel lookahead
• Block Adders
•High-radix addition (i.e., radix 2h) : Increases the latency for
generating g and p signals and sum digits, but simplifies the carry
network (optimal radix?)
Either way, the carries c4, c8, and c12 are determined first
Dr. Amr Talaat
ELECT 90X
ELECT 90X
Block Ripple Adder
Programmable Logic Circuits Dr. Amr Talaat
Larger Carry-Lookahead Adder Design
Block generate and propagate signals
Programmable Logic Circuits
g [i,i+3] = gi+3 gi+2 pi+3 gi+1 pi+2 pi+3 gi pi+1 pi+2 pi+3
p [i,i+3] = pi pi+1 pi+2 pi+3
g[i,i+3] p[i,i+3]
ELECT 90X
A Building Block for p [i,i+3]
Carry-Lookahead Addition
Programmable Logic Circuits
Four-bit g [i,i+3]
lookahead
pi+3
carry generator.
c4
gi+3
p3 Block Signal Generation
g3 Intermediate Carries
c3 ci+3
p2 pi+2
Four-bit gi+2
adder g2
p1 pi+1
Dr. Amr Talaat
c2 ci+2
g1 gi+1
p0 pi
c1 ci+1
g0 gi
ci
c0
ELECT 90X
Combining Block g and p Signals
Programmable Logic Circuits
Dr. Amr Talaat
ELECT 90X
A Two-Level Carry-Lookahead Adder
Programmable Logic Circuits
c12 c8 c4 c0
g [0,63]
Dr. Amr Talaat
ELECT 90X
Ling Adder and Related Designs
Programmable Logic Circuits
ELECT 90X
Carry Determination as Prefix Computation
Programmable Logic Circuits
Block B'
Block B" g p
g
j0 i0
j1 i1
p
(g", p") (g', p')
g" p" g' p'
¢
g = g" + g'p"
g p p = p'p"
Dr. Amr Talaat
(g, p)
Block B g p
ELECT 90X
Formulating the Prefix Computation Problem
Programmable Logic Circuits
c1 c2 . . . ck–1 ck
The desired pairs are found by evaluating all prefixes of
(g0, p0) ¢ (g1, p1) ¢ . . . ¢ (gk–2, pk–2) ¢ (gk–1, pk–1)
Given x0 x1 x2 . . . xk–1
Find x0 x0+x1 x0+x1+x2 . . . x0+x1+...+xk–1
ELECT 90X
Example Prefix-Based Carry Network
g3, p3 g2, p2 g1, p1 g0, p0
6 1 2 5
Programmable Logic Circuits
+ + Four-input
prefix sums
network
+ +
12 6 7 5 g p
g[0,3], p[0,3] g[0,2], p[0,2] g[0,1], p[0,1] g[0,0], p[0,0] Scan
g
order
=g(c , --) = g(c2,3,p--)
3, 4p3 2
=
g1(c
, p21, --) =g(c , p,
0 1 0
--)
p
¢ ¢ Four-bit
Carry
lookahead
Dr. Amr Talaat
¢ ¢ network
ELECT 90X
Alternative Parallel Prefix Networks
Programmable Logic Circuits
s k/2–1 . . . s0
+ . .. +
s k–1 . . . s k/2
Parallel prefix sums network built of two k/2-input
networks and k/2 adders. (Ladner-Fischer)
Dr. Amr Talaat
ELECT 90X
Brent-Kung Recursive Construction
x k–1 x k–2 . . . x3 x2 x1 x0
Programmable Logic Circuits
+ + +
. . .
s k–1 s k–2 . . . s3 s2 s1 s0
Parallel prefix sums network built of one k/2-input
Dr. Amr Talaat
ELECT 90X
Brent-Kung Carry Network (8-Bit Adder)
Programmable Logic Circuits
[7, 7 ] [6, 6 ] [5, 5 ] [4, 4 ] [3, 3 ] [2, 2 ] [1, 1 ] [0, 0 ] g[1,1] p[1,1]
g[0,0]
p[0,0]
¢ ¢ ¢ ¢
[6, 7 ] [2, 3 ]
[4, 5 ] [0, 1 ]
¢ ¢
[4, 7 ]
[0, 3 ]
¢ ¢
Dr. Amr Talaat
¢ ¢ ¢
g[0,1] p[0,1]
ELECT 90X
Brent-Kung Carry Network (16-Bit Adder)
x15 x14 x13 x12 x x x x x x x x x x x x
11 10 9 8 7 6 5 4 3 2 1 0
Programmable Logic Circuits
Level
1
Reason for 2
latency
3
Brent-Kung
5
parallel prefix
Dr. Amr Talaat
graph for
6
16 inputs.
s 15 s 14 s 13 s 12 s s s s s s s s s s s s
11 10 9 8 7 6 5 4 3 2 1 0
ELECT 90X
Kogge-Stone Carry Network (16-Bit Adder)
x15 x14 x13 x12 x x x x x x x x x x x x
11 10 9 8 7 6 5 4 3 2 1 0
Programmable Logic Circuits
log2k levels
(minimum
possible)
Kogge-Stone
Dr. Amr Talaat
parallel prefix
graph for
16 inputs.
s 15 s 14 s 13 s 12 s s s s s s s s s s s s
11 10 9 8 7 6 5 4 3 2 1 0
ELECT 90X
Speed-Cost Tradeoffs in Carry Networks
Programmable Logic Circuits
ELECT 90X
Hybrid B-K/K-S Carry Network (16-Bit Adder)
x
15
x x
14 13
x x
12 11
x x
10 9
x
8 x7 x x x x x x x x15 x14 x13 x12 x x x x x x x x x x x x
6 5 4 3 2 1 0 11 10 9 8 7 6 5 4 3 2 1 0
Level
1
Programmable Logic Circuits
Brent-Kung: 3 Kogge-Stone:
6 levels 4 4 levels
26 cells 5
49 cells
6
s 15 s 14 s 13 s 12 s 11 s 10 s 9 s8 s s s s s s s s0 s 15 s14 s 13 s12 s s s s s s s s s s s s
7 6 5 4 3 2 1 11 10 9 8 7 6 5 4 3 2 1 0
Brent-
Kung
A Hybrid
Brent-Kung/
Kogge-Stone Kogge-
Hybrid:
parallel prefix Stone 5 levels
Dr. Amr Talaat
ELECT 90X
Simple Carry-Skip Adders
Programmable Logic Circuits
c 16 c12 c4 c0
4-Bit 4-Bit c8 4-Bit
Block Block Block 3 2 1 0
Ripple-carry stages
(a) Ripple-carry adder.
c16 c 12 c0
4-Bit 4-Bit c8 4-Bit c4
Block Block Block 3 2 1 0
p [12,15] p [8,11] p [4,7] p[0,3]
Skip Skip Skip
ELECT 90X
Another View of Carry-Skip Addition
g4j+3 p4j+3 g4j+2 p4j+2 g4j+1 p4j+1 g4j p4j
Programmable Logic Circuits
One-way street
Dr. Amr Talaat
Freeway
ELECT 90X
Multilevel Carry-Skip Adders
c out
c in
Programmable Logic Circuits
S1 S1 S1 S1 S1
S1 S1 S1 S1 S1
S2
S1 S1 S1
S2
• • • • a • • • • • • p (0)
• • • • x • • • • • • p (1)
---------- • • • • • • p (2)
• • • • x0 a2 0 • • • • • • p (3)
• • • • x1 a2 1 • • • • • • p (4)
• • • • x2 a2 2 • • • • • • p (5)
• • • • x3 a2 3 • • • • • • p (6)
---------------- -----------------
• • • • • • • • p • • • • • • • • • s
Dr. Amr Talaat
ELECT 90X
Serial Implementation with One Adder
Programmable Logic Circuits
k bits
Adder x (j)
j=0
x(i)
Partial sum
register
Serial implementation of multi-operand addition
with a single 2-operand adder.
Dr. Amr Talaat
ELECT 90X
Pipelined Implementation for Higher Throughput
Programmable Logic Circuits
x(i–6) + x(i–7)
x(i–1)
Ready to
Delays
compute s (i–12)
Delay
x(i) + x(i–1)
x(i–4) + x(i–5)
Serial multi-operand addition when each adder is a
4-stage pipeline.
ELECT 90X
Parallel Implementation as Tree of Adders
Programmable Logic Circuits
k k k k k k k
Adder Adder Adder
k+1 k+1 k+1
log2n
n–1 Adder Adder adder levels
adders
k+2 k+2
Adder
k+3
Dr. Amr Talaat
ELECT 90X
Carry-Save Adders
Cut
Programmable Logic Circuits
A ripple-carry adder FA FA FA FA
FA FA
turns into a
carry-save adder if the
carries are saved
(stored) rather than FA FA FA FA FA FA
propagated.
cout
or
3-to-2 reduction circuit Specifying full- and half-
Carry-propagate adder (CPA) and adder blocks,
carry-save adder (CSA) functions in with their inputs and
dot notation. outputs, in dot notation.
ELECT 90X
Multioperand Addition Using Carry-Save Adders
Programmable Logic Circuits
CSA CSA
CSA
Input
CSA
CSA
Sum register CSA
Carry register
Carry-propagate adder
Dr. Amr Talaat
CPA
Output
Serial carry-save addition Tree of carry-save adders reducing
using a single CSA. seven numbers to two.
ELECT 90X
Example Reduction by a CSA Tree
8 7 65 4 3 2 1 0 Bit position
Programmable Logic Circuits
7 7 7 7 7 7 62 = 12 FAs
2 5 5 5 5 5 3 6 FAs
3 4 4 4 4 4 1 6 FAs
12 FAs
1 2 3 3 3 3 2 1 4 FAs + 1 HA
2 2 2 2 2 1 2 1 7-bit adder
--Carry-propagate adder--
6 FAs
1 1 1 1 1 1 1 1 1
Representing a seven-operand
6 FAs
addition in tabular form.
4 FAs + 1 HA
7-bit adder
(compression ratio of 1.5)
Total cost = 7-bit adder + 28 FAs + 1 HA
A half-adder rearranges 2 dots
Addition of seven 6-bit (no compression, but still useful)
numbers in dot notation.
ELECT 90X
Width of Adders in a CSA Tree
[0, k–1] [0, k–1] [0, k–1] [0, k–1]
[0, k–1] [0, k–1] [0, k–1] Adding seven k-bit
Programmable Logic Circuits
k-bit CSA
Due to the gradual
[1, k] [0, k–1]
retirement (dropping out)
k-bit CSA of some of the result bits,
CSA widths do not vary
[2, k+1] [1, k] [1, k–1] much as we go down the
tree levels
The index pair k-bit CSA
Dr. Amr Talaat
ELECT 90X
ELECT 90X
Wallace Tree Multiplier
Programmable Logic Circuits Dr. Amr Talaat
ELECT 90X
Wallace Tree Multiplier
Programmable Logic Circuits Dr. Amr Talaat
ELECT 90X
DADDA Tree Multiplier
Programmable Logic Circuits Dr. Amr Talaat
ELECT 90X
DADDA Tree Multiplier
Programmable Logic Circuits Dr. Amr Talaat
ELECT 90X
DADDA Tree Multiplier
Programmable Logic Circuits Dr. Amr Talaat
ELECT 90X
Wallace Tree Multiplier
Programmable Logic Circuits Dr. Amr Talaat
Saturating Adders
Programmable Logic Circuits
ELECT 90X
Readings:
ELECT 90X