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.

IQ Math Library wishlist

Hi All,

I'm fairly new to the TI development platform, creating my first big project now. I intensively make use of the IQMath library which I think is very powerful and easy to use. Although It is great I still miss a few functions that I find a bit strange the are not implemented. Others may have more ideas but here are mine:

 

1.) Why aren't there _IQN1toIQN2 functions?

When global Q = 24 I cannot convert IQ12 to IQ16 without going through IQ24 and loose the 8 most significant bits. I know I can define these functions myself but it's much more convenient if they are in the IQMath library.

I also don't like working with a global Q. In my case, Global Q may never ever change during project development since each individual function's local Q is carefully chosen based on the range of the variables. I rather explicitly specify the local Q for each individual function. Therefor I like to use _IQ24toIQ16 and _IQ24mpy for example, even if global Q is 24.

Makes the code better readable I think.

 

2.) Why is _IQNrsmpy the only multiply function with saturation?

If I don't need the rounding I still pay the 10+ cycle penalty. I would really like to see an _IQNsmpy function which only saturates. It would also be great if the rest of the multiply functions get a saturated version. _IQNsmpyIQX for example would be really powerful.

 

3.) Wouldn't _IQN1toIQN2 functions with saturation be great?

Of course only needed when shifting left.

 

Regards,

Matthew

  • Matthew,

    I have moved this into the C2000 forum.  The C2000 team owns the library and will be better able to respond to your requests.

    Regards,

    John

     

  • Dear Matthew and the rest of developers on C2000

    I am enclosing a module which contains additional basic mathematical functions (multiply, divide, convert). All functions support saturation to maximum/minimum value in case of overflow. All operands can have custom IQ integer format.

    The functions while written in assembly are not optimized for speed.

    If anyone finds any bugs please let me(us) know.

    Best Regards, Mitja

    3362.IQ_sat.zip

  • Interesting feedback. IQMath is due for a re-fresh, so we've put these suggestions on our list to review.

     

    Thanks!

     

  • When talking about IQmath wishlist, I would really like to have saturated addition and subtraction.

    This does not seem to be available in IQmath, only in pure assembly!?

  • Hi Stephan,

    I've always done it in C just pre-pending it with "asm(" SETC OVM)" and appending it with "asm(" CLRC OVM")". Works for me every time and according to compiler register conventions there should be no problems.

    Regards, Mitja

  • Hi Mitja,

    I agree, this is the easiest way, but I think it only works for 32 bit values.

    A saturated add/sub for 16 bit values in C would be nice, too...

  • I have two additional functions I miss :

    long _IQNmin(_iqN A, _iqN B)
    long _IQNmax(_iqN A, _iqN B)

    which return the smallest or the largest of two numbers respectively.

    I don't know if the C compiler already generates the fastest and most compact code when doing it with "if...else", but if not they might be a good addition.

     

    And a question :

    Why is IQNint taking 14 cycles to execute while IQNtoIQ takes ~4 cycles? Since it doesn't do any rounding itIQNint is nothing more than IQNtoIQ0 right?