Docsity

Multiplication - Computer Arithmetic - Lecture Slides, Slides of Computer Science

Toggle sidebar
bg1
Part III
Multiplication
Number Representation
Numbers and Arithmetic
Representing Signed Numbers
Redundant Number Systems
Residue Number Systems
Addition / Subtraction
Basic Addition and Counting
Carry-Lookahead Adders
Variations in Fast Adders
Multioperand Addition
Multiplication
Basic Multiplication Schemes
High-Radix Multipliers
Tree and Array Multipliers
Variations in Multipliers
Division
Basic Division Schemes
High-Radix Dividers
Variations in Dividers
Division by Convergence
Real Arithmetic
Floating-Point Reperesentations
Floating-Point Operations
Errors and Error Control
Precise and Certifiable Arithmetic
Function Evaluation
Square-Rooting Methods
The CORDIC Algorithms
Variations in Function Evaluation
Arithmetic by Table Lookup
Implementation Topics
High-Throughput Arithmetic
Low-Power Arithmetic
Fault-Tolerant Arithmetic
Past, Present, and Future
Parts Chapters
I.
II.
III.
IV.
V.
VI.
VII.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
25.
26.
27.
28.
21.
22.
23.
24.
17.
18.
19.
20.
13.
14.
15.
16.
Elementary Operations
28. Reconfigurable Arithmetic
Appendix: Past, Present, and Future
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b

Partial preview of the text

Download Multiplication - Computer Arithmetic - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

Part III

Multiplication

Number Representation

Numbers and ArithmeticRepresenting Signed Numbers Redundant Number SystemsResidue Number Systems

Addition / Subtraction

Basic Addition and CountingCarry-Look ahead Adders Variations in Fast AddersMultioperand Addition

Multiplication

Basic Multiplication SchemesHigh-Radix Multipliers Tree and Array MultipliersVariations in Multipliers

Division

Basic Division SchemesHigh-Radix Dividers Variations in DividersDivision by Convergence

Real Arithmetic

Floating-Point ReperesentationsFloating-Point Operations Errors and Error ControlPrecise and Certifiable Arithmetic

Function Evaluation

Square-Rooting MethodsThe CORDIC Algorithms Variations in Function EvaluationArithmetic by Table Lookup

Implementation Topics

High-Throughput ArithmeticLow-Power Arithmetic Fault-Tolerant ArithmeticPast, Present, and Future

Parts Chapters I.

II.

III.

IV.

V.

VI.

VII.

1.2. 3.4. 5.6. 7.8.

10.9. 11.12.

25.26. 27.28.

21.22. 23.24.

17.18. 19.20.

13.14. Elementary Operations 15.16.

  1. Reconfigurable Arithmetic Appendix: Past, Present, and Future

III Multiplication

Topics in This Part

Chapter 9 Basic Multiplication Schemes

Chapter 10 High-Radix Multipliers

Chapter 11 Tree and Array Multipliers

Chapter 12 Variations in Multipliers

Review multiplication schemes and various speedup methods

  • Multiplication is heavily used (in arith & array indexing)
  • Division = reciprocation + multiplication
  • Multiplication speedup: high-radix, tree, recursive
  • Bit-serial, modular, and array multipliers

Basic Multiplication Schemes: Topics

Topics in This Chapter

9.1 Shift/Add Multiplication Algorithms

9.2 Programmed Multiplication

9.3 Basic Hardware Multipliers

9.4 Multiplication of Signed Numbers

9.5 Multiplication by Constants

9.6 Preview of Fast Multipliers

9.1 Shift/Add Multiplication Algorithms

Notation for our discussion of multiplication algorithms: a Multiplicand ak โ€“ 1 ak โ€“ 2... a 1 a 0 x Multiplier xk โ€“ 1 xk โ€“ 2... x 1 x 0 p Product ( a ๏‚ด x ) p 2 k โ€“ 1 p 2 k โ€“ 2... p 3 p 2 p 1 p 0 Initially, we assume unsigned operands

Fig. 9.1 Multiplication of two 4-bit unsigned binary numbers in dot notation.

Product

Partial products bit-matrix

a x

p

x (^) 0 a 20 x (^) 1 a 2 1 x (^) 2 a 22 x (^) 3 a 23

Multiplicand ๏‚ด Multiplier

Examples of Basic Multiplication

Fig. 9. Examples of sequential multipli- cation with right and left shifts.

Right-shift algorithm Left-shift algorithm ======================== ======================= a 1 0 1 0 a 1 0 1 0 x 1 0 1 1 x 1 0 1 1 ======================== ======================= p (0)^ 0 0 0 0 p (0)^ 0 0 0 0

  • x 0 a 1 0 1 0 2 p (0)^0 0 0 0 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ + x 3 a 1 0 1 0 2 p (1)^ 0 1 0 1 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ p (1)^ 0 1 0 1 0 p (1)^0 1 0 1 0
  • x 1 a 1 0 1 0 2 p (1)^ 0 1 0 1 0 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ + x 2 a 0 0 0 0 2 p (2)^ 0 1 1 1 1 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ p (2)^ 0 1 1 1 1 0 p (2)^ 0 1 0 1 0 0
  • x 2 a 0 0 0 0 2 p (2)^ 0 1 0 1 0 0 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ + x 1 a 1 0 1 0 2 p (3)^ 0 0 1 1 1 1 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ p (3)^ 0 0 1 1 1 1 0 p (3)^ 0 1 1 0 0 1 0
  • x 3 a 1 0 1 0 2 p (3)^ 0 1 1 0 0 1 0 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ + x 0 a 1 0 1 0 2 p (4)^ 0 1 1 0 1 1 1 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ p (4)^ 0 1 1 0 1 1 1 0 p (4)^ 0 1 1 0 1 1 1 0 ======================== =======================

p ( j +1)^ = ( p ( j )^ + xj a 2 k ) 2โ€“^1 |โ€“โ€“โ€“addโ€“โ€“โ€“| |โ€“โ€“shift rightโ€“โ€“|

Check: 10 ๏‚ด 11 = 110 = 64 + 32 + 8 + 4 + 2

Examples of Basic Multiplication (Continued)

Fig. 9. Examples of sequential multipli- cation with right and left shifts.

Right-shift algorithm Left-shift algorithm ======================== ======================= a 1 0 1 0 a 1 0 1 0 x 1 0 1 1 x 1 0 1 1 ======================== ======================= p (0)^ 0 0 0 0 p (0)^ 0 0 0 0

  • x 0 a 1 0 1 0 2 p (0)^0 0 0 0 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ + x 3 a 1 0 1 0 2 p (1)^ 0 1 0 1 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ p (1)^ 0 1 0 1 0 p (1)^0 1 0 1 0
  • x 1 a 1 0 1 0 2 p (1)^ 0 1 0 1 0 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ + x 2 a 0 0 0 0 2 p (2)^ 0 1 1 1 1 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ p (2)^ 0 1 1 1 1 0 p (2)^ 0 1 0 1 0 0
  • x 2 a 0 0 0 0 2 p (2)^ 0 1 0 1 0 0 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ + x 1 a 1 0 1 0 2 p (3)^ 0 0 1 1 1 1 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ p (3)^ 0 0 1 1 1 1 0 p (3)^ 0 1 1 0 0 1 0
  • x 3 a 1 0 1 0 2 p (3)^ 0 1 1 0 0 1 0 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ + x 0 a 1 0 1 0 2 p (4)^ 0 1 1 0 1 1 1 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ p (4)^ 0 1 1 0 1 1 1 0 p (4)^ 0 1 1 0 1 1 1 0 ======================== =======================

p ( j +1)^ = 2 p ( j )^ + xk โ€“ j โ€“ 1 a |shift| |โ€“โ€“โ€“โ€“addโ€“โ€“โ€“โ€“|

Check: 10 ๏‚ด 11 = 110 = 64 + 32 + 8 + 4 + 2

Time Complexity of Programmed Multiplication

Assume k -bit words

k iterations of the main loop 6-7 instructions per iteration, depending on the multiplier bit

Thus, 6 k + 3 to 7 k + 3 machine instructions, ignoring operand loads and result store

k = 32 implies 200+^ instructions on average

This is too slow for many modern applications!

Microprogrammed multiply would be somewhat better

9.3 Basic Hardware Multipliers

Fig. 9.4 Hardware realization of the sequential multiplication algorithm with additions and right shifts.

Multiplier x

Mux

Adder

0

c out

0 1

Doublewidth partial product p

Multiplicand a

Shift

Shift

( j )

x j

x (^) ja

k

k

k p ( j +1)^ = ( p ( j )^ + xj a 2 k ) 2โ€“^1 |โ€“โ€“โ€“addโ€“โ€“โ€“| |โ€“โ€“shift rightโ€“โ€“|

Performing Add and Shift in One Clock Cycle

Partial product p ( j )

k

Unused part of the multiplier x

Adderโ€™s carry-out

Adderโ€™s sum

k

k โ€“ 1

k โ€“ 1

To adder To mux control

Fig. 9.5 Combining the loading and shifting of the double-width register holding the partial product and the partially used multiplier.

Sequential Multiplication with Left Shifts

Fig. 9.4b Hardware realization of the sequential multiplication algorithm with left shifts and additions.

Multiplier x

Mux

2 k -bit adder

0

c out

0 1

Doublewidth partial product p

Multiplicand a

Shift

Shift

( j )

x k - j -

a

2 k

xk - j -1 k

2 k

The Case of a

Negative Multiplier

Fig. 9.7 Sequential multiplication of 2โ€™s-complement numbers with right shifts (negative multiplier).

============================ a 1 0 1 1 0 x 1 0 1 0 1 ============================ p (0)^ 0 0 0 0 0

  • x 0 a 1 0 1 1 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ 2 p (1)^ 1 1 0 1 1 0 p (1)^ 1 1 0 1 1 0
  • x 1 a 0 0 0 0 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ 2 p (2)^ 1 1 1 0 1 1 0 p (2)^ 1 1 1 0 1 1 0
  • x 2 a 1 0 1 1 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ 2 p (3)^ 1 1 0 0 1 1 1 0 p (3)^ 1 1 0 0 1 1 1 0
  • x 3 a 0 0 0 0 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ 2 p (4)^ 1 1 1 0 0 1 1 1 0 p (4)^ 1 1 1 0 0 1 1 1 0 +(- x 4 a ) 0 1 0 1 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ 2 p (5)^ 0 0 0 1 1 0 1 1 1 0 p (5)^ 0 0 0 1 1 0 1 1 1 0 ============================

Negative multiplicand, negative multiplier: In last step (the sign bit), subtract rather than add

Check:

  • 10 ๏‚ด โ€“ 11 = 110 = 64 + 32 + 8 + 4 + 2

Signed 2โ€™s-Complement Hardware Multiplier

Fig. 9.8 The 2โ€™s-complement sequential hardware multiplier.

Adder

k + 1

0, except in last cycle

1 0 Mux

k + 1

Enable Select

Partial product

Multiplier

Multiplicand

k + 1

c out c in

Example Multiplication

with Boothโ€™s Recoding

Fig. 9.9 Sequential multiplication of 2โ€™s-complement numbers with right shifts by means of Boothโ€™s recoding.

============================ a 1 0 1 1 0 x 1 0 1 0 1 Multiplier y - 1 1 - 1 1 - 1 Booth-recoded ============================ p (0)^ 0 0 0 0 0

  • y 0 a 0 1 0 1 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ 2 p (1)^ 0 0 1 0 1 0 p (1)^ 0 0 1 0 1 0
  • y 1 a 1 0 1 1 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ 2 p (2)^ 1 1 1 0 1 1 0 p (2)^ 1 1 1 0 1 1 0
  • y 2 a 0 1 0 1 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ 2 p (3)^ 0 0 0 1 1 1 1 0 p (3)^ 0 0 0 1 1 1 1 0
  • y 3 a 1 0 1 1 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ 2 p (4)^ 1 1 1 0 0 1 1 1 0 p (4)^ 1 1 1 0 0 1 1 1 0 y 4 a 0 1 0 1 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ 2 p (5)^ 0 0 0 1 1 0 1 1 1 0 p (5)^ 0 0 0 1 1 0 1 1 1 0 ============================

xi xi โ€“ 1 yi โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ 0 0 0 0 1 1 1 0 - 1 1 1 0 โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“

Check:

  • 10 ๏‚ด โ€“ 11 = 110 = 64 + 32 + 8 + 4 + 2

9.5 Multiplication by Constants

Explicit, e.g. y := 12 * x + 1

Implicit, e.g. A[i, j] := A[i, j] + B[i, j]

Address of A[i, j] = base + n * i + j

Software aspects:

Optimizing compilers replace multiplications by shifts/adds/subs Produce efficient code using as few registers as possible Find the best code by a time/space-efficient algorithm

0 1 2... n โ€“ 1 0 1 2...

m โ€“ 1

Row i

Column j

Hardware aspects:

Synthesize special-purpose units such as filters y [ t ] = a 0 x [ t ] + a 1 x [ t โ€“ 1] + a 2 x [ t โ€“ 2] + b 1 y [ t โ€“ 1] + b 2 y [ t โ€“ 2]