sequential multipliers lecture 9. required reading chapter 9, basic multiplication scheme chapter...

67
Sequential Multipliers Lecture 9

Upload: lester-lawson

Post on 01-Jan-2016

219 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Sequential Multipliers

Lecture 9

Page 2: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Required Reading

Chapter 9, Basic Multiplication SchemeChapter 10, High-Radix MultipliersChapter 12.3, Bit-Serial MultipliersChapter 12.4, Modular Multipliers

Behrooz Parhami, Computer Arithmetic: Algorithms and Hardware Design

Page 3: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Notation

a Multiplicand ak-1ak-2 . . . a1 a0

x Multiplier xk-1xk-2 . . . x1 x0

p Product (a x) p2k-1p2k-2 . . . p2 p1 p0

If multiplicand and multiplier are of different sizes, usually multiplier has the smaller size

Page 4: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

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

Partial Product 0

Partial Product 1

Partial Product 2

Partial Product 3

Number of partial products = number of bits in multiplier xBit-width of each partial product = bit-width of multiplicand a

Page 5: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Basic Multiplication Equations

x = xi 2i

i=0

k-1

p = a x

p = a x = a xi 2i =

= x0a20 + x1a21 + x2a22 + … + xk-1a2k-1

i=0

k-1

Page 6: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Shift/Add AlgorithmRight-shift version

Page 7: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Shift/Add AlgorithmsRight-shift algorithm

p = a x = x0a20 + x1a21 + x2a22 + … + xk-1a2k-1

= (...((0 + x0a2k)/2 + x1a2k)/2 + ... + xk-1a2k)/2 =

k times

=

p(0) = 0

p = p(k)

p(j+1) = (p(j) + xj a 2k) / 2 j=0..k-1

Page 8: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Sequential shift-and-add multiplier forright-shift algorithm

Page 9: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Right-shiftmultiplication

algorithm: Example

Page 10: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Area optimization for the sequential shift-and-add multiplier with the right-shift algorithm

Page 11: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Shift/Add AlgorithmsRight-shift algorithm: multiply-add

= (...((y2k + x0a2k)/2 + x1a2k)/2 + ... + xk-1a2k)/2 =

k times

p(0) = y2k

p = p(k)

p(j+1) = (p(j) + xj a 2k) / 2 j=0..k-1

= y + x0a20 + x1a21 + x2a22 + … + xk-1a2k-1 = y + a x

Page 12: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Signed Multiplication

• Previous sequential multipliers are for unsigned multiplication• For signed multiplication:

– assume sign-extended operation for p(j) + xja– if 2's complement multiplier is POSITIVE

right-shift sequential algorithms (shift-add) will work directly– if 2's complement multiplier is NEGATIVE than we must use

"negative weight” for xk-1 and subtract xk-1a in the last cycle• Slight increase in area due to control and one-bit sign extension on

inputs of adder– Unsigned: k bit number + k bit number k+1 bit number– Signed: k+1 bit sign extended number + k+1 bit sign extended

number k+1 bit number

Page 13: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Sequential multiplication

of 2’s-complementnumbers

with right shifts(positive multiplier)

Page 14: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Sequential multiplication

of 2’s-complementnumbers

with right shifts(negative multiplier)

Page 15: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Shift/Add AlgorithmLeft-shift version

Page 16: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Shift/Add AlgorithmsLeft-shift algorithm

p = a x = x0a20 + x1a21 + x2a22 + … + xk-1a2k-1

= (...((02 + xk-1a)2 + xk-2a)2 + ... + x1a)2 + x0a=

k times

=

p(0) = 0

p = p(k)

p(j+1) = (p(j) 2 + xk-1-ja) j=0..k-1

Page 17: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Sequential shift-and-add multiplier forleft-shift algorithm

Left shifts are not as efficient fortwo's complement because mustsign extend multiplicand by k bits

Page 18: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Left-shiftmultiplication

algorithm: Example

Page 19: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

p(0) = y2-k

p = p(k)

p(j+1) = (p(j) 2 + xk-(j+1)a) j=0..k-1

Shift/Add AlgorithmsLeft-shift algorithm: multiply-add

= (...((y2-k 2 + xk-1a)2 + xk-2a)2 + ... + x1a)2 + x0a =

k times

= y + xk-1a2k-1 + xk-2a2k-2 + … + x1a21 + x0a = y + a x

Page 20: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Shift/Add AlgorithmRight-shift version

with Carry-Save Adder

Page 21: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Sequential shift-and-add multiplierwith a carry save adder

Page 22: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

High-Radix Sequential Multipliers

Page 23: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

High-Radix Notation

a Multiplicand (an-1an-2 . . . a1 a0)r

x Multiplier (xn-1xn-2 . . . x1 x0)r

p Product (a x) (p2n-1p2n-2 . . . p2 p1 p0)r

Page 24: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Radix-4, or two-bit-at-a-time, multiplication in dot notation

Page 25: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Basic Multiplication Equations

x = xi ri

i=0

n-1

p = a x

p = a x = a xi ri =

= x0ar0 + x1a r1 + x2a r2 + … + xn-1a rn-1

i=0

n-1

Page 26: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

High-Radix Shift/Add AlgorithmsRight-shift high-radix algorithm

p = a x = x0ar0 + x1ar1 + x2ar2 + … + xn-1arn-1

= (...((0 + x0arn)/r + x1arn)/r + ... + xn-1arn)/r =

n times

=

p(0) = 0

p = p(n)

p(j+1) = (p(j) + xj a rn) / r j=0..n-1

Page 27: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

High-Radix Shift/Add AlgorithmsLeft-shift high-radix algorithm

p = a x = x0ar0 + x1ar1 + x2ar2 + … + xn-1arn-1

= (...((0r + xn-1a)r + xn-2a)r + ... + x1a)r + x0a=

n times

=

p(0) = 0

p = p(n)

p(j+1) = (p(j) r + xn-1-ja) j=0..n-1

Page 28: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

The multiple generation part of a radix-4multiplier with precomputation of 3a

Page 29: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Example of radix-4 multiplicationusing the 3a multiple

Page 30: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

The multiple generation part of a radix-4multiplier based on replacing 3a with 4a (carry into next higher radix-4 multiplier

digit) and -a

Page 31: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Higher Radix Multiplication

• In radix-8, one must precompute 3a, 5a, 7a – Overhead becomes prohibitive and does not

help

• However, when we discuss CSA this may be useful

Page 32: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Radix-2 Booth Recoding

ijj+1

Page 33: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Radix-2 Booth Recoding

yi = -xi + xi-1

Page 34: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Sequential multiplication of

2’s-complementnumbers with

right shifts using Booth’s recoding

Page 35: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Notation

Y Multiplicand ym-1ym-2 . . . y1 y0

X Multiplier xm-1xm-2 . . . x1 x0

P Product (Y X ) p2m-1p2m-2 . . . p2 p1 p0

If multiplicand and multiplier are of different sizes, usually multiplier has the smaller size

Page 36: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Radix-2 BoothMultiplierBasic Step

Page 37: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Radix-2 BoothMultiplierBasic Step

in Xilinx FPGAs

Page 38: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Radix-2 Booth Multiplierin Xilinx FPGAs

Page 39: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Radix-4 Booth Recoding

(1) -1 0 1 0 0 -1 1 0 -1 1 -1 1 0 0 -1 0

Page 40: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

zi/2 = -2xi+1 + xi + xi-1

Page 41: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Example radix-4 multiplication with modifiedBooth’s recoding of the 2’s-complement

multiplier

Page 42: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

The multiple generation part of a radix-4multiplier based on Booth’s recoding

Page 43: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Notation

Y Multiplicand ym-1ym-2 . . . y1 y0

X Multiplier xm-1xm-2 . . . x1 x0

P Product (Y X ) p2m-1p2m-2 . . . p2 p1 p0

If multiplicand and multiplier are of different sizes, usually multiplier has the smaller size

Page 44: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Radix-4 BoothMultiplierBasic Step

Page 45: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Radix-4 Booth Multiplier:Left Shifter & Control

Page 46: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

High-Radix Multiplierswith Carry-Save Adder

Page 47: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Radix-4 multiplication with a carry-save adderused to combine the

cumulative partial product, xia, and 2xi+1a into two numbers

Page 48: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Radix-4 multiplier with a carry-save adder and Booth’s recoding

Page 49: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Booth recoding and multiple selection logic for high-radix multiplication

Page 50: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Radix-4 multiplier with two carry-save adders

Page 51: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Radix-16 multiplier with carry-save adders

Page 52: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Bit-Serial Multipliers

Page 53: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Bit Serial MultipliersAdvantages

• small area

• reduced pin count

• reduced wire length

• high clock rate

Page 54: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Systolic Array

• Systolic array: synchronous arrays of processing elements that are interconnected by only short, local wires thus allowing very high clock rates

Page 55: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Semisystolic Bit-Serial Multiplier (1)

Page 56: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Semisystolic Bit-Serial Multiplier (2)

a3x0 a2x0 a1x0 a0x0

a3x1 a2x1 a1x1 a0x1

a3x2 a2x2 a1x2 a0x2

a3x3 a2x3 a1x3 a0x3

a3 0 a2 0 a1 0 a0 0

a3 0 a2 0 a1 0 a0 0

a3 0 a2 0 a1 0 a0 0

a3 0 a2 0 a1 0 a0 0

p0

p1

p2

p3

p4

p5

p6

p7

Page 57: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Retiming

d

kk

k+n k+n+d

d kk+d

k+d+n k+d+n

Page 58: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Retimed Semisystolic Bit-Serial Multiplier (1)

Page 59: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Retimed Semisystolic Bit-Serial Multiplier (2)

a3 0 a2 0 a1 0 a0x0

a3 0 a2 0 a1x0 a0x1

a3 0 a2x0 a1x1 a0x2

a3x0 a2x1 a1x2 a0x3

a3 x1 a2x2 a1x3 a0 0

a3 x2 a2x3 a1 0 a0 0

a3x3 a2 0 a1 0 a0 0

a3 0 a2 0 a1 0 a0 0

p0

p1

p2

p3

p4

p5

p6

p7

Page 60: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Systolic Bit-Serial Multiplier

Page 61: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Modular Multipliers

Page 62: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Modular MultiplicationSpecial Cases

a

x

pH pL

a x = p = pH 2k + pL

k bits

a x mod 2k = pL

a x mod 2k-1 = pL + pH + carry

p

a

x

a x mod 2k+1 = pL - pH - borrow

Page 63: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Modular MultiplicationSpecial Case (1)

a x mod 2k-1 = (pH 2k + pL) mod (2k-1) = = (pH (2k mod (2k-1)) + pL) mod (2k-1) = = pH + pL mod (2k-1) =

=pH + pL if pH + pL < 2k - 1

pH + pL - (2k-1) if pH + pL 2k - 1

= pL + pH + carry

carry = carry from addition pL + pH

Page 64: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Modular MultiplicationSpecial Case (2)

a x mod 2k+1 = (pH 2k + pL) mod (2k+1) = = (pH (2k+1-1) + pL) mod (2k+1) = = pL - pH mod (2k+1) =

=pL - pH if pL - pH 0

pL - pH + (2k+1) if pL - pH < 0

= pL - pH + borrow

borrow = borrow from subtraction pL + pH

Page 65: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

Modulo (2b-1) Carry Save Adder

Page 66: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

4 x 4 Modulo 15 Multiplier

Page 67: Sequential Multipliers Lecture 9. Required Reading Chapter 9, Basic Multiplication Scheme Chapter 10, High-Radix Multipliers Chapter 12.3, Bit-Serial

4 x 4 Modulo 13 Multiplier