Professional Documents
Culture Documents
FALLSEM2020-21 CSE2001 TH VL2020210104507 Reference Material I 20-Aug-2020 Module 2 Lecture 2
FALLSEM2020-21 CSE2001 TH VL2020210104507 Reference Material I 20-Aug-2020 Module 2 Lecture 2
FALLSEM2020-21 CSE2001 TH VL2020210104507 Reference Material I 20-Aug-2020 Module 2 Lecture 2
Example 2: 11 x 13
Flowchart for Unsigned Binary Multiplication
Another Example: (-13) x (+11)
1 0 0 1 1 (-13)
1 0 1 0 1 x (-11)
1 1 1 1 1 1 0 0 1 1
0 0 0 0 0 0 0 0 0
1 1 1 1 0 0 1 1
0 0 0 0 0 0 0
1 1 0 0 1 1
1 0 1 0 1 1 1 0 1 1 1 1 (- 273)
Signed Multiplication
• For a negative multiplier, a straightforward solution is to form the 2’s-
complement of both the multiplier and the multiplicand and proceed
as in the case of a positive multiplier.
• This is possible because complementation of both operands does not
change the value or the sign of the product.
• A technique that works equally well for both negative and positive
multipliers – Booth algorithm.
Booth Algorithm
Example: 7 x 3
Booth Algorithm for
Twos Complement
Multiplication
Another Example:
1. (+7) x (-3)
2. (-4) x (+2)
Multiplier
V ersion of multiplicand
selected by bit i
Bit i Bit i -1
0 0 0 X M
0 1 + 1 X M
1 0 1 X M
1 1 0 X M
0 0 1 0 1 1 0 0 1 1 1 0 1 0 1 1 0 0 0
0 + 1 - 1 + 1 0 - 1 0 + 1 0 0 - 1 + 1 - 1 + 1 0 - 1 0 0
0 1 1 0 1 (+13) 0 1 1 0 1
0 1 0 1 1 x (+11) +1 -1 +1 0 -1
1 1 1 1 1 1 0 0 1 1
2’s-complement of +13 0 0 0 0 0 0 0 0 0
1 0 0 1 1 0 0 0 0 1 1 0 1
1 1 1 0 0 1 1
0 0 1 1 0 1
1 0 0 0 1 0 0 0 1 1 1 1 (+ 143)
Booth Algorithm
Considering the product (-13)(+11) then use the 2’s-complement of the multiplier
1 0 0 1 1 (-13 ) 1 0 0 1 1
0 1 0 1 1 x (+11) +1 -1 +1 0 -1
0 0 0 0 0 0 1 1 0 1
2’s-complement of -13 0 0 0 10 0 0 101 0 0 0
0 1 1 0 1 1 1 1 1 0 0 1 1
0 0 0 1 1 0 1
1 1 0 0 1 1
1 1 1 0 1 1 1 0 0 0 1 (- 143)
Can you try?
1. (+13) x (-11)
2. (-13) x (-11)
Booth Algorithm
Considering the product (+13)(-11) then use the 2’s-complement of the
multiplier
0 1 1 0 1 (+13 ) 0 1 1 0 1
1 0 1 0 1 x (-11) -1 +1 -1 +1 -1
1 1 1 1 1 1 0 0 1 1
2’s-complement of +13 0 0 0 0 0 1 1 0 1
1 0 0 1 1 1 1 1 1 0 0 1 1
0 0 0 1 1 0 1
1 1 0 0 1 1
1 0 1 1 0 1 1 1 0 0 0 1 (- 143)
Booth Algorithm
Considering the product (-13)(-11) then use the 2’s-complement of the multiplier
1 0 0 1 1 (-13 ) 1 0 0 1 1
1 0 1 0 1 x (-11) -1 +1 -1 +1 -1
0 0 0 0 0 0 1 1 0 1
2’s-complement of -13 1 1 1 1 1 0 0 1 1
0 1 1 0 1 0 0 0 0 1 1 0 1
1 1 1 0 0 1 1
0 0 1 1 0 1
1 0 0 0 1 0 0 0 1 1 1 1 ( 143)
Booth Algorithm
• Best case – a long string of 1’s (skipping over 1s)
• Worst case – 0’s and 1’s are alternating
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
Worst-case
multiplier
+1 - 1 +1 - 1 +1 - 1 +1 - 1 +1 - 1 +1 - 1 +1 - 1 +1 - 1
1 1 0 0 0 1 0 1 1 0 1 1 1 1 0 0
Ordinary
multiplier
0 -1 0 0 +1 - 1 +1 0 - 1 +1 0 0 0 -1 0 0
0 0 0 0 1 1 1 1 1 0 0 0 0 1 1 1
Good
multiplier
0 0 0 +1 0 0 0 0 -1 0 0 0 +1 0 0 -1
Booth Algorithm
• The speed of doing multiplication with the Booth algorithm is the
same as with the normal algorithm
• To speed up the multiplication process in the Booth’s algorithm a
technique called bit – pair recoding is used
• It is also called modified Booth’s algorithm
• Bit-pair recoding halves the maximum number of summands
(versions of the multiplicand).
Bit-Pair Recoding of Multipliers
1 1 1 0 1 0 0
0 0 1 +1 1 0
0 1 2
selected at position i
i + 1 i i 1
0 0 0 0 X M
0 0 1 + 1 X M
0 1 0 + 1 X M
0 1 1 + 2 X M
1 0 0 2 X M
1 0 1 1 X M
1 1 0 1 X M
1 1 1 0 X M
0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 0 0 1 1
0 0 0 0 1 1 0 1
1 1 1 0 0 1 1
0 1 1 0 1 ( + 13 ) 0 0 0 0 0 0
´ 1 1 0 1 0 (- 6 ) 1 1 1 0 1 1 0 0 1 0 ( - 78 )
0 1 1 0 1
0 -1 - 2
1 1 1 1 1 0 0 1 1 0
1 1 1 1 0 0 1 1
0 0 0 0 0 0
1 1 1 0 1 1 0 0 1 0
Manual Division
21 10101
13 274 1101 100010010
26 1101
14 10000
13 1101
1 1110
1101
1
an an-1 a0 qn-1 q0
Dividend Q
A Quotient
Setting
0 mn-1 m0
Divisor M
Flowchart for Unsigned Binary Division
Restoring Division
• Shift A and Q left one binary position
• Subtract M from A, and place the answer back in A
• If the sign of A is 1, set q0 to 0 and add M back to A (restore A);
otherwise, set q0 to 1
• Repeat these steps n times
Examples Initially 0 0 0 0 0
0 0 0 1 1
1 0 0 0
Shift 0 0 0 0 1 0 0 0
Subtract 1 1 1 0 1 First cycle
Set q 1 1 1 1 0
0
Restore 1 1
0 0 0 0 1 0 0 0 0
1 0
Shift 0 0 0 1 0 0 0 0
1 1 1 0 0 0 Subtract 1 1 1 0 1
1 1 Set q 1 1 1 1 1 Second cycle
0
Restore 1 1
1 0 0 0 0 1 0 0 0 0 0
Shift 0 0 1 0 0 0 0 0
Subtract 1 1 1 0 1
Set q0 0 0 0 0 1 Third cycle
Shift 0 0 0 1 0 0 0 0 1
Subtract 1 1 1 0 1 0 0 1
Set q0 1 1 1 1 1
Fourth cycle
Restore 1 1
0 0 0 1 0 0 0 1 0
Remainder Quotient
Non-restoring Division
• Avoid the need for restoring A after an unsuccessful subtraction.
• Step 1: (Repeat n times)
- If the sign of A is 0, shift A and Q left one bit position and subtract
M from A; otherwise, shift A and Q left and add M to A.
- Now, if the sign of A is 0, set q0 to 1; otherwise, set q0 to 0.
Shift 1 1 1 0 0 0 0 0
Add 0 0 0 1 1 Second cycle
Set q 1 1 1 1 1 0 0 0 0
0
Add Shift 1 1 1 1 0 0 0 0
1 1 1 1 1 Add 0 0 0 1 1 Third cycle
Restore
0 0 0 1 1 remainder Set q 0 0 0 0 1 0 0 0 1
0
0 0 0 1 0
Remainder Shift 0 0 0 1 0 0 0 1
Subtract 1 1 1 0 1 Fourth cycle
Set q 1 1 1 1 1 0 0 1 0
0
Quotient
A nonrestoring-division example.