CA Unit 2
CA Unit 2
Tech
Subject Name: Computer Architecture
Subject Code: IT-402
Semester: 4th
Downloaded from be.rgpvnotes.in
UNIT-II
An arithmetic logic unit (ALU) is a digital circuit used to perform arithmetic and logic operations. It represents the
fundamental building block of the central processing unit (CPU) of a computer. Modern CPUs contain very
powerful and complex ALUs.
Fixed-Point representation
Fixed Point Representation
The positive numbers are represented as unsigned numbers but for negative values. For example, the arithmetic
uses plus + o i us - sig to i di ate positi e o egati e u e s. But i i a y otatio , o is used to i di ate
positive and 1 is used to indicate negative numbers. In addition to the sign, a number may have a binary or
decimal point to represent fractions, integers or mixed integers.
Integer representation
Whe the u e is positi e, a is used to ep ese t the positi e u e o he the u e is egati e, the
+14 ss 00001110
+14 ss 01110001
+14 ss 01110010
-14 ss 11110010
From the table, we can derive an algorithm for addition and subtraction as follows:
When the signs of A & B are identical, add the two magnitudes and attach the sign of A to the result.
Addition (Subtraction) Algorithm:
When the sign of A & B are different, compare the magnitude and subtract the smaller number from the
large number. Choose the sign of the result to be same as A if A > B, or the complement of the sign of A if A
< B. If the two numbers are equal, subtract B from A and make the sign of the result positive.
Hardware Implementation
The hardware consists of two registers A and B to store the magnitudes, and two flip-flops As and Bs to store the
corresponding signs. The results can be stored in the register A and As which acts as an accumulator. The
su t a tio is pe fo ed y addi g A to the s o ple e t of B. The output a y is t a sfe ed to the flip-flop E.
The overflow may occur during the add operation which is stored in the flip-flop A Ë… F. Whe ss , the output
of E is t a sfe ed to the adde ithout a y ha ge alo g ith the i put a y of ". The output of the pa allel
adder is equal to A + B which is an add operation. When m ss 1, the content of register B is complemented and
t a sfe ed to pa allel adde alo g ith the i put a y of . The efo e, the output of pa allel is e ual to A + B +
ss A – B which is a subtract operation.
For Add operation, identical signs dictate addition of magnitudes and for operation identical signs dictate
As and Bs are compared by an exclusive-OR gate. If outputss0, signs are identical, if 1 signs are different.
addition of magnitudes and for subtraction, different magnitudes dictate magnitudes be added.
Two magnitudes are subtracted if signs are different for add operation and identical for subtract operation.
Magnitudes are added with a microoperation EA
Magnitudes are subtracted with a microoperation EA ss B and number (this number is checked again for 0
to ake positi e [Asss ] i A is o e t esult. E ss i di ates A < B, so e take s o ple e t of A.
Generally, the multiplication of two final point binary number in signed magnitude representation is performed by
a process of successive shift and ADD operation. The process consists of looking at the successive bits of the
ultiplie least sig ifi a t it fi st . If the ultiplie is , the the ultipli a d is opied do othe ise, s a e
copied. The numbers copied down in successive lines are shifted one position to the left and finally, all the
numbers are added to get the product.
The hardware for the multiplication of signed magnitude data is shown in the figure below.
Initially, the multiplier is stored q register and the multiplicand in the B register. A register is used to store the
partial product and the sequence counter (SC) is set to a number equal to the number of bits in the multiplier. The
su of A a d B fo the pa tial p odu t a d oth shifted to the ight usi g a state e t “h EAQ as sho i the
ha d a e algo ith . The flip flops As, Bs & Qs sto e the sig of A, B & Q espe ti ely. A i a y i se ted i to the
flip-flop E during the shift right.
Hardware Algorithm
multiplicand E A Q SC
Initially, 0 00000 10011 101(5)
Iteration1(Qnss1), 00000
add B 0 +10111
first partial product 10111
shrEAQ, 0 01011 11001 100(4)
Iteration2(Qnss1) 01011
Add B 1 +10111 11001
Second partial 00010
product
shrEAQ, 0 10001 01100 011(3)
Iteration3(Qnss0)
0 01000 10110 010(2)
shrEAQ,
Iteration4(Qnss0)
0 00100 01011 001(1)
shrEAQ,
Iteration5(Qnss1 00100
Add B 0 +10111 01011
Fifth partial product 11011
shrEAQ, 0 01101 10101 000
Final Production AQ 0110110101
Booth Algorithm
The algo ith that is used to ultiply i a y i tege s i sig ed s o ple e t fo is alled ooth ultipli atio
algorithm. It works on the pri iple that the st i g s i the ultiplie does t eed additio ut just the shifti g
k m k+1 m 3ss1 1
a d the sti g of s f o it eight to 2 can be treated as 2 – 2 (Example, +14 ss 001110 ss 2 –2
ss 14). The product can be obtained by shifting the binary multiplication to the left and subtraction the multiplier
shifted left once.
A o di g to ooth algo ith , the ule fo ultipli atio of i a y i tege s i sig ed s o ple e t fo a e:
The multiplicand is subtracted from the partial product of the fi st least sig ifi a t it is i a st i g of s
The multiplicand is added to the partial product if the first least significant bit is 0 (provided that there was
in the multiplicand.
The divisor is stored in register B and a double length dividend is stored in register A and Q. the dividend is shifted
to the left and the divider is subtracted by adding twice complement of the value. If E ss 1, then A >ss B. In this
case, a quotient bit 1 is inserted into Qn and the partial remainder is shifted to the left to repeat the process. If E
ss 0, then A > B. In this case, the quotient bit Qn remains zero and the value of B is added to restore the partial
remainder in A to the previous value. The partial remainder is shifted to the left and approaches continues until
the sequence counter reaches to 0. The registers E, A & Q are shifted to the left with 0 inserted into Qn and the
previous value of E is lost as shown in the flow chart for division algorithm.
Restoring method
Method described above is restoring method in which partial remainder is restored by adding the divisor to the
negative result. Other methods:
Non-restoring method: In contrast to restoring method, when A -B is negative, B is not added to restore A but
i stead, egati e diffe e e is shifted left a d the B is added. Ho is it possi le? Let s a gue:
Divide Overflow
The division algorithm may produce a quotient overflow called dividend overflow. The overflow can occur of the
number of bits in the quotient are more than the storage capacity of the register. The overflow flip-flop DVF is set
to 1 if the overflow occurs.
The division overflow can occur if the value of the half most significant bits of the dividend is equal to or greater
than the value of the divisor. Similarly, the overflow can occuessr if the dividend is divided by a 0. The overflow
may cause an error in the result or sometimes it may stop the operation. When the overflow stops the operation
of the system, then it is called divide stop.
Floating-Point Representation
The floating-point representation of a number has two parts: mantissa and exponent
Mantissa: represents a signed, fixed-point number. Maybe a fraction or an integer
Exponent: designates the position of the decimal (or binary) point
Example1: decimal number +6132.789 is represented in floating-point as:
Fraction exponent
+0.6132789 +04
Floating-Point arithmetic
e
Floating-point is interpreted to represent a number in the form: m * r . Only the mantissa m and exponent e are
physically represented in resisters. The radix r and the radix point position are always .
Example2: binary number +1001.11 is represented with an 8-bit fraction and 6-bit exponent as,
Fraction exponent
+01001110 000100
or equivalently,
e +4
m * 2 ss +(.1001110)2 * 2
Normalization
A floating-point number is said to be normalized if the most significant digit of the mantissa is nonzero. For,
example, decimal number 350 is normalized but 00035 is not.
The control hardware can be viewed as a state machine that changes from one state to another in every clock
cycle, depending on the contents of the instruction register, the condition codes and the external inputs. The
outputs of the state machine are the control signals. The sequence of the operation carried out by this machine is
dete i ed y the i i g of the logi ele e ts a d he e a ed as ha d i ed .
Fixed logic circuits that correspond directly to the Boolean expressions are used to generate the control
signals.
Hardwired control is faster than micro-programmed control.
A controller that uses this approach can operate at high speed.
Control Word : A control word is a word whose individual bits represent various
Terminology:
control signals.
Micro-routine : A sequence of control words corresponding to the control sequence of a machine
instruction constitutes the micro-routine for that instruction.
Micro-instruction : Individual control words in this micro-routine are referred to as microinstructions.
Micro-program : A sequence of micro-instructions is called a micro-program, which is stored in a ROM or
RAM called a Control Memory (CM).
Control Store : the micro-routines for all instructions in the instruction set of a computer are stored in a
special memory called the Control Store.
The complexity of the digital system is derived form the number of sequences that are performed
When the control signals are generated by hardware, it is hardwired
In a bus-oriented system, the control signals that specify micro operations are groups of
bits that select the paths in multiplexers, decoders, and ALUs
The control unit initiates a series of sequential steps of micro operations
The o t ol a ia les a e ep ese ted y a st i g of s a d s alled a o t ol o d
A micro programmed control unit is a control unit whose binary control variables are stored in memory
The control unit initiates a series of sequential steps of micro operations
The o t ol a ia les a e ep ese ted y a st i g of s a d s alled a control word
A micro programmed control unit is a control unit whose binary control variables are stored in memory
A sequence of microinstructions constitutes a micro program
The control memory can be a read-only memory
Dynamic microprogramming permits a micro program to be loaded and uses a writable control memory
A computer with a micro programmed control unit will have two separate memories: a main memory and
The micro program consists of microinstructions that specify various internal control signals for execution
a control memory
The control memory address register specifies the address of the microinstruction
The control data register holds the microinstruction read from memory
The microinstruction contains a control word that specifies one or more
Micro operations for the data processor