Beruflich Dokumente
Kultur Dokumente
Technische Hochschule
Zurich
Lecture notes on
Computer Arithmetic:
Principles, Architectures,
and VLSI Design
June 25, 1998
Reto Zimmermann
Integrated Systems Laboratory
Swiss Federal Institute of Technology (ETH)
CH-8092 Zurich, Switzerland
zimmermann@iis.ee.ethz.ch
Contents
Contents
::::::::::::::::::::::: 4
:::::::::::::::::::::::::::::::::::::::::: 4
1.2 Motivation : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 4
1.3 Conventions : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 5
1.4 Recursive Function Evaluation : : : : : : : : : : : : : : : : : : : : : 6
Arithmetic Operations : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 8
2.1 Overview : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 8
2.2 Implementation Techniques : : : : : : : : : : : : : : : : : : : : : : : 9
Number Representations : : : : : : : : : : : : : : : : : : : : : : : : : : : 10
3.1 Binary Number Systems (BNS) : : : : : : : : : : : : : : : : : : : 10
3.2 Gray Numbers : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 13
3.3 Redundant Number Systems : : : : : : : : : : : : : : : : : : : : : : 14
3.4 Residue Number Systems (RNS) : : : : : : : : : : : : : : : : : : 16
3.5 Floating-Point Numbers : : : : : : : : : : : : : : : : : : : : : : : : : : 18
3.6 Logarithmic Number System : : : : : : : : : : : : : : : : : : : : : 19
3.7 Antitetrational Number System : : : : : : : : : : : : : : : : : : : 19
3.8 Composite Arithmetic : : : : : : : : : : : : : : : : : : : : : : : : : : : 20
3.9 Round-Off Schemes : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 21
Addition : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 22
4.1 Overview : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 22
4.2 1-Bit Adders, (m, k)-Counters : : : : : : : : : : : : : : : : : : : : 23
Contents
: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 78
: : : : : : : : : : : : : : : : : : : : : : : : : : 78
7.4 Signed Division : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 79
7.5 SRT Division : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 80
7.6 High-Radix Division : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 81
7.7 Division by Multiplication : : : : : : : : : : : : : : : : : : : : : : : 81
7.8 Remainder / Modulus : : : : : : : : : : : : : : : : : : : : : : : : : : : : 82
7.9 Divider Implementations : : : : : : : : : : : : : : : : : : : : : : : : : 83
7.10 Square Root Extraction : : : : : : : : : : : : : : : : : : : : : : : : : 84
Elementary Functions : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 85
8.1 Algorithms : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 85
8.2 Integer Exponentiation : : : : : : : : : : : : : : : : : : : : : : : : : : : 86
8.3 Integer Logarithm : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 87
VLSI Design Aspects : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 88
9.1 Design Levels : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 88
9.2 Synthesis : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 90
9.3 VHDL : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 91
9.4 Performance : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 93
9.5 Testability : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 95
Bibliography : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 96
7.2 Restoring Division
: : : : : : : : : : : : : : : : : : : 26
4.4 Carry-Save Adder (CSA) : : : : : : : : : : : : : : : : : : : : : : : : : 45
4.5 Multi-Operand Adders : : : : : : : : : : : : : : : : : : : : : : : : : : : 46
4.6 Sequential Adders : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 52
Simple / Addition-Based Operations : : : : : : : : : : : : : : : : 53
5.1 Complement and Subtraction : : : : : : : : : : : : : : : : : : : : : 53
5.2 Increment / Decrement : : : : : : : : : : : : : : : : : : : : : : : : : : : 54
5.3 Counting : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 58
5.4 Comparison, Coding, Detection : : : : : : : : : : : : : : : : : : : 60
5.5 Shift, Extension, Saturation : : : : : : : : : : : : : : : : : : : : : : 64
5.6 Addition Flags : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 66
5.7 Arithmetic Logic Unit (ALU) : : : : : : : : : : : : : : : : : : : : : 68
Multiplication : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 69
6.1 Multiplication Basics : : : : : : : : : : : : : : : : : : : : : : : : : : : : 69
6.2 Unsigned Array Multiplier : : : : : : : : : : : : : : : : : : : : : : : 71
6.3 Signed Array Multipliers : : : : : : : : : : : : : : : : : : : : : : : : : 72
6.4 Booth Recoding : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 73
6.5 Wallace Tree Addition : : : : : : : : : : : : : : : : : : : : : : : : : : : 75
6.6 Multiplier Implementations : : : : : : : : : : : : : : : : : : : : : : : 75
6.7 Composition from Smaller Multipliers : : : : : : : : : : : : : 76
6.8 Squaring : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 76
Division / Square Root Extraction : : : : : : : : : : : : : : : : : : 77
7.1 Division Basics : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 77
4.3 Carry-Propagate Adders (CPA)
Contents
1.2 Motivation
1.3 Conventions
1.1 Outline
Naming conventions
Logic operators :
1.3 Conventions
+ (or),
(and),
(xor),
(xnor), (not)
Unit-gate model (
microprocessors (CPU)
signal processors (DSP)
Inverter, buffer :
A=0 T =0
(i.e. ignored)
non-standard operations
high-performance components
library development
A = m ; 1 T = dlog me
2.
a3 a2 a1 a0
1 funrsa.epsi
219 20 mm
z
a3 a2 a1 a0
1.
f is non-associative (r.m.n.)
) serial structure :
funn.epsi
119 17 mm
A = O(n) T = O(1)
f is associative (r.s.a.)
) serial or single-tree structure :
A = O(n) T = O(log n)
zi = f (ai x) ; i = 0 : : : n ; 1
) parallel structure :
m const.)
A = O(n) T = O(n)
z3 z2 z1 z0
a3 a2 a1 a0
1 funrmn.epsi
219 25 mm
3
z3 z2 z1 z0
a3 a2 a1 a0
k i
2.
= zn (r.s.) :
A = O(n2) T = O(log n)
ti = f (ai ti;1) ; i = 0 : : : n ; 1
t;1 = 0=1 z = tn;1
1.
f is non-associative (r.s.n.)
) serial structure :
A = O(n) T = O(n)
Computer Arithmetic: Principles, Architectures, and VLSI Design
f is associative (r.m.a.)
1
2
z3
funrma1.epsi
19 43 mm
z2
z1
z0
a3 a2 a1 a0
) or shared-tree structure :
1 funrsn.epsi
219 24 mm
3
a3 a2 a1 a0
1funrma2.epsi
219 21 mm
z3 z2 z1 z0
z
6
2 Arithmetic Operations
2.1 Overview
2 Arithmetic Operations
2 Arithmetic Operations
2.1 Overview
based on operation
related operation
always : 1 5
floating-point
in most cases : 6
<< , >>
sometimes : 7, 8
=,<
+1 , 1
+/
+,
arithops.epsi
98 83 mm
+,
sometimes : 6
in most cases : 7, 8, 9
Table look-up techniques using ROMs :
(same as on
the left for
floating-point
numbers)
sqrt (x)
exp (x)
trig (x)
complexity
log (x)
hyp (x)
shift/extension
7 division
comparison
8 square root extraction
increment/decrement
9 exponential function
complement
10 logarithm function
addition/subtraction 11 trigonometric functions
multiplication
12 hyperbolic functions
n ; m)-bit fraction
A = an;1 2n;1 +
+ a12 + a0 =
Range : 0 2n ; 1]
nX
;1
i=0
ai2i
Sign : an;1
Properties : asymmetric range, compatible with
unsigned numbers in many arithmetic operations
(i.e. same treatment of positive and negative numbers)
Complement : ;A = 2n ; A ; 1 = A
3 Number Representations
Complement : ;A = 2n ; A = A + 1 ,
where A = (an;1 an;2 : : : a0 )
3 Number Representations
Fixed-point numbers :
10
: : : a0 )
11
3 Number Representations
111...1
011...1
100...0
000...0
Graphical representation
n1
3 Number Representations
n1
numrep.epsi
95 73 mm
unsigned
2s complement
binary ! Gray :
1s complement
gi = bi+1 bi bn = 0 ;
i = 0 : : : n ; 1 (n.)
sign-magnitude
Gray ! binary :
Conventions
bi = bi+1 gi bn = 0 ;
i = n ; 1 : : : 0 (r.m.a.)
12
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Gray
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
0
0
0
0
1
1
1
1
1
1
1
1
0
0
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
0
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
13
0 1g
binary
b3 b2 b1 b0 g3 g2 g1 g0
15
3 Number Representations
Range:
M=
nY
;1
i=0
nX
;1
i=0
Ciai
mn;2 ::: m0 ,
= (: : :
0 1 0
|{z}
i
(m1 m0) = (3 2) , M = 6
;4 ;3 ;2 ;1 0 1 2 3 4 5 6 7 8
2 0 1 2 0 1 2 0 1 2 0 1 2
0 1 0 1 0 1 0 1 0 1 0 1 0
|
j5j6 = A = (a1
{z
a0) = (j5j3
j5j2 ) = (2 1)
j4 + 5j6 = (1 0) + (2 1) =
= (j1 + 2j3 j0 + 1j2) = (0 1) = j3j6
j4 5j6 = (1 0) (2 1) =
= (j1 2j3 j0 1j2) = (2 0) = j2j6
: : :)
Example :
possible range
mi, anywhere in ZZ
, Ci
A
a1
a0
ai = A mod mi = jAjmi , A = mi qi + ai
jAjM
3 Number Representations
16
17
single
double
n nM nE
32
64
23
52
8
11
bias
EA =y
range
precision
10;7
10;15
18
19
3 Number Representations
3 Number Representations
a;d)
RTRUNC = (an;1 : : : a0 )
Truncation :
bias = ; 12 + 2d+1
Number representations :
(= average error )
integer :
tag
00
value
2s complement integer
rational :
01
slash
logarithmic :
10
log integer
log fraction
antitetrational :
11
a.t. integer
a.t. fraction
denominator n numerator
Round-to-nearest-even/-odd :
4 Addition
0
0
ROUND if (a;1 : : : a;d ) 6= 0
RROUND ;EVEN = R
0
0
(an;1 : : : a1 0) otherwise
bias = 0 (symmetric)
4.1 Overview
4 Addition
21
4.1 Overview
HA
1-bit adders
FA
(m,k)
(m,2)
= blog mc + 1)
CSKA
CSLA
CIA
CLA
PPA
COSA
carry-propagate adders
(cout s) = 2cout + s = a + b
CPA
s=a b
cout = ab
CSA
3-operand
adders.epsi
103 121 mm
carry-save adders
multi-operand
adder
array
A = 3 T = 2 (1)
(sum)
(carry-out)
a b
adder
tree
a b
a b
multi-operand adders
array
adder
tree
adder
hasym.epsi
23HA
mm
18
c
out
s
Legend:
HA:
FA:
(m,k):
(m,2):
half-adder
full-adder
(m,k)-counter
(m,2)-compressor
based on component
chaschema1.epsi
out
19 28 mm
haschema2.epsi
21 43 mm
c out
(reference)
s
related component
22
23
4 Addition
4 Addition
(m, k)-counters
(sk;1 : : : s0) =
kX
;1
mX
;1
sj 2j = ai
A = 7 T = 4 (2 )
g = ab (generate)
c0 = ab
p = a b (propagate) c1 = a + b
s = a b cin = p cin
cout = ab + acin + bcin = ab + (a b)cin
= g + pcin = pg + pcin = pa + pcin
= cinc0 + cinc1
j =0
c out
s k-1 s 0
A = 28 T = 10
a0a1 a2a3a4a5a6
a0a1 a2
a3a4 a5a6
FA
FA
FA
FA
count73par.epsi
FA
36 48 mm
a b
a b
a b
count73ser.epsi
42 59 mm
faschematic1.epsi
g
p
29 43 mm
c out
p
faschematic4.epsi
c out
c in
29 1 41 mm
c in
c out
faschematic5.epsi
0
c0
35 47 mm
1
c1
FA
s2
24
s2
s1
s0
s1
s0
tree structure
linear
structure
25
a n-1:j b n-1:j
2ci+1 + si
CPA
c out
A
a i-1:k b i-1:k
a k-1:0 b k-1:0
...
FA
FA
c in
Sum (cout
...
i=0
A = 28 T = 14
faschematic2.epsi
c in
32 35 mm
(reference)
cntsymbol.epsi
23 mm
18 (m,k)
g
HA
faschematic3.epsi
p
32
mm c
29
c out
in
HA
in
a m-1
...
m
;k
A = 7 Plog
k=1 bm2 c 7(m ; log m)
TLIN = 4m + 2blog mc TTREE = 4dlog3 me + 2blog mc
a b
out
a0
a b
a b
fasymbol.epsi
FA
c18 21 mm
c
speedup1.epsi
CPA
c i84 26 mm
cj
CPA
ck
c in
...
s n-1:j
cpasymbol.epsi
CPA
c out 29 26 mm c in
s i-1:k
s k-1:0
a n-1
b n-1
a1
b1
a0
b0
speedup2.epsi
104 50 mm
c out
A = 7n T = 2n AT = 14n2
a n-1
b n-1
a1
b1
a0
c out
FA
c n-1
c1
b0
FA
carry propagation
c in
postprocessing
...
s n-1
...
rca.epsi
57c 23FA
mm
preprocessing
...
s1
s0
c in
...
s n-1
s1
s0
26
27
4 Addition
4 Addition
8n
4n1=2
a n-1:j b n-1:j
a i-1:k b i-1:k
a k-1:0 b k-1:0
c out
0
c out
CPA
cj
ci
CPA
cska.epsi
36 mm
99
1
ci
CPA
ck
39n3=2
AT
a k-1:0 b k-1:0
...
...
ci
2:8n1=2
a i-1:k b i-1:k
32n3=2
AT
14n
c i0
c i1
...
c in
CPA
csla.epsi
102 50CPA
mm
0
s i-1:k
CPA
ck
c in
1
s i-1:k
0
ck
...
P i-1:k
s n-1:j
s i-1:k
s i-1:k
s k-1:0
28
29
s k-1:0
4 6 10 12 14 16 18 20 22 24 26 28 ... 38
2 3 4 5 6 7 8 9 10 11 ... 16
1 2 4 7 11 16 22 29 37 46 56 67 ... 137
max ngroup
= 1 [12, 11]
a i-1
IFA
b i-1
a i-2
b i-2
IFA
a k+1
b k+1
IFA
ak
bk
IHA
...
10n
2:8n1=2
AT
a i-1:k b i-1:k
...
c out
ci
ci
...
CPA
86
cia.epsi
si-1:k
43 mm
28n3=2
ci
ciagate.epsi
100
s i-2 112 mm
s i-1
(i-k-1)IFA + IHA
a k-1:0 b k-1:0
2IFA + IHA
s k+1
IFA + IHA
sk
IHA
ck
IHA
0
ck
CPA
c in
...
bits i-1...k
...
bits 6...4
bits 3,2
bit 1
bit 0
P i-1:k
+1
s i-1:k
s k-1:0
c out
30
c in
31
4 Addition
2 log n
AT
6n log
c0 = c00
c1 = g0 + p0c00
c2 = g1 + p1g0 + p1p0c00
c3 = g2 + p2g1 + p2p1g0 + p2p1 p0c00
g30 = g3 + p3g2 + p3p2g1 + p3p2 p1g0
p30 = p3p2p1 p0
4 Addition
...
(g3,p3)
(g0,p0)
clbsymbol.epsi
26 mm c
27 CLB
0
. . . c0
(g,p)
3 3 c3
level 0
a3
...
b3
a2
FA
level 1
...
level 2
FA
...
b2
a1
FA
FA
a0
FA
b0
FA
c in
CLB
s2
s1
32
...
(gn-1 , p n-1 )
carry-lookahead:
prefix algorithm
add.epsi///figures
73 64 mm
c1
p0
c3 . . . c0
+ preprocessing : gi = ai bi
+ postprocessing : si = pi
pi = ai bi
ci
4 Addition
33
postprocessing:
: : : y0), associative
or
y1 = Y1:01
{z
y2 = Y2:02
{z
y3 = Y3:03
|
}
Y3:21
{z
y1 = Y1:01
y3 = Y3:02
: : : xi) at level l
Carry-propagation is prefix problem : Yil:k = (Gli:k Pil:k )
(G0i:i Pi0:i) = (gi pi)
(Gli:k Pil:k ) = (Gli;:j+1 1 Pil:;j+1 1) (Glj;:k1 Pjl:;k1) ; k j i
= (Gil;:j+1 1 + Pil:;j+1 1Glj;:k1 Pil:;j+1 1Pjl:;k1)
ci+1 = Gmi:0 ; i = 0 : : : n ; 1 l = 1 : : : m
Parallel-prefix algorithms [14] :
multi-tree structures (T = O(n) ! O(log n))
sharing subtrees (A = O(n2 ) ! O(n log n))
different algorithms trading area vs. delay (influences
also from wiring and maximum fan-out FOmax )
c0
s0
s n-2
...
s1
...
s n-1
gi = aibi
pi = ai bi
(g0 , p0 )
c out
CLB
preprocessing:
c in
c n p n-1
CLB
T = 4 + 2T
a1
b1
a0
b0
a n-1
b n-1
a n-2
b n-2
...
c in
Associativity of
5n + 3A
56n log n
Prefix problem
AT
c 11 . . . c 8 cla.epsi c 7 . . . c 4
97 48 mm
s0
4 log n
CLB
c 15 . . . c 12
...
s3
CLB
c out
14n
FA
cosa.epsi
100 57 mm
b1
si = pi ci
34
35
4 Addition
Prefix algorithms
Algorithms visualized by directed acyclic graphs (DAG)
with array structure (n bits m levels)
Graph vertex symbols :
(Gil;:j+1 1 Pil:;j+1 1) (Gjl;:k1 Pjl:;k1 )
y?;
;
; (Gl P l )
(Gli:k Pil:k ) ?
i:k i:k
1
2
?
i
;
(Gli:k Pil:k ) ?
(Gli:k Pil:k )
0
1
2
3
4
sk.epsi///figures
67 30 mm
A = 2n ; dlog ne ; 2 T = 2dlog ne ; 2
FOmax log n
A = n ; 1 T = n ; 1 FOmax = 2
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0
1
2
3
4
5
6
...
ser.epsi///figures
69 38 mm
14
15
36
bk.epsi///figures
67 38 mm
37
1
2
(contains no logic)
Performance measures :
A : graph size (number of black nodes)
0
1
2
3
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
(Gil;:k1 Pil:;k 1 )
4 Addition
k n ; 2dlog ne + 2
k = 0 : serial-prefix graph
k = n ; 2dlog ne + 1 : Brent-Kung parallel-prefix
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0
1
graph
ks.epsi///figures
67 52 mm
A = n ; 1 + k T = n ; 1 ; k FOmax = var.
4
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0
1
2
3
4
5
6
7
8
9
10
2n ; 1:4n1=2
1:4n1=2
FOmax
1:4n1=2
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0
1
2
3
4
5
cia.epsi///figures
67 34 mm
38
var.epsi///figures
68 54 mm
39
4 Addition
b3
a2
b2
a1
b1
a0
4 Addition
A =3
T =3
b0
c in
0
unfact.epsi
1
20 26 mm
2
3
3 2 1 0
depth-decr.
transform
0
fact.epsi
1
20 26 mm
2
3
;!
size-decr.
transform
A =4
T =2
askgate.epsi///figures
100 103 mm
c out
P n-1:0
s3
s2
s1
s0
40
Multilevel adders
41
Self-timed adders
Hybrid adders
Arbitrary combinations of speed-up techniques possible
) hybrid/mixed adder architectures
Often used combinations : CLA and CSLA [15]
m process
area [lambda^2]
RCA
128-bit
1e+07
CSKA-2L
CIA-1L
CIA-2L
64-bit
PPA-SK
Transistor-level adders
PPA-BK
32-bit
addperf.ps
84 84 mm
CLA
COSA
const. AT
16-bit
1e+06
8-bit
5
delay [ns]
5
10
20
43
= a0 i + a1 i + a2 i ;
i = 0 1 : : : n ; 1 (n.)
p
( )
a 0,n-1
a 1,n-1
a 2,n-1
csa.epsi
27FA
mm
. . . 67
FA
cn
c2
s n-1
FA
c1
s1
s0
45
FA
a 2,n-1
CSA
FA
HA
a 3,n-1
FA
a 2,2
a 2,1
...
FA
a 3,2
CPA
a 2,0
cparray.epsi
93 57 mm FA
FA
CPA
HA
a 3,1
a 3,0
FA
FA
HA
s2
s1
s0
CPA
...
sn
s n-1
FA
...
...
a 3,n-1
mopadd.epsi
CSA
30 58 mm
a 3,2
...
csarray.epsi
99FA 57 mm
FA
a 3,1
FA
FA
CSA
a 3,0
HA
CSA
...
FA
FA
a 2,0
a 0,2
a 1,2
A m-1
a 0,0
a 1,0
A3
...
FA
a 0,n-1
a 1,n-1
A0 A1 A2
FA
...
Array adders
a 0,0
a 1,0
A = O(mn + n)
T = O(m + n)
a 2,0
A = 7n T = 4
CPA = RCA :
(C S )out = A + (C S )in
A = (m ; 2)ACSA + ACPA
T = (m ; 2)TCSA + TCPA
p
p
4 Addition
csasymbol.epsi
26 mm
21 CSA
2ci+1 + si
p
p
p
ttt
att
A0 A1 A2
a 0,0
a 1,0
3n log2 n
40n log n
6n log2 n
56n log n
6n log2 n
(C S ) = C + S = A0 + A1 + A2
a 2,1
2 log n
4 log n
2 log n
4 log n
2 log n
aat 3
att
att
a 2,1
n log n
10n
3n log n
14n
3n log n
3
2
PPA-SK
PPA-BK
PPA-KS
CLA 5
COSA
14n2
32n3=2
xn4=3 4
39n3=2
28n3=2
36n4=3
44n5=4
a 0,1
a 1,1
8n
8n
14n
10n
10n
10n
CSKA-1L
CSKA-2L
CSLA-1L
CIA-1L
CIA-2L
CIA-3L
2n
4n1=2
xn1=3 4
2:8n1=2
2:8n1=2
3:6n1=3
4:4n1=4
opt.1 syn.2
p
aaa
AT
a 0,1
a 1,1
7n
RCA
a 0,1
a 1,1
a 2,2
adder
4 Addition
a 0,2
a 1,2
4 Addition
Fast CPA :
A = O(mn + n log n)
T = O(m + log n)
CPA
FA
FA
sn
s n-1
FA
HA
s2
s1
CPA
...
s0
S
Computer Arithmetic: Principles, Architectures, and VLSI Design
46
47
4 Addition
4 Addition
(m, 2)-compressors
2(c +
mX
;4
l =0
0
c out
clin
m-4
c out
cprsymbol.epsi
26 mm
37 (m,2)
...
i=0
ai +
mX
;4
...
...
l=0
mX
;1
A = 7(m ; 2)
TLIN = 4(m ; 2) TTREE = 6(dlog me ; 1)
a m-1
a0
clout) + s =
c in0
c inm-4
A = 14 T = 6
A = 14 T = 8
a0 a1
a0 a1 a2 a3
FA
cpr42fa.epsi
32 38 mm
c out
c in
FA
cpr42opt.epsi
1
41 53 mm
c out
c in
(4,2)
cpradd.epsi
99 44 mm
(4,2)
(4,2)
FA
FA
HA
sn
s n-1
s2
s1
4 Addition
CPA
48
s0
FA
(4,2)
optimized
CSA
# operands
with full-adders
tree depth
FA
s n+1
a 0,0
a 1,0
a 2,0
a 3,0
a 0,1
a 1,1
a 2,1
a 3,1
a 0,2
a 1,2
a 2,2
a 3,2
a 0,n-1
a 1,n-1
a 2,n-1
a 3,n-1
(4,2)
a2 a3
49
7 8 9 10
2 3 4 6 9 13 19 28 42 63 94
2 4 8 16 32 64 128
A = 42 T = 16
a0a1 a2a3
0
c out
FA
A = 42 T = 12
a0a1a2a3
a4a5 a6a7
FA
1
c out
0
c out
c in0
c in1
FA
2
c out
FA
cpr82fa.epsi
47 65 mm
3
c out
FA
4
c out
FA
c
c in2
a4a5a6a7
(4,2)
(4,2)
1
c out
2
c out
c in0
c in1
cpr82cpr42.epsi
47 50 mm
c in2
3
c out
c in3
4
c out
c in4
(4,2)
c in3
c in4
full-adder tree
Computer Arithmetic: Principles, Architectures, and VLSI Design
50
51
4 Addition
2s complementer (negation)
Z
A
A ; B = A + (;B )
=A+B+1
sub.epsi
29 32 mm
CPA
c out
S
A B
2s complement adder/subtractor
A B = A + (;1)sub B
= A + (B sub) + sub
CSA
accucsa.epsi
33 52 mm
CPA
c out
A + B (mod 2n ; 1)
= A + B + cout
52
sub
1
2
1
2
n log2 n
(cout Z ) = A ; cin
a2
a1
a0
...
Z
dec.epsi
93 41 mm
c out
A = 3n T = n + 1 AT
c in
...
z n-1
a0
z2
z1
z0
Incrementer-decrementer
...
incfa.epsi
59c 23HA
mm c
2
1
) AND-prefix struct.
n log n + 2n T = dlog ne + 2 AT
a n-1
incsymbol.epsi
+1
c out 29 26 mm c in
53
Ci:k = Ci:j+1Cj:k
Decrementer
= 0 () FA ! HA)
a1
c in
Prefix problem :
addmod.epsi
28 mm
29 CPA
Incrementer
Adds a single bit cin to an n-bit operand A
(cout Z ) = cout2n + Z = A + cin
c out
(end-around carry)
zi = ai ci
ci+1 = aici ; i = 0 : : : n ; 1
c0 = cin cout = cn (r.m.a.)
1s complement adder
CPA
addsub.epsi
36 35 mm
c n-1
2s complement subtractor
accucpa.epsi
CPA
27 28 mm
HA
+1
si
a n-1
neg.epsi
21 32 mm1
;A = A + 1
bitseradd.epsi
FA
25 27 mm
A = ACPA + AREG
T = TCPA + TREG
L=m
A = AFA + AFF
T = TFA + TFF
L=n
c out
HA
c in
...
z n-1
z1
a n-1
z0
a2
a1
a0
a2
a1
dec
a0
...
...
c out
incdec.epsi
94 46 mm
inc.epsi
83 33 mm
c out
c in
c in
...
...
HA
z n-1
z2
z1
z0
z n-1
54
z2
z1
z0
55
Fast incrementers
Gray incrementer
a2
a1
c0 = an;1 an;2
a0 (parity)
ci+1 = ai ci ; i = 0 : : : n ; 3 (r.m.a.)
z0 = a0 c0
zi = ai ai;1 ci;1 ; i = 1 : : : n ; 2
zn;1 = an;1 cn;2
a0
c in
inccg.epsi
62 39 mm
c out
z3
z2
z1
z0
a6
a5
a4
a3
a2
a1
a0
c in
incpp.epsi
98 63 mm
c out
z7
z6
z5
z4
z3
z2
z1
z0
56
5.3 Counting
c out
c in
Ring counters
Shift register connected to ring :
clk
Q
c in
cntring.epsi
51 16 mm
q n-1
q1
q0
q2
q1
01)
clk
cntasync.epsi
64 18 mm
q n-1
q0
Applications:
fast dividers (no logic between FF)
state counter for one-hot coded FSMs
q2
q1
cntripple.epsi
87 36 mm
...
q2
5.3 Counting
Gray counter
Binary counter
Sequential in-/decrementer
Incrementer speed-up
techniques applicable
Down- and up-down-counters
using decrementers /
incrementer-decrementers
q n-1
57
5.3 Counting
...
q n-1
q1
q0
q0
q2
58
59
Comparators
Subtractor (A ; B ) :
Comparison operations
EQ = (A = B )
(equal)
NE = (A 6= B ) = EQ
(not equal)
GE = (A B )
(greater or equal)
LT = (A < B ) = GE
(less than)
GT = (A > B ) = GE EQ
(greater than)
LE = (A B ) = GT = GE + EQ (less or equal)
cmpsub.epsi
37 31 mm
GE = cout
EQ = Pn;1:0
CPA
GE = c out
EQ = P n-1:0
ARCA = 7n TRCA = 2n or
APPA;KS 32 n log n TPPA;KS
2 log n
Optimized comparator :
a0
b0
a2
b2
a n-1
b n-1
EQ = (A = B )
a1
b1
Equality comparison
...
A = 6n TLIN = 2n TTREE
cmpeq.epsi
40 36 mm
2 log n
a0
b0
a1
b1
EQ
a2
b2
a n-1
b n-1
Magnitude comparison
cmpripple.epsi
100 47 mm
equality
EQ
60
Decoder
Decodes binary number An;1:0 to vector Zm;1:0 (m = 2n )
zi =
1 if A = i
0 else
;
a2
i = 0 ::: m ; 1
a1
= 2A
61
Detection operations
All-zeroes detection :
All-ones detection :
z = an;1 + an;2 + + a0
z = an;1 an;2 a0 (r.s.a.)
A = n T = log n
a0
decoder.epsi
58 28 mm
decodersym.epsi
26 mm
21decoder
magnitude
GE
equality &
magnitude
...
GE = (A B )
z7
z6
z5
z4
z3
z2
z1
z0
a) non-encoded output :
A = (n ; 1)2n T = dlog ne
Encoder
Encodes vector Am;1:0 to binary number Zn;1:0 (m = 2n )
(condition: 9i 8k j if k = i then ak = 1 else ak = 0)
Z = i if ai = 1 ; i = 0 : : : m ; 1 Z = log2 A
A
encodersym.epsi
26 mm
21encoder
z0
a n-2
A = 2n T = n
a1
...
a0
lzdnenc.epsi
50 28 mm
...
z n-1
z n-2
z1
z0
z1
A = n(2n;1 ; 1)
T =n;1
a n-1
a7a5a3a1
a6a4a2a0
encoder.epsi
30 34 mm
f0g1f0j1g ! f0g1f0g
z2
(note: connections
according to PPA-SK)
62
63
shift b)
unsigned
signed
rotate
extend
l.
r.
unl.
signed r.
signed l.
r.
saturate unsigned
signed
an;2
0 an;1
an;1
an;3
an;1 an;1 an;2
an+k;1
a2n;1 an+k;2
an;2
a0 an;1
0 an;1
an;1
an;1 an;1 an;2
an;1
an;2
an;1
an;1
an;1
:::
:::
:::
:::
:::
:::
:::
:::
:::
:::
:::
:::
:::
:::
a0 0
a1
a0 0
a1
ak
ak
a0 an;1
a1
a0
a0 0
a0
a0 0
an;1
an;1
sll
srl
sla
sra
C
V
formula
cn
cn cn;1
an bnsn + anbn sn
Z
8i : si = 0
N
sn;1
A = O(n2)
T = O(log n)
rol
ror
a3
a2
a1
a3
a0
a0
s1 s0
barshift.epsi
44 49 mm
s1 s0
z3
z2
z1
z0
z3
multiplexers
a1
s1 s0
s1
64
a2
s1 s0
muxshift.epsi
41 28 mm
s0
z2
z1
z0
tristate buffers
65
5.6 Addition Flags
condition
flag
unsigned
formula
signed
S = A + B (+) or S = A ; B (;)
zero
Z
Z
negative
N
positive
N
S > max overflow C (+)
VC
S < min underflow C (;)
VC
operation: A ; B
A=B
EQ
Z
Z
A 6= B
NE
Z
Z
A B
GE
C
N V + NV
A>B
GT
CZ (N V + NV )Z
A<B
LT
C
NV + NV
A B
LE
C + Z NV + NV + Z
operation:
S=0
S<0
S 0
zero flag
negative flag, sign
C , N : for free
V : fast cn, cn;1 computed by e.g. PPA ) very cheap
Z : a) cin = 1 (subtract.) : Z = (A = B ) = Pn;1:0 (of PPA)
b) cin = 0=1 :
Z = sn;1 + sn;2 + + s0 (r.s.a.)
1)
A = ACPA + n TZ = TCPA + dlog ne
2)
Implementation of shift/extension/rotation by
constant values : hard-wired
variable values : multiplexers
n possible values : nbyn barrel-shifter/rotator
Example : 4by4 barrel-rotator
Applications :
adaption of magnitude (shift a)) or word length
(extension) of operands (e.g. for addition)
multiplication/division by multiples of 2 (shift)
logic bit/byte operations (shift, rotation)
scaling of numbers for word-length reduction (i.e.
ignore leading zeroes, shift b)) or normalization (e.g.
of floating-point numbers, shift a)) using LZD
reducing error after over-/underflow (saturation)
shift a)
66
67
6 Multiplication
6 Multiplication
c out alusymbol.epsi c in
29 mm
30 ALU
flags
op
ALU operations
arithmetic
add
inc
pass
logic
and
or
xor
pass
shift/
rotate
sll
sla
rol
A + B + cin
A+1
A
aibi
ai + bi
ai bi
ai
A 1
A a1
A r1
A;B
A;1
;A
ai bi
ai + bi
ai bi
ai
A 1
A a1
A r1
sub
dec
neg
nand
nor
xnor
not
srl
sra
ror
Algorithm
1) Generation of n partial products Pi
2) Adding up partial products :
a) sequentially (sequential shift-and-add),
b) serially (combinational shift-and-add), or
c) in parallel
Speed-up techniques
68
Sequential multipliers :
partial products generated
and added sequentially (using
accumulator)
mulseq.epsi
34 28 mm
P=
CPA
A = O(n) T = O(log n) L = n
Array multipliers :
partial products generated and
added simultaneously in linear
array (using array adder)
69
CSA
mularr.epsi
mm
34 47
CSA
A = O(n ) T = O(n)
i=0 j =0
b3
CSA
A = 8n2 ; 11n
T = 6n ; 9
aibj 2i+j
a1 b3
a2 b3 a2 b2
+ a3b3 a3b2 a3b1
p7 p6 p5 p4
CSA
;1
nX
;1 nX
a0 b3
a1 b2
a2 b1
a3 b0
p3
b2
a0 b2 a0 b1 a0 b0
a1 b1 a1 b0
a2 b0
p2 p1 p0
b1
b0
a0
CPA
p0
a1
Parallel multipliers :
partial
products
generated in parallel and added
subsequently in multi-operand
adder (using tree adder)
mulpar.epsi
34 43 mm
a2
CPA
a3
A = O(n ) T = O(log n)
2
HA
HA
p1
FA
CSA
tree
mulbraun.epsi
FA
99 83 mm
FA
p2
Signed multipliers :
a) complement operands before and result after
multiplication ) unsigned multiplication
b) direct implementation (dedicated multiplier structure)
Computer Arithmetic: Principles, Architectures, and VLSI Design
HA
70
FA
FA
FA
CSA
p3
CPA
3
p7
FA
FA
HA
p6
p5
p4
71
6 Multiplication
Sequential multiplication
Minimal (or canonical) signed-digit (SD) represent. of A
s = a b cin
cout = ab + acin + bcin
a0 b3
a1b3 a1 b2
a2 b3 a2 b2 a2 b1
a3 b3 a3 b2 a3 b1 a3 b0
a3
a3
+ 1 b3
b3
p7 p6 p5 p4 p3
a0 b2 a0 b1 a0 b0
a1 b1 a1 b0
a2 b0
p2
p1
6 Multiplication
A : +8n
T : +7
0 0 0 ;p3
=
1
+ 1 1 1 p3
f;2 ;1 0 +1 +2g
=0
mulbooth.epsi
41 43 mm
CSA
array/tree
CPA
73
A = O(n2) T = O(log n)
p
3 p3 p3 p3 p2 p1 p0 =
| {z }
i=0
A : =2
T : =2
T : ;0
2;1
n=X
p0
A=
Booth
recoding
Baugh-Wooley multiplier
p2 p1 p0
p2 p1 p0
Sequential multipliers :
low performance, small area, component re-use (adder)
p6 p5 p4 p3 p2 p1 p0
ext. sign
6 Multiplication
p6 p5 p4 p3 p2 p1 p0
=0
75
6 Multiplication
6.8 Squaring
AH BL
AH BH AL BL
AL BH
P = A2 = AA
4 (n n)-bit multipliers
+ (2n)-bit CSA + (3n)-bit CPA
Algorithms (radix-2)
Subtract-and-shift : partial remainders Ri [1, 2]
a0 a3 a0 a2 a0 a1 a0 a0
a1 a3 a1 a2 a1 a1 a1 a0
a2 a3 a2 a2 a2 a1 a2 a0
+ a3a3 a3a2 a3a1 a3a0
a2 a3 a1 a3 a0 a3 a0 a2 a0 a1
a0 a0
a3 a3
a1 a2
a1 a1
+
a2 a2
p7 p6 p5 p4 p3
p2 p1 p0
76
qi =
1 if
0 if
Ri+1 ; B 2i 0
Ri+1 ; B 2i < 0
qi0 =
1 if
;1 = 1 if
Ri+1 0
Ri+1 < 0
77
q0 = 1 if
i
1 if
A = 9n2 T = 2n2 + 4n
a6 b3
b3
a6
b2
a5
b1
a4
b0
a3
q3
FA
q2
FA
q1
FA
FA
FA
FA
q0
FA
FA
FA
FA
r3
r2
r1
r0
+/ CPA
+/ CPA
divnr.epsi
mm CPA
46 38 +/
+/ CPA
+/ CPA
R
Computer Arithmetic: Principles, Architectures, and VLSI Design
FA
FA
FA
divarray.epsi
81 101 mm
FA
a1
A B
FA
a2
qi0 2 f1 1g ! qi 2 f0 1g : qi = 12 (qi0 + 1)
Q = (qn;1 qn;2 qn;3 : : : q0 1)
A = (n + 1)ACPA
= O(n2) or O(n2 log n)
T = (n + 1)TCPA
= O(n2) or O(n log n)
FA
78
a0
79
if
>
:1
if
B 2i Ri+1
qi0 is SD number
Ri+1 < B 2i
i
Ri+1 < ;B 2
Radix
CPA
:::
; 1g
Division by convergence
A = A R0R1
Q= B
B R0 R1
Rm;1 ! A
Rm;1 B
Algorithm :
+/ CSA
+/ CSA
divsrt.epsi
mm
+/ CSA
50 38
+/ CSA
+/ CPA
= Q1 resp. 2Qn
Bi+1 = Bi Ri Ai+1 = Ai Ri
Ri = B i + 1 ; i = 0 : : : m ; 1
A0 = A B0 = B Q = Am (r.s.n.)
Quadratic convergence :
B
1
B
R
80
Division by reciprocation
L = dlog ne
81
A =A 1
Q= B
B
f (X ) = 0
1 0 1
A B
:::
;1
A = nACSA + 2ACPA
= O(n2)
T = nTCSA + TCPA
= O(n)
= 2m , qi0 2 f
if 2n;1
) ;B 2i
find
qi0 = >0 if ;B 2i
by recursion
Xi+1 = Xi ; ff0((XXo))
i
f (X ) = X1 ; B f 0 (X ) = ; X12 f B1 = 0
Algorithm :
Xi+1 = Xi (2 ; B Xi) ; i = 0 : : : m ; 1
X0 = B Q = Xm (r.s.n.)
L = O(log n)
Speed-up : first approximation X0 from table
Quadratic convergence :
R = A rem B
sign(R) = sign(A)
M = A mod B M
M= R
R+B
if A
else
82
83
A2
0 22n ; 1]
A = Q2 + R
Algorithm
qi = Ri+1 2i 2Qi+1 + 2i
Qi = Qi+1 + qi2i
Ri = Ri+1 ; qi2i 2Qi+1 + qi2i ; i = n ; 1 : : : 0
Rn = A Qn = 0 R = R0 Q = Q0 (r.m.n.)
Implementation
similar to division-by-convergence
two (or more) recursive formulas : one formula
converges to a constant, the other to the result
A ADIV =2
T TDIV
+/ CPA
sqrtnr.epsi
+/ CPA
mmCPA
42 36+/
+/ CPA
+/ CPA
R
Computer Arithmetic: Principles, Architectures, and VLSI Design
8 Elementary Functions
84
= (: : :
0 1 0
|{z}
A
: : :)
L=0
85
Ab )2 Ab
Ei = Ei2+1 Abi ; i = n ; 1 : : :
En = 1 E = E0 (r.s.n.)
2n ; 1 (!)
C)
Z = blog2 Ac
For detection/comparison of order of magnitude
Algorithms : square-and-multiply
a)
8 Elementary Functions
xy = ey ln x = 2y log x
= A| A{z A}
b)
Approximated exponentiation :
AB
8.1 Algorithms
8 Elementary Functions
0 2n ; 1]
Q2
8 Elementary Functions
A4b A2b Ab
2
or
86
87
Gate-level design
ci
carry chain :
c i-1
carrychain.epsi
54 17 mm
c out
ki
pi
g i-1
c in
c in
k i-1 p i-1
a
b
fulladder :
c in
c in
facmos.epsi
76 40 mm
c in
s
c in
c out
b
a
c in
88
9.2 Synthesis
89
9.3 VHDL
9.2 Synthesis
9.3 VHDL
High-level synthesis
relational
shift, rotate (93 only)
adding
sign (unary)
multiplying
exponent, absolute
:
:
:
:
:
:
Synthesis
Arithmetic packages
numeric_bit, numeric_std (IEEE standard 1076.3),
std_logic_arith (Synopsys)
91
9.3 VHDL
Resource sharing
Pipelining
Pipelining is basically possible with every combinational
circuit ) higher throughput
) 2 adders + 1 multiplexer
b)
High speed
Fast circuit architectures, pipelining, replication
(parallelization), and combinations of those
Aext
Bext
Sext
S
Cout
9.4 Performance
9.4 Performance
92
9.4 Performance
93
9.5 Testability
Low power
9.5 Testability
94
95
Bibliography
Bibliography
Bibliography
96
Bibliography
98
97