Motorola DSP Developer's Kit |
Motorola DSP Developer's Kit |
Motorola DSP Developer's Kit | ![]() ![]() |
[ Y ] = mot###_sqrt( X )
Input/Output
Input: Vector X (includes the real part Xr
, and the imaginary part Xi
)
Output: Vector Y (includes the real part Yr,
and the imaginary part Yi
)
Algorithm
sqrt(a+bi) = [sqrt(sqrt(a^2+b^2))]*[cos(angle(a+bi)/ 2)+i*sin(angle(a+bi)/2)]
To implement it in fix point dsp, we change this to
sqrt(a+bi) = sqrt(sqrt((a^2+b^2)/2))]*[cos(angle(a+bi)/ 2)+i*sin(angle(a+bi)/2)] * [power(2,.25)]
For the ANGLE-C.ASM algorithm, please refer to angle-c.asm
. The following describes how to calculate SIN and COS
for (i=0; i < fracbits; i++) { atan_tab[i] = atan(pow(2,double(-i)))/4; } K = 0.30362641811371; X = x = K; Y = y = 0; Z = z = angle; Z = z = x>>2 ; /* Circular Function */ for (i = 0; i < fracbits; ++i) { x = X >> i; y = Y >> i; z = atan[i]; if (Z >= 0) { X -= y; Y += x; Z -= z; } else { X += y; Y -= x; Z += z; } } X = X << 1; //cos(angle) Y = Y << 1; //sin(angle) return X and Y;
Memory & Register
X,Y, i
Status Register
The assembly function sqrt-c.asm
does not explicitly set any status registers/bits during the function execution.
Data Size Limit
The length of vector X can't be larger than the continuous available data memory size.
Data Range Limit
The value of input vector X must be between -1.0 and +1.0.
Precision
In the case of DSP563, precision is 14 bits.
In the case of DSP566, precision is 15 bits.
![]() | sqrt-pr.asm | sum-r.asm | ![]() |