Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE 246: Computer Arithmetic Algorithms and Hardware Design Instructor: Prof. Chung-Kuan Cheng Winter 2004 Lecture 7.

Similar presentations


Presentation on theme: "CSE 246: Computer Arithmetic Algorithms and Hardware Design Instructor: Prof. Chung-Kuan Cheng Winter 2004 Lecture 7."— Presentation transcript:

1 CSE 246: Computer Arithmetic Algorithms and Hardware Design Instructor: Prof. Chung-Kuan Cheng Winter 2004 Lecture 7

2 CSE 2462 Topics: Midterm Sample Posted Division  Restoring Division  Nonrestoring Division  High Radix Division

3 CSE 2463 Midterm Sample Posted: Midterm Date: 2/10/2004 The midterm will cover topics discussed in the class as well as the assigned homework. A Sample Midterm is posted at: http://www.cse.ucsd.edu/classes/wi04/cse246/sample.pdf

4 CSE 2464 Division Division is much more complicated than multiplication MultiplicationDivision X Y Z (n bits) (2n bits) q d Z (n bits) (2n bits) s (n bits) multiplication division

5 CSE 2465 Division Nomenclature Z = dq + s Z: dividend d: divisor q: quotient s: remainder q = Z / d

6 CSE 2466 A Simple Example 0 1 1 0 1 0 10 1 1 0 0 1 1 1 0 1 0 1 1 This is called “ restoring ” division because we compare the partial remainder to the divisor (using a subtraction) and place a zero in the quotient if the result was negative.

7 CSE 2467 Nonrestoring Division 0 1 1 0 1 0 10 1 1 1-1 1 0 1 0 0 1 1 0 1 -1 1 1 0 0 1 0 1 0 0 0 0 1 1 1 0 1 -1 1 1 0 - - + (negative) If the partial remainder is positive, divide by +1. If the partial remainder is negative, divide by – 1. The last positive remainder is correct. q = 1 1-1 0 = 1 0 1 0 s = 1 1

8 CSE 2468 Quotient Digit Conversion 1. Replace – 1 with 0 2. Shift left by one bit Example: 1 1-1-1 1-1-1 1 0 0 1 0 0 1

9 CSE 2469 Faster Division The division algorithms presented are O(n log n). How do we reduce this? If we use radix-4 division, this changes to O((n/2) log n) If we use radix-4 division and carry save addition, we can achieve O(n/2)

10 CSE 24610 High Radix Division SRT (Sweeney, Robertson, & Tocher) 1. nonrestoring 2. redundant quotient 3. carry-save addition

11 CSE 24611 Radix-2 SRT Division Assumption: ½ ≤ d < 1 s (0) є [-½, ½) (If this assumption does not hold, we make it so by modifying the operands) If 2s (j-1) < -½ Then q j = -1 Else If 2s (j-1) ≥ -½ Then q j = 1 Else q j = 0 2s (j-1) qjqj 1 -½-½ ½

12 CSE 24612 Radix-2 SRT Example.1 1 0 1 1 0.1 0 1 1 0 1 1 1 0 1 0 1 1 0 0 0 1 1 1 1 0 1 1 0 0 1 0 1 -1 1 1 s (0) ≥ ½ ; q 1 = 1 - ½ < s (1) < ½ ; q 2 = 0 s (2) ≥ ½ ; q 3 = 1 s (3) ≥ ½ ; q 4 = 1 q = 1.010, s =.000100

13 CSE 24613 Another Radix-2 SRT Example.1 0 0 0 1 1.1 1 0 1 0-1 0 1 1 0 -1 0 0 0 0 0 -1 0 0 1 1 1 0 -1 1 1 s (0) ≥ ½ ; q 1 = 1 - ½ < s (1) < ½ ; q 2 = 0 s (2) < - ½ ; q 3 = -1 q = 1.0(-1)(-1) s =.000101 + - ½ < s (3) < ½ ; q 4 = 0

14 CSE 24614 Radix-2 SRT Division Continued ½ ≤ d < 1(1) s (j-1) є [-½, ½)(2) 2s (j-1) є [-1, 1)(3) (from (2)) s (j) = 2s (j-1) – q j d є [-½, ½) (4)

15 CSE 24615 Radix-4 Division ½ ≤ d < 1 4s (j-1) = q j d + s (j) q j є [-3, 3] Limit the range of the quotient to q j є [-2, 2] s (j-1) є [-hd, hd] h < 1 4s (j-1) є [-4hd, 4hd] In order to have q j є [-2, 2] we need -4hd + 2d ≥ -hd  2d ≥ 3hd 4hd - 2d ≤ hd  3hd ≤ 2d or h ≤ 2/3


Download ppt "CSE 246: Computer Arithmetic Algorithms and Hardware Design Instructor: Prof. Chung-Kuan Cheng Winter 2004 Lecture 7."

Similar presentations


Ads by Google