CSE 246: Computer Arithmetic Algorithms and Hardware Design Instructor: Prof. Chung-Kuan Cheng Fall 2006 Lecture 7 Division
CSE 2462 Topics: Division Restoring Division Nonrestoring Division High Radix Division
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 = R0=AR0=A R2R R3R R4R R1R1 Q 1 = 0.1 Q 2 = 0.01 Q 3 = Q 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.
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
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
CSE 2467 Division Nomenclature Z = dq + s Z: dividend d: divisor q: quotient s: remainder q = Z / d
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
CSE 2469 Nonrestoring Division 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 = = s = 1 1
CSE Quotient Digit Conversion 1. Replace – 1 with 0 2. Shift left by one bit Example:
CSE 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)
CSE High Radix Division SRT (Sweeney, Robertson, & Tocher) 1. nonrestoring 2. redundant quotient 3. carry-save addition
CSE 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 -½-½ ½
CSE Radix-2 SRT Example s (0) ≥ ½ ; q 1 = 1 - ½ < s (1) < ½ ; q 2 = 0 s (2) ≥ ½ ; q 3 = 1 s (3) ≥ ½ ; q 4 = 1 q = 1.010, s =
CSE Another Radix-2 SRT Example s (0) ≥ ½ ; q 1 = 1 - ½ < s (1) < ½ ; q 2 = 0 s (2) < - ½ ; q 3 = -1 q = 1.0(-1)(-1) s = ½ < s (3) < ½ ; q 4 = 0
CSE 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)
CSE 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