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.

Using mul32() with a format different than Q31

Hello all,

I am using the ezDSP C5515 kit and I am developing a speech processing algorithm. At some point I need to do some operations on Q13.18 and I am looking to use the mul32() function supplied by the TI DSPLIB.

From what I have seen from the application in the examples folder the code works for numbers in Q0.31 format. However, when the input has N fractional bits the output has 2*(N-16)+1 fractional bits which puts a very severe limit on precision. Through trial and error I found a work-around and where you need to shift the input to the left by {(N+1)-[2*(N-16)+1]}/2 in order to get an output with the desired N fractional bits. However, this puts a problem on the maximum value allowed in the input so as the shift and the multiplication will not overflow.

When I opened the code of mul32.asm I found out that it is based on cross-multiplication in order to be able to calculate a 32-bit fractional multiplication without a 64-bit register. I noticed also the example 5.9 in spru376a which has the same code. As I understand the principle is to multiply high_byte(X)*high_byte(Y)+high_byte(X)*low_byte(Y)+low_byte(X)*high_byte(Y)+low_byte(X)*low_byte(Y). However both in mul32.asm and in example 5.9 the last argument (low*low) is missing. Why is that? I see that high*high requires a shift. What shift is required for low*low? Will adding this argument make the method work for formats other than Q0.31?

I would appreciate some comments on this!

All the best,

Elias