Nothing Special   »   [go: up one dir, main page]

0% found this document useful (0 votes)
379 views24 pages

Unit-3 PPT Co

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1/ 24

Computer Arithmetic

Arithmetic Processor
• Arithmetic instruction in digital computers manipulate data to produce
results necessary for the solution of the computational problems.
• An arithmetic processor is the part of a processor unit that execute
arithmetic instruction
• An arithmetic instruction may specify binary or decimal data, and it may be
represented in, Fixed point (integer or fraction) OR floating point form.
• An arithmetic processor is simple for binary fixed point add instruction
• It would be more complicated if it includes all arithmetic operations for
binary and decimal data in both representations.
• How to perform basic arithmetic operation with signed magnitude require
valuable knowledge for its hardware implementation.
• The designer must be thoroughly familiar with sequence of steps in order to
carry out the operation and achieve a correct result.
• Algorithm:
– The solution to any problem that is stated by a finite
number of well defined procedural step is called
algorithm.
• Flowchart:
– The convenient method for presenting algorithm is a
flowchart.
– The computational steps are specified in rectangular boxes
– Decision steps indicated inside diamond-shaped boxes
from which two or more alternate path emerge
Addition and Subtraction
• Data types considered for the arithmetic operations are,
– Fixed-point binary data in signed magnitude representation
– Fixed-point binary data in signed-2’s compliment representation
– Floating point binary data
– Binary –coded decimal (BCD) data
• Negative fixed point binary number can be represented in three ways,
– Signed magnitude (most computers use for floating point operations )
– Signed 1’s compliment
– Signed 2’s compliment(most computer use for integers)
Addition and Subtraction with Signed-
Magnitude Data
• Eight different conditions to consider for addition and
subtraction

Fig : (Addition and subtraction for signed magnitude numbers )


•Addition(Subtraction) algorithm:

– When the signs of A and B are identical(different), add the


two magnitudes and attach the sign of A to the result.
– When the sign of A and B are different(identical), compare
the magnitudes and subtract the smaller number from the
larger.
– Choose the sign of the result to be same as A if A > B or
the compliment of the sign of A if A < B.
– For equal magnitude subtract B from A and make the sign
of the result
Hardware Implementation

• A and B be two registers that hold the magnitudes of No


• As and Bs be two flip-flops that hold the corresponding signs
• The Result is transferred into A and As.
Cont..
• Parallel adder is needed to perform the micro operation A + B.
• Parallel subtractor are needed to perform A – B or B – A.
– Can be accomplished by means of compliment and add
• Comparator circuit is needed to establish if A > B, A = B or A < B
– Comparison can be determine from the end carry after the subtraction
• The sign relationship can be determine from an exclusive-OR gate
with As and Bs as inputs
• Output carry are transferred to E flip-flop
– Where it can be checked to determine the relative magnitude of the Nos.
• Add overflow flip-flop (AVF) holds the overflow bit when A and B are
added.
Hardware Algorithm
Multiplication Algorithm
• Multiplication of two fixed point binary numbers in signed magnitude representation
is done by the process of successive shift and add operations.
• Numerical Example:

• The process consist of looking at successive bits of the multiplier, least significant bit
first.
• If the multiplier bit is 1, multiplicand is copied down otherwise zeros are copied down
• Copied number in successive line shifted one position to the left from the previous
number. Finally, the numbers are added and their sum forms the product.
Hardware Implementation
• Multiplication process is change slightly.
• First, instead of providing registers to store and add simultaneously
as many binary numbers as there are bits in multiplier,
– It is convenient to provide an adder for the summation of two number
– And successively accumulate the partial products in a register
• Second, instead of shifting the multiplicand to the left, the partial
product is shifted right
– Which result in leaving the partial product and the multiplicand in the
required relative position
• Third, when the corresponding bit of the multiplier is 0, there is no
need to add all zeros to the partial product since it will not alter its
value
Cont..
• The hardware for multiplication consist of the equipment
shown in figure.
• The multiplier stored in Q register and its sign in Qs.
• The sequence counter SC is initially set to a number equal to
the number of bits in the multiplier.
– The counter is decremented by 1 after forming each partial product.
Fig: (Hardware for multiply operation)
Cont..
• Initially the multiplicand is in register B and the multiplier in Q.
• The sum of A and B forms a partial product which is transferred
to the EA register.
– Both the partial product and multiplier are shifted to the right.(shr EAQ)
– Least significant bit of A is shifted into the most significant position of Q,
– The bit from E is shifted into the most significant position of A and 0 to E.
• After the shift, one bit of partial product is shifted into Q,
pushing the multiplier bit one position to the right.
• In this manner, the rightmost flip-flop in register Q, designated
by Qn, will hold the bit of the multiplier, which must be
inspected next.
Hardware Algorithm

• jl
Fig: Numerical Example for binary multiplier
Booth’s Multiplication Algorithm
Used for multiplication in Signed 2’s complement representation

It operates on the fact that strings of 0’s in the multiplier require no
addition but just shifting

And a string of 1’s in the multiplier from bit weight 2k to 2m can be


treated as 2k+1 – 2m

E.g. +14 (001110 ) here k=3, m=1 represented as 24-21 = 16-2 = 14

Thus M x 14= M x 24 – M x 21
Used for multiplication in Signed 2’s complement representation

Prior to shifting the multiplicand can be added to the partial product ,


subtracted from the partial product or left unchanged according to the
following rules :

1. The multiplicand is subtracted from partial product upon encountering


the first least significant 1 in the string of 1’s in the multiplier

2. The multiplicand is added to the partial product upon encountering the


first 0 (provided that there was a previous 1) in the string of 0’s in the
multiplier.

3. The partial product does not change when the multiplier bit is identical
to the previous multiplier bit
Booth’s Multiplication Algorithm
Example - Booth’s Multiplication Algorithm
Binary Division
For Division in hardware, process is slightly changed

1.Instead of shifting divisor to right, dividend or partial remainder is shifted left

2.Subtraction achieved by adding A to 2’s complement of B

3. Information about Relative magnitude is available from the end carry

Hardware components identical to that of multiplication


Flow Chart - Division
Example - Division

You might also like