Download presentation
Presentation is loading. Please wait.
Published byToby Terry Modified over 9 years ago
1
CSE 246: Computer Arithmetic Algorithms and Hardware Design Instructor: Prof. Chung-Kuan Cheng Fall 2006 Lecture 7 Division
2
CSE 2462 Topics: Division Restoring Division Nonrestoring Division High Radix Division
3
CSE 2463 Division – Iteration effort Pencil and paper method: (A=QB+2 -n R and R<B) 1 bit partial quotient per iteration, n iterations A =0.1110, B =0.010; Q = A / B. Q i : Partial Quotient R i : Partial Remainder R i+1 = R i – B Q i Q = 0.1110 + 1 0 0 11 0 R0=AR0=A 1 1 0 R2R2 1 0 1 0 1 0 0 R3R3 0 0 0 1 0 0 R4R4 1 0 1100.1 1 0 0 0 R1R1 Q 1 = 0.1 Q 2 = 0.01 Q 3 = 0.001 Q 4 = 0.0000
4
CSE 2464 Division – Memory effort Lookup table is the simplest way to obtain multiple partial quotient bits in each iteration. SRT method: a lookup tables stores m-bit partial quotients decided by m bits of partial remainder and m bits of divisor. Table size: 2 2m m STR method is limited by memory wall.
5
CSE 2465 Division – Solution space Iteration Effort Memory Effort Arithmetic Effort Memory Wall Pencil-and-paper SRT Prescaling Taylor Expansion Low area Series Expansion Low latency Our target
6
CSE 2466 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
7
CSE 2467 Division Nomenclature Z = dq + s Z: dividend d: divisor q: quotient s: remainder q = Z / d
8
CSE 2468 A Simple Example 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. 0 1 1 0 1 0 10 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 0 1 1 0
9
CSE 2469 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 1 1 1 0 1 -1 1 1 0 - - + 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
10
CSE 24610 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
11
CSE 24611 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)
12
CSE 24612 High Radix Division SRT (Sweeney, Robertson, & Tocher) 1. nonrestoring 2. redundant quotient 3. carry-save addition
13
CSE 24613 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 -½-½ ½
14
CSE 24614 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
15
CSE 24615 Another Radix-2 SRT Example.1 0 0 0 1 1.1 1 0 1 0-1 0 1 1 0 -1 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
16
CSE 24616 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)
17
CSE 24617 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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.