Division by Convergence - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Division by Convergence

Description:

Division by convergence (and reciprocation) requires. multiplications ... Division by Reciprocation. To compute 1/d, ... Must use other means for Reciprocation: ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 18
Provided by: mitchth
Category:

less

Transcript and Presenter's Notes

Title: Division by Convergence


1
Division by Convergence
  • Previous division schemes can be viewed as
    manipulation of s and q in k cycles where
  • s ? 0
  • and q converges to the quotient in O(k) cycles
  • Basic step involves addition/subtraction in a
    digit-recurrence scheme
  • Division by convergence (and reciprocation)
    requires
  • multiplications
  • converges in O(log k) cycles

2
Division by Repeated Multiplication
q z/d z/d ? x (0)/x (0) ? x (1)/ x (1) . .
. x (m -1) ? x (m -1) ? q/1 To turn the above
into a division algorithm, we face three
questions 1. How to select the multipliers
x(I)? 2. How many iterations (pairs of
multiplications)? 3. How to implement in hardware?
3
Division by Convergence
Formulate as convergence computation, for d in
1/2, 1) d (i1) d (i) x (i) Set d (0) d
make d (m) converge to 1 z (i1) z (i) x (i)
Set z (0) z obtain z/d q _at_ z (m)
Q1 How to select the multipliers x(i)? x (i) 2
d (i) This choice transforms the recurrence
equations into d (i1) d (i) (2 d (i)) Set d
(0) d iterate until d (m) _at_ 1 z (i1) z
(i)(2 d (i)) Set z (0) z obtain z/d q _at_
z(m)
4
Division by Convergence
Q2 How quickly does d (i) converge to 1? d
(i1) d (i) (2 d (i) ) 1 (1 d (i) )2 1
d (i1) (1 d (i) )2 Thus, 1 d (i) e
leads to 1 d (i1) e2 quadratic
convergence In general, for k-bit operands, we
need 2m 1 multiplications and m 2s
complementations where m élog2kù
5
Quadratic Convergence
-----------
----- i d(i) d(i1)x (i1), with d (0)
d x (i) 2 d (i)
---------------- 0 1 y
(.1xxx xxxx xxxx xxxx)two ³ 1/2 1 y 1 1 y2
(.11xx xxxx xxxx xxxx)two ³ 3/4 1 y2 2 1
y4 (.1111 xxxx xxxx xxxx)two ³ 15/16 1 y4 3
1 y8 (.1111 1111 xxxx xxxx)two ³ 255/256 1
y8 4 1 y16 (.1111 1111 1111 1111)two 1
ulp
Note 1/2 d 1 y lt 1
6
Quadratic Convergence
Q3 How implemented in hardware? to be
discussed later
7
Division by Reciprocation
To find q z/d, compute 1/d and multiply it by
z Particularly efficient if several divisions by
d are required Newton-Raphson iteration to
determine a root of f(x) 0 Start with initial
estimate x(0) for the root Iteratively refine
using the recurrence x(i1) x(i) f(x (i)) /
f'(x (i)) Justification tan a (i) f'(x(i))
f(x(i) ) / (x (i) x (i1) )
8
Division by Reciprocation
To compute 1/d, find the root of f(x) 1/x
d f'(x) 1/x2, leading to the
recurrence x(i1) x(i) (2 x(i)d) One
iteration 2 multiplications a 2s
complementation Let d (i) 1/d x (i) be the
error at the ith iteration. Then d(i1) 1/d
x (i1) 1/d x (i) (2 x (i)d) d(1/d x
(i))2 d(d (i))2 Because d lt 1, we have d(i1) lt
(d (i))2
9
Choosing the Initial Value of x(0)
0 lt x (0) lt 2/d Þ d (0) lt 1/d Þ guaranteed
convergence For d in 1/2, 1) simple choice x
(0) 1.5 Þ d x(0) 0.5 better approx. x
(0) 4(31/2 1) 2d 2.9282 2d max error _at_
0.1
10
Speedup of Convergence Division
Division can be done via 2 élog2kù 1
multiplications This is not yet very
impressive 64-bit numbers, 5-ns multiplier Þ
55-ns division Three types of speedup are
possible Reducing the number of
multiplications Using narrower
multiplications Performing the multiplications
faster
11
Speedup of Convergence Division
Convergence is slow in the beginning It takes 6
multiplications to get 8 bits of convergence
and another 5 to go from 8 bits to 64
bits dx(0)x(1)x(2) (0.1111 1111 . .
.)two ----------- x(0) read from table A 2w w
lookup table is necessary and sufficient for w
bits of convergence after the first pair of
multiplications
12
Convergence Can Occur From Top or Bottom
13
Truncating 1 y(i) for Speedup
14
Example
Example (64-bit multiplication) Table of size 256
8 2K bits for the lookup step Then we need
multiplication pairs, with the multiplier being 9
bits, 17 bits, and 33 bits wide The final step
involves a single 64 64 multiplication
15
Hardware Implementation
z(i)x (i) can be pipelined with d (i) x (i)
Must use other means for Reciprocation Can begin
with a good approximation to the reciprocal by
consulting a large table or table lookup, along
with interpolation
16
Analysis of Lookup Table Size
Sample entries in the lookup table replacing the
first four multiplications in division by
repeated multiplications
------------ Address d 0.1
xxxx xxxx x(0) 1. xxxx xxxx
-------------- 55 0011
0111 1010 0101 64 0100 0000 1001
1001 ------------
-- Example d 0.1001 1011 1, so value in
range 311/512 d lt312/512
17
Analysis of Lookup Table Size
For 8 bits of convergence, the table entry f must
satisfy 311/512 (1 .f) ³ 1 28 312/512(1
.f) 1 28 Thus 199/311 .f 101/156 or for
the integer f 256 .f 163.81 .f
165.74 Two choices (address 55) 164 (1010
0100)two or 165 (1010 0101)two
Write a Comment
User Comments (0)
About PowerShow.com