How to MULTIPLY by fraction ?? (making variable iir)

Discussion in 'VHDL' started by Jam, Sep 15, 2004.

  1. Jam

    Jam Guest

    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 1-1/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 ?
    Jam, Sep 15, 2004
    #1
    1. Advertising

  2. Jam

    David Brown Guest

    "Jam" <> wrote in message
    news:ci93a6$bh1$...
    > 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 1-1/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).
    David Brown, Sep 15, 2004
    #2
    1. Advertising

  3. Jam

    Jam Guest

    I should attenuate by 1/2^5 because the gain would be 32 if I didn't
    Unfortunately it is 1- ((1/2^5) + (1/2^6))
    Maybe there is another way

    0-----|1/2^7|--
    | |
    v+ |
    --------------------------------
    0-----|1/2^6|--
    | |
    v+ |
    -------------------------------

    0-----|1/2^5|--
    out<--| |
    v - ----- | ------
    --SAin-- 0-----| T |----------|1/2^5|--SAlfp
    ^ + ----- | -------
    |__________ _|

    SaLPF <= (SAin + Salpf-(Salpf*1/2^5)) *1/2^5

    With multiple 1/2^n maybe by taking another point as output I don't need the
    final attenuation.

    So Out<= Salpf*(1/2^5+1/2^6+....)
    Salpf<=SAin+Salpf-Out

    I still have to compile the idea....
    Who knows a better way ?


    "David Brown" <> wrote in message
    news:ci95hf$6ql$...
    >
    > "Jam" <> wrote in message
    > news:ci93a6$bh1$...
    > > 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 1-1/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).
    >
    >
    >
    Jam, Sep 15, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MM
    Replies:
    1
    Views:
    2,942
    Mike Treseler
    Aug 15, 2006
  2. mackyang

    vhdl problem for iir filter

    mackyang, Jan 5, 2008, in forum: VHDL
    Replies:
    1
    Views:
    917
    omara007
    Jul 4, 2008
  3. k4kami
    Replies:
    3
    Views:
    1,882
    sanila.san
    Feb 5, 2011
  4. wzab
    Replies:
    7
    Views:
    689
    Robert Kern
    May 9, 2009
  5. Replies:
    0
    Views:
    269
Loading...

Share This Page