SlideShare ist ein Scribd-Unternehmen logo
1 von 74
Chapter 4
Arithmatic
By Aniket Bhute
aniket.bhute96@gmail.com
si  =
ci +1 =
13
7
+ Y
1
0
0
0
1
0
1
1
0
0
1
1
0
1
1
0
0
1
1
0
1
0
0
1
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
Example:
1
0= = 0
0
1 1
1
1 1 0 0
1
1 1 10
Legend for stage i
xi yi Carry­in ci Sum si Carry­out ci+1
X
Z
+ 6 0+
xi
yi
si
Carry­out
ci+1
Carry­in
ci
xi
yi
ci
xi
yi
ci
xi
yi
ci
xi
yi
ci xi yi ci⊕ ⊕=+ + +
yi
ci
xi
ci
xi
yi+ +
At the ith
stage:
Input:
ci is the carry-in
Output:
si is the sum
ci+1 carry-out to (i+1)st
state
Full adder
(FA)
ci
ci 1+
s
i
Sum Carry
yi
xi
c
i
yi
xi
c
i
yi
x
i
xi
ci
yi
si
c
i 1+
Full Adder (FA): Symbol for the complete circuit
for a single stage of addition.
•Cascade n full adder (FA) blocks to form a n-bit adder.
•Carries propagate or ripple through this cascade, n-bit ripple carry adder.
FA c0
y1
x1
s1
FA
c1
y0
x0
s0
FA
cn 1­
yn 1­
xn 1­
cn
sn 1­
Most significant bit
(MSB) position
Least significant bit
(LSB) position
Carry-in c0 into the LSB position provides a convenient way to
perform subtraction.
K n-bit numbers can be added by cascading k n-bit adders.
n­bit c
0
yn
xn
s
n
cn
y0
xn 1­
s
0
ckn
s
k 1­( )n
x0
yn 1­
y2n 1­
x2n 1­
ykn 1­
s
n 1­
s
2n 1­
s
kn 1­
xkn 1­
adder
n­bit
adder
n­bit
adder
Each n-bit adder forms a block, so this is cascading of blocks.
Carries ripple or propagate through blocks, Blocked Ripple Carry Adder
FA 1
y1
x1
s1
FA
c1
y0
x0
s0
FA
cn 1­
yn 1­
xn 1­
cn
sn 1­
Most significant bit
(MSB) position
Least significant bit
(LSB) position
•Recall X – Y is equivalent to adding 2’s complement of Y to X.
•2’s complement is equivalent to 1’s complement + 1.
•X – Y = X + Y + 1
•2’s complement of positive and negative numbers is computed similarly.
Add/Sub
control
n­bit adder
x
n 1­
x
1
x
0
c
n
s
n 1­ s
1
s
0
c
0
y
n 1­
y
1
y
0
•Add/sub control = 0, addition.
•Add/sub control = 1, subtraction.
Detecting overflows
Overflows can only occur when the sign of the two operands
is the same.
Overflow occurs if the sign of the result is different from the
sign of the operands.
Recall that the MSB represents the sign.
xn-1, yn-1, sn-1represent the sign of operand x, operand y and result s
respectively.
Circuit to detect overflow can be implemented by the
following logic expressions:
111111 −−−−−− += nnnnnn syxsyxOverflow
1−⊕= nn ccOverflow
Consider 0th
stage:
x0
y0
c0
c1
s0
FA
•c1 is available after 2 gate delays.
•s1 is available after 1 gate delay.
c
i
yi
xi
c
i
yi
x
i
xi
ci
yi
si
c
i 1+
Sum Carry
x0
y0
s2
FA
x0 y0x0
y0
s1
FA
c2
s0
FA
c1c3
c0
x0
y0
s3
FA
c4
Cascade of 4 Full Adders, or a 4-bit adder
•s0 available after 1 gate delays, c1 available after 2 gate delays.
•s1 available after 3 gate delays, c2 available after 4 gate delays.
•s2 available after 5 gate delays, c3 available after 6 gate delays.
•s3 available after 7 gate delays, c4 available after 8 gate delays.
For an n-bit adder, sn-1 is available after 2n-1 gate delays
cn is available after 2n gate delays.
Recall the equations:
iiiiiii
iiii
cycxyxc
cyxs
++=
⊕⊕=
+1
Second equation can be written as:
iiiiii cyxyxc )(1 ++=+
We can write:
iiiiii
iiii
yxPandyxGwhere
cPGc
+==
+=+1
•Gi is called generate function and Pi is called propagate function
•Gi and Pi are computed only from xi and yi and not ci, thus they can
be computed in one gate delay after X and Y are applied to the
inputs of an n-bit adder.
ci+1 = Gi + Pi ci
ci = Gi−1 + Pi −1ci −1
⇒ ci+1 = Gi + Pi (Gi −1 + Pi−1ci−1)
continuing
⇒ ci+1 = Gi + Pi (Gi −1 + Pi−1(Gi− 2 + Pi− 2ci −2 ))
until
ci+1 = Gi + PiGi−1 + PiPi−1Gi −2 + .. + Pi Pi−1..P1G0 + PiPi−1...P0c0
•All carries can be obtained 3 gate delays after X, Y and c0 are applied.
-One gate delay for Pi and Gi
-Two gate delays in the AND-OR circuit for ci+1
•All sums can be obtained 1 gate delay after the carries are
computed.
•Independent of n, n-bit addition requires only 4 gate delays.
•This is called Carry Lookahead adder.
Carry­lookahead logic
B cell B cell B cell B cell
s
3
P3
G3
c
3
P2
G2
c
2
s
2
G
1
c
1
P
1
s
1
G
0
c
0
P
0
s
0
.c4
x
1
y
1
x
3
y
3
x
2
y
2
x
0
y
0
G i
c
i
..
.
P i
s i
x i
y i
B cell
4-bit
carry-lookahead
adder
B-cell for a single stage
Carry lookahead adder (contd..)
Performing n-bit addition in 4 gate delays independent of n
is good only theoretically because of fan-in constraints.
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.
In order to add operands longer than 4 bits, we can cascade
4-bit Carry-Lookahead adders. Cascade of Carry-Lookahead
adders is called Blocked Carry-Lookahead adder.
ci+1
= Gi
+ Pi
Gi −1
+ Pi
Pi−1
Gi−2
+ .. + Pi
Pi−1
..P1
G0
+ Pi
Pi−1
...P0
c0
c4 = G3 + P3G2 + P3P2G1 + P3P2 P1G0 + P3P2 P1P0c0
Carry-out from a 4-bit block can be given as:
Rewrite this as:
P0
I
= P3P2 P1P0
G0
I
= G3 + P3G2 + P3P2G1 + P3P2P1G0
Subscript I denotes the blocked carry lookahead and identifies the block.
Cascade 4 4-bit adders, c16 can be expressed as:
c16 = G3
I
+ P3
I
G2
I
+ P3
I
P2
I
G1
I
+ P3
I
P2
I
P1
0
G0
I
+ P3
I
P2
I
P1
0
P0
0
c0
Carry­lookahead logic
4­bit adder 4­bit adder 4­bit adder 4­bit adder
s15­12
P3
IG3
I
c12
P2
IG2
I
c8
s11­8
G1
I
c4
P1
I
s7­4
G0
I
c0
P0
I
s3­0
c16
x15­12
y15­12
x11­8
y11­8
x7­4
y7­4
x3­0
y3­0
.
After xi, yi and c0 are applied as inputs:
- 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)
Product of 2 n-bit numbers is at most a 2n-bit number.
Unsigned multiplication can be viewed as addition of shifted
versions of the multiplicand.
Multiplication of unsigned
numbers (contd..)
We added the partial products at end.
Alternative would be to add the partial products at each stage.
Rules to implement multiplication are:
If the ith
bit of the multiplier is 1, shift the multiplicand and add the
shifted multiplicand to the current value of the partial product.
Hand over the partial product to the next stage
Value of the partial product at the start stage is 0.
ith
multiplier bit
carry incarry out
jth
multiplicand bit
ith
multiplier bit
Bit of incoming partial product (PPi)
Bit of outgoing partial product (PP(i+1))
FA
Typical multiplication cell
M
ultiplier
Multiplicand
m3 m2 m1 m00 0 0 0
q3
q2
q1
q0
0
p2
p1
p0
0
0
0
p3p4p5p6p7
PP1
PP2
PP3
(PP0)
,
Product is: p7,p6,..p0
Multiplicand is shifted by displacing it through an array of adders.
Combinatorial array multiplier
Combinatorial array multiplier
(contd..)
Combinatorial array multipliers are:
 Extremely inefficient.
 Have a high gate count for multiplying numbers of practical size such as 32-
bit or 64-bit numbers.
 Perform only one function, namely, unsigned integer product.
Improve gate efficiency by using a mixture of
combinatorial array techniques and sequential
techniques requiring less combinational logic.
Sequential multiplication
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 left when added to the partial product.
However, adding a left-shifted multiplicand to an
unshifted partial product is equivalent to adding an
unshifted multiplicand to a right-shifted partial
product.
q
n 1­
m
n 1­
n-bit
Adder
Multiplicand M
Control
sequencer
Multiplier Q
0
C
Shift right
Register A  (initially 0)
Add/Noadd
control
a
n 1­
a
0
q
0
m
0
0
MUX
1   1   1   1
1   0   1   1
1   1   1   1
1   1   1   0
1   1   1   0
1   1   0   1
1   1   0   1
Initial configuration
Add
M
1   1   0   1
C
First cycle
Second cycle
Third cycle
Fourth cycle
No add
Shift
Shift
Add
Shift
Shift
Add
1   1   1   1
0
0
0
1
0
0
0
1
0
0   0   0   0
0   1   1   0
1   1   0   1
0   0   1   1
1   0   0   1
0   1   0   0
0   0   0   1
1   0   0   0
1   0   0   1
1   0   1   1
QA
Product
Signed Multiplication
Considering 2’s-complement signed operands, what will happen to (-
13)×(+11) if following the same method of unsigned multiplication?
Sign extension of negative multiplicand.
1
0
11 11 1 1 0 0 1 1
110
110
1
0
1000111011
000000
1100111
00000000
110011111
13­( )
143­( )
11+( )
Sign extension is
shown in blue
Signed Multiplication
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.
Booth AlgorithmConsider in a multiplication, the multiplier is positive
0011110, how many appropriately shifted versions of
the multiplicand are added in a standard procedure?
0
0 0
1 0 1 1 0 1
0
0 0 0 0 0 0
1
0
011010
1011010
1011010
1011010
0000000
000000
011000101010
0
00
1+ 1+ 1+ 1+
Booth Algorithm
Since 0011110 = 0100000 – 0000010, if we use the
expression to the right, what will happen?
0
1
0 1 0 1 1 1
0000
00000000000000
1 1 1 1 1 1 1 0 1 0 0 1
00
0
0 0 0 1 0 1 1 0 1
0 0 0 0 0 0 0 0
0110001001000 1
2's complement of
the multiplicand
0
0
0
0
1+ 1­
0
0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0
Booth Algorithm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.
Booth recoding of a multiplier.
001101011100110100
00000000 1+ 1­1­1+1­1+1­1+1­1+
Booth Algorithm
Booth multiplication with a negative multiplier.
01
0
1 1 1 1 0 1 1
0 0 0 0 0 0 0 0 0
00
0110
0 0 0 0 1 1 0
1100111
0 0 0 0 0 0
01000 11111
1
10 1 1 0 1
1 1 0 1 0 6­( )
13+( )
X
78­( )
+11­ 1­
Booth Algorithm
Multiplier
Bit i Bit i 1­
V ersion of multiplicand
selected by biti
0
1
0
0
01
1 1
0  M
1+  M
1−  M
0  M
Booth multiplier recoding table.
X
X
X
X
Booth Algorithm
Best case – a long string of 1’s (skipping over 1s)
Worst case – 0’s and 1’s are alternating
1
0
1110000111110000
001111011010001
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
0
000000000000
00000000
1­ 1­ 1­ 1­ 1­ 1­ 1­ 1­
1­ 1­ 1­ 1­
1­1­
1+ 1+ 1+ 1+ 1+ 1+ 1+ 1+
1+
1+1+1+
1+
Worst­case
multiplier
Ordinary
multiplier
Good
multiplier
Bit-Pair Recoding of Multipliers
Bit-pair recoding halves the maximum number of
summands (versions of the multiplicand).
1+1−
(a)  Example of bit­pair recoding derived from Booth recoding
0
000
1 1 0 1 0
Implied 0 to right of LSB
1
0
Sign extension
1
21− −
−
Bit-Pair Recoding of Multipliers
i 1+ i 1
(b) Table of multiplicand selection decisions
selected at position i
MultiplicandMultiplier bit­pair
i
0
0
1
1
1
0
1
0
1
1
1
1
0
0
0
1
1
0
0
1
0
0
1
Multiplier bit on the right
0 0 X  M
1+
1
1+
0
1
2
2+
−
−
−
−
X  M
X  M
X  M
X  M
X  M
X  M
X  M
Bit-Pair Recoding of Multipliers
39
1­
0000
1 1 1 1 1 0
0 0 0 0 11
1 1 1 1 10 0
0 0 0 0 0 0
0000 111111
0 1 1 0 1
0
1 010011111
1 1 1 1 0 0 1 1
0 0 0 0 0 0
1 1 1 0 1 1 0 0 1 0
0
1
0 0
1 0
1
0 0
0
0 1
0
0 1
10
0
010
0 1 1 0 1
11
1­
6­( )
13+( )
1+
78­( )
1­ 2­
×
Figure 6.15.  Multiplication requiring only n/2 summands.
Carry-Save Addition of Summands
CSA speeds up the addition process.
40P7 P6 P5 P4 P3 P2 P1 P0
Carry-Save Addition of Summands(Cont.,)
P3 P2 P1 P0P5 P4P7 P6
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
Figure 6.17.  A multiplication example used to illustrate carry­save addition as shown in Figure 6.18.
100 1 11
100 1 11
100 1 11
11111 1
100 1 11 M
Q
A
B
C
D
E
F
(2,835)
X
(45)
(63)
100 1 11
100 1 11
100 1 11
000 1 11 111 0 00 Product
Figure 6.18. The multiplication example from Figure 6.17 performed using
carry­save addition.
00000101 0 10
10010000 1 11 1
+
1000011 1
10010111 0 10 1
0110 1 10 0
00011010 0 00
10001011 1 0 1
110001 1 0
00111100
00110 1 10
11001 0 01
100 1 11
100 1 11
100 1 11
00110 1 10
11001 0 01
100 1 11
100 1 11
100 1 11
11111 1
100 1 11 M
Q
A
B
C
S
1
C
1
D
E
F
S
2
C
2
S1
C
1
S2
S
3
C3
C2
S4
C
4
Product
x
Manual Division
 Longhand division examples.
1101
1
13
14
26
21
274 100010010
10101
1101
1
1110
1101
10000
13   1101
Longhand Division Steps
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.
Circuit Arrangement
Figure 6.21. Circuit arrangement for binary division.
qn­1
Divisor M
Control
Sequencer
Dividend Q
Shift left
N+1 bit 
adder
q0
Add/Subtract
Quotient
Setting
A
m00 mn­1
a0an
an­1
Restoring Division
Shift A and Q left one binary position
Subtract M from A, and place the answer back in A
If the sign of A is 1, set q0 to 0 and add M back to A
(restore A); otherwise, set q0 to 1
Repeat these steps n times
Examples
10111
Figure 6.22. A restoring­division example.
1 1 1 1 1
01111
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1 01
11
1 1
01
0001
Subtract
Shift
Restore
1 0000
1 0000
1 1
Initially
Subtract
Shift
10111
10000
11000
00000
Subtract
Shift
Restore
10111
01000
10000
1 1
QuotientRemainder
Shift
10111
1 0000
Subtract
Second cycle
First cycle
Third cycle
Fourth cycle
0
0
0
0
0
0
1
0
1
10000
1 1
1 0000
11111
Restore
q0Set
q0Set
q0Set
q0Set
Nonrestoring Division
Avoid the need for restoring A after an
unsuccessful subtraction.
Any idea?
Step 1: (Repeat n times)
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, if the sign of A is 0, set q0 to 1; otherwise, set q0 to 0.
Step2: If the sign of A is 1, add M to A
Examples
 A nonrestoring­division example.
Add
Restore
 remainder
Remainder
0 0 0 01
1 1 1 1 1
0 0 0 1 1
1
Quotient
0 0 1 01 1 1 1 1
0 0 0 01 1 1 1 1
Shift 0 0 0
11000
01111
Add
0 0 0 1 1
0 0 0 0 1 0 0 0
1 1 1 0 1
Shift
Subtract
Initially 0 0 0 0 0 1 0 0 0
1 1 1 0 0000
1 1 1 0 0
0 0 0 1 1
0 0 0Shift
Add
0 0 10 0 0 01
1 1 1 0 1
Shift
Subtract
0 0 0 110000
Fourth cycle
Third cycle
Second cycle
First cycle
q
0Set
q
0
Set
q
0
Set
q
0
Set
If b is a binary vector, then we have seen that it can be interpreted as
an unsigned integer by:
V(b) = b31.231
+ b30.230
+ bn-3.229
+ .... + b1.21
+ b0.20
This vector has an implicit binary point to its immediate right:
b31b30b29....................b1b0. implicit binary point
Suppose if the binary vector is interpreted with the implicit binary point is
just left of the sign bit:
implicit binary point .b31b30b29....................b1b0
The value of b is then given by:
V(b) = b31.2-1
+ b30.2-2
+ b29.2-3
+ .... + b1.2-31
+ b0.2-32
The value of the unsigned binary fraction is:
V(b) = b31.2-1
+ b30.2-2
+ b29.2-3
+ .... + b1.2-31
+ b0.2-32
The range of the numbers represented in this format is:
In general for a n-bit binary fraction (a number with an assumed binary
point at the immediate left of the vector), then the range of values is:
9999999998.021)(0 32
≈−≤≤ −
bV
n
bV −
−≤≤ 21)(0
•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.
A more convenient representation is the scientific representation, where
the numbers are represented in the form:
x = m1.m2m3m4 × b±e
Components of these numbers are:
Mantissa (m), implied base (b), and exponent (e)
A number such as the following is said to have 7 significant digits
x = ±0.m1m2m3m4m5m6m7 × b±e
Fractions in the range 0.0 to 0.9999999 need about 24 bits of precision
(in binary). For example the binary fraction with 24 1’s:
111111111111111111111111 = 0.9999999404
Not every real number between 0 and 0.9999999404 can be represented
by a 24-bit fractional number.
The smallest non-zero number that can be represented is:
000000000000000000000001 = 5.96046 x 10-8
Every other non-zero number is constructed in increments of this value.
•In a 32-bit number, suppose we allocate 24 bits to represent a fractional
mantissa.
•Assume that the mantissa is represented in sign and magnitude format,
and we have allocated one bit to represent the sign.
•We allocate 7 bits to represent the exponent, and assume that the
exponent is represented as a 2’s complement integer.
•There are no bits allocated to represent the base, we assume that the
base is implied for now, that is the base is 2.
•Since a 7-bit 2’s complement number can represent values in the range
-64 to 63, the range of numbers that can be represented is:
0.0000001 x 2-64
< = | x | <= 0.9999999 x 263
•In decimal representation this range is:
0.5421 x 10-20
< = | x | <= 9.2237 x 1018
Sign Exponent Fractional mantissa
bit
1 7 24
•24-bit mantissa with an implied binary point to the immediate left
•7-bit exponent in 2’s complement form, and implied base is 2.
If the number is to be represented using only 7 significant mantissa digits,
the representation ignoring rounding is:
Consider the number: x = 0.0004056781 x 1012
x = 0.0004056 x 1012
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
Exponent of x was decreased by 1 for every left shift of x.
A number which is brought into a form so that all of the available mantissa
digits are optimally used (this is different from all occupied which may
not hold), is called a normalized number.
Same methodology holds in the case of binary mantissas
0001101000(10110) x 28
= 1101000101(10) x 25
•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
Range of numbers representable in this system, if every number must be
normalized is:
0.5 x 2-64
<= | x | < 1 x 263
The procedure for normalizing a floating point number is:
Do (until MSB of mantissa = = 1)
Shift the mantissa left (or right)
Decrement (increment) the exponent by 1
end do
Applying the normalization procedure to: .000111001110....0010 x 2-62
gives: .111001110........ x 2-65
But we cannot represent an exponent of –65, in trying to normalize the
number we have underflowed our representation.
Applying the normalization procedure to: 1.00111000............x 263
gives: 0.100111..............x 264
This overflows the representation.
So far we have assumed an implied base of 2, that is our floating point
numbers are of the form:
x = m 2e
If we choose an implied base of 16, then:
x = m 16e
Then:
y = (m.16) .16e-1
(m.24
) .16e-1
= m . 16e
= x
•Thus, every four left shifts of a binary mantissa results in a decrease of 1
in a base 16 exponent.
•Normalization in this case means shifting the mantissa until there is a 1 in
the first four bits of the mantissa.
•Rather than representing an exponent in 2’s complement form, it turns out to be
more beneficial to represent the exponent in excess notation.
•If 7 bits are allocated to the exponent, exponents can be represented in the range
of -64 to +63, that is:
-64 <= e <= 63
Exponent can also be represented using the following coding called as excess-64:
E’ = Etrue + 64
In general, excess-p coding is represented as:
E’ = Etrue + p
True exponent of -64 is represented as 0
0 is represented as 64
63 is represented as 127
This enables efficient comparison of the relative sizes of two floating point numbers.
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.
Sign Exponent Mantissa
1 8 or 11 23 or 52
•Floating point numbers have to be represented in a normalized form to
maximize the use of available mantissa digits.
•In a base-2 representation, this implies that the MSB of the mantissa is
always equal to 1.
•If every number is normalized, then the MSB of the mantissa is always 1.
We can do away without storing the MSB.
•IEEE notation assumes that all numbers are normalized so that the MSB
of the mantissa is a 1 and does not store this bit.
•So the real MSB of a number in the IEEE notation is either a 0 or a 1.
•The values of the numbers represented in the IEEE single precision
notation are of the form:
(+,-) 1.M x 2(E - 127)
•The hidden 1 forms the integer part of the mantissa.
•Note that excess-127 and excess-1023 (not excess-128 or excess-1024) are used
to represent the exponent.
In the IEEE representation, the exponent is in excess-127 (excess-1023)
notation.
The actual exponents represented are:
-126 <= E <= 127 and -1022 <= E <= 1023
not
-127 <= E <= 128 and -1023 <= E <= 1024
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
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)
Biased exponent problem:
If a true exponent e is represented in excess-p notation, that is as e+p.
Then consider what happens under multiplication:
a. 10(x + p)
* b. 10(y + p)
= (a.b). 10(x + p + y +p)
= (a.b). 10(x +y + 2p)
Representing the result in excess-p notation implies that the exponent
should be x+y+p. Instead it is x+y+2p.
Biases should be handled in floating point arithmetic.
Floating point arithmetic: ADD/SUB
rule
Choose the number with the smaller exponent.
Shift its mantissa right until the exponents of both the
numbers are equal.
Add or subtract the mantissas.
Determine the sign of the result.
Normalize the result if necessary and truncate/round
to the number of mantissa bits.
Note: This does not consider the possibility of overflow/underflow.
Floating point arithmetic: MUL rule
Add the exponents.
Subtract the bias.
Multiply the mantissas and determine the sign of the
result.
Normalize the result (if necessary).
Truncate/round the mantissa of the result.
Floating point arithmetic: DIV rule
Subtract the exponents
Add the bias.
Divide the mantissas and determine the sign of the
result.
Normalize the result if necessary.
Truncate/round the mantissa of the result.
Note: Multiplication and division does not require alignment of the
mantissas the way addition and subtraction does.
While adding two floating point numbers with 24-bit mantissas, we shift
the mantissa of the number with the smaller exponent to the right until
the two exponents are equalized.
This implies that mantissa bits may be lost during the right shift (that is,
bits of precision may be shifted out of the mantissa being shifted).
To prevent this, floating point operations are implemented by keeping
guard bits, that is, extra bits of precision at the least significant end
of the mantissa.
The arithmetic on the mantissas is performed with these extra bits of
precision.
After an arithmetic operation, the guarded mantissas are:
- Normalized (if necessary)
- Converted back by a process called truncation/rounding to a 24-bit
mantissa.
Truncation/rounding
Straight chopping:
 The guard bits (excess bits of precision) are dropped.
Von Neumann rounding:
 If the guard bits are all 0, they are dropped.
 However, if any bit of the guard bit is a 1, then the LSB of the retained bit is
set to 1.
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.
IEEE uses the rounding method.
0.111111100000 rounds to 0.111111 + 0.000001
=1.000000 which must be renormalized to 0.100000

Weitere ähnliche Inhalte

Was ist angesagt?

Free video lectures for mca
Free video lectures for mcaFree video lectures for mca
Free video lectures for mcaEdhole.com
 
Lec13 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Sh...
Lec13 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Sh...Lec13 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Sh...
Lec13 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Sh...Hsien-Hsin Sean Lee, Ph.D.
 
Acm aleppo cpc training fifth session
Acm aleppo cpc training fifth sessionAcm aleppo cpc training fifth session
Acm aleppo cpc training fifth sessionAhmad Bashar Eter
 
Admissions in india 2015
Admissions in india 2015Admissions in india 2015
Admissions in india 2015Edhole.com
 
Lab 3 Multi-Function Gate
Lab 3   Multi-Function GateLab 3   Multi-Function Gate
Lab 3 Multi-Function GateKatrina Little
 
Booth Multiplier
Booth MultiplierBooth Multiplier
Booth MultiplierSudhir Kumar
 
Lab 2-Simple Combinational Logic
Lab 2-Simple Combinational LogicLab 2-Simple Combinational Logic
Lab 2-Simple Combinational LogicKatrina Little
 
A tabu search algorithm for the min max k-chinese postman problem
A tabu search algorithm for the min max k-chinese postman problemA tabu search algorithm for the min max k-chinese postman problem
A tabu search algorithm for the min max k-chinese postman problem政謙 陳
 
Lec10 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Mu...
Lec10 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Mu...Lec10 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Mu...
Lec10 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Mu...Hsien-Hsin Sean Lee, Ph.D.
 
Logic Gates O level Past Papers questions
Logic Gates O level Past Papers questionsLogic Gates O level Past Papers questions
Logic Gates O level Past Papers questionscvcvvc
 
Stack - Data Structure - Notes
Stack - Data Structure - NotesStack - Data Structure - Notes
Stack - Data Structure - NotesOmprakash Chauhan
 
Lect23 Engin112
Lect23 Engin112Lect23 Engin112
Lect23 Engin112John Williams
 
An algorithm for computing resultant polytopes
An algorithm for computing resultant polytopesAn algorithm for computing resultant polytopes
An algorithm for computing resultant polytopesVissarion Fisikopoulos
 
My lecture infix-to-postfix
My lecture infix-to-postfixMy lecture infix-to-postfix
My lecture infix-to-postfixSenthil Kumar
 
Lab 4 Three-Bit Binary Adder
Lab 4 Three-Bit Binary AdderLab 4 Three-Bit Binary Adder
Lab 4 Three-Bit Binary AdderKatrina Little
 
Gate 2013 complete solutions of ec electronics and communication engineering
Gate 2013 complete solutions of ec  electronics and communication engineeringGate 2013 complete solutions of ec  electronics and communication engineering
Gate 2013 complete solutions of ec electronics and communication engineeringmanish katara
 
A formalization of complex event stream processing
A formalization of complex event stream processingA formalization of complex event stream processing
A formalization of complex event stream processingSylvain HallĂŠ
 

Was ist angesagt? (20)

Free video lectures for mca
Free video lectures for mcaFree video lectures for mca
Free video lectures for mca
 
Lec13 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Sh...
Lec13 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Sh...Lec13 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Sh...
Lec13 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Sh...
 
Acm aleppo cpc training fifth session
Acm aleppo cpc training fifth sessionAcm aleppo cpc training fifth session
Acm aleppo cpc training fifth session
 
Admissions in india 2015
Admissions in india 2015Admissions in india 2015
Admissions in india 2015
 
Digital logic
Digital logicDigital logic
Digital logic
 
Lab 3 Multi-Function Gate
Lab 3   Multi-Function GateLab 3   Multi-Function Gate
Lab 3 Multi-Function Gate
 
Booth Multiplier
Booth MultiplierBooth Multiplier
Booth Multiplier
 
Lab 2-Simple Combinational Logic
Lab 2-Simple Combinational LogicLab 2-Simple Combinational Logic
Lab 2-Simple Combinational Logic
 
A tabu search algorithm for the min max k-chinese postman problem
A tabu search algorithm for the min max k-chinese postman problemA tabu search algorithm for the min max k-chinese postman problem
A tabu search algorithm for the min max k-chinese postman problem
 
04 comb ex
04 comb ex04 comb ex
04 comb ex
 
Lec10 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Mu...
Lec10 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Mu...Lec10 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Mu...
Lec10 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Mu...
 
Logic Gates O level Past Papers questions
Logic Gates O level Past Papers questionsLogic Gates O level Past Papers questions
Logic Gates O level Past Papers questions
 
Stack - Data Structure - Notes
Stack - Data Structure - NotesStack - Data Structure - Notes
Stack - Data Structure - Notes
 
Vlsi presentation final
Vlsi presentation finalVlsi presentation final
Vlsi presentation final
 
Lect23 Engin112
Lect23 Engin112Lect23 Engin112
Lect23 Engin112
 
An algorithm for computing resultant polytopes
An algorithm for computing resultant polytopesAn algorithm for computing resultant polytopes
An algorithm for computing resultant polytopes
 
My lecture infix-to-postfix
My lecture infix-to-postfixMy lecture infix-to-postfix
My lecture infix-to-postfix
 
Lab 4 Three-Bit Binary Adder
Lab 4 Three-Bit Binary AdderLab 4 Three-Bit Binary Adder
Lab 4 Three-Bit Binary Adder
 
Gate 2013 complete solutions of ec electronics and communication engineering
Gate 2013 complete solutions of ec  electronics and communication engineeringGate 2013 complete solutions of ec  electronics and communication engineering
Gate 2013 complete solutions of ec electronics and communication engineering
 
A formalization of complex event stream processing
A formalization of complex event stream processingA formalization of complex event stream processing
A formalization of complex event stream processing
 

Andere mochten auch

Eri outdoor fusion LED
Eri outdoor fusion LEDEri outdoor fusion LED
Eri outdoor fusion LEDChris Barker
 
Copd giai doan on dinh
Copd giai doan on dinhCopd giai doan on dinh
Copd giai doan on dinhNgô Lộc
 
Layerwise - Jonas van Vaerenbergh
Layerwise - Jonas van VaerenberghLayerwise - Jonas van Vaerenbergh
Layerwise - Jonas van VaerenberghThemadagen
 
Sci doc publishers - dairy science And processing
Sci doc publishers - dairy science And processingSci doc publishers - dairy science And processing
Sci doc publishers - dairy science And processingScidoc Publishers
 
The Prospective and Retrospective Memory Questionnaire
The Prospective and Retrospective Memory QuestionnaireThe Prospective and Retrospective Memory Questionnaire
The Prospective and Retrospective Memory QuestionnaireGEOFF SMITH
 
2016 06-07-flexible-and-efficient-production-with-am-hÜganäs am-powders
2016 06-07-flexible-and-efficient-production-with-am-hÜganäs am-powders2016 06-07-flexible-and-efficient-production-with-am-hÜganäs am-powders
2016 06-07-flexible-and-efficient-production-with-am-hÜganäs am-powdersSirris
 
Invisible but functional - protective coatings
Invisible but functional - protective coatingsInvisible but functional - protective coatings
Invisible but functional - protective coatingsSirris
 
Software is not a Building - Designing Technical Architecture for Change
Software is not a Building - Designing Technical Architecture for ChangeSoftware is not a Building - Designing Technical Architecture for Change
Software is not a Building - Designing Technical Architecture for ChangeCantina
 
pool-standards-july2012
pool-standards-july2012pool-standards-july2012
pool-standards-july2012ghassem eskandari
 
Messaggio di Sr. Alaide Deretti - 14 novembre 2016 (portoghese)
Messaggio di Sr. Alaide Deretti - 14 novembre 2016 (portoghese)Messaggio di Sr. Alaide Deretti - 14 novembre 2016 (portoghese)
Messaggio di Sr. Alaide Deretti - 14 novembre 2016 (portoghese)Maike Loes
 
Natale 2016 - Isole Salomone
Natale 2016 - Isole SalomoneNatale 2016 - Isole Salomone
Natale 2016 - Isole SalomoneMaike Loes
 
2° Domingo Adviento Ciclo A
2° Domingo Adviento Ciclo A2° Domingo Adviento Ciclo A
2° Domingo Adviento Ciclo AMaike Loes
 
MarĂ­a, Madre de Dios
MarĂ­a, Madre de DiosMarĂ­a, Madre de Dios
MarĂ­a, Madre de DiosMaike Loes
 

Andere mochten auch (15)

Eri outdoor fusion LED
Eri outdoor fusion LEDEri outdoor fusion LED
Eri outdoor fusion LED
 
M. Helmy
M. HelmyM. Helmy
M. Helmy
 
Ppi desempeĂąo ba
Ppi desempeĂąo baPpi desempeĂąo ba
Ppi desempeĂąo ba
 
Copd giai doan on dinh
Copd giai doan on dinhCopd giai doan on dinh
Copd giai doan on dinh
 
Layerwise - Jonas van Vaerenbergh
Layerwise - Jonas van VaerenberghLayerwise - Jonas van Vaerenbergh
Layerwise - Jonas van Vaerenbergh
 
Sci doc publishers - dairy science And processing
Sci doc publishers - dairy science And processingSci doc publishers - dairy science And processing
Sci doc publishers - dairy science And processing
 
The Prospective and Retrospective Memory Questionnaire
The Prospective and Retrospective Memory QuestionnaireThe Prospective and Retrospective Memory Questionnaire
The Prospective and Retrospective Memory Questionnaire
 
2016 06-07-flexible-and-efficient-production-with-am-hÜganäs am-powders
2016 06-07-flexible-and-efficient-production-with-am-hÜganäs am-powders2016 06-07-flexible-and-efficient-production-with-am-hÜganäs am-powders
2016 06-07-flexible-and-efficient-production-with-am-hÜganäs am-powders
 
Invisible but functional - protective coatings
Invisible but functional - protective coatingsInvisible but functional - protective coatings
Invisible but functional - protective coatings
 
Software is not a Building - Designing Technical Architecture for Change
Software is not a Building - Designing Technical Architecture for ChangeSoftware is not a Building - Designing Technical Architecture for Change
Software is not a Building - Designing Technical Architecture for Change
 
pool-standards-july2012
pool-standards-july2012pool-standards-july2012
pool-standards-july2012
 
Messaggio di Sr. Alaide Deretti - 14 novembre 2016 (portoghese)
Messaggio di Sr. Alaide Deretti - 14 novembre 2016 (portoghese)Messaggio di Sr. Alaide Deretti - 14 novembre 2016 (portoghese)
Messaggio di Sr. Alaide Deretti - 14 novembre 2016 (portoghese)
 
Natale 2016 - Isole Salomone
Natale 2016 - Isole SalomoneNatale 2016 - Isole Salomone
Natale 2016 - Isole Salomone
 
2° Domingo Adviento Ciclo A
2° Domingo Adviento Ciclo A2° Domingo Adviento Ciclo A
2° Domingo Adviento Ciclo A
 
MarĂ­a, Madre de Dios
MarĂ­a, Madre de DiosMarĂ­a, Madre de Dios
MarĂ­a, Madre de Dios
 

Ähnlich wie Arithmetic by aniket bhute

COA-unit-2-Arithmetic.ppt
COA-unit-2-Arithmetic.pptCOA-unit-2-Arithmetic.ppt
COA-unit-2-Arithmetic.pptRuhul Amin
 
Chapter 04 - ALU Operation.ppt
Chapter 04 - ALU Operation.pptChapter 04 - ALU Operation.ppt
Chapter 04 - ALU Operation.pptMonirJihad1
 
COMPUTER ORGANIZATION NOTES Unit 6
COMPUTER ORGANIZATION NOTES Unit 6COMPUTER ORGANIZATION NOTES Unit 6
COMPUTER ORGANIZATION NOTES Unit 6Dr.MAYA NAYAK
 
LOGIC GATES - SARTHAK YADAV
LOGIC GATES - SARTHAK YADAVLOGIC GATES - SARTHAK YADAV
LOGIC GATES - SARTHAK YADAVDeepak Yadav
 
UNIT - II.pptx
UNIT - II.pptxUNIT - II.pptx
UNIT - II.pptxamudhak10
 
Binary Adder Design(COA).ppt
Binary Adder Design(COA).pptBinary Adder Design(COA).ppt
Binary Adder Design(COA).pptRohitPaul71
 
Chapter 07 Digital Alrithmetic and Arithmetic Circuits
Chapter 07 Digital Alrithmetic and Arithmetic CircuitsChapter 07 Digital Alrithmetic and Arithmetic Circuits
Chapter 07 Digital Alrithmetic and Arithmetic CircuitsSSE_AndyLi
 
Binary Adders.pdf
Binary Adders.pdfBinary Adders.pdf
Binary Adders.pdfRamKumar612299
 
Logic System Design KTU Chapter-4.ppt
Logic System Design KTU Chapter-4.pptLogic System Design KTU Chapter-4.ppt
Logic System Design KTU Chapter-4.pptAlbin562191
 
Computer Organization And Architecture lab manual
Computer Organization And Architecture lab manualComputer Organization And Architecture lab manual
Computer Organization And Architecture lab manualNitesh Dubey
 
Assignment solution-week7
Assignment solution-week7Assignment solution-week7
Assignment solution-week7PUSHPALATHAV1
 
Unit 3 Arithmetic building blocks and memory Design (1).pdf
Unit 3 Arithmetic building blocks and  memory Design (1).pdfUnit 3 Arithmetic building blocks and  memory Design (1).pdf
Unit 3 Arithmetic building blocks and memory Design (1).pdfShreyasMahesh
 
Lecture 18 M - Copy.pptx
Lecture 18 M - Copy.pptxLecture 18 M - Copy.pptx
Lecture 18 M - Copy.pptxAzeenShahid
 
combinational-circuit (1).ppt
combinational-circuit (1).pptcombinational-circuit (1).ppt
combinational-circuit (1).pptKrishnavenimanickam2
 
combinational-circuit.pptx it tis creative study of digital electronics for ...
combinational-circuit.pptx it tis creative study of  digital electronics for ...combinational-circuit.pptx it tis creative study of  digital electronics for ...
combinational-circuit.pptx it tis creative study of digital electronics for ...RishabhSingh308993
 
3306565.ppt
3306565.ppt3306565.ppt
3306565.pptJP Chicano
 
Latches time borrowing and stealing sequential
Latches time borrowing and stealing sequentialLatches time borrowing and stealing sequential
Latches time borrowing and stealing sequentialShaziyaBibi1
 
DPCO-Unit 2-Combinational Circuit.pdf
DPCO-Unit 2-Combinational Circuit.pdfDPCO-Unit 2-Combinational Circuit.pdf
DPCO-Unit 2-Combinational Circuit.pdfssuser08e250
 

Ähnlich wie Arithmetic by aniket bhute (20)

COA-unit-2-Arithmetic.ppt
COA-unit-2-Arithmetic.pptCOA-unit-2-Arithmetic.ppt
COA-unit-2-Arithmetic.ppt
 
Chapter 04 - ALU Operation.ppt
Chapter 04 - ALU Operation.pptChapter 04 - ALU Operation.ppt
Chapter 04 - ALU Operation.ppt
 
COMPUTER ORGANIZATION NOTES Unit 6
COMPUTER ORGANIZATION NOTES Unit 6COMPUTER ORGANIZATION NOTES Unit 6
COMPUTER ORGANIZATION NOTES Unit 6
 
LOGIC GATES - SARTHAK YADAV
LOGIC GATES - SARTHAK YADAVLOGIC GATES - SARTHAK YADAV
LOGIC GATES - SARTHAK YADAV
 
UNIT - II.pptx
UNIT - II.pptxUNIT - II.pptx
UNIT - II.pptx
 
Binary Adder Design(COA).ppt
Binary Adder Design(COA).pptBinary Adder Design(COA).ppt
Binary Adder Design(COA).ppt
 
Chapter 07 Digital Alrithmetic and Arithmetic Circuits
Chapter 07 Digital Alrithmetic and Arithmetic CircuitsChapter 07 Digital Alrithmetic and Arithmetic Circuits
Chapter 07 Digital Alrithmetic and Arithmetic Circuits
 
Lec20
Lec20Lec20
Lec20
 
Binary Adders.pdf
Binary Adders.pdfBinary Adders.pdf
Binary Adders.pdf
 
Logic System Design KTU Chapter-4.ppt
Logic System Design KTU Chapter-4.pptLogic System Design KTU Chapter-4.ppt
Logic System Design KTU Chapter-4.ppt
 
Computer Organization And Architecture lab manual
Computer Organization And Architecture lab manualComputer Organization And Architecture lab manual
Computer Organization And Architecture lab manual
 
Assignment solution-week7
Assignment solution-week7Assignment solution-week7
Assignment solution-week7
 
Arithmetic Logic
Arithmetic LogicArithmetic Logic
Arithmetic Logic
 
Unit 3 Arithmetic building blocks and memory Design (1).pdf
Unit 3 Arithmetic building blocks and  memory Design (1).pdfUnit 3 Arithmetic building blocks and  memory Design (1).pdf
Unit 3 Arithmetic building blocks and memory Design (1).pdf
 
Lecture 18 M - Copy.pptx
Lecture 18 M - Copy.pptxLecture 18 M - Copy.pptx
Lecture 18 M - Copy.pptx
 
combinational-circuit (1).ppt
combinational-circuit (1).pptcombinational-circuit (1).ppt
combinational-circuit (1).ppt
 
combinational-circuit.pptx it tis creative study of digital electronics for ...
combinational-circuit.pptx it tis creative study of  digital electronics for ...combinational-circuit.pptx it tis creative study of  digital electronics for ...
combinational-circuit.pptx it tis creative study of digital electronics for ...
 
3306565.ppt
3306565.ppt3306565.ppt
3306565.ppt
 
Latches time borrowing and stealing sequential
Latches time borrowing and stealing sequentialLatches time borrowing and stealing sequential
Latches time borrowing and stealing sequential
 
DPCO-Unit 2-Combinational Circuit.pdf
DPCO-Unit 2-Combinational Circuit.pdfDPCO-Unit 2-Combinational Circuit.pdf
DPCO-Unit 2-Combinational Circuit.pdf
 

Mehr von Aniket Bhute

Cn transmission media by aniket bhute
Cn transmission media by aniket bhuteCn transmission media by aniket bhute
Cn transmission media by aniket bhuteAniket Bhute
 
Basic structure of computers by aniket bhute
Basic structure of computers by aniket bhuteBasic structure of computers by aniket bhute
Basic structure of computers by aniket bhuteAniket Bhute
 
Basic processing unit by aniket bhute
Basic processing unit by aniket bhuteBasic processing unit by aniket bhute
Basic processing unit by aniket bhuteAniket Bhute
 
Address translation-mechanism-of-80386 by aniket bhute
Address translation-mechanism-of-80386 by aniket bhuteAddress translation-mechanism-of-80386 by aniket bhute
Address translation-mechanism-of-80386 by aniket bhuteAniket Bhute
 
8251 usart programmable communication interface by aniket bhute
8251  usart  programmable communication interface by aniket bhute8251  usart  programmable communication interface by aniket bhute
8251 usart programmable communication interface by aniket bhuteAniket Bhute
 
Assembler numericals by aniket bhute
Assembler numericals by aniket bhuteAssembler numericals by aniket bhute
Assembler numericals by aniket bhuteAniket Bhute
 

Mehr von Aniket Bhute (6)

Cn transmission media by aniket bhute
Cn transmission media by aniket bhuteCn transmission media by aniket bhute
Cn transmission media by aniket bhute
 
Basic structure of computers by aniket bhute
Basic structure of computers by aniket bhuteBasic structure of computers by aniket bhute
Basic structure of computers by aniket bhute
 
Basic processing unit by aniket bhute
Basic processing unit by aniket bhuteBasic processing unit by aniket bhute
Basic processing unit by aniket bhute
 
Address translation-mechanism-of-80386 by aniket bhute
Address translation-mechanism-of-80386 by aniket bhuteAddress translation-mechanism-of-80386 by aniket bhute
Address translation-mechanism-of-80386 by aniket bhute
 
8251 usart programmable communication interface by aniket bhute
8251  usart  programmable communication interface by aniket bhute8251  usart  programmable communication interface by aniket bhute
8251 usart programmable communication interface by aniket bhute
 
Assembler numericals by aniket bhute
Assembler numericals by aniket bhuteAssembler numericals by aniket bhute
Assembler numericals by aniket bhute
 

KĂźrzlich hochgeladen

Internet of things -Arshdeep Bahga .pptx
Internet of things -Arshdeep Bahga .pptxInternet of things -Arshdeep Bahga .pptx
Internet of things -Arshdeep Bahga .pptxVelmuruganTECE
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - GuideGOPINATHS437943
 
Crushers to screens in aggregate production
Crushers to screens in aggregate productionCrushers to screens in aggregate production
Crushers to screens in aggregate productionChinnuNinan
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solidnamansinghjarodiya
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgsaravananr517913
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Coursebim.edu.pl
 
DM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in projectDM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in projectssuserb6619e
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating SystemRashmi Bhat
 
Designing pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptxDesigning pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptxErbil Polytechnic University
 
Configuration of IoT devices - Systems managament
Configuration of IoT devices - Systems managamentConfiguration of IoT devices - Systems managament
Configuration of IoT devices - Systems managamentBharaniDharan195623
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxsiddharthjain2303
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptNarmatha D
 
BSNL Internship Training presentation.pptx
BSNL Internship Training presentation.pptxBSNL Internship Training presentation.pptx
BSNL Internship Training presentation.pptxNiranjanYadav41
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm Systemirfanmechengr
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...Erbil Polytechnic University
 

KĂźrzlich hochgeladen (20)

Internet of things -Arshdeep Bahga .pptx
Internet of things -Arshdeep Bahga .pptxInternet of things -Arshdeep Bahga .pptx
Internet of things -Arshdeep Bahga .pptx
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - Guide
 
Crushers to screens in aggregate production
Crushers to screens in aggregate productionCrushers to screens in aggregate production
Crushers to screens in aggregate production
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solid
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Course
 
DM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in projectDM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in project
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Designing pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptxDesigning pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptx
 
Configuration of IoT devices - Systems managament
Configuration of IoT devices - Systems managamentConfiguration of IoT devices - Systems managament
Configuration of IoT devices - Systems managament
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptx
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.ppt
 
BSNL Internship Training presentation.pptx
BSNL Internship Training presentation.pptxBSNL Internship Training presentation.pptx
BSNL Internship Training presentation.pptx
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm System
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 

Arithmetic by aniket bhute

  • 1. Chapter 4 Arithmatic By Aniket Bhute aniket.bhute96@gmail.com
  • 2. si  = ci +1 = 13 7 + Y 1 0 0 0 1 0 1 1 0 0 1 1 0 1 1 0 0 1 1 0 1 0 0 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 Example: 1 0= = 0 0 1 1 1 1 1 0 0 1 1 1 10 Legend for stage i xi yi Carry­in ci Sum si Carry­out ci+1 X Z + 6 0+ xi yi si Carry­out ci+1 Carry­in ci xi yi ci xi yi ci xi yi ci xi yi ci xi yi ci⊕ ⊕=+ + + yi ci xi ci xi yi+ + At the ith stage: Input: ci is the carry-in Output: si is the sum ci+1 carry-out to (i+1)st state
  • 3. Full adder (FA) ci ci 1+ s i Sum Carry yi xi c i yi xi c i yi x i xi ci yi si c i 1+ Full Adder (FA): Symbol for the complete circuit for a single stage of addition.
  • 4. •Cascade n full adder (FA) blocks to form a n-bit adder. •Carries propagate or ripple through this cascade, n-bit ripple carry adder. FA c0 y1 x1 s1 FA c1 y0 x0 s0 FA cn 1­ yn 1­ xn 1­ cn sn 1­ Most significant bit (MSB) position Least significant bit (LSB) position Carry-in c0 into the LSB position provides a convenient way to perform subtraction.
  • 5. K n-bit numbers can be added by cascading k n-bit adders. n­bit c 0 yn xn s n cn y0 xn 1­ s 0 ckn s k 1­( )n x0 yn 1­ y2n 1­ x2n 1­ ykn 1­ s n 1­ s 2n 1­ s kn 1­ xkn 1­ adder n­bit adder n­bit adder Each n-bit adder forms a block, so this is cascading of blocks. Carries ripple or propagate through blocks, Blocked Ripple Carry Adder
  • 6. FA 1 y1 x1 s1 FA c1 y0 x0 s0 FA cn 1­ yn 1­ xn 1­ cn sn 1­ Most significant bit (MSB) position Least significant bit (LSB) position •Recall X – Y is equivalent to adding 2’s complement of Y to X. •2’s complement is equivalent to 1’s complement + 1. •X – Y = X + Y + 1 •2’s complement of positive and negative numbers is computed similarly.
  • 7. Add/Sub control n­bit adder x n 1­ x 1 x 0 c n s n 1­ s 1 s 0 c 0 y n 1­ y 1 y 0 •Add/sub control = 0, addition. •Add/sub control = 1, subtraction.
  • 8. Detecting overflows Overflows can only occur when the sign of the two operands is the same. Overflow occurs if the sign of the result is different from the sign of the operands. Recall that the MSB represents the sign. xn-1, yn-1, sn-1represent the sign of operand x, operand y and result s respectively. Circuit to detect overflow can be implemented by the following logic expressions: 111111 −−−−−− += nnnnnn syxsyxOverflow 1−⊕= nn ccOverflow
  • 9. Consider 0th stage: x0 y0 c0 c1 s0 FA •c1 is available after 2 gate delays. •s1 is available after 1 gate delay. c i yi xi c i yi x i xi ci yi si c i 1+ Sum Carry
  • 10. x0 y0 s2 FA x0 y0x0 y0 s1 FA c2 s0 FA c1c3 c0 x0 y0 s3 FA c4 Cascade of 4 Full Adders, or a 4-bit adder •s0 available after 1 gate delays, c1 available after 2 gate delays. •s1 available after 3 gate delays, c2 available after 4 gate delays. •s2 available after 5 gate delays, c3 available after 6 gate delays. •s3 available after 7 gate delays, c4 available after 8 gate delays. For an n-bit adder, sn-1 is available after 2n-1 gate delays cn is available after 2n gate delays.
  • 11. Recall the equations: iiiiiii iiii cycxyxc cyxs ++= ⊕⊕= +1 Second equation can be written as: iiiiii cyxyxc )(1 ++=+ We can write: iiiiii iiii yxPandyxGwhere cPGc +== +=+1 •Gi is called generate function and Pi is called propagate function •Gi and Pi are computed only from xi and yi and not ci, thus they can be computed in one gate delay after X and Y are applied to the inputs of an n-bit adder.
  • 12. ci+1 = Gi + Pi ci ci = Gi−1 + Pi −1ci −1 ⇒ ci+1 = Gi + Pi (Gi −1 + Pi−1ci−1) continuing ⇒ ci+1 = Gi + Pi (Gi −1 + Pi−1(Gi− 2 + Pi− 2ci −2 )) until ci+1 = Gi + PiGi−1 + PiPi−1Gi −2 + .. + Pi Pi−1..P1G0 + PiPi−1...P0c0 •All carries can be obtained 3 gate delays after X, Y and c0 are applied. -One gate delay for Pi and Gi -Two gate delays in the AND-OR circuit for ci+1 •All sums can be obtained 1 gate delay after the carries are computed. •Independent of n, n-bit addition requires only 4 gate delays. •This is called Carry Lookahead adder.
  • 13. Carry­lookahead logic B cell B cell B cell B cell s 3 P3 G3 c 3 P2 G2 c 2 s 2 G 1 c 1 P 1 s 1 G 0 c 0 P 0 s 0 .c4 x 1 y 1 x 3 y 3 x 2 y 2 x 0 y 0 G i c i .. . P i s i x i y i B cell 4-bit carry-lookahead adder B-cell for a single stage
  • 14. Carry lookahead adder (contd..) Performing n-bit addition in 4 gate delays independent of n is good only theoretically because of fan-in constraints. 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. In order to add operands longer than 4 bits, we can cascade 4-bit Carry-Lookahead adders. Cascade of Carry-Lookahead adders is called Blocked Carry-Lookahead adder. ci+1 = Gi + Pi Gi −1 + Pi Pi−1 Gi−2 + .. + Pi Pi−1 ..P1 G0 + Pi Pi−1 ...P0 c0
  • 15.
  • 16. c4 = G3 + P3G2 + P3P2G1 + P3P2 P1G0 + P3P2 P1P0c0 Carry-out from a 4-bit block can be given as: Rewrite this as: P0 I = P3P2 P1P0 G0 I = G3 + P3G2 + P3P2G1 + P3P2P1G0 Subscript I denotes the blocked carry lookahead and identifies the block. Cascade 4 4-bit adders, c16 can be expressed as: c16 = G3 I + P3 I G2 I + P3 I P2 I G1 I + P3 I P2 I P1 0 G0 I + P3 I P2 I P1 0 P0 0 c0
  • 17. Carry­lookahead logic 4­bit adder 4­bit adder 4­bit adder 4­bit adder s15­12 P3 IG3 I c12 P2 IG2 I c8 s11­8 G1 I c4 P1 I s7­4 G0 I c0 P0 I s3­0 c16 x15­12 y15­12 x11­8 y11­8 x7­4 y7­4 x3­0 y3­0 . After xi, yi and c0 are applied as inputs: - 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)
  • 18.
  • 19. Product of 2 n-bit numbers is at most a 2n-bit number. Unsigned multiplication can be viewed as addition of shifted versions of the multiplicand.
  • 20. Multiplication of unsigned numbers (contd..) We added the partial products at end. Alternative would be to add the partial products at each stage. Rules to implement multiplication are: If the ith bit of the multiplier is 1, shift the multiplicand and add the shifted multiplicand to the current value of the partial product. Hand over the partial product to the next stage Value of the partial product at the start stage is 0.
  • 21. ith multiplier bit carry incarry out jth multiplicand bit ith multiplier bit Bit of incoming partial product (PPi) Bit of outgoing partial product (PP(i+1)) FA Typical multiplication cell
  • 22. M ultiplier Multiplicand m3 m2 m1 m00 0 0 0 q3 q2 q1 q0 0 p2 p1 p0 0 0 0 p3p4p5p6p7 PP1 PP2 PP3 (PP0) , Product is: p7,p6,..p0 Multiplicand is shifted by displacing it through an array of adders. Combinatorial array multiplier
  • 23. Combinatorial array multiplier (contd..) Combinatorial array multipliers are:  Extremely inefficient.  Have a high gate count for multiplying numbers of practical size such as 32- bit or 64-bit numbers.  Perform only one function, namely, unsigned integer product. Improve gate efficiency by using a mixture of combinatorial array techniques and sequential techniques requiring less combinational logic.
  • 24. Sequential multiplication 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 left when added to the partial product. However, adding a left-shifted multiplicand to an unshifted partial product is equivalent to adding an unshifted multiplicand to a right-shifted partial product.
  • 26. 1   1   1   1 1   0   1   1 1   1   1   1 1   1   1   0 1   1   1   0 1   1   0   1 1   1   0   1 Initial configuration Add M 1   1   0   1 C First cycle Second cycle Third cycle Fourth cycle No add Shift Shift Add Shift Shift Add 1   1   1   1 0 0 0 1 0 0 0 1 0 0   0   0   0 0   1   1   0 1   1   0   1 0   0   1   1 1   0   0   1 0   1   0   0 0   0   0   1 1   0   0   0 1   0   0   1 1   0   1   1 QA Product
  • 27.
  • 28. Signed Multiplication Considering 2’s-complement signed operands, what will happen to (- 13)×(+11) if following the same method of unsigned multiplication? Sign extension of negative multiplicand. 1 0 11 11 1 1 0 0 1 1 110 110 1 0 1000111011 000000 1100111 00000000 110011111 13­( ) 143­( ) 11+( ) Sign extension is shown in blue
  • 29. Signed Multiplication 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.
  • 30. Booth AlgorithmConsider in a multiplication, the multiplier is positive 0011110, how many appropriately shifted versions of the multiplicand are added in a standard procedure? 0 0 0 1 0 1 1 0 1 0 0 0 0 0 0 0 1 0 011010 1011010 1011010 1011010 0000000 000000 011000101010 0 00 1+ 1+ 1+ 1+
  • 31. Booth Algorithm Since 0011110 = 0100000 – 0000010, if we use the expression to the right, what will happen? 0 1 0 1 0 1 1 1 0000 00000000000000 1 1 1 1 1 1 1 0 1 0 0 1 00 0 0 0 0 1 0 1 1 0 1 0 0 0 0 0 0 0 0 0110001001000 1 2's complement of the multiplicand 0 0 0 0 1+ 1­ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  • 32. Booth Algorithm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. Booth recoding of a multiplier. 001101011100110100 00000000 1+ 1­1­1+1­1+1­1+1­1+
  • 33. Booth Algorithm Booth multiplication with a negative multiplier. 01 0 1 1 1 1 0 1 1 0 0 0 0 0 0 0 0 0 00 0110 0 0 0 0 1 1 0 1100111 0 0 0 0 0 0 01000 11111 1 10 1 1 0 1 1 1 0 1 0 6­( ) 13+( ) X 78­( ) +11­ 1­
  • 34. Booth Algorithm Multiplier Bit i Bit i 1­ V ersion of multiplicand selected by biti 0 1 0 0 01 1 1 0  M 1+  M 1−  M 0  M Booth multiplier recoding table. X X X X
  • 35. Booth Algorithm Best case – a long string of 1’s (skipping over 1s) Worst case – 0’s and 1’s are alternating 1 0 1110000111110000 001111011010001 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 000000000000 00000000 1­ 1­ 1­ 1­ 1­ 1­ 1­ 1­ 1­ 1­ 1­ 1­ 1­1­ 1+ 1+ 1+ 1+ 1+ 1+ 1+ 1+ 1+ 1+1+1+ 1+ Worst­case multiplier Ordinary multiplier Good multiplier
  • 36.
  • 37. Bit-Pair Recoding of Multipliers Bit-pair recoding halves the maximum number of summands (versions of the multiplicand). 1+1− (a)  Example of bit­pair recoding derived from Booth recoding 0 000 1 1 0 1 0 Implied 0 to right of LSB 1 0 Sign extension 1 21− − −
  • 38. Bit-Pair Recoding of Multipliers i 1+ i 1 (b) Table of multiplicand selection decisions selected at position i MultiplicandMultiplier bit­pair i 0 0 1 1 1 0 1 0 1 1 1 1 0 0 0 1 1 0 0 1 0 0 1 Multiplier bit on the right 0 0 X  M 1+ 1 1+ 0 1 2 2+ − − − − X  M X  M X  M X  M X  M X  M X  M
  • 39. Bit-Pair Recoding of Multipliers 39 1­ 0000 1 1 1 1 1 0 0 0 0 0 11 1 1 1 1 10 0 0 0 0 0 0 0 0000 111111 0 1 1 0 1 0 1 010011111 1 1 1 1 0 0 1 1 0 0 0 0 0 0 1 1 1 0 1 1 0 0 1 0 0 1 0 0 1 0 1 0 0 0 0 1 0 0 1 10 0 010 0 1 1 0 1 11 1­ 6­( ) 13+( ) 1+ 78­( ) 1­ 2­ × Figure 6.15.  Multiplication requiring only n/2 summands.
  • 40. Carry-Save Addition of Summands CSA speeds up the addition process. 40P7 P6 P5 P4 P3 P2 P1 P0
  • 41. Carry-Save Addition of Summands(Cont.,) P3 P2 P1 P0P5 P4P7 P6
  • 42. 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
  • 43. Carry-Save Addition of Summands Figure 6.17.  A multiplication example used to illustrate carry­save addition as shown in Figure 6.18. 100 1 11 100 1 11 100 1 11 11111 1 100 1 11 M Q A B C D E F (2,835) X (45) (63) 100 1 11 100 1 11 100 1 11 000 1 11 111 0 00 Product
  • 44. Figure 6.18. The multiplication example from Figure 6.17 performed using carry­save addition. 00000101 0 10 10010000 1 11 1 + 1000011 1 10010111 0 10 1 0110 1 10 0 00011010 0 00 10001011 1 0 1 110001 1 0 00111100 00110 1 10 11001 0 01 100 1 11 100 1 11 100 1 11 00110 1 10 11001 0 01 100 1 11 100 1 11 100 1 11 11111 1 100 1 11 M Q A B C S 1 C 1 D E F S 2 C 2 S1 C 1 S2 S 3 C3 C2 S4 C 4 Product x
  • 45.
  • 47. Longhand Division Steps 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.
  • 49. Restoring Division Shift A and Q left one binary position Subtract M from A, and place the answer back in A If the sign of A is 1, set q0 to 0 and add M back to A (restore A); otherwise, set q0 to 1 Repeat these steps n times
  • 50. Examples 10111 Figure 6.22. A restoring­division example. 1 1 1 1 1 01111 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 01 11 1 1 01 0001 Subtract Shift Restore 1 0000 1 0000 1 1 Initially Subtract Shift 10111 10000 11000 00000 Subtract Shift Restore 10111 01000 10000 1 1 QuotientRemainder Shift 10111 1 0000 Subtract Second cycle First cycle Third cycle Fourth cycle 0 0 0 0 0 0 1 0 1 10000 1 1 1 0000 11111 Restore q0Set q0Set q0Set q0Set
  • 51. Nonrestoring Division Avoid the need for restoring A after an unsuccessful subtraction. Any idea? Step 1: (Repeat n times) 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, if the sign of A is 0, set q0 to 1; otherwise, set q0 to 0. Step2: If the sign of A is 1, add M to A
  • 52. Examples  A nonrestoring­division example. Add Restore  remainder Remainder 0 0 0 01 1 1 1 1 1 0 0 0 1 1 1 Quotient 0 0 1 01 1 1 1 1 0 0 0 01 1 1 1 1 Shift 0 0 0 11000 01111 Add 0 0 0 1 1 0 0 0 0 1 0 0 0 1 1 1 0 1 Shift Subtract Initially 0 0 0 0 0 1 0 0 0 1 1 1 0 0000 1 1 1 0 0 0 0 0 1 1 0 0 0Shift Add 0 0 10 0 0 01 1 1 1 0 1 Shift Subtract 0 0 0 110000 Fourth cycle Third cycle Second cycle First cycle q 0Set q 0 Set q 0 Set q 0 Set
  • 53.
  • 54. If b is a binary vector, then we have seen that it can be interpreted as an unsigned integer by: V(b) = b31.231 + b30.230 + bn-3.229 + .... + b1.21 + b0.20 This vector has an implicit binary point to its immediate right: b31b30b29....................b1b0. implicit binary point Suppose if the binary vector is interpreted with the implicit binary point is just left of the sign bit: implicit binary point .b31b30b29....................b1b0 The value of b is then given by: V(b) = b31.2-1 + b30.2-2 + b29.2-3 + .... + b1.2-31 + b0.2-32
  • 55. The value of the unsigned binary fraction is: V(b) = b31.2-1 + b30.2-2 + b29.2-3 + .... + b1.2-31 + b0.2-32 The range of the numbers represented in this format is: In general for a n-bit binary fraction (a number with an assumed binary point at the immediate left of the vector), then the range of values is: 9999999998.021)(0 32 ≈−≤≤ − bV n bV − −≤≤ 21)(0
  • 56. •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. A more convenient representation is the scientific representation, where the numbers are represented in the form: x = m1.m2m3m4 × bÂąe Components of these numbers are: Mantissa (m), implied base (b), and exponent (e)
  • 57. A number such as the following is said to have 7 significant digits x = Âą0.m1m2m3m4m5m6m7 × bÂąe Fractions in the range 0.0 to 0.9999999 need about 24 bits of precision (in binary). For example the binary fraction with 24 1’s: 111111111111111111111111 = 0.9999999404 Not every real number between 0 and 0.9999999404 can be represented by a 24-bit fractional number. The smallest non-zero number that can be represented is: 000000000000000000000001 = 5.96046 x 10-8 Every other non-zero number is constructed in increments of this value.
  • 58. •In a 32-bit number, suppose we allocate 24 bits to represent a fractional mantissa. •Assume that the mantissa is represented in sign and magnitude format, and we have allocated one bit to represent the sign. •We allocate 7 bits to represent the exponent, and assume that the exponent is represented as a 2’s complement integer. •There are no bits allocated to represent the base, we assume that the base is implied for now, that is the base is 2. •Since a 7-bit 2’s complement number can represent values in the range -64 to 63, the range of numbers that can be represented is: 0.0000001 x 2-64 < = | x | <= 0.9999999 x 263 •In decimal representation this range is: 0.5421 x 10-20 < = | x | <= 9.2237 x 1018
  • 59. Sign Exponent Fractional mantissa bit 1 7 24 •24-bit mantissa with an implied binary point to the immediate left •7-bit exponent in 2’s complement form, and implied base is 2.
  • 60. If the number is to be represented using only 7 significant mantissa digits, the representation ignoring rounding is: Consider the number: x = 0.0004056781 x 1012 x = 0.0004056 x 1012 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 Exponent of x was decreased by 1 for every left shift of x. A number which is brought into a form so that all of the available mantissa digits are optimally used (this is different from all occupied which may not hold), is called a normalized number. Same methodology holds in the case of binary mantissas 0001101000(10110) x 28 = 1101000101(10) x 25
  • 61. •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 Range of numbers representable in this system, if every number must be normalized is: 0.5 x 2-64 <= | x | < 1 x 263
  • 62. The procedure for normalizing a floating point number is: Do (until MSB of mantissa = = 1) Shift the mantissa left (or right) Decrement (increment) the exponent by 1 end do Applying the normalization procedure to: .000111001110....0010 x 2-62 gives: .111001110........ x 2-65 But we cannot represent an exponent of –65, in trying to normalize the number we have underflowed our representation. Applying the normalization procedure to: 1.00111000............x 263 gives: 0.100111..............x 264 This overflows the representation.
  • 63. So far we have assumed an implied base of 2, that is our floating point numbers are of the form: x = m 2e If we choose an implied base of 16, then: x = m 16e Then: y = (m.16) .16e-1 (m.24 ) .16e-1 = m . 16e = x •Thus, every four left shifts of a binary mantissa results in a decrease of 1 in a base 16 exponent. •Normalization in this case means shifting the mantissa until there is a 1 in the first four bits of the mantissa.
  • 64. •Rather than representing an exponent in 2’s complement form, it turns out to be more beneficial to represent the exponent in excess notation. •If 7 bits are allocated to the exponent, exponents can be represented in the range of -64 to +63, that is: -64 <= e <= 63 Exponent can also be represented using the following coding called as excess-64: E’ = Etrue + 64 In general, excess-p coding is represented as: E’ = Etrue + p True exponent of -64 is represented as 0 0 is represented as 64 63 is represented as 127 This enables efficient comparison of the relative sizes of two floating point numbers.
  • 65. 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. Sign Exponent Mantissa 1 8 or 11 23 or 52
  • 66. •Floating point numbers have to be represented in a normalized form to maximize the use of available mantissa digits. •In a base-2 representation, this implies that the MSB of the mantissa is always equal to 1. •If every number is normalized, then the MSB of the mantissa is always 1. We can do away without storing the MSB. •IEEE notation assumes that all numbers are normalized so that the MSB of the mantissa is a 1 and does not store this bit. •So the real MSB of a number in the IEEE notation is either a 0 or a 1. •The values of the numbers represented in the IEEE single precision notation are of the form: (+,-) 1.M x 2(E - 127) •The hidden 1 forms the integer part of the mantissa. •Note that excess-127 and excess-1023 (not excess-128 or excess-1024) are used to represent the exponent.
  • 67. In the IEEE representation, the exponent is in excess-127 (excess-1023) notation. The actual exponents represented are: -126 <= E <= 127 and -1022 <= E <= 1023 not -127 <= E <= 128 and -1023 <= E <= 1024 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
  • 68. 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) Biased exponent problem: If a true exponent e is represented in excess-p notation, that is as e+p. Then consider what happens under multiplication: a. 10(x + p) * b. 10(y + p) = (a.b). 10(x + p + y +p) = (a.b). 10(x +y + 2p) Representing the result in excess-p notation implies that the exponent should be x+y+p. Instead it is x+y+2p. Biases should be handled in floating point arithmetic.
  • 69. Floating point arithmetic: ADD/SUB rule Choose the number with the smaller exponent. Shift its mantissa right until the exponents of both the numbers are equal. Add or subtract the mantissas. Determine the sign of the result. Normalize the result if necessary and truncate/round to the number of mantissa bits. Note: This does not consider the possibility of overflow/underflow.
  • 70. Floating point arithmetic: MUL rule Add the exponents. Subtract the bias. Multiply the mantissas and determine the sign of the result. Normalize the result (if necessary). Truncate/round the mantissa of the result.
  • 71. Floating point arithmetic: DIV rule Subtract the exponents Add the bias. Divide the mantissas and determine the sign of the result. Normalize the result if necessary. Truncate/round the mantissa of the result. Note: Multiplication and division does not require alignment of the mantissas the way addition and subtraction does.
  • 72. While adding two floating point numbers with 24-bit mantissas, we shift the mantissa of the number with the smaller exponent to the right until the two exponents are equalized. This implies that mantissa bits may be lost during the right shift (that is, bits of precision may be shifted out of the mantissa being shifted). To prevent this, floating point operations are implemented by keeping guard bits, that is, extra bits of precision at the least significant end of the mantissa. The arithmetic on the mantissas is performed with these extra bits of precision. After an arithmetic operation, the guarded mantissas are: - Normalized (if necessary) - Converted back by a process called truncation/rounding to a 24-bit mantissa.
  • 73. Truncation/rounding Straight chopping:  The guard bits (excess bits of precision) are dropped. Von Neumann rounding:  If the guard bits are all 0, they are dropped.  However, if any bit of the guard bit is a 1, then the LSB of the retained bit is set to 1. 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.
  • 74. 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. IEEE uses the rounding method. 0.111111100000 rounds to 0.111111 + 0.000001 =1.000000 which must be renormalized to 0.100000