|
Atari coding BBS
Re: DSP DIV : I'm lost |
Posted by: dml
|
Jul,04.2013-20:07
|
Yep mikro is right, you need to watch out with mul/div because 48bit and 24bit sources don't behave the same way - they hold different kinds of number format.
If you prefer to think purely as integers or 'normal' fixed point (like translating from 68k approach), think of the 24bit sources as being shifted right ('denormalized') by 1 extra bit, with the true LSB missing somewhere - resulting in outputs 2x or 0.5x what you might want/expect.
IIRC you can actually stop this behaviour by modifying the OMR but it's not very wise because you might be including other good code which will then stop working. I haven't tried it but there is something in the manual about it I'm sure.
The reason for this weird behaviour is to represent input coefficients in the range (-1.0 <= c < 1.0) - something which is very common when performing signal processing or waveform generation (accumulation of matrix or sin/cos terms) - but for outputs to be real numbers with both an integer and fraction part.
So the encoding of 0.5 is actually $400000 not $800000, because that would steal the sign bit (this is fine using a mulu on 68k, but DSP multiplies can be summed with a signed accumulator in same op and the source needs a sign to be useful)
Quite often you can include this behaviour in your program without realizing because divides and multiplies can happen close together, and the effect will then cancel out (div shifts right, mul shifts left).
The most annoying situation is where you want to do several multiplies in a row, because the effect compounds and you need to renormalize sometime.
I have spent a few sessions scratching my head over some math which looked like it made sense, until I realized everything was 2x (or worse) and overflowing or something bad like that.
enjoy!
|
[All messages in this thread] [Start new thread]
What's the anti-troll code? That's your personal code to be able to add comments and messages on the dhs.nu site.
Don't have a code or forgot it? Fix it here.
|