21CSS201T Coa Unit 3 Notes
21CSS201T Coa Unit 3 Notes
& Architecture:
21CSC202J
Unit 2 : HALF ADDER
(Computer Organisation by Carl Hamacher)
What is a Half Adder?
A combinational logic circuit which is designed to add two
binary digits is known as half adder. The half adder
provides the output along with a carry value (if any). The
half adder circuit is designed by connecting an EX-OR gate
and one AND gate. It has two input terminals and two
output terminals for sum and carry.
HALF ADDER
In case of half adder, the output of the EX-OR
gate is the sum of two bits while the output of
the AND gate is the carry. However, the carry
obtained is one addition will not be forwarded in
the next addition, so it is called half adder.
The output equations of the half adder are −
Sum,S=A⊕B
Carry,C=A.B
FULL ADDER
si = xi yi ci + xi yi ci + xi yi ci + xi yi ci = x i yi c i
c i +1 = yi c i + x i ci + x i y i
E xample:
X 7 0 1 1 1 Carry-out xi Carry-in
+ Y = +6 = + 00 1 1 1 1 0 0 0 yi
c i+1 ci
Z 13 1 1 0 1 si
ci + 1 Full adder ci
(FA)
s
i
Full Adder (FA): Symbol for the complete circuit for a single stage of addition.
n-bit adder
•Cascade n full adder (FA) blocks to form a n-bit adder.
•Carries propagate or ripple through this cascade, n-bit ripple carry adder.
x y x y x y
n- 1 n- 1 1 1 0 0
c c
n- 1 1
c FA FA FA c
n 0
s s s
n- 1 1 0
Most significant bit Least significant bit
(MSB) position (LSB) position
cn
n-bit n-bit n-bit c
c kn 0
adder adder adder
s s( s s s s
kn - 1 k - 1) n 2n - 1 n n- 1 0
x y x y x y
n- 1 n- 1 1 1 0 0
c c
n- 1 1
c
n FA FA FA 1
s s s
n- 1 1 0
x x x
n- 1 1 0
c n-bit adder
n c
0
s s s
n- 1 1 0
Overflow = cn cn−1
Computing the add time
x0 y0
Consider 0th stage:
•c1 is available after 2 gate delays.
•s1 is available after 1 gate delay.
c1 FA c0
s0
Sum Carry
yi
c
i
xi
xi
yi si c
c i +1
i
ci
x
i
yi
Computing the add time (contd..)
Cascade of 4 Full Adders, or a 4-bit adder
x0 y0 x0 y0 x0 y0 x0 y0
FA FA FA FA c0
c4 c3 c2 c1
s3 s2 s1 s0
si = xi yi ci
ci +1 = xi yi + xi ci + yi ci
Second equation can be written as:
ci +1 = xi yi + ( xi + yi )ci
We can write:
ci +1 = Gi + Pi ci
where Gi = xi yi and Pi = xi + yi
c4
c
3
c
2
c
1
. c
4-bit
carry-lookahead
B cell B cell B cell B cell 0
adder
s s s s
3 2 1 0
G3 P3 G2 P2 G P G P
1 1 0 0
Carry-lookahead logic
xi yi
. .
. c
i
G i
P i
si
Carry lookahead adder (contd..)
Last AND gate and OR gate require a fan-in of (n+1) for a n-bit
adder.
For a 4-bit adder (n=4) fan-in of 5 is required.
Practical limit for most gates.
P0I = P3 P2 P1 P0
G0I = G3 + P3 G2 + P3 P2 G1 + P3 P2 P1G0
Subscript I denotes the blocked carry lookahead and identifies the block.
c16 = G3I + P3I G2I + P3I P2I G1I + P3I P2I P10 G0I + P3I P2I P10 P00 c0
Blocked Carry-Lookahead adder
x15-12 y15-12 x11-8 y11-8 x7-4 y7-4 x3-0 y3-0
c 16 4-bit adder
c 12
4-bit adder
c8
4-bit adder
c4
4-bit adder . c0
G3I P3I G2 I P 2I G 1I P 1I G 0I P0 I
Carry-lookahead logic
0 m3 0 m2 0 m1 0 m0
(PP0)
q0
0
PP1 p0
q1
0
PP2 p1
q2
0
PP3 p2
q3
0
,
p7 p6 p5 p4 p3
Shift right
C a a q q
n - 1 0 n - 1 0
Multiplier Q
Add/Noadd
control
n-bit
Adder Control Sequencer
MUX
(Shift and add
control logic)
0 0
m m
n - 1 0
Multiplicand M
Sequential multiplication (contd..)
M
1 1 0 1
Initial configuration
0 0 0 0 0 1 0 1 1
C A Q
0 1 1 0 1 1 0 1 1 Add
Shift First cycle
0 0 1 1 0 1 1 0 1
1 0 0 1 1 1 1 0 1 Add
Shift Second cycle
0 1 0 0 1 1 1 1 0
0 1 0 0 1 1 1 1 0 No add
Shift Third cycle
0 0 1 0 0 1 1 1 1
1 0 0 0 1 1 1 1 1 Add
Shift Fourth cycle
0 1 0 0 0 1 1 1 1
Product
Computer Organization
& Architecture:
21CSC202J
Unit 2 : Arithmetic
Chapter 6
(Computer Organisation by Carl Hamacher)
Multiplication of positive numbers
Multiplication of unsigned numbers
0 m3 0 m2 0 m1 0 m0
(PP0)
q0
0
PP1 p0
q1
0
PP2 p1
q2
0
PP3 p2
q3
0
,
p7 p6 p5 p4 p3
Shift right
C a a q q
n - 1 0 n - 1 0
Multiplier Q
Add/Noadd
control
n-bit
Adder
MUX Control
sequencer
0 0
m m
n - 1 0
Multiplicand M
Sequential multiplication (contd..)
M
1 1 0 1
Initial configuration
0 0 0 0 0 1 0 1 1
C A Q
0 1 1 0 1 1 0 1 1 Add
Shift First cycle
0 0 1 1 0 1 1 0 1
1 0 0 1 1 1 1 0 1 Add
Shift Second cycle
0 1 0 0 1 1 1 1 0
0 1 0 0 1 1 1 1 0 No add
Shift Third cycle
0 0 1 0 0 1 1 1 1
1 0 0 0 1 1 1 1 1 Add
Shift Fourth cycle
0 1 0 0 0 1 1 1 1
Product
EXAMPLE
Computer Organization
& Architecture:
21CSC202J
Unit 2 : Arithmetic
Chapter 6
(Computer Organisation by Carl Hamacher)
Signed Multiplication
Signed Multiplication
⚫ Considering 2’s-complement signed operands, what will happen to
(-13)(+11) if following the same method of unsigned multiplication?
1 0 0 1 1 ( - 13)
0 1 0 1 1 ( + 11)
1 1 1 1 1 1 0 0 1 1
1 1 1 1 1 0 0 1 1
Sign extension is
shown in blue 0 0 0 0 0 0 0 0
1 1 1 0 0 1 1
0 0 0 0 0 0
1 1 0 1 1 1 0 0 0 1 ( - 143 )
0 1 1 0 1 ( + 13) 0 1 1 0 1
X1 1 0 1 0 (- 6 ) 0 - 1 +1 - 1 0
0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 0 0 1 1
0 0 0 0 1 1 0 1
1 1 1 0 0 1 1
0 0 0 0 0 0
1 1 1 0 1 1 0 0 1 0 ( - 78 )
Multiplier
Version of multiplicand
selected by biti
Bit i Bit i -1
0 0 0 XM
0 1 + 1 XM
1 0 − 1 XM
1 1 0 XM
0 1 1 0 1 ( + 13) 0 1 1 0 1
X1 1 0 1 0 (- 6 ) 0 - 1 +1 - 1 0
0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 0 0 1 1
0 0 0 0 1 1 0 1
1 1 1 0 0 1 1
0 0 0 0 0 0
1 1 1 0 1 1 0 0 1 0 ( - 78 )
0 0 0 0 X M
0 0 1 + 1 X M
0 1 0 + 1 X M
0 1 1 + 2 X M
1 0 0 −2 X M
1 0 1 −1 X M
1 1 0 −1 X M
1 1 1 0 X M
0 1 1 0 1
0 -1 -2
1 1 1 1 1 0 0 1 1 0
1 1 1 1 0 0 1 1
0 0 0 0 0 0
1 1 1 0 1 1 0 0 1 0
10
P7 P6 P5 P4 P3 P2 P1 P0
Carry-Save Addition of
Summands(Cont.,)
P7 P6 P5 P4 P3 P2 P1 P0
Carry-Save Addition of
Summands(Cont.,)
⚫ Consider the addition of many summands,
we can:
➢ Group the summands in threes and perform carry-save addition on
each of these groups in parallel to generate a set of S and C vectors
in one full-adder delay
➢ Group all of the S and C vectors into threes, and perform carry-save
addition on them, generating a further set of S and C vectors in one
more full-adder delay
➢ Continue with this process until there are only two vectors remaining
➢ They can be added in a RCA or CLA to produce the desired product
CARRY SAVE ADDITION OF
SUMMANDS
EXAMPLE: 110110*101101
Computer Organization
& Architecture:
21CSC202J
Unit 2 : Arithmetic
Chapter 6
(Computer Organisation by Carl Hamacher)
Integer Division
Manual Division
21 10101
13 274 1101 100010010
26 1101
14 10000
13 1101
1 1110
1101
1
an an-1 a0 qn-1 q0
Dividend Q
A Quotient
Setting
0 mn-1 m0
Divisor M
Shift 0 0 0 1 0 0 0 0 1
Subtract 1 1 1 0 1 0 0 1
Set q0 1 1 1 1 1 Fourth cycle
Restore 1 1
0 0 0 1 0 0 0 1 0
Remainder Quotient
Shift 1 1 1 0 0 0 0 0
Add 0 0 0 1 1 Second cycle
Set q 1 1 1 1 1 0 0 0 0
0
Shift 1 1 1 1 0 0 0 0
1 1 1 1 1 Add 0 0 0 1 1 Third cycle
Restore
0 0 0 1 1 Set q 0 0 0 0 1 0 0 0 1
remainder 0
Add 0 0 0 1 0
Remainder Shift 0 0 0 1 0 0 0 1
Subtract 1 1 1 0 1 Fourth cycle
Set q 1 1 1 1 1 0 0 1 0
0
Quotient
A nonrestoring-division example.
EXAMPLE: NON RESTORING
DIVISION
Computer Organization
& Architecture:
21CSC202J
Unit 2 : Arithmetic
Chapter 6
(Computer Organisation by Carl Hamacher)
Floating-Point Numbers
and
Operations
Fractions
If b is a binary vector, then we have seen that it can be interpreted as
an unsigned integer by:
Suppose if the binary vector is interpreted with the implicit binary point is
just left of the sign bit:
implicit binary point .b31b30b29....................b1b0
0 V (b) 1 − 2− n
Scientific notation
•Previous representations have a fixed point. Either the point is to the
immediate right or it is to the immediate left. This is called Fixed point
representation.
•Fixed point representation suffers from a drawback that the representation
can only represent a finite range (and quite small) range of numbers.
x = m1 .m2 m3 m4 b e
Components of these numbers are:
x = 0.m1 m2 m3 m4 m5 m6 m7 b e
1 7 24
If the number is shifted so that as many significant digits are brought into
7 available slots:
x = 0.4056781 x 109 = 0.0004056 x 1012
0001101000(10110) x 28 = 1101000101(10) x 25
Normalization (contd..)
•A floating point number is in normalized form if the most significant
1 in the mantissa is in the most significant bit of the mantissa.
•All normalized floating point numbers in this system will be of the form:
0.1xxxxx.......xx
x = m 16e
Then:
y = (m.16) .16e-1 (m.24) .16e-1 = m . 16e = x
This enables efficient comparison of the relative sizes of two floating point
numbers.
IEEE notation
IEEE Floating Point notation is the standard representation in use. There are
two representations:
- Single precision.
- Double precision.
Both have an implied base of 2.
Single precision:
- 32 bits (23-bit mantissa, 8-bit exponent in excess-127 representation)
Double precision:
- 64 bits (52-bit mantissa, 11-bit exponent in excess-1023 representation)
Fractional mantissa, with an implied binary point at immediate left.
This is because the IEEE uses the exponents -127 and 128 (and -1023 and
1024), that is the actual values 0 and 255 to represent special conditions:
- Exact zero
- Infinity
Floating point arithmetic
Addition:
3.1415 x 108 + 1.19 x 106 = 3.1415 x 108 + 0.0119 x 108 = 3.1534 x 108
Multiplication:
3.1415 x 108 x 1.19 x 106 = (3.1415 x 1.19 ) x 10(8+6)
Division:
3.1415 x 108 / 1.19 x 106 = (3.1415 / 1.19 ) x 10(8-6)
⚫ Rounding:
⚫ If there is a 1 in the MSB of the guard bit then a 1 is added to the LSB of
the retained bits.
Rounding
⚫ Rounding is evidently the most accurate
truncation method.
⚫ However,
⚫ Rounding requires an addition operation.
⚫ Rounding may require a renormalization, if the addition operation de-
normalizes the truncated number.