Upload
lamanh
View
218
Download
0
Embed Size (px)
Citation preview
MULTIPLIERS
B. Baas 188
Multipliers
• Multiplies are widely used in digital signal processing, generally more so than in general-purpose workloads
• Major categories of multiplier types– Signed 2’s complement × Signed 2’s complement
Very useful for fixed-point 2’s complement data
– Unsigned × UnsignedVery useful for sign-magnitude data
• Hardware is typically built in a manner broadly similar to how you would do it with paper and pencil
• The naming convention is somewhat unfortunate:
multiplicand
multiplierx
a3 a2 a1 a0
× b3 b2 b1 b0
s s s p30 p20 p10 p00 b0
s s p31 p21 p11 p01 0 b1
s p32 p22 p12 p02 0 0 b2
p33 p23 p13 p03 0 0 0 b3
B. Baas 189
Multipliers
• Example: 4-bit signed 2’s complement multiplicand “a” times 4-bit multiplier “b”
• b could be signed or unsigned
• s = partial product sign extension bits
• pxy = ax × by
= ax AND by
B. Baas 190
3 Main Steps in Every Multiplier
1) Generation of partial products
2) Reduction or “compression” of the partial product array (normally using carry-save addition) so that the product is composed of two words
– Linear array addition
– Tree addition (Wallace tree)
3) Final adder: Carry-propagate adder (CPA)
– Converts the product in carry-save form into a single word form
– Any style of CPA is fine though we probably favor faster ones
multiplicand
multiplierx
product
Carry-Propagate Adder
Carry-Save
Adders
Partial-
Product
Array
multiplier
multiplicand
B. Baas 191
Straight-forward Partial Product Generation
Yi Partial product
0 0
1 +x (= multiplicand)
• This is the simplest method to generate partial products
• Hardware looks at one bit of the multiplier (Yi) at a time
• Partial products are copies of the multiplicand AND’d by bits of the multiplier
• Number of bits in the multiplier= Number of partial products= Number of terms/words/rows that
must be added
multiplicand
multiplierx
Carry-Propagate Adder
Carry-Save
Adders
Partial-
Product
Array
multiplier
multiplicand
B. Baas 192
Straight-forward Partial Product Generation
Yi Partial product
0 0
1 +x (= multiplicand)
• There are only two possible partial products whose hardware could be built using:
– a row of 2:1 muxes
– a row of AND gates (this should be more efficient)
multiplicand
00
+x
BOOTH ENCODING OF THE “MULTIPLIER” INPUT
B. Baas 194
Booth Encoding
• Method to reduce the number of partial products
• Named after Andrew Booth (1918-2009) who published the algorithm in 1951 while at Birkbeck College, London
• Booth-n
– Examines n+1 bits of the multiplier
– Encodes n bits
– n × reduction in the number of partial products
• But partial products must then be more complex than simply 0 or +multiplicand
Partial-
Product
Array
multiplier
Partial Product
Array
multiplier
B. Baas 195
Booth Encoding:Booth-2 or “Modified Booth”
Yi+1 Yi Yi-1 Partial product Comment
0 0 0 0 no string of 1’s
0 0 1 +x end of string of 1’s
0 1 0 +x a string of 1’s
0 1 1 +2x end of string of 1’s
1 0 0 –2x beginning of string of 1’s
1 0 1 – x –2x + x
1 1 0 – x beginning of string of 1’s
1 1 1 0 center of string of 1’s
[Waser and Flynn]
• Examine multiplier bits Yi+1, Yi, and Yi-1
• Can view multiplier as being built of strings of 1’s– Examine multiplier bits Yi+1, Yi, and Yi-1
– Perspective of moving left towards MSB
• There are 𝑁+2
2= 𝑁
2+ 1 partial products in the worst case
B. Baas 196
Booth Encoding:Booth-2 or “Modified Booth”
Yi+1 Yi Yi-1 Partial product Comment
0 0 0 0 no string of 1’s
0 0 1 +x end of string of 1’s
0 1 0 +x a string of 1’s
0 1 1 +2x end of string of 1’s
1 0 0 –2x beginning of string of 1’s
1 0 1 – x –2x + x
1 1 0 – x beginning of string of 1’s
1 1 1 0 center of string of 1’s
[Waser and Flynn]
• There are five possible partial products compared to two with non-Booth encoding
+2x
+x
0
–x
–2x
B. Baas 197
Booth Encoding:Booth-2 or “Modified Booth”
• Fortunately, these five possible partial products are very easy to generate
• Correctly generating the –x and –2x PPs requires a little care
– The key issue is to not separate 1) negation and 2) adding “1” LSB during the inversion process
multiplicand 0
s
0
multiplicand
0
~multiplicand 1
~s
1
~multiplicand
1
0 0
0
–2x
–x
0
+2x
+x
B. Baas 198
Booth Encoding:Booth-2 or “Modified Booth”
• Example: multiplier = 0010 = 2– Add 0 to right of LSB since first group has no group with
which to overlap
– Examine 3 bits at a time
– Encode 2 bits at a time
Overlap one bit between partial products
– 2x
+x 0 0 1 0 0
–2x
+x
s
0
s
0
4 × (+x) –2x
= +2x
B. Baas 199
Booth Encoding:Booth-2 or “Modified Booth”
• Example: multiplier = 1001 = –7– Add 0 to right of LSB since first group has no group with
which to overlap
– Examine 3 bits at a time
– Encode 2 bits at a time
Overlap one bit between partial products
+x
–2x 1 0 0 1 0
+x
–2x
s
0
s
0
4 × (–2x) +x
= –7x
B. Baas 200
Booth Encoding:Booth-2 or “Modified Booth”
• Example: multiplier = 01111111 = +127– Nice example of encoding a long string of 1’s
– Examine 3 bits at a time
– Encode 2 bits at a time
0
+2x
0 1 1 1 1 1 1 1 0
+2x
–x
s
0
s
0
64 × (+2x) + 16 × (0) + 4 × (0) – x
= +127x
0
0
0s s
–xs ss s
s s
s s
00
00
00
00
00
B. Baas 201
Booth Encoding:Booth-2 or “Modified Booth”
• End of a string of 1’s
• Beginning of a string of 1’s
0 1 1 1 1 1 1 1
+2x
0
0
0 0 1 1 1 1 1 1
+x
0
0
......
1 1 1 1 1 0 0
–2x
0
0
...1 1 1 1 1 1 0
–x
0
0
...
B. Baas 202
Booth Encoding: Booth-3
Yi+2 Yi+1 Yi Yi-1 Partial product
0 0 0 0 0
0 0 0 1 +x
0 0 1 0 +x
0 0 1 1 +2x
0 1 0 0 +2x
0 1 0 1 +3x
0 1 1 0 +3x
0 1 1 1 +4x
1 0 0 0 –4x
1 0 0 1 –3x
1 0 1 0 –3x
1 0 1 1 –2x
1 1 0 0 –2x
1 1 0 1 –x
1 1 1 0 –x
1 1 1 1 0 [Waser and Flynn]