Professional Documents
Culture Documents
COA Unit 2
COA Unit 2
Flowchart of Multiplication:
1. Initially multiplicand is stored in B register and multiplier is stored in Q
register.
2. Sign of registers B (Bs) and Q (Qs) are compared using XOR functionality
(i.e., if both the signs are alike, output of XOR operation is 0 unless 1) and
output stored in As (sign of A register).
Note: Initially 0 is assigned to register A and E flip flop. Sequence counter is
initialized with value n, n is the number of bits in the Multiplier.
3. Now least significant bit of multiplier is checked. If it is 1 add the content of
register A with Multiplicand (register B) and result is assigned in A register
with carry bit in flip flop E. Content of E A Q is shifted to right by one
position, i.e., content of E is shifted to most significant bit (MSB) of A and
least significant bit of A is shifted to most significant bit of Q.
4. If Qn = 0, only shift right operation on content of E A Q is performed in a
similar fashion.
5. Content of Sequence counter is decremented by 1.
6. Check the content of Sequence counter (SC), if it is 0, end the process and
the final product is present in register A and Q, else repeat the process.
Example:
Multiplicand = 10111
Multiplier = 10011
Booth's Multiplication Algorithm
The booth algorithm is a multiplication algorithm that allows us to multiply the two
signed binary integers in 2's complement, respectively. It is also used to speed up the
performance of the multiplication process. It is very efficient too. It works on the string
bits 0's in the multiplier that requires no additional bit only shift the right-most string
bits and a string of 1's in a multiplier bit weight 2k to weight 2m that can be considered
as 2k+ 1 - 2m.
Qn Qn + 1 M = (0111) AC Q Qn + 1 SC
M' + 1 = (1001) & Operation
1001
0 1 Addition (A + M) 0111
0101 0100
Qn Qn + 1 M=010111 AC Q Qn + 1 SC
M' + 1 = 1 0 1 0 0 1
1 0 Subtract M 101001
101001
0 1 Addition (A + M) 010111
010100
1 0 Subtract M 101001
110011
Assuming A = a1a0 and B= b1b0, the various bits of the final product term P
can be written as:-
1. P(0)= a0b0
2. P(1)=a1b0 + b1a0
3. P(2) = a1b1 + c1 where c1 is the carry generated during the addition for the
P(1) term.
4. P(3) = c2 where c2 is the carry generated during the addition for the P(2)
term.
For the above multiplication, an array of four AND gates is required to form the
various product terms like a0b0 etc. and then an adder array is required to
calculate the sums involving the various product terms and carry combinations
mentioned in the above equations in order to get the final Product bits.
1. The first partial product is formed by multiplying a0 by b1, b0. The
multiplication of two bits such as a0 and b0 produces a 1 if both bits are 1;
otherwise, it produces 0. This is identical to an AND operation and can be
implemented with an AND gate.
2. The first partial product is formed by means of two AND gates.
3. The second partial product is formed by multiplying a1 by b1b0 and is shifted
one position to the left.
4. The above two partial products are added with two half-adder(HA) circuits.
Usually there are more bits in the partial products and it will be necessary to
use full-adders to produce the sum.
5. Note that the least significant bit of the product does not have to go through
an adder since it is formed by the output of the first AND gate.
Division Algorithm
The Division of two fixed-point binary numbers in the signed-magnitude
representation is done by the cycle of successive compare, shift, and subtract
operations.
The binary division is easier than the decimal division because the quotient digit
is either 0 or 1. Also, there is no need to estimate how many times the dividend
or partial remainders adjust to the divisor.
Flowchart of Division :
Initially, the dividend is in A & Q and the divisor is in B.
The sign of the result is transferred into Q, to be part of the quotient. Then a
constant is set into the SC to specify the number of bits in the quotient.
Since an operand must be saved with its sign, one bit of the word will be
inhabited by the sign, and the magnitude will be composed of n -1 bits.
The condition of divide-overflow is checked by subtracting the divisor in B
from the half of the bits of the dividend stored in A. If A ≥ B, DVF is set and
the operation is terminated before time. If A < B, no overflow condition
occurs and so the value of the dividend is reinstated by adding B to A.
The division of the magnitudes starts with the dividend in AQ to left in the
high-order bit shifted into E.
(Note – If shifted a bit into E is equal to 1, and we know that EA > B as EA
comprises a 1 followed by n -1 bits whereas B comprises only n -1 bits). In
this case, B must be subtracted from EA, and 1 should insert into Q, for the
quotient bit.
If the shift-left operation (shl) inserts a 0 into E, the divisor is subtracted by
adding its 2’s complement value and the carry is moved into E. If E = 1, it
means that A ≥ B; thus, Q, is set to 1. If E = 0, it means that A < B, and the
original number is reimposed by adding B into A.
Now, this process is repeated with register A containing the partial
remainder.
Example of a binary division using digital hardware:
Divisor B = 10001, Dividend A = 0111000000
An arithmetic logic unit(ALU) is a major component of the central processing unit of the a
computer system. It does all processes related to arithmetic and logic operations that need to be
done on instruction words. In some microprocessor architectures, the ALU is divided into the
arithmetic unit (AU) and the logic unit (LU).
An ALU can be designed by engineers to calculate many different operations. When the
operations become more and more complex, then the ALU will also become more and more
expensive and also takes up more space in the CPU and dissipates more heat. That is why
engineers make the ALU powerful enough to ensure that the CPU is also powerful and fast, but
not so complex as to become prohibitive in terms of cost and other disadvantages.
ALU is also known as an Integer Unit (IU). The arithmetic logic unit is that part of the CPU that
handles all the calculations the CPU may need. Most of these operations are logical in nature.
Depending on how the ALU is designed, it can make the CPU more powerful, but it also
consumes more energy and creates more heat. Therefore, there must be a balance between how
powerful and complex the ALU is and how expensive the whole unit becomes. This is why faster
CPUs are more expensive, consume more power and dissipate more heat.
The description of how ALU interacts with the processor is given below. Every arithmetic logic
unit includes the following configurations:
Accumulator
The intermediate result of every operation is contained by the accumulator, which means
Instruction Set Architecture (ISA) is not more complex because there is only required to hold
one bit.
Generally, they are much fast and less complex but to make Accumulator more stable; the
additional codes need to be written to fill it with proper values. Unluckily, with a single
processor, it is very difficult to find Accumulators to execute parallelism. An example of an
Accumulator is the desktop calculator.
Stack
Whenever the latest operations are performed, these are stored on the stack that holds programs
in top-down order, which is a small register. When the new programs are added to execute, they
push to put the old programs.
Register-Register Architecture
It includes a place for 1 destination instruction and 2 source instructions, also known as a 3-
register operation machine. This Instruction Set Architecture must be more in length for storing
three operands, 1 destination and 2 sources. After the end of the operations, writing the results
back to the Registers would be difficult, and also the length of the word should be longer.
However, it can be caused to more issues with synchronization if write back rule would be
followed at this place.
The MIPS component is an example of the register-to-register Architecture. For input, it uses
two operands, and for output, it uses a third distinct component. The storage space is hard to
maintain as each needs a distinct memory; therefore, it has to be premium at all times. Moreover,
there might be difficult to perform some operations.
Generally, the combination of Register and Accumulator operations is known as for Register -
Stack Architecture. The operations that need to be performed in the register-stack Architecture
are pushed onto the top of the stack. And its results are held at the top of the stack. With the help
of using the Reverse polish method, more complex mathematical operations can be broken
down. Some programmers, to represent operands, use the concept of a binary tree. It means that
the reverse polish methodology can be easy for these programmers, whereas it can be difficult
for other programmers. To carry out Push and Pop operations, there is a need to be new hardware
created.
In this architecture, one operand comes from the register, and the other comes from the external
memory as it is one of the most complicated architectures. The reason behind it is that every
program might be very long as they require to be held in full memory space. Generally, this
technology is integrated with Register-Register Register technology and practically cannot be
used separately.
units.
Advantages of ALU
IEEE 754 numbers are divided into two based on the above three components: single
precision and double precision.
BIASED NORMALISED
TYPES SIGN BIAS
EXPONENT MANTISA
Single precision 1(31st bit) 8(30-23) 23(22-0) 127
Double 1(63rd
11(62-52) 52(51-0) 1023
precision bit)
Example –
85.125
85 = 1010101
0.125 = 001
85.125 = 1010101.001
=1.010101001 x 2^6
sign = 0
1. Single precision:
biased exponent 127+6=133
133 = 10000101
Normalised mantisa = 010101001
we will add 0's to complete the 23 bits
2. Double precision:
biased exponent 1023+6=1029
1029 = 10000000101
Normalised mantisa = 010101001
we will add 0's to complete the 52 bits