Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 10 Fast Dividers.

Similar presentations


Presentation on theme: "Lecture 10 Fast Dividers."— Presentation transcript:

1 Lecture 10 Fast Dividers

2 Computer Arithmetic: Algorithms and Hardware Design
Required Reading Behrooz Parhami, Computer Arithmetic: Algorithms and Hardware Design Chapter 14, High-Radix Dividers Note errata at:

3 Recommended Reading J-P. Deschamps, G. Bioul, G. Sutter, Synthesis of Arithmetic Circuits: FPGA, ASIC and Embedded Systems Chapter 6, Arithmetic Operations: Division 6.2.4, SRT Radix-2 Division 6.2.5, SRT Radix-2 Division with Stored Carry Encoding 6.2.6, P-D Diagram 6.2.7, SRT-4 Division Chapter 13, Dividers 13.2.3, SRT Dividers 13.2.4, SRT-4 Divider

4 Classification of Dividers
Array Dividers Dividers by Convergence Sequential Radix-2 High-radix Restoring Non-restoring regular SRT regular using carry save adders SRT using carry save adders

5 Array Dividers

6 Unsigned Fractional Division
zfrac Dividend z-1z z-(2k-1)z-2k dfrac Divisor d-1d d-(k-1) d-k qfrac Quotient q-1q q-(k-1) q-k sfrac Remainder …0s-(k+1) s-(2k-1) s-2k k 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) For Fractions: zfrac = qfrac dfrac + sfrac where zfrac = 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 Division
Basic 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 controlled subtractor cells.

12 Non-Restoring Unsigned Fractional Division
s(-1) = z-d for 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) + d end for if s(k-1)  0 q-k = 1 q-k = 0 Correction step

13 Fig. 15.8 Nonrestoring array divider built of controlled add/subtract cells.

14 Sequential Dividers

15 Sequential Fractional Division
Basic 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) = z for 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) + d end for q = BSD_2’s_comp_conversion(q) Correction_step

17 Integer Division Correction step We have: z = q d + s
We need: sign(s) = sign (z) z = (q-1) d + (s+d) z = q’ d + s’ z = (q+1) d + (s-d) z = q” d + s”

18 Fractional Division Correction step
We have: zfrac = qfrac dfrac + sfrac We need: sign(sfrac) = sign(zfrac) 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

19 Non-restoring Fractional Division
s(0) = z for 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) + d end for q = BSD_2’s_comp_conversion(q) Correction_step

20 Fig 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) = z for 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 for Conversion of q Correction step

23 SRT Non-Restoring Fractional Division
Assumptions 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) = z for 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 for Conversion of q Correction step

26

27

28 Fig. 14.6 Example of unsigned radix-2 SRT division.

29 Sequential Dividers with Carry-Save Adders

30 Fig. 14.8 Block diagram of a radix-2 divider with partial remainder 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 v1v0.v-1v-2 u + v - t = 00.00u-3u-4….u-k + 00.00v-3v-4….v-k 1 2 0  <

32 Using Carry-Save Adders with the Dividers
1 2 - t 1 2 1 2 t < - -  t < 0 t  0 1 2 1 2 -  u+v < u+v  0 u+v < 0 q-j = -1 q-j = 0 q-j = 1

33

34 Fig Constant thresholds used for quotient digit selection in radix-2 division with qk–j in {–1, 0, 1}.

35 p-d Plot for Radix-2 Division
Fig A p-d plot for radix-2 division with d  [1/2,1), partial remainder in [–d, d), and quotient digits in [–1, 1].

36 High-Radix Sequential Dividers

37 Radix-4 division in dot notation

38 New Versus Shifted Old Partial Remainder in Radix-4 Division
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 q-j? If the choice is +3 or -3, how do you form 3d?

39 p-d Plot for Radix-4 SRT Division with Digit Set [-3,3]
Fig A p-d plot for radix-4 SRT division with quotient digit set [–3, 3].

40 Radix-4 SRT Divider with the Digit Set {-2, -1, 0, 1, 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 ––| Fig New versus shifted old partial remainder in radix-4 division with q–j in [–2, 2]. 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)

41 p-d Plot for Radix-4 SRT Division with Digit Set [-2,2]
Fig A p-d plot for radix-4 SRT division with quotient digit set [–2, 2].

42 Radix r Divider 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 Fig Block diagram of radix-r divider with partial remainder in stored-carry form.

43 Multiply/Divide Unit

44 Multiply-Divide Unit The control unit proceeds through necessary steps for multiplication or division (including using the appropriate shift direction) The slight speed penalty owing to a more complex control unit is insignificant Fig Sequential radix-2 multiply/divide unit.


Download ppt "Lecture 10 Fast Dividers."

Similar presentations


Ads by Google