"Jam" <(EMail Removed)> wrote in message
news:ci93a6$bh1$(EMail Removed)...
> Hi all,
>
> I am making a variable IIR filter:
>
> in the form of (1/z"coeff") . For 51 kHz (fs=10e6) the coeff would be
> 0.96875
> Which can be made as 11/2^5. Which is 1*Sa  shr(Sa,5)
> Because of the shift I get an attenuation of 2^5. Therefor I compensate Sa
> first by multiplying (SHL) by 2^5
>
> To make smaller steps I can use 1(1/2^5+1/2^6)
> But now the multiplying part.... I cannot use the same trick
> here....multiplying by 2^5+2^6 is not ok. I have to multiply by 1/2^5 +
> 1/2^6 =21,3
>
> Anyone knows how to solve this problem ?
>
The way to do a general fractional multiply Sa * x is to pick a scaling
factor n and do it as (Sa * (x * 2^n)) / (2^n). In your first case, where x
was 1/(2^5), it's easy  pick n = 5. In general, however, you can't do
that. I'm not quite sure from your post if you now have x = (1/(2^5) +
1/(2^6)), or x = 1/((2^5) + (2^6)). In the first case, the answer is again
easy  pick n = 6, giving (Sa * 3) / (2^6), i.e., shr(Sa*3, 6). In the
second case, it's going to be inexact  you might pick n = 9 and use
shr(Sa*5, 9), or use bigger shifts for higher accuracy (and more work in the
multiplier).
