Texas Instruments TMS320C3x 사용자 설명서

다운로드
페이지 757
Fast Logarithms on a Floating-Point Device
 
5-44
5.11 Fast Logarithms on a Floating-Point Device
The following TMS320C30/C40 function calculates the log base two of a number
in about half the time of conventional algorithms. Furthermore, the method can
easily be scaled for faster execution if less accuracy is desired. The method is
efficient because the algorithm uses the floating-point multipliers’ exponent/nor-
malization hardware in a unique way. The following is a proof of the algorithm.
The value of a floating point number X is given by:
X = 2^EXP_old * mant_old
Since the bit fields used to store the exponent and mantissa are actually inte-
ger, the exponent is already in log2 (log base 2) form. In fact, the exponent is
nothing more than a normalizing shift value. By converting both sides of the
first equation to a logarithm, the logarithm of the value becomes the sum of the
exponent and mantissa in log form:
log2(X) = EXP_old + log2(mant_old) (Log base two)
Since EXP is in the exponent register, no calculation is needed and the value
can be used directly as an integer. To extract the value of the exponent, PUSH,
POP, and masking operations are used. The remaining mantissa conversion
is done by first forcing the exponent bits to zero using an LDE 1.0 instruction.
This causes the exponent term 2^EXP to equal 1.0, leaving 1.0 <= Value < 2.0.
Then, by using the following identity, the logarithm of the mantissa can be ex-
tracted from the final results exponent. If the value (mant_old) is repeatedly
squared, the sequence becomes:
X_new = mant_old^N
where:
1.0  
X_new < 2^N
N = 1,2,4,8,16...
Since the hardware multiplier restructures the new value (X_new) during each
squaring operation, X_new is represented by a new exponent (EXP_new) and
mantissa (mant_new):
X_new = 2^EXP_New * mant_new
By then applying familiar logarithm rules, we find that EXP_new holds the loga-
rithm of Old_mant. This is best shown by setting the previous two equations
equal to each other and taking the logarithm of both sides:
mant_old^N = 2^EXP_new * mant_new
N=1,2,4,8,16...