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 28th November 2012 at http://forums.arm.com


    I agree with your comments.

    But in previous, we worked with IQmath library provided by TI. This IQ math library allows the user to multiply different Q formats and allows takes about rounding and saturation of the result.

    My question whether this CMSIS DSP libarary provides the same capabilities as IQmath ?



    Hi Jags,
    The CMSIS DSP library has been optimized using the underlying data types that are supported by the Cortex-M4 (8-bit, 16-bit, and 32-bit integers as well as floating-point).  This gives the best execution time.  The CMSIS library is quite a bit higher in level than the IQMath library and provides functions like FFTs, filters, matrix operations, etc.  The CMSIS functions typically operate on blocks of data.  If you are looking to do low-level math operations, like individual multiplications and additions, then you're best off defining your own macros which perform the operation and do the shifting necessary to mix different Q data types.

    That said, it is possible to use the CMSIS functions to perform mixed Q arithmetic.  You just need to keep in mind exactly which Q formats are used and do additional shifting, as needed.  In your example of multiplying Q17 by Q27 to yield a Q19 result I would approach as follows:

    Let A represent the vector of Q17 values.  Each value is 18 bits and you should place them into the high 18 bits of a 32-bit word. 
    Similarly let B represent the Q27 input data.  Each value is 28 bits and you should place them into the high 28 bits of a 32-bit word.
    Then perform a Q31 multiplication using the function arm_mult_q31().  This will generated a Q31 result.  If you want a Q19 output then you should take the high 20-bits of the result.

    Would this work?
Reply
  • Note: This was originally posted on 28th November 2012 at http://forums.arm.com


    I agree with your comments.

    But in previous, we worked with IQmath library provided by TI. This IQ math library allows the user to multiply different Q formats and allows takes about rounding and saturation of the result.

    My question whether this CMSIS DSP libarary provides the same capabilities as IQmath ?



    Hi Jags,
    The CMSIS DSP library has been optimized using the underlying data types that are supported by the Cortex-M4 (8-bit, 16-bit, and 32-bit integers as well as floating-point).  This gives the best execution time.  The CMSIS library is quite a bit higher in level than the IQMath library and provides functions like FFTs, filters, matrix operations, etc.  The CMSIS functions typically operate on blocks of data.  If you are looking to do low-level math operations, like individual multiplications and additions, then you're best off defining your own macros which perform the operation and do the shifting necessary to mix different Q data types.

    That said, it is possible to use the CMSIS functions to perform mixed Q arithmetic.  You just need to keep in mind exactly which Q formats are used and do additional shifting, as needed.  In your example of multiplying Q17 by Q27 to yield a Q19 result I would approach as follows:

    Let A represent the vector of Q17 values.  Each value is 18 bits and you should place them into the high 18 bits of a 32-bit word. 
    Similarly let B represent the Q27 input data.  Each value is 28 bits and you should place them into the high 28 bits of a 32-bit word.
    Then perform a Q31 multiplication using the function arm_mult_q31().  This will generated a Q31 result.  If you want a Q19 output then you should take the high 20-bits of the result.

    Would this work?
Children
No data