Texas Instruments TMS320C64X User Manual

Page 97

Advertising
background image

DSP_recip16

4-69

C64x+ DSPLIB Reference

16-Bit Reciprocal

DSP_recip16

Function

void DSP_recip16 (short *x, short *rfrac, short *rexp, short nx)

Arguments

x[nx]

Pointer to Q.15 input data vector of size nx.

rfrac[nx]

Pointer to Q.15 output data vector for fractional values.

rexp[nx]

Pointer to output data vector for exponent values.

nx

Number of elements of input and output vectors.

Description

This routine returns the fractional and exponential portion of the reciprocal of
an array x[ ] of Q.15 numbers. The fractional portion rfrac is returned in Q.15
format. Since the reciprocal is always greater than 1, it returns an exponent
such that:

(rfrac[i] * 2rexp[i]) = true reciprocal

The output is accurate up to the least significant bit of rfrac, but note that this
bit could carry over and change rexp. For a reciprocal of 0, the procedure will
return a fractional part of 7FFFh and an exponent of 16.

Algorithm

This is the C equivalent of the assembly code without restrictions. Note that
the assembly code is hand optimized and restrictions may apply.

void DSP_recip16(short *x, short *rfrac, short *rexp, short
nx)

{

int i,j,a,b;

short neg, normal;

for(i=nx; i>0; i−−)

{

a=*(x++);

if(a<0)

/* take absolute value */

{

a=−a;

neg=1;

}

else neg=0;

normal=_norm(a);

/* normalize number */

a=a<<normal;

Advertising