Vous êtes sur la page 1sur 16

RUNNING ADDITION

ON
PARTIAL-PRODUCTS
(MULTIPLICATION)
Partial-Products Multiplication

Partial-products multiplication involves:

• Using the distributive property;


• Thinking about expanded notation;
• Using extended facts to calculate partial products; and
• Adding partial products to find the final answer.
 Several important observations:
1. Multiplication involves the generation of partial
products:
• One for each digit in the multiplier;
• These partial products are then summed to produce the
final product.
2. The partial products are easily defined.
• When the multiplier bit is 0,the partial product is 0;
• When the multiplier is 1, the partial product is the
multiplicand;
3. Total product is produced by summing the partial
products:
• each successive partial product is shifted one position to
the left relative.
4. Multiplication of two n-bit binary integers
produces up to 2n bits;

 We can perform a running addition on the partial


products:
• Rather than waiting until the end;
• Eliminates the need for storage of all the partial
products;
• Fewer registers are needed
 We can save some time on the generation of partial
products:
• For each 1 on the multiplier, an add and a shift
operation are required
• For each 0, only a shift is required.
Multiplication Example ‫المضروب‬

‫المضا ِعف‬
Running addition.
1  add & shift
0  shift only

‫الناتج‬

• Complex.
• Work out a partial product for each digit.
• Shift the partial product appropriately.
• Add partial products.
• Need double-length result.
Execution of Example

Product (143)
BOOTH’s ALGORITHM
 This is a kind of algorithm which uses a more
straightforward approach. This algorithm also has the
benefit of the speeding up the multiplication process
and it is very efficient too. Binary multiplication which
has signed number uses this type of algorithms named
as Booth's algorithm.
 Booth’s algorithm for two complements multiplication:
1. Multiplier and multiplicand are placed in the Q and M register
respectively.
2. Result for this will be stored in the AC and Q registers.
3. Initially, AC and Q-1 register will be 0.
4. Multiplication of a number is done in a cycle.
5. A 1-bit register Q-1 is placed right of the least significant bit Q0 of
the register Q.
6. In each of the cycle, Q0 and Q-1 bits will be checked.
 If Q0 and Q-1 are 11 or 00 then the bits of AC, Q and Q-1 are
shifted to the right by 1 bit.
 If the value is shown 01 then multiplicand is added to AC. After
addition, AC, Q0, Q-1 register are shifted to the right by 1 bit.
7. If the value is shown 10 then multiplicand is subtracted from AC.
After subtraction AC, Q0, Q-1 register is shifted to the right by 1 bit.
 Basically, Booth’s algorithm uses the concept of an arithmetic right
shift in which the leftmost bit is not only shifted right by 1 bit but it
also remains in the original position.

Example 1: Let us multiply (-6) and (2) using Booth’s algorithm.


Solution: (6)10 = (0110)2
As it is given multiplicand, M= (-6)10 =2 complement of 0110 = 1010
Multiplier, Q= (2)10 = 0010

Product by Booth’s algorithm= 1111 0100


 The Booth's algorithm serves two purpose:
1. Fast multiplication (when there are consecutive 0's or
1's in the multiplier).
Example 1:
 If there is a sequence of 0's in the multiplier, the

multiplication is easy as all 0's can be skipped.


Example 2:
 However, it does not help if there is a sequence of 1's in
the multiplier. We have to go through each one of them:
2. Signed Multiplication
 The following example shows signed 2's complement

representation can be used to represent negative


operands as well as positive ones in multiplication.
 Example 1:

Use n=6 bits to represent the product. We first represent both


operands in signed 2's complement, and then carry out the
normal multiplication:
Machine Algorithm for Long Division
 More complex than multiplication.
 Based on long division.

‫الحاصل‬

‫القاسم‬ ‫المقسوم‬

‫الباقي‬
Signed Long Division
1. Load divisor into M and the dividend into A, Q
registers. Dividend must be 2n-bit twos
complement number
 0111 (7) becomes 00000111
 1001 (-7) becomes 11111001

2. Shift A, Q left 1 bit position


3. If M and A have the same signs, AA –M
else AA+M
4. Step 3 is successful if sign of A is the same as before step 3
and at the end of step 3
A. if successful or (A=0 AND Q=0) then set Q01
B. if unsuccessful and (A  0 OR Q0) then restore the previous value
of A
5. Repeat steps 2 through 4 as many times as there are bit
positions in Q.
6. The reminder is in A. If the signs are of Divisor and dividend
were the same, the quotient is in Q, otherwise the correct
quotient is the twos complement of Q.
Examples of Long Division (signed)
A Q M=0011 A Q M=0011
0000 0111 Initial Value 1111 1001 Initial Value
0000 1110 shift 1111 0010 shift
1101 subtract 0010 Add
0000 1110 restore 1111 0010 Restore
0001 1100 shift 1110 0100 Shift
1110 subtract 0001 Add
0001 1100 restore 1110 0100 Restore
0011 1000 shift 1100 1000 Shift
0000 subtract 1111 Add
0000 1001 set Q0 = 1 1111 1001 Q0 =1
0001 0010 Shift 1111 0010 Shift
1110 subtract 0010 Add
0001 0010 restore 1111 0010 Restore

(a) 7/3 (b) -7/3

Vous aimerez peut-être aussi