0% found this document useful (0 votes)
99 views

Arithmetic Algorithms

This document discusses various arithmetic algorithms used in digital logic and computer architecture. It covers Booth's multiplication algorithm, restoring division algorithm, and non-restoring division algorithm. It provides examples and flowcharts to illustrate how each algorithm works. It also discusses the hardware implementation and components required for multiplication and division operations.

Uploaded by

joel roy
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views

Arithmetic Algorithms

This document discusses various arithmetic algorithms used in digital logic and computer architecture. It covers Booth's multiplication algorithm, restoring division algorithm, and non-restoring division algorithm. It provides examples and flowcharts to illustrate how each algorithm works. It also discusses the hardware implementation and components required for multiplication and division operations.

Uploaded by

joel roy
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 27

Digital Logic & Computer Architecture

Data Representation and


Arithmetic Algorithms

Arithmetic Algorithms
Sejal Chopra
Assistant Professor - Dept. of Computer Engineering
Don Bosco Institute of Technology, Mumbai
Topics to be discussed

● Booth’s Multiplication Algorithm

● Restoring Division Algorithm

● Non-restoring Division Algorithm


Multiplication Example
Flowchart for Booth’s Algorithm
Example on Booth’s Algorithm (FLOW TABLE METHOD)
Logic Behind Booth’s Algorithm
Logic Behind
Conclusions to implement the hardware:
Booth’s Algorithm
• Size of the result is 2-n bits
• Consider a pair of multiplier bits:
✔ If a combination of 0-0 or 1-1 :add zeros which implies shift right by
one position .
✔ If a combination of 0-1:Add M and shift right
✔ If a combination of 1-0:Sub M (same as adding 2’s C of M) and shift
right
• Require a strobe input to allow either add/sub or add just zeros(just shifting to be done)
• To achieve 2’s C :an ex-or gate
• Finally have to maintain the sign bit(restore MSB bit):known as arithmetic shift.
• A Counter to count the number of operations.
• A 1-bit register to store the implied zero of the multiplier.
Question: What is the difference between Logical shift and arithmetic shift?
Hardware Implementation of Booth’s Algorithm
Class Exercise

Compute the result of (+15)*(-15).

Show the multiplication process using Booth’s Algorithm when the following
binary numbers are multiplied (-13)*(-6).
Booth’s Advantage
Serial multiplication Booth algorithm

00010100 20
×00011110 30 00010100 20
00000000 ×000111100 30
00010100
111111111101100
00010100
00010100
00010100
00000000 00000010100
00000000
0000001001011000 600
00000000
000001001011000 600
Two partial product additions
Four partial product additions
Booth’s Disadvantage
• Algorithm works out to be inefficient with isolated 1’s
• Ex:00101010101(0) recoded as 0+1-1+1-1+1-
1+1-1 which requires 8 instead of 5 operations
• Remedy 1:Examine 3 bits of Q at a time rather than 2
• Remedy 2:Use Bit Pair recording technique which
combines two adjacent operations of Booth’s
algorithm.
Integer Division
• Division is a more tedious process than multiplication.
• Negative numbers are really bad!
• Based on long division
• For the unsigned case, there are two standard approaches:
1) Restoring division
2) Non restoring division
Understanding Division operation
Strategy for unsigned division using restoring algorithm

Shift the dividend one bit at a time starting from MSB into a
register.
Subtract the divisor from this register.
✔ If the result is negative (“didn’t go”):
- Add the divisor back into the register.
- Record 0 into the result register.
✔ If the result is positive:
- Do not restore the intermediate result.
- Set a 1 into the result register.
Flowchart for restoring division method
Example on Restoring algorithm
Example on Restoring algorithm
Think over it…….

As a designer of the processor which does this kind of unsigned


division ,mention what hardware components do you require ?
Hardware for unsigned division
Algorithm for restoring division
Set Register A to 0.
Load dividend in Q.
Load divisor into M
Repeat n times:
- Shift A and Q left one bit.
-Subtract M from A.
-Place the result in A.
-If sign of A is 1, set q0 to 0 and add M back to A.
Else set q0 to 1.

End of the process:


- Quotient will be in Q.
- Remainder will be in A.
Algorithm for non-restoring division
• Restoring division can be improved using non-restoring algorithm
The effect of restoring algorithm actually is:
If A is positive, we shift it left and subtract M, that is compute 2A-M If A is negative, we
restore it (A+M), shift it left, and subtract M, that is, 2(A+M) – M = 2A+M.
Set q0 to 1 or 0 appropriately.
Non-restoring algorithm is:
Set A to 0.
Repeat n times:
If the sign of A is positive:
Shift A and Q left and subtract M . Check sign of A again : if negative set q o =0 else 1
Else if the sign of A is negative:
Shift A and Q left and add M. Check sign of A again : if negative set qo=0 else 1
If the sign of A is 1, add A to M.
Flowchart for non-restoring division method
Example on non-restoring algorithm
Example on non-restoring algorithm
Difference between the two methods
Sr.No Restoring Algorithm Non-restoring Algorithm
1 Needs restoring of reg A if the result of Does not need restoring
subtraction is negative
2 In each cycle ,A is shifted left and In each cycle ,A is shifted left first and then divisor
then divisor is subtracted from it. is either added or subtracted depending on the
sign of A
3 Does not need restoring of Needs restoring of remainder if remainder
remainder is negative
4 Slower algorithm Faster algorithm
You have completed this topic, you should be able to:

Perform signed multiplication using Booth’s Algorithm.

Perform unsigned division using Restoring and non-restoring


algorithm
References Used

• William Stallings, “Computer Organization and Architecture:


Designing for Performance”, tenth Edition, Pearson.
• B.Govindarajalu,”Computer Architecture and Organisation:
Design Principles and applications”, Second Edition,McGraw-
Hill
• P .Chakraborty, “Computer Organization and
Architecture”,Jacob Publication.
• Dr. M. Usha, T. S. Srikanth, “Computer System Architecture and
Organization”,First Edition, Wiley-India.

You might also like