0% found this document useful (0 votes)
170 views

Digital Arithmetic - Ercegovac/Lang 2003 1 - Introduction

The document discusses digital arithmetic and provides an overview of the topics covered in the book including addition, multiplication, division and other arithmetic operations. It describes number representation systems and different levels of implementing arithmetic from numerical computations to logic design. It also covers fixed-radix and non-conventional number systems as well as redundant representation.

Uploaded by

Aashish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
170 views

Digital Arithmetic - Ercegovac/Lang 2003 1 - Introduction

The document discusses digital arithmetic and provides an overview of the topics covered in the book including addition, multiplication, division and other arithmetic operations. It describes number representation systems and different levels of implementing arithmetic from numerical computations to logic design. It also covers fixed-radix and non-conventional number systems as well as redundant representation.

Uploaded by

Aashish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

1

DIGITAL ARITHMETIC

Miloš D. Ercegovac
Computer Science Department
University of California Los Angeles
and
Tomás Lang
Department of Electrical and Computer Engineering
University of California at Irvine
Viewgraphs Copyright c 2003 by the authors
Copyright c 2004 by Elsevier Science (USA)

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


2
ABOUT THE BOOK

Objectives Theory and design of arithmetic algorithms for digital systems


Topics – not all covered in depth –
1. Overview [Chapter 1]
2. Two-Operand Addition [Chapter 2]
3. Multi-operand Addition [Chapter 3]
4. Multiplication [Chapter 4]
5. Division by Digit Recurrence [Chapter 5]
6. Square Root by Digit Recurrence [Chapter 6]
7. Reciprocal, Division, Reciprocal Square RToot, and Inverse Square Root
by Iterative Approximation [Chapter 7]
8. Floating-point Representation, Algorithms, and Implementations [Chapter
8]
9. Digit-Serial Arithmetic [Chapter 9]
10. Function Evaluation [Chapter 10]
Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction
3
11. CORDIC Algorithm and Implementations [Chapter 11]

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


4
Chapter 1: Review of the Basic Number Representations and Arithmetic
Algorithms

• General-purpose processors

3 Main use: numerical computations

3 Address calculations
- basic operations
- fixed point and floating point
- IEEE standard
- vector processors

• Special-purpose (application-specific) processors


- for numerically intensive applications
- single computation or classes of computations

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


5
Application-specific processor

• Areas of application:
- signal processing
- embedded systems
- matrix computations
- graphics, vision, multi-media
- cryptography and security
- robotics, instrumentation; others?
• Features:
- better use of technology
- improvement in speed, area, power
- flexibility in
* implementation; decomposition into modules
* number systems and data formats; algorithms
• Need good design tools; difficult to change; FPGAs?

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


6
GENERAL-PURPOSE VS. APPLICATION-SPECIFIC

• Flexibility

• Matching specific applications

• Use of VLSI and special technology

• Use of hardware-level parallel processing

• Lower software overhead

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


7
ARITHMETIC PROCESSORS: USER’S VIEW

AP = (operands, operation, results, conditions, singularities)


• Numerical operands and results specified by
– Set of numerical values x ∈ N (finite and ordered set)
– Range Vmin ≤ x ≤ Vmax
– Precision
– Number representation system (NRS)
• Set of operations: addition, subtraction, multiplication, division, ...
• Conditions: values of the results – zero, negative, etc.
• Singularities: Illegal results – overflow, underflow, Nan, etc.

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


8
LEVELS OF DESCRIPTION AND IMPLEMENTATION

• Numerical computations (applications)


• Algorithms
• Arithmetic operations

Operations Operands-Result Algorithm


Numerical function Numbers Numerical Algorithm
↓ ↓
↓ N umber System Arithmetic design
↓ ↓
Digit-vector function Digit vector Digit-vector Algorithm
↓ ↓
↓ Digit Coding RT L design
↓ ↓
Bit-vector function Bit vector Bit-vector Algorithm

Logic Design

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


9
NUMBER REPRESENTATION SYSTEMS

value: x ∈ N =⇒NRS =⇒X ∈ V : digit vector


• Digit Vector

X = (xa, . . . , xi, . . . , xb)


– indexing:

Leftward Zero Origin (LZ) (integers)

X = (xn−1, xn−2, . . . , x0)


Rightward One Origin (RO) (fractions)

X = (x1, x2, . . . , xn)


– Digit set Di - set of values for digit xi (usually consecutive integers)

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


10
NUMBER REPRESENTATION (cont.)

• Number of (unambiguously) representable numbers


|N | ≤ Π|Di|

• Number representation system

F :N →V

• Choose NRS to
– allow efficient computation(s)
– suitable interface with other systems
• Different implementation-performance constraints
=⇒ variety of NRS

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


11
SOME CHARACTERISTICS OF NRS

a) Range: finite set of digit-vector values

b) Unambiguity: two numbers should not have same representation

If x ∈ N, y ∈ N, x 6= y then F (x) 6= F (y)

c) Nonredundant/redundant
Redundant: F −1(X) = F −1(Y )

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


12
WEIGHTED NUMBER REPRESENTATION SYSTEMS

Integer x represented by digit vector X = (xn−1 . . . , x0),


n−1
x= xi · w i
X

i=0
where
W = (wn−1, . . . , w0) weight vector
Define
R = (rn−1, . . . , r0) radix vector
so that
w0 = 1 wi = wi−1ri−1

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


13
WEIGHTED NUMBER REPRESENTATION (cont.)

• Fixed-radix NRS
ri = r
Then wi = ri so that
n−1
x= xi r i
X

i=0

• Canonical digit set


Di = {0, 1, 2, . . . , |ri| − 1}
• Conventional number system

– Fixed radix positive


– Canonical digit set

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


14
NON-CONVENTIONAL FIXED-RADIX SYSTEM

• Negative radix
n−1
r = −2, x = Pi=0 xi(−2)i
1011 = (-8) + 0 + (-2) + 1 = -9
0111 = 0 + 4 + (-2) + 1 = 3

• Complex radix

r = 2j, j = −1, xi ∈ {0, 1, 2, 3} (Knuth’s quarter imaginary NRS)
W: -8j -4 +2j +1
1231 =⇒1 × (−8j) + 2 × (−4) + 3 × (2j) + 1 × 1 = −7 − 2j
• Non-canonical digit set, r = 2, {-1,0,1} or {0,1,2}
Example: radix 4 D = {−3, −2, −1, 0, 1, 2, 3}

x = 27 represented by (1, 2, 3) or (2, −2, 3)

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


15
REDUNDANT NRS

• Fixed radix r
• Non-canonical digit set

D = {−a, −a + 1, . . . , −1, 0, 1, . . . , b − 1, b}

• Symmetric if a = b
• Redundant a + b + 1 > r (a, b ≤ r − 1)
– ”standard” a, b ≤ r − 1
– over-redundant a, b > r − 1
– Redundancy factor
a 1
ρ = , ρ>
r−1 2

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


16
EXAMPLES OF REDUNDANT DIGIT SETS

r a Digit set ρ Comment


2 1 { -1, 0, 1} 1 minimally/maximally redundant
4 2 {-2, -1, 0, 1, 2} 2/3 minimally redundant
4 3 {-3, -2, . . . , 2, 3} 1 maximally redundant
4 4 {-4, . . . , 4} 4/3 over-redundant
9 4 {-4, . . . , 4} 1/2 non-redundant
10 5 {-5, . . . , 5} 5/9 minimally redundant
10 6 {-6, . . . , 6} 2/3 redundant
10 9 {-9, . . . , 9} 1 maximally redundant
10 13 {-13, . . . , 13} 13/9 over-redundant

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


17
MIXED-RADIX NUMBER SYSTEM

• ri 6= rj
• Example: Representation of time R = (31, 24, 60, 60)
• Example: Factorial number system

ri = i + 2, i = 0, . . . , n − 1
R = (n + 1, n, . . . , 3, 2)
wi = (i + 1)!

Canonical digit set


Integers in range 0 ≤ x ≤ (n + 1)! − 1

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


18
NON-WEIGHTED NUMBER SYSTEMS: RESIDUE (RNS)

• Base vector B of moduli mi

B = (mn−1, mn−2, . . . , m0)

mi positive integers and pairwise relatively prime

• Integer x is represented by vector

X = (xn−1, xn−2, . . . , x0)

where xi = x mod mi
• Represents uniquely integers in the range
n−1
0 ≤ x < Πi=0 mi

(more later)

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


19
REPRESENTATION OF SIGNED INTEGERS

A. Directly in the number representation


Examples: Signed-Digit Number System
B. With an extra symbol: Sign-and-magnitude
C. Additional mapping on positive integers
Signed integers x

Positive integers xR

Digit-vectors X

Examples:
• True-and-Complement (TC):
– 2’s complement
– 1s’ complement
• Biased representation

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


20
TRUE-AND-COMPLEMENT SYSTEM

• −k ≤ x ≤ k signed integer (implicit value)


• xR positive integer (representation value)
• C – complementation constant
• Mapping xe = x mod C
• Unambiguous if k < C/2
• Equivalent to


 x if x ≥ 0
xR = 

C − |x| if x < 0
• Converse mapping


 xR if xR < C/2
x = 

xR − C if xR > C/2

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


21
NUMBER REPRESENTATION (cont.)

• xR represented in any number system


• In fixed-radix system two common choices:
– 2’s complement: C = r n (Range-complement system)
– 1s’ complement: C = r n − 1 (Diminished-radix-complement system)

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


22
BIASED REPRESENTATION

• B – bias
• −k ≤ x ≤ k
• xR = x + B
•B≥k

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


23
TYPES OF ARITHMETIC ALGORITHMS

• Bottom-up development
Primitives
+ Addition/subtraction
+ Multioperand addition
+ Arithmetic shifts
+ Multiplication by digit
+ Result-digit selection (PLA)
+ Table look-up
+ Multiplication
• Algorithms
+ Composition of primitives

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


24
TYPES (cont.)

• (Digit) Recurrences (continued sums)


3 Residual recurrence: R[i + 1] = f (R[i], X, Y, Z[i], zi+1)
Uses: Add/sub, single-position shifts, multiplication by digit
3 Output digit selection: zi+1 = g(R[i], X, Y, Z[i])
(keep R[i + 1] bounded)
Uses: Comparisons, PLA
3 Result recurrence
Z[i + 1] = Z[i] + zi+1ri+1 (continued sum)

Uses: Concatenation

• Examples:
3 multiplication R[i + 1] = 1r (R[i] + X · r nyi)
3 division R[i + 1] = rR[i] − qi+1Y qi+1 = g(R[i + 1], Y )

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


25
Types of algorithms

• Continued product recurrences


R[i + 1] = f (R[i], X, Y, Z[i], zz+1)
Uses: Add/sub, variable shifts, mult. by digit

zi+1 = g(R[i], X, Y, Z[i])(keep R[i + 1] bounded)


Uses: Comparisons, PLA
Z[i + 1] = Z[i](1 + zi+1r−(i+1)) (continued product)
Uses: Variable shift, addition

• Example:
3 division
R[i + 1] = rR[i](1 + qi+1r−(i+1)) + qi+1
qi+1 = g(R[i], Y )
Q[i + 1] = Q[i](1 + qi+1r−(i+1))

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


26
TYPES (cont.)

• Iterative Approximations
Z[i + 1] = f (Z[i], X, Y ) until g(Z(i)) < ε

Example:
3 reciprocal
Z[i + 1] = Z[i](2 − Z[i]X)

• Polynomial Approximations
z = a 0 + a 1 x + a 2 x2 + · · ·

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


27
PERFORMANCE

• Measures
+ Execution time
+ Throughput
• Improving speed
a) Arithmetic level
+ Reducing number of steps
Example: higher radix
Example: combinational instead of sequential
+ Reducing time of step
Example: carry-save adder instead of carry-propagate
+ Overlap steps (concurrency/pipelining)
Example: multiple generation and addition (in mult.)
Example: simultaneous additions (in mult.)
b) Implementation level
+ Reduce number of logic levels

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction


28
POWER AND COST

• Measures
+ Packaging
+ Interconnection complexity
+ Number of pins
+ Number of chips and types of chips
+ Number of gates and types of gates
+ Area
+ Design cost; verification and testing cost
+ Power dissipation
+ Power consumption
• Reduction of cost

Digital Arithmetic - Ercegovac/Lang 2003 1 – Introduction

You might also like