Unit II Material
Unit II Material
2 Arithmetic Unit
Chap–III 1
COMPUTER ARCHITECTURE Arithmetic Unit
AC.MQ capable of left and right shifting. The main additional Bit -sliced ALU
data processing capability is provided by the parallel adder that
It is possible to construct an entire fixed point ALU on a
receives inputs from AC and DR and places its results in AC.
The MQ register is so called because it stores the multiplier single IC chip especially if the word size m is kept fairly
during the multiplication operation, and quotient during the small ex: 4 or 8 bits. Such an m-bit ALU can be designed to
division operation. DR stores the multiplicand or the divisor be expandable in that k copies of the ALU chip can be
while the result is stored in AC.MQ. connected to form a single ALU capable of processing km-bit
In many instances DR serves as a memory buffer register to operands directly. The resulting array like circuit is called bit
store data addressed by the instruction address field ADR. sliced because each component chip processes an independent
System Bus slice of m bits from each km bit operand. Bit sliced ALU’ s
have advantage that any desired word size or even several
different word sizes can be handled by selecting the appropriate
A ccu m u lato r (A C ) M u ltiplier – Q u o tient D ata R egister (D R ) number of components (bit slices) to use.
R egister M Q
{
programmed. Certain operations require information to be
Division → AC. MQ ← MQ / DR MQ – Quotient
exchanged between slices. For ex if a shift operation is to be
AND → AC ← AC ^ DR AC – Reminder implemented then each slice must send a bit to and receive a
OR → AC ← AC V DR bit from left or right neighbors .Similarly when performing
addition the carry bits may have to be transmitted between the
XOR → AC ← AC .XOR. DR neighboring slices.
NOT → AC ← AC *
Chap–III 2
COMPUTER ARCHITECTURE Arithmetic Unit
Data in (16 bits) Data out (16 bits) 3.2.1 Signed-Magnitude Representation
The positive and negative numbers are differentiated by
treating the most significant 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
+18 = 0 0 0 1 0 0 1 0
R(0:3) R(4:7) R(8:11) R(12:1
5) ↓ ↓
one sign bit seven bit magnitude
ALU ALU ALU ALU
Range : − ( 2 − 1) to + ( 2 − 1)
Circuits Circuits Circuits Circuits n −1 n −1
Cout cin
Control Control Control Control Eg. A 7 bit register can store numbers from –63 to +63
circuits circuits circuits circuits
Drawbacks
1. Addition and subtraction requires both the sign bit and
magnitude bits to be considered.
External control signals
2. Two representation for zero (0)
Fig: Bit Sliced ALU
+0 → 00000000
3.2 INTEGER REPRESENTATION FIXED POINT –0 → 10000000
The numbers used in digital machines are represented using 3.2.2 Two’s Complement Representation
binary digits 0 and 1. The storage element called flipflops can
In two’s complement system, forming the 2’s complement
hold this digits. Group of flip flops forms a register in computer
of a number is done by subtracting that number from 2N.
systems.
Eg. Representation of –4
Eg. The number 41 can be represented as
In Sign-magnitude 1100
00101001 [8 bit representation]
In 1’s complement 1011
Thus if a register contains 8 bits, a signed binary number
In 2’s complement 1100
in the system will have 7 magnitude bits or integer and a single
sign bit and the system is called signed magnitude binary integer Advantages
system. i. Only one arithmetic operation is required while subtracting
Eg. +18 = 00010010 using 2’s complement notation.
–18 = 10010010 ii. Used in arithmetic applications.
Chap–III 3
COMPUTER ARCHITECTURE Arithmetic Unit
Chap–III 4
COMPUTER ARCHITECTURE Arithmetic Unit
Chap–III 5
COMPUTER ARCHITECTURE Arithmetic Unit
carry to the binary adder is the C4. The S outputs of the full For signed numbers the result is (X-Y) provided there is no
adders generates the required sum bits. overflow.
The n-bit binary adder requires n-full adders. The n-data
bits for the X inputs are from one register R1 and n-data bits for Y3 Y2 Y1 Y0
the Y input come from another register R2. The sum can be transferred
to the third register or one of the source register. (R1 or R2)
M
Y3 X3 Y2 X2 Y1 X1 Y0 X0
xor X3 xor X2 xor X1 xor X0
FA C3 FA C2 FA C1 FA Cin
FA FA FA FA
C3 C2 C1 Cin
Cout S3 S2 S1 S0
Fig: 4-Bit Binary Adder Cout S3 S2 S1 S0
Chap–III 6
COMPUTER ARCHITECTURE Arithmetic Unit
D = X + B + Cin Cin C0
S1 X0
Æ 4 bit binary number at A inputs.
v
X A0
S0 FA
Y Æ 4 bit binary number at B inputs. S0 D0
vv vv vv
v
S1 B0
0 4X 1
Cin Æ Input carry which can be 0 or 1. Y0
1 M UX
Y0* 2
0 C1
By controlling the value of Y with two selection inputs S0 3
1
X1
v
and S1 and making Cin equal to 0 or 1 it is possible ot generate A1
FA
8 possible arithmetic operations. S0 B1
D1
v v vvv
v
S1
Y1 0 4X 1
Addition: When S1S0 = 00, the value of B is applied to the Y1 1 M UX
Y input of the adder. If Cin = 0 the output D = X + Y. If Cin = 1 0 2
1 3 C2
v
then the output is D = X + Y + 1. Both cases perform the add
A2
micro operation with or with out carry. X2
v
FA D2
Subtraction: When S1S0 = 01, the complemented value of Y S0 B2
vvv
v
S0
is applied to the B input of the adder. If C in = 0 the Y2 S1
S1 4 X 1
01 M U X
Y2
vv
output D=X+(Comp)Y. This is equivalent to D = X–Y-1. If 10
0
Cin = 1 then the output is D = X+(Comp)Y+1.This produces X 21
v
1 32 C3
plus the 2’s complement of Y, which is equivalent to X–Y. Both
X3 A3
v
cases perform the subtraction micro operation with or with out
borrow. FA D3
B3
v
vv
S0
S1
When S1S0=10 the input from the B are neglected all 0’s Y3
v
0 4X 1 Cout
Y3 1 M UX
vv
are applied to the B input The output becomes D = X+1
0 2
1 3
v
When S 1S 0 = 11 all 1’s are inserted in to B input of the
adder to produce the Decrement operation. D = X-1, When Cin = 0. 3.3.5 Addition & Subtraction of Signed Numbers
This is because the number with all 1’s equal to 2’s complement
We designate the magnitude of two number by A and B.
of 1. (2’s complement of 0001 = 1111). Adding a number A to
When signed number are added or subtracted we find that there
the 2’s complement of 1 produce D= X-1. are 8 different condition to consider, depending on the sign of
When Cin = 1 then D = X-1+1 = X the number and the operation performed. These conditions are
listed in the following table (1st column). The other columns
Chap–III 7
COMPUTER ARCHITECTURE Arithmetic Unit
show the actual operation to be performed with the magnitude to a 3rd register. However a saving is achieved by transferring
of the number. The last column is needed to prevent -0. the result into X and Xs. Thus X and Xs together form an
When two equal number are subtracted the result should be +0 accumulator register.
not -0.
Consider now the hardware implementation of the algorithm
Operation Add Magnitudes Subtract Magnitudes When above.
X >Y X<Y X =Y 1) First a parallel adder is needed to perform the micro
(+X) + (+Y) +(X+Y) operation X + Y.
(+X) + (-Y) + (X - Y) - (X - Y) + (X - Y) 2) A comparator circuit is needed to establish if X > Y, X = 0
(-X)+(+X) - (X - Y) + (X - Y) + (X - Y) or X < Y.
(-X) + (-Y) _- (X + Y) 3) Two parallel subtract circuits are needed to perform the micro
(+X) - (Y) + (X - Y) - (Y - X) + (X - Y) operation X – Y and Y – X
(+X) - (-Y) + (X + Y) 4) The sign relation can be determined from an XOR gate
(-X) - (+Y) - (X + Y) with Xs and Ys input.
(-X) - (-Y) - (X - Y) + (Y - X) + (X - Y) This procedure required a magnitude comparator, an adder,
and two subtractions. However a different procedure can be found
Addition Algorithm: that required less equipment.
a) When the signs of X and Y are identical add the two a) First we know that subtraction can be accomplished by means
magnitudes and attach the sign of X to the result. of complement and addition.
b) When the signs of X and Y are different compare the b) The result of a comparison can be determined from the end
magnitude and subtract the smaller number from the larger. carry after the subtraction.
Choose the sign of the result as X if X > Y or complement
The following fig shows the hardware implementation of
of the sign of X if X < Y.
the addition and subtraction operation. It consists of register
c) If the two magnitudes are equal, subtract Y from X and X and Y and sign flip flop Xs and Ys. Subtraction is done
make the result positive. by adding X to the 2’s complement of Y. The output carry
Hardware Implementation: is transferred to flip flop E. Where it can be checked to
determine the relative magnitude of the two numbers. The
To implement the two arithmetic operations with hardware
add-overflow flip flop VF holds the overflow bit when X
it is first necessary that the two numbers be stored in register.
and Y are added. The register provides other micro operation
Let X and Y be two register that hold the magnitude of the
that may be needed when we specify the sequence of steps
number and Xs and Ys be two flip flop that hold the
in the algorithm.
corresponding signs. The result of operation may be transferred
Chap–III 8
COMPUTER ARCHITECTURE Arithmetic Unit
The addition of X plus Y is done through the parallel adder. XOR gate is 0 the signs are (equal) identical, if it is 1 the signs
The S (Sum) output of the adder is applied to the input of are different.
the X register. The complement provides an output of Y or
1. For an addition operation the identical signs dictate that the
complement of Y depending on the state of mode control
magnitude be added.
M. The complementor consists of XOR gates and the parallel
adder consists of full-adder. The M signal is applied to the 2. For subtraction operation different signs dictate that
input carry of the adder. magnitude be added..
1. When M = 0, the output of Y is transferred to the adder, 3. For magnitude are added with a micro operation.
the input carry is 0 and the output of the adder is the EX Å X + Y, Where EX Å Reg that combines that combines
sum X + Y. E and X. The carry in E after the addition constitutes an
2. When M=1, the 1’s complement of Y is applied to the overflow if it is equal to 1.
adder, the input carry is 1 and the output S = X + Y +1. The value of E is transferred into the add-overflow flip-flop
This is equal to A plus 2’s complement of B. Which is VF.
equal to the subtraction X – Y.
4. The two magnitude are subtracted if the two signs are
Ys Y Register different for an addition operation or identical for subtract
operation. The magnitude is subtracted by adding X to the
number are subtracted so VF is cleared to 0.
Chap–III 9
COMPUTER ARCHITECTURE Arithmetic Unit
The final value of E is immaterial. same as the other bits of the number. A carryout of the sign-bit
position is discarded. The subtraction consists of first taking 2’s
Subtract operation Add operation
complement of the subtrahend and then adding it to the minuend.
Minuend in X Augend in X When two numbers of n digits each are added and the sum
Subtrahend in Y Addend in Y occupies n+1digits. We say that an overflow occurred. An
overflow can be detected by inspecting the last two carries out
= 0 Xs (+) Ys = 1 =1 Xs (+) Ys = 0 of the addition. When the two carries are applied to the XOR
gate the overflow is detected when the output of the gate is
Xs=Ys Xs≠Ys Xs≠Ys Xs=Ys equal to 1.
EX Å X+Y+1 EA Å X+Y The register configuration for hardware implementation is
VF Å 0 shown in the figure below. This is same as the figure above but
the sign bits are not separated from the rest of the register. We
VF Å E
= 0 E = 1 name the X register XS (Accumulator) and the Y register YS.
X<Y X≥Y The left most bit in XS and YS represents the sign bits of the
number. The two sign bits are added or subtracted together with
XÅ X' ≠ 0 =0
X the other bits in the completes and parallel adder. The overflow
flip-flop V is set to 1 if there is an overflow. The output carry
XÅX+1
Xs Å Xs’ Xs Å 0 in this case is discarded.
YS register
END
(Result in X and Xs)
V Complementer & parallel adder
Fig: - Flow chart for add and subtract operation
Overflow
3.3.5.1 Addition and subtraction with signed 2’s complement data
XS register
The left most bit of a binary number represents assign bit
0Æ positive, 1Æ negative. If the sign bit is 1 the entire number The algorithm for adding and subtracting two binary number
is represented in 2’s complement form. in signed 2’s complement is shown below. The sum is obtained
Thus +33 Ex: is represented as 00100001 and by adding the contents of XS and YS (including their sign bits).
-33 as 11011111. Note that 11011111 is the 2’s complement The overflow bit V is set to 1 if XOR of the last two carries
of 00100001 and vice versa. is 1 and it is cleared to 0 otherwise.
The addition of two numbers in signed 2’s complement form The subtract operation is accomplished by adding the content
consists of adding the number with the sign bits treated the of Ac to the 2’s complement of YS. Taking the 2’s complement
Chap–III 10
COMPUTER ARCHITECTURE Arithmetic Unit
Chap–III 11
COMPUTER ARCHITECTURE Arithmetic Unit
X3 Y3 X2 Y2 X1 Y1 X0 Y0 Propogate Pi = x i +y i
C3 C2 C1 C0 FA0 For first full addeer
FA3 FA2 FA1 FA0
C1 = G 0 +C 0 P0
C4 C3 C2 C1 FA1 For second full addeer
S3 S2 S1 S0 C 2 = G1 +C1P1
3.3.6.1 The Look Ahead Carry Adder
= G1 + P1 ( G 0 + C0 P0 ) [∵ C1 = G 0 + P0 C0 ]
In parallel adder, the speed with which an addition can be
performed is limited by the time required for the carries to ∴ C 2 = G1 + G 0 P1 + C0 P1P0
propagate or ripple through all of the stages of adder. One method Similarly
of speeding up this process is by climinating this ripple carry
C3 = G 2 +C 2 P2
delay is called Look-Ahead Carry addition and is based on two
functions of the full adder called the carry generate and the = G 2 + (G1 + G 0 P1 + C0 P1P0 ) P2
carry propagate function
= G 2 + G1 P2 + G 0 P1P2 + C0 P2 P1 P0
Xi Pi
Yi Si
In all the above expressions, the carry output for each full
-adder stage is dependent only on the initial input carry (C0), its G0
and P0 functions and the G and P functions of the preceeding stages.
Gi
Since, each of the G and P functions can be expressed in
C i+1
terms of the x and y inputs to the full adders, all of the output
Ci carries are immediately available and the adder circuit need not
Fig. Full-Adder-Bit Stage Cell. have to wait for a carry to ripple through all of the stages
before a final result is achieved. Thus the look ahead carry
From the full adder circuit, technique speeds up the addition process.
X 3 Y3 X2 Y2 X1 Y1 Y0
Si = x i ⊕ yi ⊕ ci
C4 C3 C2 C1 C0
ci+1 = x i yi + yi ci + ci x i FA FA FA FA
= x i yi + ci + ( x i + yi ) G3 P3 G2 P2 G1 P1 G0 P0
S3 S2 S1 S0
Generate G i = x i yi Carry Look-ahead Logic
Now the expression for the carry out co. of each full adder I I
G0 P0
stage for the four bit example. Fig. 4-bit adder.
Chap–III 12
COMPUTER ARCHITECTURE Arithmetic Unit
In general, the final expression for any carry variable is In the above fig., the carryout C4 from the low order adder
is available 3 gate delays after the input operands X, Y and C0
Ci+1 = G i + Pi G i −1 + Pi Pi −1G i − 2 + .......... are applied to the 16 bit carry lookahead adder.
+ Pi Pi −1 ........ Pi G 0 + Pi Pi −1 ....... P0 G 0
C8 is available after a further 2 gate delays, C12 is available
after a further 2 gate delays and C16 is available after a further
All carries can be obtained three gate delays after the input
2 gate delays.
signals X, Y and C0 are applied because only one gate delay is
needed to develop all Pi and Gi signals, and followed by two (i.e.) C16 is available after a total of
gate delays in the AND-OR circuit for Ci+1 (See fig. Full-
(3×2) + 3 = 9 gate delays
Adder-Bit stage cell)
If a ripple carry adder is used, C16 is available only after 31
After a further XOR gate delay, all sum bits are available.
gate delays for S15 and 32 gate delays for C16.
Therefore, independent of n, the n-bit addition process requires
only four gate delays. Higher-Level generate and propagate functions
Delays in Carry Look ahead adder By using Higher-Level block generate and propagate
X15-12 Y15-12 X11-8 Y11-8 X7-4 Y7-4 X3-0 Y3-0 functions, it is possible to use the lookahead approach to develop
the carries C4, C8, C12 ....... in parallel in a higher-level carry
C16 C12 C8 C4 lookahead circuit.
4 bit 4 bit 4 bit 4 bit C0
adder adder adder adder In Fig. 16 bit Carry Look Ahead Adder
Chap–III 13
COMPUTER ARCHITECTURE Arithmetic Unit
Chap–III 14
COMPUTER ARCHITECTURE Arithmetic Unit
H/W algorithm:- = 0 Qn = 1
Chap–III 15
COMPUTER ARCHITECTURE Arithmetic Unit
Chap–III 16
COMPUTER ARCHITECTURE Arithmetic Unit
Chap–III 17
COMPUTER ARCHITECTURE Arithmetic Unit
rest of the reg. To show this different we rename the reg. A, B Multiply
and Q as AC, BR and QR respectively. Qn designates the LSB
of multiplier in reg. QR. An extra FF Qm+1 is appended to QR
Multiplicand in YS
to facilitate a double bit inspection of the multiplier Multiplier in QR
YS Register Sequence Counter
XS ← 0
Qn+1 ← 0
SC ← N
Complementer &
11le adder
Qn Qn+1
Qn Qn+1
= 10 = 01
Chap–III 18
COMPUTER ARCHITECTURE Arithmetic Unit
10111 × Worst 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 10
10011 Case +1 –1 +1 –1 +1 –1 +1 –1 +1 –1 +1 –1 +1 –1 +1 –1 +1 –1
10 01 1 0 assumption Ordinary 1 1 0 0 0 1 0 1 1 0 1 1 1 0 0 1 0 0
Multiplir 0 –1 0 0 +1 –1 +1 0 –1 +1 0 0 –1 0 +1 –1 0
–1 0 +1 0 –1
(average)
10 11 1 × implied
–1 0 +1 0 –1 Good 0 0 0 0 1 1 1 1 1 0 0 0 0 1 1 1 0
0000001001 ← 2’s comp of the multiplicand 10111 Multiplir 0 0 0 +1 0 0 0 0 –1 0 0 0 +1 0 0 –1
Chap–III 19
COMPUTER ARCHITECTURE Arithmetic Unit
Chap–III 20
COMPUTER ARCHITECTURE Arithmetic Unit
0 -1 -2 Example 1
0 1 1 0 0 (12) × 1 1 0 0 0 (–8)
In the recoded multiplier bits,
Chap–III 21
COMPUTER ARCHITECTURE Arithmetic Unit
0 -2 0 0 0 1 1 1 ×
0 +1 –1 +1 –1
0 1 1 0 0
1111111001
0 –2 0
000000111
0000000000 ← M × O
11111001
11101000 ←Take 2’s compl. of M × 2 shifted by 2 bit position. 0000111
000000 000000
1110100000 0000100011
2’s Comp form II Method (Bit Pair Recoding of Multiplier)
Multiplier
0001100000 ← (–96)
Take 2’s compl. of the result and put negative sign in front. 0 0 0 1 0 1 0
Sign
Note : Using multiplier bit pair recording, multiplication Extension 0 0 +1 -1 +1 -1
requires only half the number of summands as a normal
multiplication algorithm. 0 +1 +1
Example 2: 0 0 1 1 1 ×
Multiplicand –7 0 +1 +1
Multiplier –5 0000000111
If both multiplicand and multiplier are negative, take two’s 00000111
complement of both and do positive multiplication as the sign
000000
and value of the product will not change.
0000100011
Therefore Multiplicand 00111
As given in II Method, bit pair recoding of multipliers
Multiplier 00101
technique halves the maximum number of summands.
Chap–III 22
COMPUTER ARCHITECTURE Arithmetic Unit
3.3.9.2 Carry Save addition of summands Case (ii) Addition Using Carry save adder
Multiplication of 2 numbers involves the addition of several Wn-1 Xn-1 W1 X1 W0 X0
summands (partial products). A technique called carry save
addition speeds up the addition process.
FA FA FA 0
In ordinary multiplication process, while adding the O
summands, the carry produced by second bit position has to be yn-1 y1 y0
added with third bit position and so on. Thus the carry ripple an an-1 a1 a0
along the rows.
FA FA FA FA 0
Eg. Consider the addition of 3 numbers W, X, Y
i.e. Z = W + X + Y
Zn+1 Zn Zn-1 Z1 Z0
Case (i) Using ripple carry adders, Z = W + X + Y can be
implemented as Fig. Addition using ripple carry adder.
FA FA FA FA C = 10101
Z = 1000100
Zn+1 Zn Zn-1 Z1 Z1 Z0 In carry save addition, instead of letting the carries ripple
along the rows, they are saved and introduced into the next row,
at the correct weighted positions.
Eg :
Carry save addition transforms W, X & Y into S & C. Its
W = 10101
advantage is that all bits of S and C Vectors are produced in a
X = 11011 short, fixed amount of time after W, X and Y are applied. Carry
propagation takes place only in the second row.
110000
Example 2
Y = 010100
Consider the multiplication operation M × Q = P for 6 bit
Z = 1000100
operands
Chap–III 23
COMPUTER ARCHITECTURE Arithmetic Unit
1 0 1 1 0 1 W6
C4 S4
1 0 1 1 0 0 0 1 0 0 1 1 Level 4 CPA
+
Eg 2: Using Ripple Carry Addition Final Product Carry propagation
O mq mq mq mq mq adder
5 0 4 0 3 0 2 0 1 0
mq mq mq mq mq mq mq
5 1 4 1 3 1 2 1 1 1 0 1 0 0
Example 3
1 0 1 1 0 1 M
FA FA FA F
A FA FA 0
1 1 1 1 1 1 ×
1 0 1 1 0 1 W1
mq mq mq mq mq mq
5 2 4 2 3 2 2 2 1 2 0 2 1 0 1 1 0 1 W2
1 0 1 1 0 1 W3
FA F
A FA FA F
A FA 0 1 1 0 0 0 0 1 1 S1
0 0 1 1 1 1 0 0 C1
mq mq mq mq mq mq
5 3 4 3 3 3 2 3 1 3 0 3
1 0 1 1 0 1 W4
FA FA FA FA FA F
A 0 1 0 1 1 0 1 W5
1 0 1 1 0 1 W6
mq mq mq mq mq mq
5 4 4 4 3 4 2 4 1 4 0 4 1 1 0 0 0 0 1 1 S2
0 0 1 1 1 1 0 0 C2
F
A FA FA FA FA FA 0 1 1 0 0 0 0 1 1 S1
0 0 1 1 1 1 0 0 C1
mq
5 5
mq
4 5
mq
3 5
mq
2 5
mq
1 5
mq
0 5
1 1 0 0 0 0 1 1 S2
1 1 0 1 0 1 0 0 0 1 1 S3
FA FA FA F
A F
A FA 0
0 0 0 0 1 0 1 1 0 0 0 C3
0 0 1 1 1 1 0 0 C2
0 1 0 1 1 1 0 1 0 0 1 1 S4
P P P P P P P P P P P P 0 1 0 1 0 1 0 0 0 0 0 C4
1
1 10 9 8 7 6 5 4 3 2 1 0
Fig. Using Ripple carry addition for 6×6 bits multiplication 1 0 1 1 0 0 0 1 0 0 1 1 Product
Chap–III 24
COMPUTER ARCHITECTURE Arithmetic Unit
Delay through the carry save array is somewhat less than Note
delay through the ripple carry array. It is because the S and C No of CSA levels needed to
vector outputs from each row are produced in parallel in one reduce k summands to 2 vectors = 1.7 log2 k–1.7
full adder delay.
But if bit pair recoding of the multiplier is done instead of
Steps for addition of summands in the multiplication of longer n summands for n × n multiplication, only n/2 summands are
operands produced. This reduces the number of CSA levels required =
1. Group the summands into threes and perform carry save 1.7 log2 k–3.4.
addition to produce S and C vectors in one full adder delay.
Note
2. Group all the S and C vectors into threes and perform carry
save addition to generate further set of S and C vectors in 1. Bit pair recoding of the → reduces the number of summands
one more full adder delay. multiplier by a factor of 2
3. Do the step 2 unitl there are only two vectors remaining. 2. Carry save adder → adds the summands and produces
4. Perform ripple carry addition or carry lookahead addition to only Sum and Carry (2)
produce the desired product. 3. Carry lookahead adder → used to add the final sum and carry.
Delays in carry save addition 3.3.10 Division
For 6 × 6 array multiplier (Eg. given above) Division of two-fixed point binary number in signed
magnitude representation is done by a process of compare, shift
1 gate delay to select the summands based on multiplier bits and subtract operations. Binary division is simpler than decimal
+ division because the quotient digits are either 0 or 1.
6 gate delays (two gate delays for each CSA level) (3 CSA levels)
Consider an example the divisor Y consists of five bits and
+
the dividend X of 10 bits. The five MSB bits of the dividend
8 gate delays (for carry lookahead addition Final addt of C&S are compared with the divisor. Since the five bit number is
15 gate delay smaller than Y we try again by taking 6 MSB bits of X and
compare this number with Y. The 6 bit number is greater than
For the same 6 × 6 array multiplication, the delay when Y, so we place a 1 for the quotient bit in the 6th position above
ripple carry addition is used is the dividend. The difference is called a partial remainder, because
the division could have stopped here to obtain a quotient of 1
6(n–1)–1 = 6(6–1) = 6(5)–1 and the remainder is equal to the partial remainder. The process
is continued by comparing a partial remainder with the divisor.
= 29 gate delay 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
Thus carry save addition halves the delay when compared and subtracted from the partial remainder. If the partial remainder
to ordinary array multiplier that uses ripple carry addition. is smaller than the divisor, the quotient bit is 0 and no subtraction
Chap–III 25
COMPUTER ARCHITECTURE Arithmetic Unit
is needed. The divisor is shifted once to the right in any case. The best way to avoid a divide overflow is to use floating-
The result gives both a quotient and remainder. point data.
Division Overflow (i) Example 1
1 1 0 1 0 Divisor B = 10001
The division operation may result in a quotient with a 1 0 0 0 1 0 1 1 1 0 0 0 0 0 0 Quotient Q
overflow, i.e. when the operation is implemented with hardware
Dividend A
this is because the length of the register is finite and will not
hold the number that exceeds the standard length. The divide - 1 0 0 0 1 5 bits of A < B, take 6 bits of A
overflow condition must be avoided in normal computer → shift right B & Sub; enter 1 in Q 6 bit
- 0 1 0 1 1 0
operation because the entire quotient will be too long to transfer position
- - 1 0 0 0 1
into memory unit that has words of standard length, that is, 7 bits of remainder > B Shr B & subtract,
- - 0 0 1 0 1 0
same as the length of register. enter 1 in Q
- - - 0 0 1 0 1 0
- - - - 1 0 0 0 1 Remainder < B, enter 0 in Q.
When the dividend is twice as long as the divisor the
- - - - 0 0 0 1 1 0 Remainder >B Shr B and sub enter 1 in Q
condition to overflow can be stated as follows. A divide- - - - - - 0 0 0 1 1
overflow condition occurs if the high order half bits of dividend Remainder < B; enter 0 in Q
constitute a number greater than or equal to the divisor. Another Quotient → 11010 Shr B, Final remainder
fact associated with division is the fact that the division with Remainder → 00011
Zero is avoided. The divide overflow condition takes care of
this condition as well. This occurs because any dividend will (ii) Example 2 Divisor B = 0101
be greater than or equal to a divisor, which is equal to zero. 1 1 1 1 0 1
Dividend A
Overflow condition is usually detected when the special FF is 0101 1 0 0 1 1 0 0 1 0
Quotient Q
set. We will call it a divide-overflow FF and label it DVF. 0 1 0 1
4 bits of A > B; Sub enter 1 in Q Shr B
1) The occurrence of divide overflow can be handled in a 5 bits of A>B sub enter 1 in Q
variety of ways. In some computer it is the responsibility 0 1 0 0 1 6 bits of A>B ; sub Shr B Enter 1 in Q
of the programmer to check if DVF is set after each - 0 1 0 1 7 bits of A>B ; sub Shr B Enter 1 in Q
(division) divide instruction. They then can branch to a - 0 1 0 0 0 8 bits of A<B ;
subroutine that takes a corrective measure such as rescaling - - 0 1 0 1 Enter 0 in Q
the data to avoid overflow. - - 0 0 1 1 0 Shr B
- - - 0 1 0 1 A>B, sub enter 1 in Q
2) In some olden computers, the occurrence of divide overflow - - - 0 0 0 1 1
stopped the computer and this condition was referred to as - - - - 0 0 1 1 0
divide stop. Stopping the operation of computer is not
- - - - - 0 1 0 1
recommended because it is time consuming. The procedure
in most computers is to provide an interrupt required, when 0 0 0 1
DVF is set. The instruction causes the computer to suspend
the current program and branch to a service routine to Quotient 1 1 1 1 0 1 Remainder 0 0 0 1
take a corrective measure.
Chap–III 26
COMPUTER ARCHITECTURE Arithmetic Unit
Chap–III 27
COMPUTER ARCHITECTURE Arithmetic Unit
formed in register X. The quotient sign is in Qs and sign of the Register Q holds the dividend at the start of operation.
remainder in Xs is same as the original sign of the dividend.
Register X is initially set to 0.
Divide Operation
After division Register Q contains quotient.
Register X contains Remainder
Dividend in XQ
Divisor in Y Algorithm
Divide Magnitude 1. Shift X and Q left one binary position
2. Subtract M from X and place the answer back in X
QsÅXs⊕Ys Shl EXQ
3. If the sign of X is 1, set q0 to 0 and add M back to X
= 0 = 1 (restore X); otherwise set q0 to 1.
E
10
EXÅX+Y+1 11 1 0 0 0 8 Quotient = 2
3 2.2
EXÅX+Y+1 XÅX+Y+1 Reminder = 2
11
=1 =0 =1 X≥Y 10
Eg.:
E E
X≥Y X<Y X Q
X<Y QnÅ1
EXÅX+Y EXÅX+Y
Initial Condt 00000 1000
DVFÅ1 DVFÅ0 = 0
EXÅX+Y M 00011
Shift X & Q 00001 000
SCÅ SC -1
Sub M 11101 Cycle I
END
(Divide =0 ≠0 Set q0=0 11110
SC
overflow)
Restore M 00011
00001 0000
END (Quotient is in Q
Remainder is in X) Shift X & Q 00010 000
Sub M 11101
Fig: - Flow chart for divide operation (Restoring Method) Cycle II
Set q0=0 11111
In this configuration, Restore M 00011
Register M holds the divisor 00010 0000
Chap–III 28
COMPUTER ARCHITECTURE Arithmetic Unit
Chap–III 29
COMPUTER ARCHITECTURE Arithmetic Unit
Chap–III 30
COMPUTER ARCHITECTURE Arithmetic Unit
Chap–III 31
COMPUTER ARCHITECTURE Arithmetic Unit
Chap–III 32
COMPUTER ARCHITECTURE Arithmetic Unit
( )
X + Y = Xs×BXE − YE + Ys × BYE
X E ≤ YE E
X = Xs×BXE
( )
X − Y = Xs×BXE − YE − Ys × BYE
X Normalize and
round
Chap–III 33
COMPUTER ARCHITECTURE Arithmetic Unit
Add / Sub 1. Check for zeros
EA = A+B+1 EA A+B
0.2751 × 104
Add/Sub
3. Since the exponents are equal
A A+1 =0
add
E
AS AS =0 0.00523 × 104
=1 E
=1 0.27510 × 104
=0 =0
A
Shr A 0.28033 × 104
=1 A1 E
A1 Implementation Steps
EA EA+1
=0 A 0
Normalize 1. In the figure, the firtst step is to compare expontnets to
Sht A
determine the number of times the mantissa of the smaller
EA EA-1
exponent to be shifter.
2. The shift value n is then given to the shifter unit to shift
END the mantissa of the smaller number.
3. The sign of the exponent after subtraction determines which
The flow chart depicts the generalized approach for add/sub is smaller or which is larger no and thereby to shift the
of floating point numbers. mantissa of the smaller number.
Chap–III 34
COMPUTER ARCHITECTURE Arithmetic Unit
4. The mantissas are added / subtracted. The sign of the result Division
is determined by combinatorial control network. if E′A > E′B
1. Subtract the exponents and add 127.
then sign is positive or if E ′A < E ′B then sign is negative.
2. Divide the mantissas and determine the sign of the result.
5. The result is normalized by truncating the leading zeros and 3. Normalize the resulting value, if necessary.
by subtracting E′ by X, the number of leading zeros.
Divisor in B
Multiplication Dividend in A
1. Add the exponents and subtract 127. =0
B
2. Multiply the mantissas and determine the sign of the result. =0
=0
3. Normalize the resulting value of necessary. A
=0
Multiplicand in B Exponents in a, b, q QS AS + BS
Multiplier in Q Q 0 Q 0
=0 EA A+B+1
B
If B or Q is zero, product in
=1 =0
=0 A is zero Divide A>B E A<B
=0 by A A+B A A+B
Q zero
Exception Sht A
=0
a a +1
a q
a a + bias a a+b+1
a a+b Exponent addition
q a
a a bias
Subtract bias from a
(127) Divide magnitude of mantissa
Chap–III 35
COMPUTER ARCHITECTURE Arithmetic Unit
Similarly, allowing guard bits during intermediate steps results (iii) Rounding Procedure
in extended mantissa. Thus this extended mantissa should be
Rounding achieves the closest approximation to the number
truncated to 24 bits while generating final results.
being truncated and is an unbiased technique 1.A is added to
There are several ways to truncate the LSB position of the bits to be retained if there is a 1 in the
(i) Chopping MSB position of the bits being removed.
(ii) Von-Neumann rouding Eg
(iii) rounding
0.b–1 b–2 b–3 1...... is rounded to
(i) Chopping
0.b–1 b–2 b–3 (+)
Chopping is the simplest way to do truncation. i.e. Remove
the guard bits and make no changes in the retained bits. 0.001
Chap–III 36
COMPUTER ARCHITECTURE Arithmetic Unit
001101
(iii) 0 0 0 1 1 1 000111 + 7
(–) (+) (–) Ashr AQ 000110 100101 1 011
111000 001000 – 8
001111 –1 5 1 1 Ashr AQ 000011 010010 1 010
0 1 Add BR 110011
Cin-1 = 0
0
110110
Cn = 0
Chap–III 37
COMPUTER ARCHITECTURE Arithmetic Unit
+1 0 –1 +1 0 –1 level VI
Totally 6 CSA levels are required to reduce 16 summands to 2.
2’s comp of the multiplicand (110101)
1’s compliment = 001010+1 b)
+1 = 1 L-I
2’s compliment = 0 0 1 0 1 1 L-II
Multiply:
L-III
11 0 1 0 1 ×
L-IV
+1 0 –1 +1 0 –1
L-V
00000001011
L-VI
0000000000
111110101 L-VII
00001011 L-VIII
4. a) How many CSA levels are needed to reduce 16 X − Y = (0.3 × 102− 3 − 0.2 ) × 103 = ( −0.17 ) × 103 = −170
summands to 2.
X × Y = (0.3 × 0.2 ) ×10 2+ 3 = 0.06 × 105 = 6000
b) Draw the pattern for reducing 32 summands to 2 to
prove that the claim of 8 levels is correct. X ÷ Y = (0.3 ÷ 0.2 ) × 102− 3 = 1.5 × 10−1 = 0.15
Chap–III 38
COMPUTER ARCHITECTURE Arithmetic Unit
Chap–III 39
A
9) Derive an algorithm for evaluating the SQRT of a binary 10) Design a 4 bit combinational circuit decrementer using 4 FA’s
fixed point number. Solution
Solution: A3 1 A2 1 A1 1 A0 1
Chap–III 40
COMPUTER ARCHITECTURE Arithmetic Unit
Chap–III 41
COMPUTER ARCHITECTURE Arithmetic Unit
Chap–III 42
COMPUTER ARCHITECTURE Arithmetic Unit
12) Draw a logic circuit which performs both addition and 7) Explain briefly about arithmetic operations?
subtraction. Refer Sec. 3.1
B3 B2 B1 B0 8) Write an algorithm for Addition & Subtraction?
Refer Sec. 3.3.5
9) Explain the Addition (Subtraction) Algorithm:
M Refer Sec. 3.3.5
xor xor xor xor
A3 A2 A1 A0 10) Explain Addition and subtraction with signed 2’s
complement data
FA FA FA FA Refer Sec. 3.3.5.1
C3 C2 C1 C0 11) Write an Multiplication Algorithm ?
Refer Sec. 3.3.7
C4 S3 S2 S1 S0
12) Explain the multiplication algorithm using signed –
Magnitude data
When M =0 The above circuit behaves like a adder.
M=1 The above circuit behaves like a subtractor. Refer Sec. 3.3.7
13) Write an Booth Multiplication Algorithm ?
PART - B
Refer Sec. 3.3.8.1
1) Explain the 4-bit binary adder?
14) Explain Multiplication with Booth Algorithm.
Refer Sec. 3.3.2
Refer Sec. 3.3.8.1
2) Explain the binary adder / sub tractor with a neat block 15) Write briefly about Array multiplier ?
diagram
Refer Sec. 3.3.7.1
Refer Sec.
15) Explain Division Algorithms.
3) Explain the binary incrementer with a neat block Refer Sec. 3.3.10
diagram
16) Explain about Floating-point Arithmetic operations.
Refer Sec.
Refer Sec. 3.3.11
4) Design a 4-bit binary arithmetic circuit 17) Explain about floating point addition/subtraction algorithm.
Refer Sec. 3.3.4 Refer Sec. 3.3.11.2
5) With a neat block diagram fixed point ALU 18) Explain the multiplication of floating point numbers.
Refer Sec. 3.1 Refer Sec. 3.3.11.2
6) Explain the Bit –sliced ALU with a neat block diagram. 19) Explain the Division of two floating point numbers.
Refer Sec. 3.1 Refer Sec. 3.3.11.2
Chap–III 43
COMPUTER ARCHITECTURE Arithmetic Unit
20) Explain briefly about Decimal Arithmetic Unit? Derivation of BCD Adder
A decimal Arithmetic unit is a digital function that performs Binary SUM BCD SUM Decimal
digital micro operation. It can add or subtract decimal no. K Z8 Z4 Z2 Z1 C S8 S4 S2 S1
Usually by forming the 1’s or 10’s complement of the
0 0 0 0 0 0 0 0 0 0 0
subtracted. The unit accepts the coded decimal no and
0 0 0 0 1 0 0 0 0 1 1
generates
0 0 0 1 0 0 0 0 1 0 2
Results in the same adopted binary code. 0 0 0 0 1 1 0 0 1 1 3
A single stage decimal arithmetic unit consists of 9 binary 0 0 1 0 0 0 0 1 0 0 4
input variable and 5-binary output variable, since a min of 0 0 1 0 1 0 0 1 0 1 5
4 bits is required to represent each coded decimal digit. 0 0 1 1 0 0 0 1 1 0 6
Each stage must have 4 inputs for the augends digit, four 0 0 1 1 1 0 0 1 1 1 7
inputs for the addend digit and an input carry. The output includes 0 1 0 0 0 1 0 0 0 0 8
4 terminals for the sum digit and one for the o/p carry. 0 1 0 0 1 1 0 0 0 1 9
BCD adder 0 1 0 1 0 1 0 0 0 0 10
0 1 0 1 1 1 0 0 0 1 11
Consider the arithmetic addition of two decimal digits in
0 1 1 0 0 1 0 0 1 0 12
BCD, together with a possible carry from a previous stage.
0 1 1 0 1 1 0 0 1 1 13
Since each input digit does not exceed 9, the output sum
0 1 1 1 0 1 0 1 0 0 14
can’t be greater than 9+9+1=19, the 1 in the sum being an
0 1 1 1 1 1 0 1 0 1 15
input carry. Suppose we apply two BCD digits to a 4 bit
1 0 0 0 0 1 0 1 1 0 16
binary adder. The adder will form the sum in binary and
1 0 0 0 1 1 0 1 1 1 17
produce the result that may change from 0 to 19.These binary
1 0 0 1 0 1 1 0 0 0 18
number are labeled by K, Z8, Z4, Z2 and Z1.K is the carry
1 0 0 1 1 1 1 0 0 1 19
and the subscripts under the letter Z represents the wt. 8,4,2
and 1 that may be assigned to the 4 bits in the BCD code. One method of adding decimal not in BCD could be to
employ one 4 bit binary adder and perform the arithmetic
The first column in the table lists the binary sums as they
operation one digit at a time. The lower pair of BCD digits
appear in the output of a 4-bit binary adder. The output
is first added to produce a binary sum. If the result is equal
sum of two decimal numbers must be represented in BCD
to or greater than 1010, it is corrected by adding 0110 to
and appear in the 2nd column of the table. It is apparent that
when the binary sum is equal to or less than 1001 the the binary sum. This 2nd operation could automatically
corresponding BCD number is identical and therefore no produce an output carry for the next pair of significant digits.
conversion is needed. When the binary sum is greater than The next higher order pair of digits, together with the input
1001 we obtain a non-valid BCD representation carry is then added to produce their binary sum. If this
Chap–III 44
COMPUTER ARCHITECTURE Arithmetic Unit
Chap–III 45
COMPUTER ARCHITECTURE Arithmetic Unit
A Å A +B + 1 Contents of A plus 10’s 1. The parallel method uses a decimal arithmetic unit composed
complement of B into A of as many BCD adders as there are digits in the number.
The sum is formed in parallel and required only one micro
QL Å QL + 1 Increment BCD number in QL
operation.
d Shr A Decimal shift right A 0110 00 1 1 0 1 00
d Shl A Decimal shift left A
1000 0111 1001
Incrementing or decrement the register is same for binary
and decimal except for the number of states that the register
is allowed to have. A decimal counter goes through 10 states
from 0000 to 1001 and back to 0000, since 9 is the last BCD Adder BCD Adder BCD Adder
count. A binary counter goes through 16 states from 0000
to 1111 when incremented and from 1111 to 0000 when 1 0 1 0 1 0 0 0 0 0 0 1 1
decremented.
Fig: -Parallel addition (decimal) 624 + 879 = 1503
A decimal shift right or left is preceded by the letter by the
2. In the digit – serial bit – parallel method the digits and
letter d to indicate that a shift over the 4-bits that a shift
applied to the single BCD adder serially; while the bits of
is over the 4-bits that hold the decimal digits.
each coded digit will be transferred in parallel. The sum is
Ex:- Reg A Æ 7860 in BCD. bit pattern is 0111 1000 0110 formed by shifting the decimal no thru BCD adder one at
0000 a time for k decimal digits this configuration required k
Then the micro operation d shr A Æ Shift the decimal micro operation one for each decimal shift.
number to the right to give 0786. This shift is over 4-bits Augend Sum
and changes the content of the register.
0 0 0
0
000 0111 1000 0110 1 0 1 0
1 1 0 BCD 1
22) Explain BCD Addition & Subtraction in binary-signed
0 0 0 Adder 1
magnitude form?
The algorithm for addition and subtraction of binary signed- 1 0 1
0 1 0
magnitude number applies also to decimal signed-magnitude 0 1 0
number provided that we interpret the micro operation 0 1 1
symbols in the proper manner. Similarly the algorithm for 1
binary 2’s complement number applies to decimal signed Addend Carry
10’s complement number.
Decimal data can be added in three different ways. Fig:- Digit-Serial –Bit Parallel
Chap–III 46
COMPUTER ARCHITECTURE Arithmetic Unit
3. In the all serial adder, the bits are shifted one at a time thru The register organization for the decimal multiplication is
a full adder. The bin sum formed after 4 shifts must be shown below. We are assuming here 4 digits no., with each
corrected in to a valid BCD digit. This correct consists of digit occupying four bits, for a total of 16 bits for each no.
checking the binary sum. If it is greater than or equal to There are 3 register, A, B and Q each having corresponding
1010, the binary sum is corrected by adding to it 0110 and sign FF As, Bs and Qs. Register A and B have four more
bits designated by Ae and Be that provide an extension of
generating a carry for the next pain of digits.
one more digit to the Reg. The BCD arithmetic unit adds
Augend the 5 digits in 11le and places the sum in the 5-digit A
Reg. The end carry goes to FF E. The purpose Ae is to
0110 001 010 S
0 0 FA accommodate an overflow while adding the multiplicand to
C the partial product during the multiplication. The purpose of
1000 011 100 digit Be is to form the 9’s comp of the divisor when
Correction
1 1 subtracted from the partial remainder during the division
op~. The least significant digit in register Q is Ql.
Addend
B
Carry
Chap–III 47
COMPUTER ARCHITECTURE Arithmetic Unit
in B is added to the partial product in A once and QL is Next the partial product and the multiplier are shifted once
decremented QL is checked again and the process is repeated to the right. This places zero in Ae and transfers the next
until it is equal to 0. In this way the multiplicand in B is multiplier quotient in to QL. The process is then repeated
added to the partial product a no of times equal to the k times to form a double length product in AQ.
multiplier digit. Any temp overflow digit will reside in Ae
24) Explain BCD Division algorithm in binary-signed
and can range in value from 0 to 9.
magnitude form?
Multiply
Decimal Division is similar to binary Division except that
quotient digits may have any of the 10 values from 0 to 9.
Multiplicand in B In the restoring division method, the division is subtracted
Multiplier in Q from the dividend on partial remainder as may times as
necessary until a negative remainder results. The correct
remainder is then restored by adding the divisor.The decimal
As Å Qs ⊕ Bs Division algorithm is similar to binary algorithm except that
AÅ 0, Be Å 0 the way the quotient bits are formed. The dividend is shifted
SC Å K
to the left (or partial remainder) with its most significant
digit placed in Ae. The divisor is then subtracted by adding
the 10’s complement value. Since Be is initially cleared, it’s
≠0
complement value is 9 as reg. The carry in E determine the
relative magnitude of A and B. If E = 0, it signifies that
A<B. In this case the divisor is added to restore the partial
QL
remainder and QL stays at 0. (Inserted there during the
slight.). It E =1 it signifies that A>B. The quotient digit in
AÅA+B
=0 Ql Å Ql -1 Ql is incremented and divisor is subtracted again. This
d Shr AQ process is repeated until the sub~ results in a negative
SC Å SC -1 difference which is recognized by E being 0. When in this
occurs the quotient restore the positive remainder. In this
way the quotient digit is made equal to the number of times
≠0 that the partial remainder ‘goes’ in to the divisor.
SC
The partial remainder and the quotient bits are shifted once
to the left and the process is repeated k times to form k
END quotient digits. The remainder is then found in the register
(Product is in AQ) A and the quotient is in register Q. The value of E is
Fig: -Flow chart for Decimal Multiplication neglected.
Chap–III 48
COMPUTER ARCHITECTURE Arithmetic Unit
Product
Fig: - Flow Chart for decimal Division
Chap–III 49