This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DSPLIB recip16 & ldiv16 functions

I'd like to use the recip16 and ldiv16 functions in DSPLIB, but the documentation leaves much to be desired.

For instance recip16()  takes an input X of type Q.15 and returns two outputs, R and REXP, both of type Q.15. The documentation states that  R*REXP is the "true reciprocal" of X. That would seem to imply that

X * R * REXP = 1<<32

but I doubt this. I suspect that

(X * R) << REXP = 1<<32

Which statement is true?

The function ldiv16 is described with similar ambiguity. Its inputs are X (Q.31), Y (Q.15) and its outputs are R and REXP (both Q.15). The documentation of these latter seems to have been copied from recip16 and doesn't make sense in this context. I'm guessing that what's really meant is that

(Y * R) <<REXP = X

Is this interpretation correct?

Finally, the documentation for both functions mentions that they are based on an iteration of the form:

Ym = 2 * Ym - Ym * Ym * Xnorm

but neither Ym nor Xnorm are defined. Does anyone understand what's going on here?

 

  • David,

    Have you looked at the source code for the functions you are interested in?  They contain better description sometimes. 

    The recip16.asm code defines result as: reciprocal = z[i] * zexp[i].  It also describes the algorithm which is used in the computation.

    The ldiv16.asm code defines the division as x * 1/y, so it does use the recip16 function to calculate 1/y.

    Regards.