Professional Documents
Culture Documents
U-III Slides COA
U-III Slides COA
U-III Slides COA
Computer Arithmatic
Prof. Atul Barve
Prestige Institute of Engineering, Management & Research,
Indore
● Addition
● Subtraction,
● Two’s Compliment
Representation,
● Signed Addition and Subtraction
Topics ● Multiplication and Division
● Booths Algorithm,
● Division Operation,
● Floating Point Arithmetic
Operation
● Design of Arithmetic unit
1
09-05-2024
INTRODUCTION
● Based on the number system two basic data types are implemented in the
computer system: fixed point numbers and floating point numbers.
● Representing numbers in such data types is commonly known as fixed point
representation and floating point representation, respectively.
● Depending on the design, the hardware can interpret number as an integer
or fraction.
● In integer number radix point is fixed and the number system is referred to
as fixed point number system. We can represent positive or negative integer
numbers.
● Floating point number system allows the representation of numbers having
both integer part and fractional part.
2
09-05-2024
1 1 0 0 0 1 0 0
0 0 1 1 1 0 1 1
3
09-05-2024
So, take 1’s complement of 1101, which will be 0010, then add with given
number. So, 1110+0010=1 0000 , then add this carry bit to the LSB,
0000+1=0001 , which is the answer.
4
09-05-2024
5
09-05-2024
6
09-05-2024
7
09-05-2024
8
09-05-2024
9
09-05-2024
10
09-05-2024
11
09-05-2024
● There are eight different conditions to consider, when the signed numbers
are added or subtracted
Subtract Magnitudes
Operation Add Magnitudes
When A>B When A<B When A=B
(+A)+(+B) +(A+B)
(+A)+(-B) +(A-B) -(B-A) +(A-B)
(-A)+(+B) -(A-B) +(B-A) +(A-B)
(-A)+(-B) -(A+B)
(+A)-(+B) +(A-B) -(B-A) +(A-B)
(+A)-(-B) +(A+B)
(-A)-(+B) -(A+B)
(-A)-(-B) -(A-B) +(B-A) +(A-B)
12
09-05-2024
Hardware Implementation
● To implement the two arithmetic operations with hardware, it is first
necessary that the two numbers be stored in registers.
● Let A and B be two registers that hold the magnitudes of the numbers, and
AS and BS be two flip flops that hold the corresponding signs.
● The result of the operation may be transferred to a third register.
● Algorithm:
● First, a parallel adder is needed to perform the micro operation A + B.
● Second, a comparator circuit is needed to establish if A>B, A=B, or A< B.
● Third, two parallel subtractor circuits are needed to perform the micro
operations A-B and B- A.
Flowchart
13
09-05-2024
14
09-05-2024
15
09-05-2024
16
09-05-2024
17
09-05-2024
18
09-05-2024
19
09-05-2024
1001
Perform Arithmetic Right Shift operations (ashr) 1100 1001 1 3
1 1 Perform Arithmetic Right Shift operations (ashr) 1110 0100 1 2
0 1 Addition (AC + BR) 0111
0101 0100
● Disadvantages:
Complex to understand
Limited applicability
Higher latency
Higher power consumption
20
09-05-2024
21
09-05-2024
DIVISION : FLOWCHART
22
09-05-2024
DIVISION ALGORITHM
The hardware divide algorithm:
● The dividend is in A and Q and the divisor in B.
● The sign of the result is transferred into QS to be part of the quotient.
● A constant is set into the sequence counter SC to specify the number of bits in the
quotient.
● adding As in multiplication, we assume that operands are transferred to registers
from a memory unit that has words of n bits.
● Since an operand must be stored with its sign, one bit of the word will be occupied
by the sign and the magnitude will consist of n-1 bits.
● A divide overflow condition is tested by subtracting the divisor in B from half of the
bits of the dividend stored in A.
● If A > B, the divide overflow flip-flop DVF is set and the operation is terminated
prematurely.
● If A <B, no divide overflow occurs so the value of the dividend is restored by B to A.
DIVISION : Example
23
09-05-2024
24