Unit 2 - Arithmetic Unit
Unit 2 - Arithmetic Unit
INTRODUCTION
In this chapter mainly we are going to study about the Arithmetic and Logic
operations. Arithmetic and Logic operations means, Addition, Subtraction,
Multiplication and Division for the binary numbers. After studying this chapter, you
can able to understand the distinction between the way in which numbers are
represented (the binary format) and the algorithms used for the basic arithmetic
operations. Also, in this chapter we will study about twos complement representation,
present an overview of the techniques for doing basic arithmetic operation in two
complement notations. We begin our examination of the processor with an overview of
the arithmetic and logic unit (ALU). The chapter then focuses on the most complex
aspect of the ALU, computer arithmetic. The logic functions that are part of the ALU
are described in earlier, and implementations of simple logic and arithmetic functions
in digital logic are also described. Computer arithmetic is commonly performed on two
very different types of numbers: integer and floating point. In both cases, the
representation chosen is a crucial design issue and is treated first, followed by a
discussion of arithmetic operations.
In this system, he most significant (leftmost) bit in the word as a sign bit. If the
sign bit is 0, the number is positive; if the sign bit is 1, the number is negative. The
simplest form of representing sign bit is the sign magnitude representation. One of the
draws back for sign magnitude number is addition and subtraction need to consider both
sign of the numbers and their relative magnitude. Another drawback is there are two
representations for 0 (Zero) i.e +0 and -0.
For our understanding, in all three systems, the leftmost bit is 0 for positive number and
1 for negative number.
Addition
In addition two numbers are added like addition of +ve integers. On any addition,
the result may be larger than can be held in the word size being used. This condition is
called overflow. When overflow occurs, the ALU must set the overflow bit as 1
indicating the overflow. If two numbers are added, and they are both positive or both
negative, then overflow occurs if and only if the result has the opposite sign. If one of
the operand is –ve then it has to be represented in either of the complement form for
getting correct result.
Subtraction
To subtract one number (subtrahend) from another (minuend), take the 2’s
complement ( or negation) or 1’s complement of the subtrahend and add it to the
minuend. When using the complement methods in subtraction and having no additional
1 in the extreme left cell, then, this means a negative result. In this case, the solution is
the negative of 1’s complement of the result (if using 1’s complement initially), or the
negative of 2’s complement of the result (if using 2’s complement initially).If there is a
carry in the extreme left then in 1’s complement, it is discarded and 2’s complement, it
is added to the result.
Arithmetic Operations occur at the machine instruction level. They are
implemented along with basic logic functions such as
Now we are going to discuss about the addition and subtraction of the numbers
are how taking part in the logic circuit. Generally, in the login circuit consider that three
inputs and two outputs in which one input will be the carry in and one output will be
the carry out.
In this table Xi, Yi, Carry-in (Ci) are the inputs and sum of all these numbers are
mentioned in Si, Carry-out of this input is given in Ci+1. Binary numbers of 1 to 7 is
given as input and corresponding output is given in Si and Ci+1. Also, the calculation
of this Si and Ci+1 is given below in equation.
Consider an example of addition of 4 bits unsigned numbers 7 and 6. The
following example takes place of this.
In this diagram xi, yi are the normal input and ci is the carry input. Si is the sum of the
input and ci+1 is the carry out.
In this Ripple carry adder circuit is used for more number of stages need to be added
means, this can be used. And one stage (Full Adder) carry out value will be the carry in
value for the next stage.
Subtraction Operation on two unsigned Numbers
In-order to perform subtraction operation X-Y on two’s complement number X
and Y, determine the two’s complement of Y and add it to X.
si xi yi ci
ci 1 xi yi xi ci yi ci
ci 1 xi yi ( xi yi )ci
We can write the above equation like
ci 1 Gi Pi ci
where Gi xi yi and Pi xi yi
ci 1 Gi Pi ci
ci Gi 1 Pi 1ci 1
ci1 Gi Pi (Gi 1 Pi 1ci 1 )
continuing
ci1 Gi Pi (Gi 1 Pi 1 (Gi 2 Pi 2 ci 2 ))
until
ci1 Gi PiGi 1 Pi Pi1 Gi 2 .. Pi Pi 1 ..P1G0 Pi Pi 1 ...P0 c 0
xi yi
. .
. ci
Gi Pi si
Let us consider the design in a 4-bit adders. The carries can be implemented as
c1 G0 P0 c0
c2 G1 PG
1 0 P1 P0 c0
c3 G2 P2G1 P2 PG
1 0 P2 P1 P0 c0
c4 G3 P3G2 P3 P2G1 P3 P2 PG
1 0 P3 P2 P1 P0 c0
The above diagram explains about the 4-bit carry lookahead addition using the B cell
which is explained in pervious topic. Same like this 4n bit adder also can be explained
by using the diagram given below.
After xi, yi and c0 are applied as inputs the following can be handled in this.
- Gi and Pi for each stage are available after 1 gate delay.
- PI is available after 2 and GI after 3 gate delays.
- All carries are available after 5 gate delays.
- c16 is available after 5 gate delays.
- s15 which depends on c12 is available after 8 (5+3) gate delays (Recall that for a 4-
bit carry lookahead adder, the last sum bit is available 3 gate delays after all inputs are
available)
So far we have discussed about binary addition and subtraction. Now we are going to
discuss about the binary multiplication.
MULTIPLICATION
In this multiplication we are going to discuss the following different methods.
1. Multiplication of unsigned numbers
a. Sequential Multiplication
2. Signed-Operand Multiplication
a. Booth Algorithm
3. Fast Multiplication
a. Bit-Pair recording of multipliers
b. Carry-save addition of summands
Above different methods are having the different algorithms and circuits that leads to
solve the problems using the binary numbers.
In this case each of multiplication taken care with typical multiplication cell.
Multiplication is usually provided in the machine instruction set of a processor. Practical
size of multiplying numbers as 32 or 64 bit numbers. The simplest way to perform
multiplication is to use adder circuitry in the ALU for a number of sequential steps.
Sequential Multiplication
So far we have discussed about normal binary multiplication. But when the
computer operates the instructions execution, it may work with the sequential
multiplication to avoid the more carry values to be added. Now we are going to discuss
the sequential multiplication method with its algorithm.
Algorithm:
1. Recall the rule for generating partial products:
If the ith bit of the multiplier is 1, add the appropriately shifted
multiplicand to the current partial product.
Multiplicand has been shifted right when added to the partial product.
Consider the above figure in which the multiplier and multiplicand values are
given as 1011 and 1101 which are loaded into the Q and A registers respectively.
Initially the register C is zero and hence the A register is zero, which stores the carry in
addition. Since the B0 =1, then the number in the B is added to the bits of A and produce
the addition result as 1101, and the Q and A register are shifted their values one bit right
so the new values during the first cycle are 0110 and 1101 respectively. This process
has to be repeated four times to perform the 4 bit multiplication. The final multiplication
result will be available in the A and Q registers as 10001111.
2. Signed-operand Multiplication
In this method, Sign will be used (+ or -) also will be there. So, one more bit for
the sign need to be added along with the original values.
Considering 2’s-complement signed operands, what will happen to (-13) x (+11)
if following the same method of unsigned multiplication?
In this above example, after completing the normal multiplication, sign bit need
to extended as like given in red color. Since this is a signed multiplication, this
procedure needs to follow. For a negative multiplier, a straightforward solution is to
form the 2’s-complement of both the multiplier and the multiplicand and proceed as in
the case of a positive multiplier. This is possible because complementation of both
operands does not change the value or the sign of the product. A technique that works
equally well for both negative and positive multipliers – Booth algorithm. Now we are
going to discuss the Booth Multiplication with examples.
Since 0011110 = 0100000 – 0000010, if we use the expression to the right, what
will happen?
If you applying the truth table and now you will get the value as
The Booth algorithm generates a 2n-bit product and treats both positive and
negative 2‟scomplement n-bit operands uniformly. In general, in the Booth algorithm,
−1 times the shifted multiplicand is selected when moving from 0 to 1, and +1 times the
shifted multiplicand is selected when moving from 1 to 0, as the multiplier is scanned
from right to left.
Example 2:
We may also consider another example for the booth multiplication that
Multiplicand (M) is (+13) and Multiplier (Q) is (-6).
Binary values for the above M and Q are
In this case we need to know, how can we find the binary number for negative
multiplier. As we know, if the sign bit of the multiplicand or multiplier is + then we
should add 0 and if the sign bit is – then we should add 1.
In this example Multiplier is -6. So initially we should write the binary for +6. Next
should find the 1’s complement value. To find once complement of the given value, if
a bit is 0 then change it to 1 and if a bit is 1 then change it 0. After finding 1’s
complement, Add 1 with the 1’s complement value. Now you have the 2’s complement
value. This is given below to understand clearly.
In general, in the Booth scheme, -1 times the shifted multiplicand is selected when
moving from 0 to 1, and +1 times the shifted multiplicand is selected when moving
from 1 to 0, as the multiplier is scanned from right to left.
Above is the booth recording of a multiplier. In this booth multiplier based on the sifting
the bits, can be classified into 3 methods.
a. Worst-case multiplier
b. Ordinary multiplier
c. Good multiplier
In this fast multiplication, there are two different methods can be used.
From this we already know how to apply the booth multiplication. To understand easily
booth multiplication can be solved like,
Now we are going to apply Bit-Pair Recording of multipliers method in given
problem. After applying the truth table in multiplier we get the values. Then have to
do like this.
Once the values are applied and got the values, before going to the final step sign bit
extension also should be extended as like given on “Blue” color. After that can add
those multiplier values. While adding this finally, if any carry comes then it should be
discarded.
Finally, when we are finding the product, in some places a more number of 1’s is going
to be added. At that time carry out value will be higher. To avoid that only carry save
addition of summands will be used. To us this method, you have to understand this.
In this case given bits are considered as A, B, C, D, E, and F. So set of 3 multiplier
values are taken for adding in each stage. After adding each stage we will get one Sum
(S) value and one Carry (C) value.
When we start doing to solve this problem, the position of the bits should not be
changed. If the position is changed when we are doing the problem, then the hole
calculation will be wrong. So as solved in this example, have to follow with each and
every step. Here instead of forwarding the carry value into other bits, it is saved in that
particular bit position. So through out this calculation, maximum number of 1s can be
added is only three. So the carry also will be the 1 maximum.
INTEGER DIVISION
Integer Division has generally two different methods.
1. Restoring Division
2. Non-Restoring Division
These above two methods are having different algorithms to be following. Now
we are going to study one by one. First we are going to solve some problems using the
Restoring Division. Before going to start, we should know the normal binary division.
So we will have Dividend value and Divisor values. If the values are given in numerical,
then it should be converted into binary and no sign bits will be used here.
Now we are going to solve the Numerical division and Binary division.
Numerical division
For the same Dividend and Divisor, we are going to do the Binary Division
Binary division
Now we are going to implement the Integer Division by using a algorithm. Position the
divisor appropriately with respect to the dividend and performs a subtraction. If the
remainder is zero or positive, a quotient bit of 1 is determined, the remainder is extended
by another bit of the dividend, the divisor is repositioned, and another subtraction is
performed. If the remainder is negative, a quotient bit of 0 is determined, the dividend
is restored by adding back the divisor, and the divisor is repositioned for another
subtraction.
Algorithm
M1 1 1 1
Q0 0 1 1
Before doing the Integer division, first do the normal binary division
Non-Restoring Division
Same like Restoring algorithm, we are going to see the Non-restoring method to be
followed by using the algorithm. To avoid the need for restoring A after an unsuccessful
subtraction, we implement the following algorithm.
Algorithm
If the sign of A is 0, shift A and Q left one bit position and subtract M
from A; otherwise, shift A and Q left and add M to A.
Now we are going to see with the examples. In this example we consider the Dividend
(M) is 8 and Divisor (Q) is 3. Initially we have to find the binary value of it. So
M1 1 1 1
Q0 0 1 1
Before doing the Integer division, first do the normal binary division
After all the cycles has been completed, only in this Non-Restoring division we have to
check the carry bit. If carry bit 0, then we can stop the process and write the Quotient
and Remainder.
But, after completion of all the cycles, the carry bit is 1, then we have to do one more
like add the M value with the remainder and stop the process for restoring it.