This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

CMSIS DSP Library

Note: This was originally posted on 27th November 2012 at http://forums.arm.com

Hi,

I am new user to CMSIS. I have gone through the DSP library function. I am interested in fixed point arithemetic.

As per the documentation, i have understood that Q7, Q15 and Q31 formats are only supported. Is that correct ?


I would like to multiply different Q formats. Example : For multiplication, input 1 is Q17, input2 is Q 27 and output required is Q19.

How can we use the DSP library functions such as arm_mult_q31 for the example mentioned ?
Parents
  • Note: This was originally posted on 27th November 2012 at http://forums.arm.com

    Why do you want to mix and match lots of Q formats?

    Because you always end up doing format conversion you pretty rapidly accumulate error, so it's not entirely sure what you hope to achieve.

    The Q7, Q15, and Q31 formats are chosen because they always encode a value between -1 and 1. Q7 is encoded in a byte value, Q15 as a short, and Q32 as a long. In each case you get N-1 fractional bits plus a single integer bit (effectively only acting as a 2's complement sign bit for these formats), so the only difference is effective precision of the fractional part.

    The advantage of this approach is that if you multiply two numbers together there is little normalization to do (you are guaranteed to only get one integer bit out). As soon as you allow multiple integer bits then you need to rescale the inputs and outputs (worst case in a format with N integer bits you get 2N integer bits in the output), and you start accumulating error and generating values you cannot actually legally encode in your format. This is very hard to encapsulate in any library, and is often the "wrong solution" because it has so many corner cases.

    HTH,
    Iso
Reply
  • Note: This was originally posted on 27th November 2012 at http://forums.arm.com

    Why do you want to mix and match lots of Q formats?

    Because you always end up doing format conversion you pretty rapidly accumulate error, so it's not entirely sure what you hope to achieve.

    The Q7, Q15, and Q31 formats are chosen because they always encode a value between -1 and 1. Q7 is encoded in a byte value, Q15 as a short, and Q32 as a long. In each case you get N-1 fractional bits plus a single integer bit (effectively only acting as a 2's complement sign bit for these formats), so the only difference is effective precision of the fractional part.

    The advantage of this approach is that if you multiply two numbers together there is little normalization to do (you are guaranteed to only get one integer bit out). As soon as you allow multiple integer bits then you need to rescale the inputs and outputs (worst case in a format with N integer bits you get 2N integer bits in the output), and you start accumulating error and generating values you cannot actually legally encode in your format. This is very hard to encapsulate in any library, and is often the "wrong solution" because it has so many corner cases.

    HTH,
    Iso
Children
No data