DL& Co Unit-3
DL& Co Unit-3
Computer Aritnmetic:
Introduction:
The two algorithms are similar except for the sign comparison. The procedure to be followed for
identical signs in the addition algorithm is the same as for different signs in the subtraction
algorithm, and vice versa.
Computer Organization
Hardware Implementation:
To implement the two arithmetic operations with hardware, it is first necessary that the two
numbers be stored in registers.
i.
Let A and B be two registers that hold the magnitudes of the numbers, and A S and BS be
two flip-flops that hold the corresponding signs.
ii.
The result of the operation may be transferred to a third register: however, a saving is
achieved if the result is transferred into A and A S. Thus A and AS together form an
accumulator register.
Consider now the hardware implementation of the algorithms above.
o First, a parallel-adder is needed to perform the microoperation A + B.
o Second, a comparator circuit is needed to establish if A > B, A = B, or A < B.
o Third, two parallel-subtractor circuits are needed to perform the microoperations A - B
and B - A. The sign relationship can be determined from an exclusive-OR gate with AS and
BS as inputs.
The below figure shows a block diagram of the hardware for implementing the addition and
subtraction operations. It consists of registers A and B and sign flip-flops AS and BS.
o Subtraction is done by adding A to the 2' s complement of B. The output carry is
transferred to flip-flop E, where it can be checked to determine the relative magnitudes of
the two numbers.
o The add-overflow flip-flop AVF holds the overflow bit when A and B are added.
Figure (i): Hardware for addition and subtraction with Signed-Magnitude Data
The complementer provides an output of B or the complement of B depending on the state of the
mode control M.
When M = 0, the output of B is transferred to the adder, the input carry is 0, and the
output of the adder is equal to the sum A + B.
When M= 1, the l's complement of B is applied to the adder, the input carry is 1, and output
This is equal to A plus the 2's complement of B, which is
equivalent to the subtraction A - B.
Computer Organization
Hardware Algorithm
Multiplication Algorithms:
Multiplication of two fixed-point binary numbers in signed-magnitude representation is done with
paper and pencil by a process of successive shift and adds operations. This process is best
illustrated with a numerical example.
Hardware Algorithm:
Initially, the multiplicand is in B and the multiplier in Q. Their corresponding signs are in Bs and
Qs, respectively. The signs are compared, and both A and Q are set to correspond to the sign of the
product since a double-length product will be stored in registers A and Q. Registers A and E are
cleared and the sequence counter SC is set to a number equal to the number of bits of the
multiplier.
After the initialization, the low-order bit of the multiplier in Qn is tested.
i. If it is 1, the multiplicand in B is added to the present partial product in A .
ii. If it is 0 , nothing is done. Register EAQ is then shifted once to the right to form the
new partial product.
The sequence counter is decremented by 1 and its new value checked. If it is not equal to zero,
the process is repeated and a new partial product is formed. The process stops when SC = 0.
The final product is available in both A and Q, with A holding the most significant bits and Q
holding the least significant bits.
A flowchart of the hardware multiply algorithm is shown in the below figure (l).
Computer Organization
Division Algorithms:
Division of two fixed-point binary numbers in signed-magnitude representation is done
with paper and pencil by a process of successive compare, shift, and subtract operations.
The division process is illustrated by a numerical example in the below figure (q).
The divisor B consists of five bits and the dividend A consists of ten bits. The five most
significant bits of the dividend are compared with the divisor. Since the 5-bit number is
smaller than B, we try again by taking the sixth most significant bits of A and compare this
number with B. The 6-bit number is greater than B, so we place a 1 for the quotient bit. The
divisor is then shifted once to the right and subtracted from the dividend.
The difference is called a partial remainder because the division could have stopped here
to obtain a quotient of 1 and a remainder equal to the partial remainder. The process is
continued by comparing a partial remainder with the divisor.
• If the partial remainder is greater than or equal to the divisor, the quotient bit is equal to 1.
The divisor is then shifted right and subtracted from the partial remainder.
• If the partial remainder is smaller than the divisor, the quotient bit is 0 and no subtraction is
needed. The divisor is shifted once to the right in any case. Note that the result gives both a
quotient and a remainder.
Computer Organization
The sign of the quotient is determined from the signs of the dividend and the divisor. If the two
signs are alike, the sign o f the quotient is plus. If they are unalike, the sign is minus. The sign of
the remainder is the same as the sign of the dividend.
Divide Overflow
The division operation may result in a quotient with an overflow. This is not a problem
when working with paper and pencil but is critical when the operation is implemented
with hardware. This is because the length of registers is finite and will not hold a number
that exceeds the standard length.
To see this, consider a system that has 5-bit registers. We use one register to hold the
divisor and two registers to hold the dividend. From the example shown in the above, we
note that the quotient will consist of six bits if the five most significant bits of the
dividend constitute a number greater than the divisor. The quotient is to be stored in a
standard 5-bit register, so the overflow bit will require one more flip-flop for storing the
sixth bit.
This divide-overflow condition must be avoided in normal computer operations
because the entire quotient will be too long for transfer into a memory unit that has
words of standard length, that is, the same as the length of registers.
This condition detection must be included in either the hardware or the software of
Computer Organization
the computer, or in a combination of the two.
Computer Organization
1. 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.
3. The division of the magnitudes starts by shifting the dividend in AQ to the left with
the high-order bit shifted into E. If the bit shifted into E is 1, we know that EA > B because EA
consists of a 1 followed by n-1 bits while B consists of only n -1 bits. In this case, B must be
subtracted from EA and 1 inserted into Qn for the quotient bit.
4. If the shift-left operation inserts a 0 into E, the divisor is subtracted by adding its 2's
complement value and the carry is transferred into E . If E = 1, it signifies that A ≥ B;
therefore, Qn is set to 1 . If E = 0, it signifies that A < B and the original number is restored by
adding B to A . In the latter case we leave a 0 in Qn.
This process is repeated again with registers EAQ. After n times, the quotient is
formed in register Q and the remainder is found in register A
Computer Organization
.
Design of fast adders
A carry-look ahead adder (CLA) or fast adder is a type of adder used in digital logic.
A carry-look ahead adder improves speed by reducing the amount of time required to
determine carry bits.
It can be contrasted with the simpler, but usually slower, ripple-carry adder (RCA), for
which the carry bit is calculated alongside the sum bit, and each stage must wait until the
previous carry bit has been calculated to begin calculating its own sum bit and carry bit.
The carry-lookahead adder calculates one or more carry bits before the sum, which
reduces the wait time to calculate the result of the larger-value bits of the adder
A carry-Lookahead adder is a fast parallel adder as it reduces the propagation delay by
more complex hardware, hence it is costlier.
This method makes use of logic gates so as to look at the lower order bits of the augend
and addend to see whether a higher order carry is to be generated or not.