Professional Documents
Culture Documents
yi
Carryin ci
Sum s i
Carryout c i+1
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
1
0
1
0
0
1
0
0
0
1
0
1
1
1
si = xi yi ci + xi yi ci + xi yi ci + xi yi ci = x i yi ci
ci+1 = yi c i + x i ci + x i y i
Example:
X
7
+ Y = +6
13
Z
0
= +00
1
1
1
1
1
1
0
1
0
1
Carryout
ci+1
xi
yi
si
Legendforstage
Carryin
ci
i
Sum
Carry
yi
c
i
xi
yi
xi
c
si
ci
xi
ci + 1
yi
Fulladder
(FA)
i +1
yi
ci
xn
cn
yn 1
cn
FA
sn
x1
Mostsignificantbit
(MSB)position
y1
FA
s1
x0
c1
y0
FA
c0
s0
Leastsignificantbit
(LSB)position
xk n 1 yk n 1
x2n 1 y2n
nbit
adder
c kn
kn 1
xn y n
cn
nbit
adder
k 1 n
2n 1
xn
yn 1 x0 y0
nbit
adder
n 1
cn
yn 1
cn
FA
sn
x1
Mostsignificantbit
(MSB)position
y1
FA
s1
x0
c1
y0
FA
s0
Leastsignificantbit
(LSB)position
n 1
Add/Sub
control
n 1
nbitadder
n 1
Detecting overflows
Overflows can occur when the sign of the two
Overflow cn cn 1
y0
x0
c1
FA
c0
s0
Carry
Sum
yi
c
i
xi
yi
ci
si
xi
c
i
yi
i +1
x3
c4
FA
c3
s3
s0
s1
s2
s3
y2
x2
FA
c2
after
after
after
after
FA
x0
c1
1
3
5
7
gate
gate
gate
gate
delays,
delays,
delays,
delays,
y0
FA
c0
s0
s1
s2
available
available
available
available
y1
x1
c1
c2
c3
c4
available
available
available
available
after
after
after
after
2
4
6
8
gate
gate
gate
gate
delays
delays
delays
delays
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
ci 1 Gi Pi ci
ci Gi 1 Pi 1ci 1
ci1 Gi Pi (Gi 1 Pi 1ci 1 )
continuing
ci1 Gi Pi (Gi 1 Pi 1 (Gi 2 Pi 2 ci 2 ))
until
ci1 Gi PiGi 1 Pi Pi1 Gi 2 .. Pi Pi 1 ..P1G0 Pi Pi 1 ...P0 c 0
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.
c4
Bcell
G3
P3
Bcell
G2
P2
Bcell
G
1
Bcell
G
0
4-bit
carry-lookahead
adder
P
0
Carrylookaheadlogic
n-bit adder.
cascade 4-bit Carry-Lookahead adders. Cascade of CarryLookahead adders is called Blocked Carry-Lookahead
adder.
c4 G3 P3 G2 P3 P2 G1 P3 P2 P1 G0 P3 P2 P1P0 c0
Rewrite this as:
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 blo
Cascade 4 4-bit adders, c16 can be expressed as:
I
c16 G3 P3 G2 P3 P2 G1 P3 P2 P1 G0 P3 P2 P1 P0 c0
x1512
c16
y1512
4bitadder
x118
c12
4bitadder
s1512
G3 I
P3 I
y118
x74
c8
4bitadder
s118
G2 I
P 2I
y74
x30
c4
4bitadder
s74
G 1I
P 1I
y30
s30
G 0I
P0 I
Carrylookaheadlogic
c0
Multiplication of unsigned
numbers (contd..)
We added the partial products at end.
Alternative would be to add the partial products at each
stage.
ithmultiplierbit
ithmultiplierbit
carryout
jthmultiplicandbit
FA
carryin
m3 0
m2 0
m1 0
q0
0
PP1
PP3
q3
0
p6
p5
p4
p3
p1
M
ul
q2
0
p0
tip
lie
r
q1
0
PP2
p7
m0
p2
,
Combinatorial array
multiplier
(contd..)
Sequential multiplication
Recall the rule for generating partial products:
If the ith bit of the multiplier is 1, add the appropriately shifted
RegisterA(initially0)
Shiftright
an
n 1
MultiplierQ
Add/Noadd
control
n-bit
Adder
Control
sequencer
MUX
0
m
n 1
MultiplicandM
M
1101
0
C
Initialconfiguration
0000
1011
1101
1011
0110
1
0
1101
Add
Shift
Firstcycle
0011
1001
1101
1110
Add
Shift
Secondcycle
0
0
1001
0100
1110
1111
Noadd
Shift
Thirdcycle
0001
1111
1000
1111
Add
Shift
Fourthcycle
Product
Signed Multiplication
Considering 2s-complement signed operands, what will
Signextensionis
showninblue
1
1
Signextensionofnegativemultiplicand.
13
( + 11)
143
Signed Multiplication
For a negative multiplier, a straightforward
Booth Algorithm
0
1
0
1
0
0
1
0
1
0
0
1 0 1 1 0
0 +1 +1 + 1+1
1
0
0
1
0
1
1
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
0
1
0
1
0
0
1
0
1
Booth
Algorithm
In general, in the Booth scheme, -1 times the shifted
0 +1 1 +1
0 1
0 +1
0 1 +1 1 + 1
Boothrecodingofamultiplier.
0 1
Booth Algorithm
0 1 1 0 1
X1 1 0 1 0
( + 13)
6
0 1 1 0 1
0 1 +1 1 0
0
1
0
1
0
0
1
0
1
0
0
1
0
1
0
0
1
0
0
0
0
1
1
0
0
0
0
1
1
0
0 0 0 0
0 1 1
0 1
1
1 1 1 0 1 1 0 0 1 0
Boothmultiplicationwithanegativemultiplier.
78
Booth Algorithm
Multiplier
Versionofmultiplicand
selectedbybit i
Bit i
Bit i 1
0 XM
+ 1 XM
1 XM
0 XM
Boothmultiplierrecodingtable.
Booth Algorithm
Best case a long string of 1s (skipping over 1s)
Worst case 0s and 1s are alternating
0
Worstcase
multiplier
+1 1 +1 1 +1 1 +1 1 +1 1 +1 1 +1 1 +1 1
Ordinary
multiplier
0 1 0
0 +1 1 +1
0 1 +1
0 1
0 +1
0 1
0 +1
0 1
Good
multiplier
Bit-Pair Recoding of
Bit-pair recoding halves the maximum number
Multipliers
of summands (versions of the multiplicand).
Signextension
Implied0torightofLSB
1
1 +1 1
(a)ExampleofbitpairrecodingderivedfromBoothrecoding
Bit-Pair Recoding of
Multipliers
Multiplierbitpair
Multiplierbitontheright
Multiplicand
selectedatposition
i+1
i1
XM
+1
XM
+1
XM
+2
XM
XM
XM
XM
XM
(b)Tableofmultiplicandselectiondecisions
= -2 bi + bi-1 + bi-2
Bit-Pair Recoding of
Multipliers
0 1 1 0 1
0 1 +1 1 0
0 1 1 0 1 ( + 13 )
1 1 0 1 0 6
0
1
0
1
0
0
1
0
1
0
0
1
0
1
0
0
1
0
0
0
0
1
1
0
0
0
0
1
1
0
0 0 0 0
0 1 1
0 1
1
1 1 1 0 1 1 0 0 1 0 78
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
Figure6.15.Multiplicationrequiringonlyn/2summands.
37
Carry-Save Addition of
CSA speeds up the addition process.
Summands
P7
P6
P5
P4
P3
P2
P1
38P0
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:
Carry-Save Addition of
Summands
1
(45)
(63)
B
C
D
E
F
(2,835)
Product
Figure6.17.AmultiplicationexampleusedtoillustratecarrysaveadditionasshowninFigure6.18.
x 1
+ 0
2
2
S1
S2
B
C
C3
C2
S4
C
1
Product
Figure6.18. ThemultiplicationexamplefromFigure6.17performedusing
carrysaveaddition.
Manual Division
13
21
274
26
1101
14
13
1
Longhanddivisionexamples.
10101
100010010
1101
10000
1101
1110
1101
1
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
Shiftleft
an
qn1
a0
an1
DividendQ
N+1bit
adder
q0
Quotient
Setting
Add/Subtract
Control
Sequencer
0
m0
mn1
DivisorM
Figure6.21.Circuitarrangementforbinarydivision.
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 q 0 to 1
Repeat these steps n times
Examples
1 0
1 1
1 0 0 0
1 1
1 0
Initially 0
0
Shift
0
Subtract 1
Set q0 1
Restore
0
Shift
0
Subtract 1
Set q0 1
Restore
0
Shift
0
Subtract 1
Set q0 0
0
0
0
1
1
0
0
0
1
1
0
1
0
0
1
1
0
1
0
1
1
1
0
0
0
0
1
1
1
0
1
1
0
1
1
1
0
0
1
1
1 0 0 0
0
0
1
1
0
0
1
1
0
0
1
0
0
1
1
0
Shift
0 0 0 1
Subtract 1 1 1 0
Set q0 1 1 1 1
Restore
1
0 0 0 1
0
1
1
1
0
0 0 0 1
0 0 1
Remainder
0 0 0
Firstcycle
0 0 0 0
0 0 0
Secondcycle
0 0 0 0
0 0 0
Thirdcycle
Fourthcycle
0 0 1 0
Quotient
Figure6.22.Arestoringdivisionexample.
Nonrestoring Division
Avoid the need for restoring A after an
unsuccessful subtraction.
Any idea?
Step 1: (Repeat n times)
Examples
Initially
1 1 1 1 1
0 0 0 1 1
Add 0 0 0 1 0
Remainder
Restore
remainder
Shift
Subtract
Set q 0
0
0
0
1
1
Shift
Add
Set q
0 0 0
1 1 1 0 0
0 0 0 1 1
1 1 1 1 1
0 0 0
1 1 1 1 0
0 0 0 1 1
0 0 0 0 1
0 0 0 1 0
1 1 1 0 1
1 1 1 1 1
0 0 1
Shift
Add
Set q
Shift
Subtract
Set q
0
0
0
0
1
1
0
0
0
1
1
0
1
0
0
1
Anonrestoringdivisionexample.
0
1
1
1
0
1 0 0 0
0 0 0
Firstcycle
0 0 0 0
Secondcycle
0 0 0 0
Thirdcycle
0 0 0 1
Fourthcycle
0 0 1 0
Quotient
.b31b30b29....................b1b0
0 V (b) 1 2 32 0.9999999998
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:
0 V (b) 1 2 n
x m1 .m 2 m3 m4 b
x 0.m1 m2 m 3 m4 m 5 m6 m 7 b
1724
SignExponentFractionalmantissa
bit
24-bit mantissa with an implied binary point to the immediate left
7-bit exponent in 2s complement form, and implied base is 2.
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)x28=1101000101(10)x25
gives: .111001110........x265
But we cannot represent an exponent of 65, in trying to normalize the
number we have underflowed our representation.
63
Applying the normalization procedure1.00111000............x2
to:
gives: 0.100111..............x264
This overflows the representation.
Sign
1
Exponent
8 or 11
Mantissa
23 or 52
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
Multiplication:
3.1415 x 108 x 1.19 x 106 = (3.1415 x 1.19 ) x 10(8+6)
Division:
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.
Rounding:
If there is a 1 in the MSB of the guard bit then a 1 is added to
Rounding
Rounding is evidently the most accurate
truncation method.
However,
Rounding requires an addition operation.
Rounding may require a renormalization, if the addition