Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > How to MULTIPLY by fraction ?? (making variable iir)

Reply
Thread Tools

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

 
 
Jam
Guest
Posts: n/a
 
      09-15-2004
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 ?


 
Reply With Quote
 
 
 
 
David Brown
Guest
Posts: n/a
 
      09-15-2004

"Jam" <(E-Mail Removed)> wrote in message
news:ci93a6$bh1$(E-Mail 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 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).



 
Reply With Quote
 
 
 
 
Jam
Guest
Posts: n/a
 
      09-15-2004
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" <(E-Mail Removed)> wrote in message
news:ci95hf$6ql$(E-Mail Removed)...
>
> "Jam" <(E-Mail Removed)> wrote in message
> news:ci93a6$bh1$(E-Mail 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 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).
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there any way that i can find wether float variable contains fraction?? nas C++ 10 06-19-2007 09:03 PM
The Power of the Pixel; 5 Years of Advertising at Only a Fraction of the Normal Cost. walter.alex@gmail.com HTML 4 11-20-2005 11:18 PM
String Fraction to Number Peter Java 6 05-06-2004 08:24 PM
what'ch think of my fraction program, is it correct and good and efficient? John Cho C++ 9 03-02-2004 10:51 AM
Re: fraction reducing funtion Sam Holden C++ 2 08-04-2003 04:45 AM



Advertisments