Division algorithm
Several algorithms exist to perform division in digital designs. These algorithms fall into two main categories: slow division and fast division. Slow division algorithms produce 1 digit of the final quotient per iteration. Examples of slow division include Restoring, Non-performing Restoring, Non-Restoring, and SRT division. Fast division methods start with a close approximation to the final quotient and produce twice as many digits of the final quotient on each iteration. Newton-Raphson and Goldschmidt fall into this category.
The following division methods are all based on the form where:
Q = Quotient N = Numerator (dividend) D = Denominator (divisor)
Slow Division
Slow division methods are all based on a standard recurence equation: where:
= the partial remainder of the division R = the radix = the digit of the quotient in position n-j+1 (the position numbers begin with 0 and are numbered from least-significant (0) to most significant (n-1) n = number of digits in the quotient D = the denominator
Restoring Division
Restoring Division operates on fixed-point fractional numbers and depends on the following assumptions:
The quotient digits 'q' are formed from the digit set {0,1}
The basic algorithm for binary (radix 2) restoring division is:
P[0] = N i=0 while(i<n) { TP[i+1] = 2P*[i] - D if(TP[i] > 0) q[n-(i+1)] = 1; P[i+1] = TP[i+1] if(TP[i} <= 0) q[n-(i+1)] = 0; P[i+1] = TP[i+1] + D i++ }
Non-performing restoring division is similar to restoring division except that the falue of 2*P[i] is saved, so D does not need to be added back in for the case of TP[i] <= 0.
Non-Restoring Divsion
Non-Restoring division uses the digit set {-1,1} for the quotient digits insted of {0,1}. The basic algorithm for binary (radix 2) non-restoring division is:
P[0] = N i = 0 while(i<n) { if(P[i] >= 0) q[n-(i+1)] = 1; P[i+1] = 2*P[i] - D if(P[j] < 0) q[n-(i+1)] = -1; P[i+1] = 2*P[i] + D i++ }
Following this algorithm, the quotient is in a non-standard form consisting of digits of -1 and +1. This form needs to be converted to binary to form the final quotient. Example:
Convert the following quotient to the digit set {0,1}: Steps: 1. Mask the negative term: 2. Form the Two's complement of N: 3. Form the positive term: 4. Sum and :
SRT Division
Named for its creators (Sweeny, Robertson, and Toker), SRT division is a popular method for division in many microprocessor implementations. SRT division is similar to Non-Restoring division, but it uses a lookup table based on the dividend and the divisor to determine each quotient digit. The Intel Pentium processor's infamous divider bug was cause by an incorrectly coded lookup table.
Fast Division
Newton-Raphson Division
Newton-Raphson uses Newton's method to converge to the quotient. The strategy of Newton-Raphson is to find the reciprocal of D, and multiply that reciprocal by N to find the final quotient Q.
The steps of Newton-Raphson are:
- Calculate an estimate for the reciprocal of the divisor (D):
- Compute successively more accurate estimates of the reciprocal:
- Compute the quotient by multiplying the dividend by the reciprocal of the divisor:
Assuming the divisor is scaled so , the initial estimate for the reciprocal of the divisor is:
Successively more accurate estimates of the reciprocal can be calculated using:
Goldschmidt Division
Goldschmidt uses series expansion to converge to the quotient. The strategy of Goldschmidt is repeatedly multiply the dividend and divisor by a factor F to converge the divisor to 1 as the dividend converges to the quotient Q:
The steps for Goldschmidt are:
- Calculate an estimate for the muliply factor .
- Multiply the dividend and divisor by .
- Loop to step 1.
Assuming the divisor is scaled so , the first factor is:
Multiplying the dividend and divisor by the factor yields:
After a sufficient number of iterations 'k':