Upload
basil
View
49
Download
0
Embed Size (px)
DESCRIPTION
Lecture 10. Fast Dividers. Required Reading. Behrooz Parhami, Computer Arithmetic: Algorithms and Hardware Design. Chapter 14, High-Radix Dividers Note errata at: http://www.ece.ucsb.edu/~parhami/text_comp_arit_1ed.htm#errors. Recommended Reading. J-P. Deschamps, G. Bioul, G. Sutter, - PowerPoint PPT Presentation
Citation preview
1
FastDividers
Lecture 10
Required Reading
Chapter 14, High-Radix Dividers
Note errata at:http://www.ece.ucsb.edu/~parhami/text_comp_arit_1ed.htm#errors
Behrooz Parhami, Computer Arithmetic: Algorithms and Hardware Design
Recommended Reading
J-P. Deschamps, G. Bioul, G. Sutter, Synthesis of Arithmetic Circuits: FPGA, ASIC and Embedded Systems
Chapter 6, Arithmetic Operations: Division6.2.4, SRT Radix-2 Division6.2.5, SRT Radix-2 Division with Stored Carry Encoding6.2.6, P-D Diagram6.2.7, SRT-4 Division
Chapter 13, Dividers13.2.3, SRT Dividers13.2.4, SRT-4 Divider
4
Classification of Dividers
Sequential
Radix-2 High-radix
RestoringNon-restoring
• regular• SRT• regular using carry save adders• SRT using carry save adders
ArrayDividers
Dividersby Convergence
5
ArrayDividers
6
Unsigned Fractional Division
zfrac Dividend .z-1z-2 . . . z-(2k-1)z-2k
dfrac Divisor .d-1d-2 . . . d-(k-1) d-k
qfrac Quotient .q-1q-2 . . . q-(k-1) q-k
sfrac Remainder .000…0s-(k+1) . . . s-(2k-1) s-2kk bits
7
Integer vs. Fractional Division
For Integers:
z = q d + s 2-2k
z 2-2k = (q 2-k) (d 2-k) + s (2-2k)
zfrac = qfrac dfrac + sfrac
For Fractions:
wherezfrac = z 2-2k
dfrac = d 2-k
qfrac = q 2-k
sfrac = s 2-2k
8
Unsigned Fractional Division Overflow
Condition for no overflow:
zfrac < dfrac
9
Sequential Fractional DivisionBasic Equations
s(0) = zfrac
s(j) = 2 s(j-1) - q-j dfrac
2k · sfrac = s(k)
sfrac = 2-k · s(k)
10
Restoring Unsigned Fractional Division
s(0) = z
for j = 1 to k if 2 s(j-1) - d > 0 q-j = 1 s(j) = 2 s(j-1) - d else q-j = 0 s(j) = 2 s(j-1)
11
Fig. 15.7 Restoring array divider composed of controlledsubtractor cells.
12
Non-Restoring Unsigned Fractional Division
s(-1) = z-dfor j = 0 to k-1 if s(j-1) 0 q-j = 1 s(j) = 2 s(j-1) - d else q-j = 0 s(j) = 2 s(j-1) + dend forif s(k-1) 0 q-k = 1else
q-k = 0 Correction step
13
Fig. 15.8 Nonrestoring array divider built of controlledadd/subtract cells.
14
SequentialDividers
15
Sequential Fractional DivisionBasic Equations
s(0) = zfrac
s(j) = 2 s(j-1) - q-j dfrac
2k · sfrac = s(k)
sfrac = 2-k · s(k)
16
Non-restoring Fractional Division
s(0) = zfor j = 1 to k if 2s(j-1) 0 q-j = 1
s(j) = 2 s(j-1) - d else
q-j = -1
s(j) = 2 s(j-1) + dend for
q = BSD_2’s_comp_conversion(q)Correction_step
17
Integer Division
Correction step
We have: z = q d + s
z = (q-1) d + (s+d)z = q’ d + s’
z = (q+1) d + (s-d)z = q” d + s”
We need: sign(s) = sign (z)
18
Fractional Division
Correction step
We have: zfrac = qfrac dfrac + sfrac
zfrac = (qfrac–2-k) dfrac + (sfrac+dfrac 2-k)zfrac = q’frac dfrac + s’frac
zfrac = (qfrac+2-k) dfrac + (sfrac – dfrac 2-k)zfrac = q”frac dfrac + s”frac
We need: sign(sfrac) = sign(zfrac)
19
Non-restoring Fractional Division
s(0) = zfor j = 1 to k if 2s(j-1) 0 q-j = 1
s(j) = 2 s(j-1) - d else
q-j = -1
s(j) = 2 s(j-1) + dend for
q = BSD_2’s_comp_conversion(q)Correction_step
20
Fig. 14.3 The new partial remainder, s(j), as a function of the shifted old partial remainder, 2s(j–1), in radix-2 nonrestoring division.
21
Fig. 14.4 The new partial remainder s(j) as a function of 2s(j–1), with q–j in {–1, 0, 1}.
22
Non-restoring Fractional Division with shifting over zeros
s(0) = zfor j = 1 to k if 2s(j-1) d q-j = 1
s(j) = 2 s(j-1) - d elseif 2s(j-1) < -d q-j = -1 s(j) = 2 s(j-1) + d else q-j = 0 s(j) = 2 s(j-1)
end forConversion of qCorrection step
23
SRT Non-Restoring Fractional DivisionAssumptions
d 1/2 (positive, bit-normalized divider)
-d ≤ -1/2 ≤ z, s(j) < 1/2 < d
If the latter condition not true: z = z >> 1 perform k+1 instead of k steps of the algorithm q = q << 1 and s = s << 1
z’=z/2 and z’=q’·d + s’
z = 2z’ = (2q’) ·d + 2s’=q ·d + s
24
Fig. 14.5 The relationship between new and old partial remainders in radix-2 SRT division.
25
SRT Non-Restoring Fractional Division
s(0) = zfor j = 1 to k if 2s(j-1) 1/2 q-j = 1
s(j) = 2 s(j-1) - d elseif 2s(j-1) < -1/2 q-j = -1 s(j) = 2 s(j-1) + d else q-j = 0 s(j) = 2 s(j-1)
end forConversion of qCorrection step
26
27
28
Fig. 14.6 Example of unsigned radix-2 SRT division.
29
SequentialDividers
with Carry-Save Adders
30
Fig. 14.8 Block diagram of a radix-2 divider with partialremainder in stored-carry form.
31
Using Carry-Save Adders with the Dividers
sum = u = u1u0.u-1u-2u-3u-4….u-k
carry = v = v1v0.v-1v-2v-3v-4….v-k
t = u1u0.u-1u-2 + v1v0.v-1v-2
u + v - t = 00.00u-3u-4….u-k + 00.00v-3v-4….v-k
< 0 1
2
32
Using Carry-Save Adders with the Dividers
0 t1
2-
t 0
q-j = 1
t <
q-j = -1
1
2-
u+v <1
2-1
2
t < 01
2-
q-j = 0
u+v < 0 u+v 0
33
34
Fig. 14.7 Constant thresholds used for quotient digitselection in radix-2 division with qk–j in {–1, 0, 1}.
35
Fig. 14.10 A p-d plot for radix-2 division with d[1/2,1), partial remainder in[–d, d), and quotient digits in [–1, 1].
d
p
Infeasible region (p cannot be 2d)
Infeasible region (p cannot be < 2d)
.100 .101 .110 .111 1.
00.1
00.0
11.1
10.0
10.1
11.0
01.1
01.0
00.1
01.0
01.1
10.0
d
2d
2d
d
Worst-case error margin in comparison
Choose 1
Choose 1
Choose 0
1
1
1 max
1 min
1 min
1 max
0 max
0 min
Ove
rla
p
Ove
rla
p
0
p-d Plot for Radix-2 Division
36
High-RadixSequentialDividers
37
Radix-4 division in dot notation
38
Radix-4 fractional division with left shifts and q–j [–3, 3]
s(j) = 4 s(j–1) – q–j d with s(0) = z and s(k) = 4k s|–shift–||–– subtract ––|
Two difficulties: How do you choose from among the 7 possible values for qj? If the choice is +3 or 3, how do you form 3d?
New Versus Shifted Old Partial Remainder in Radix-4 Division
39
d
p
Infeasible region (p cannot be 4d)
.100 .101 .110 .111
10.1
10.0
01.1
00.0
00.1
01.0
11.1
11.0
d
2d
Choose 2
Choose 0
Choose 1
3
1
2 max
2 min
1 min
1 max
0 max
Ove
rlap
0
3d
4d
Choose 3
3 min
2
Ove
rlap
O
verla
p
Fig. 14.12 A p-d plot for radix-4 SRT division with quotient digit set [–3, 3].
p-d Plot for Radix-4 SRT Division with Digit Set [-3,3]
–4d 4d
d
–d
4s (j–1)
–3 –2 –1 0 +1 +2 +3
s (j)
2d/3
8d/3 –2d/3
–8d/3
Fig. 14.13 New versus shifted old partial remainder in radix-4 division with q–j in [–2, 2].
Radix-4 fractional division with left shifts and q–j [–2, 2]
s(j) = 4 s(j–1) – q–j d with s(0) = z and s(k) = 4k s|–shift–||–– subtract ––|
For this restriction to be feasible, we must have: s [hd, hd) for some h < 1, and 4hd – 2d hd This yields h 2/3 (choose h = 2/3 to minimize the restriction)
Radix-4 SRT Divider with the Digit Set {-2, -1, 0, 1, 2}
41
d
p
.100 .101 .110 .111
10.1
10.0
01.1
00.0
00.1
01.0
11.1
11.0
Choose 2
Choose 0
Choose 1 1
2 min
1 min
2 max
1 max
0 max
0
2
Ove
rlap
O
verla
p
Infeasible region (p cannot be 8d/3)
8d/3
5d/3
4d/3
2d/3
d/3
Fig. 14.14 A p-d plot for radix-4 SRT division with quotient digit set [–2, 2].
p-d Plot for Radix-4 SRT Division with Digit Set [-2,2]
42
Carry v
CSA tree
Adder
Divisor d
k k
Select q –j
Shift left
2s Sum u
Multiple generation /
selection
Carry Sum
q –j
. . . q –j | | d or its complement
Fig. 14.15 Block diagram of radix-r divider with partial remainder in stored-carry form.
Process to derive the details:
Radix r
Digit set [–, ] for q–j
Number of bits of p (v and u) and d to be inspected
Quotient digit selection unit (table or logic)
Multiple generation/selection scheme
Conversion of redundant q to 2’s complement
Radix r Divider
43
Multiply/DivideUnit
44
The control unit proceeds through necessary steps for multiplication or division (including using the appropriate shift direction)
Fig. 15.9 Sequential radix-2 multiply/divide unit.
Multiplier x or quotient q
Mux
Adder out c
0 1
Partial product p or partial remainder s
Multiplicand a or divisor d
Shift control
Shift
Enable
in c
q k–j
MSB of 2s (j–1)
k
k
k
j x
MSB of p (j+1)
Divisor sign
Multiply/ divide control
Select
Mul Div
The slight speed penalty owing to a more complex control unit is insignificant
Multiply-Divide Unit