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.

TMS320F28335: Understanding IQmath multiplier

Part Number: TMS320F28335

Hi

I'm trying to make a model of an older code, which involves IQmath. I'm not able to find anything regarding the multiplication method of IQmath, and unfortunatly i am not able to test it. I hope you can help instead. I am in no position to avoid the IQmath, i just want to model it. 

When i read i.e.:

_IQmpy(5,6) is this to be understood as 5*6*2^24 ?

What about

_IQmpy(_IQ(3.14),_iq 5), would this be 3.14*2^24*5*2^24? Or is it 3.14*5*2^24? 

Thank you !

  • Simon,

    Function arguments for _IQmpy() are _IQ format numbers, not floating point numbers.

    And if you want to convert from IQ format to floating point format, you want to divide by 2^(Qformat_value).

    So if 5 and 6 are inputs, and the format is Q24, the floating-point inputs are actually 5/2^24 and 6/2^24. Their product would be so small (30/2^48), and in IQ format it would be (30/2^48)*2^24 = 30/2^24, which is so small the answer would round to 0.

    In your second case, _IQ(3.14) would convert the floating-point number 3.14 to 3.14*2^24 = 3,292,528.64, which would rounded to 3,292,529 for IQ representation. The second argument is _iq 5, which means the floating-point number is 5/2^24. So the floating-point operation being performed is (3.14 * 5/2^24), and the result would be (3.14 * 5/2^24)*2^24 = 15.7, rounded to 16. Alternately, (3,292,529 * 5)/2^24 = 15.7, rounded to 16.

    So I would expect the result of the _IQmpy operations to be 0 and 16, respectively. It would help if you could confirm this.

    Thanks,

    Sira

  • Simon,

    Sorry, in my answer above, I mistakenly used 2^20 instead of 2^24, so 3.14 in IQ24 format would be 52,680,458.24, not 3,292,528.64. But everything else I said should still hold.

    Thanks,

    Sira

  • Hi Sira

    Thank you for your answer. Just an additional question. 

    If the case is:

    _IQmpy(_IQ(3.14),_IQ(2))

    would the floating point format be equal to 3.14*2*2^72 then? That just does not make sense to me. 

    Thank you,

    Simon

  • Simon,

    _IQmpy(_IQ(3.14),_IQ(2)) would mean the floating-point numbers you are multiplying are 3.14 and 2.0, so the expected answer is 6.28.

    _IQ(3.14) would result in 3.14 * 2^24

    _IQ(2) would result in 2*2^24

    Then the _IQmpy() would result in (3.14*2*2^48)/2^24 (the division by 2^24 is effectively a right-shift by 24 bits, because when you multiply two numbers with 24 fractional bits each, you get 48 fractional bits, but you only want 24 fractional bits in the result, so the right-shift by 24-bits).

    So you would get 6.28*2^24, which in floating-point is 6.28*2^24/2^24 = 6.28.

    Hope this makes sense.

    Thanks,

    Sira

  • Ah yes okay, i get it. Thank you so much Sira :)