Unit - 3 of Computer Architecture
Unit - 3 of Computer Architecture
Arithmetic
BY ASST. PROF. SHWETA MAURYA
Topics To be Covered
Introduction
Addition and Subtraction
Multiplication Algorithms
Division Algorithms
Floating-point Arithmetic operations
Decimal Arithmetic Unit
Decimal Arithmetic operations
Arithmetic Operation
Arithmetic instructions in digital computers manipulate data to produce results
necessary for the solutions of computational problems.
4 basic arithmetic operations:
-Addition
-Subtraction
- Multiplication
- Division
Addition,subtraction,multiplication,and division for the following types of data:
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
Addition and subtraction
Algorithm:
>When the signs of A and B are identical , add the two
magnitude
and attach the sign of A to the result.
>When the sign of A and B are different ,compare the
magnitudes.
and attached the sign of maximum one.
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 magnitude of the numbers.
As and Bs be two flip flops that hold the corresponding signs.
The results of the operation may be transferred into A and As .
Hardware implementation –
Cont..
Hardware Algorithm-
Flowchart
Hardware Algorithm-
Flowchart
Addition and Subtraction with
signed2’s complement data
The left most bit of binary number represents the sign bit;
::0 for positive
:: 1 for negative.
If the sign bit is 1, the entire the entire number is represented in 2’s
compliment form.
The addition of two numbers in signed-2’s complement form consists of
adding the number with the sign bits treated the same as the other bits of the
number .A carry out of the sign bit position is discarded .
The subtraction consists of first taking the 2’s compliment of the subtrahend
and then adding it to the minuend.
When two numbers of n digits each are added and the sum occupies n+1
Digits, we say that an overflow occurred.
When the two carries are applied to an exclusive-OR gate, the overflow is
detected when the output of the gate is equal to 1.
Hardware Implementation
Hardware Algorithm- Flowchart
Multiplication Algoerithm
Hardware Implementation for Signed
Magnitude Data
Adder for the summation of only two binary numbers and successively
accumulate the partial products in a register.
Instead of shifting the multiplicand to the left , the partial product is shifted to
the right
The hardware for multiplication consists of the equipment shown in fig. plus
two are more registers.
These registers are together with registers A and B..
The multiplier stored in the 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.
The sum of A and B forms a partial product which is transferred to the EA
register.
The shift will be denoted by the statement “ shr EAQ “to designate the
right shift depicted . The least significant bit of A is shifted into the most
significant position of Q.
Hardware Implementation
After the initialization , the low order bit of the multiplier is in Qn is tested .
- if it is 1, :::: >the multiplicand In B is added to the present partial product in
A.
- If it is 0, nothing is done .
Register EAQ shifted once to the right to form the new partial product.
The process stops when SC=0.
Note that the partial product formed in A is shifted into Q one bit at a time
and eventually replaces multiplier.
The final product is available in both A and Q,with A holding the most
significant bits and Q holding the least significant bits.
Division Algorithm
The sign of the remainder is the same as the sign of the dividend .
Divide overflow
This occurs as operation is implemented as Hardware .
Register length is finite and can not hold a number which exceed the length of register.
A divide-overflow condition occurs when high order half bits of dividend >= divisor.
Over flow condition is usually detected when a special flip-flop is set .
Which will call it a divide overflow flip-flop and label it DVF
Handling ::
Can be handled in variety of ways :
- In some computers it is the responsibility of the programmers to check if DVF is set after each
divide instruction
-The occurrence of a divide overflow stopped the computer and this condition was referred to as a
DIVIDE STOP.
-
- The best way to avoid a divide overflow is to use floating point data
Hardware Allgorithm:
Hardware Allgorithm:
Hardware Algorithm:
Floating Point Arithmetic
Operations
2 parts – Mantissa->signed fixed point number
– exponent->the position of the decimal(binary)
point
– Eg:6132.739 – +06132739->fraction – 4->
exponent – Similar to +0.6132739*10^+4 • General
form M*r^e
– M->mantissa
– r->radix
– E->exponent
For binary fp; –
Similar to fp decimal point, but uses radix 2 –
Eg:+1001.11
– 01001110(mantssa)
– 000100(exponent)
Normalization
Youtube link ::
https://www.youtube.com/watch?v=9O7OJi7RCLQ
Applications in Decimal Number Display.
Systematic running of counters.
Organized digital clocks.