DSPRelated.com
Forums

Cic Decimator:How many bits to discard at each stage?

Started by fabionucara January 30, 2011
Hi, I've read the Reference "IEEE Transaction on acoustics, and signal
processing" about Cic filters for decimation and interpolation and I found
out something not clear to me.

Reading the paragraph about the decimation filter, the reference explain
that the number of bits to discard at each stage, in order to make the
variance from the first 2N sources less than or equal to the variance for
the last error source are given by the formula:

Bj = floor (  -log2(Fj) + log2(σT2N+1) + 0.5*log2(6/N)  )

I've implemented this formula on Matlab, and I found out that for some
values of R,M,N(cic Parameters), the value of Bj became negative!!

For example using these parameters:
Bin = 8 bits
Bout = 8 bits
N=4
R=2
M=1

the values of Bj are for 2N stages:

-1     0     0    -1    -1     0     1     2


Another Example:
Bin = 8 bits
Bout = 8 bits
N=5
R=4
M=1

Bj values

-1     2     1     1     1     0     1     1     1     0



What do negative values mean?
I maked my code with Matlab and I checked it with calculus on paper and I 
obtained same negative results, then I'm sure that values are correct. 
I have to consider them like not dicarding bits?


On 01/30/2011 10:28 AM, fabionucara wrote:
> Hi, I've read the Reference "IEEE Transaction on acoustics, and signal > processing" about Cic filters for decimation and interpolation and I found > out something not clear to me. > > Reading the paragraph about the decimation filter, the reference explain > that the number of bits to discard at each stage, in order to make the > variance from the first 2N sources less than or equal to the variance for > the last error source are given by the formula: > > Bj = floor ( -log2(Fj) + log2(σT2N+1) + 0.5*log2(6/N) )
Without the specific article in hand, the above equation is nearly meaningless -- what do the variables mean? It would also help to cite the specific article -- you give the name of the journal, but you need to also give year, month, author and title of the article.
> I've implemented this formula on Matlab, and I found out that for some > values of R,M,N(cic Parameters), the value of Bj became negative!! > > For example using these parameters: > Bin = 8 bits > Bout = 8 bits > N=4 > R=2 > M=1 > > the values of Bj are for 2N stages: > > -1 0 0 -1 -1 0 1 2 > > > Another Example: > Bin = 8 bits > Bout = 8 bits > N=5 > R=4 > M=1 > > Bj values > > -1 2 1 1 1 0 1 1 1 0 > > > > What do negative values mean?
You are giving values to variables that don't exist in your referenced equation, and not giving values to variables that do. How can we say?
> I maked my code with Matlab and I checked it with calculus on paper and I > obtained same negative results, then I'm sure that values are correct. > I have to consider them like not dicarding bits?
Any time you low-pass filter a process you can effectively extend its precision, and need to save more bits coming out of the filter than went in. I suspect this is the case, but you've given so little information here that it's hard to say. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html
>On 01/30/2011 10:28 AM, fabionucara wrote: >> Hi, I've read the Reference "IEEE Transaction on acoustics, and signal >> processing" about Cic filters for decimation and interpolation and I
found
>> out something not clear to me. >> >> Reading the paragraph about the decimation filter, the reference
explain
>> that the number of bits to discard at each stage, in order to make the >> variance from the first 2N sources less than or equal to the variance
for
>> the last error source are given by the formula: >> >> Bj = floor ( -log2(Fj) + log2(σT2N+1) + 0.5*log2(6/N) ) > >Without the specific article in hand, the above equation is nearly >meaningless -- what do the variables mean? > >It would also help to cite the specific article -- you give the name of >the journal, but you need to also give year, month, author and title of >the article. > >> I've implemented this formula on Matlab, and I found out that for some >> values of R,M,N(cic Parameters), the value of Bj became negative!! >> >> For example using these parameters: >> Bin = 8 bits >> Bout = 8 bits >> N=4 >> R=2 >> M=1 >> >> the values of Bj are for 2N stages: >> >> -1 0 0 -1 -1 0 1 2 >> >> >> Another Example: >> Bin = 8 bits >> Bout = 8 bits >> N=5 >> R=4 >> M=1 >> >> Bj values >> >> -1 2 1 1 1 0 1 1 1 0 >> >> >> >> What do negative values mean? > >You are giving values to variables that don't exist in your referenced >equation, and not giving values to variables that do. How can we say? > >> I maked my code with Matlab and I checked it with calculus on paper and
I
>> obtained same negative results, then I'm sure that values are correct. >> I have to consider them like not dicarding bits? > >Any time you low-pass filter a process you can effectively extend its >precision, and need to save more bits coming out of the filter than went >in. I suspect this is the case, but you've given so little information >here that it's hard to say. > >-- > >Tim Wescott >Wescott Design Services >http://www.wescottdesign.com > >Do you need to implement control loops in software? >"Applied Control Theory for Embedded Systems" was written for you. >See details at http://www.wescottdesign.com/actfes/actfes.html
Thanks for reply to my post! The Hogenauer reference paper is: IEEE TRANSACTIONS ON ACOUSTICS, SPEECH, AND SIGNAL PROCESSING, VOL. ASSP-29, NO. 2, APRIL 1981 155 "An Economical Class of Digital Filters for Decimation and Interpolation" All Formulas are inside this paper and it's difficult to insert them here on the website because there are a lot of mathematical expression with summations and indexes. The problem is that it's not possible to find this reference for free on the web because is part of IEEE. I hope to find someone that has implemented cic filters following this reference or find out someone that use Hogenauer pruning bits method
On 01/31/2011 07:36 AM, fabios84 wrote:
>> On 01/30/2011 10:28 AM, fabionucara wrote: >>> Hi, I've read the Reference "IEEE Transaction on acoustics, and signal >>> processing" about Cic filters for decimation and interpolation and I > found >>> out something not clear to me. >>> >>> Reading the paragraph about the decimation filter, the reference > explain >>> that the number of bits to discard at each stage, in order to make the >>> variance from the first 2N sources less than or equal to the variance > for >>> the last error source are given by the formula: >>> >>> Bj = floor ( -log2(Fj) + log2(σT2N+1) + 0.5*log2(6/N) ) >> >> Without the specific article in hand, the above equation is nearly >> meaningless -- what do the variables mean? >> >> It would also help to cite the specific article -- you give the name of >> the journal, but you need to also give year, month, author and title of >> the article. >> >>> I've implemented this formula on Matlab, and I found out that for some >>> values of R,M,N(cic Parameters), the value of Bj became negative!! >>> >>> For example using these parameters: >>> Bin = 8 bits >>> Bout = 8 bits >>> N=4 >>> R=2 >>> M=1 >>> >>> the values of Bj are for 2N stages: >>> >>> -1 0 0 -1 -1 0 1 2 >>> >>> >>> Another Example: >>> Bin = 8 bits >>> Bout = 8 bits >>> N=5 >>> R=4 >>> M=1 >>> >>> Bj values >>> >>> -1 2 1 1 1 0 1 1 1 0 >>> >>> >>> >>> What do negative values mean? >> >> You are giving values to variables that don't exist in your referenced >> equation, and not giving values to variables that do. How can we say? >> >>> I maked my code with Matlab and I checked it with calculus on paper and > I >>> obtained same negative results, then I'm sure that values are correct. >>> I have to consider them like not dicarding bits? >> >> Any time you low-pass filter a process you can effectively extend its >> precision, and need to save more bits coming out of the filter than went >> in. I suspect this is the case, but you've given so little information >> here that it's hard to say. >> >> -- >> >> Tim Wescott >> Wescott Design Services >> http://www.wescottdesign.com >> >> Do you need to implement control loops in software? >> "Applied Control Theory for Embedded Systems" was written for you. >> See details at http://www.wescottdesign.com/actfes/actfes.html > > > > > > Thanks for reply to my post! > > The Hogenauer reference paper is: > > IEEE TRANSACTIONS ON ACOUSTICS, SPEECH, AND SIGNAL PROCESSING, VOL. > ASSP-29, NO. 2, APRIL 1981 155 > > "An Economical Class of Digital Filters for Decimation > and Interpolation" > > All Formulas are inside this paper and it's difficult to insert them here > on the website because there are a lot of mathematical expression with > summations and indexes. The problem is that it's not possible to find this > reference for free on the web because is part of IEEE. > > I hope to find someone that has implemented cic filters following this > reference or find out someone that use Hogenauer pruning bits method
Academic papers tend to take a long time to reach application in the real world, and when they do the folks implementing them often hold the implementation details pretty tightly. Most of the regulars here know how to calculate the necessary bit depth for the output of a CIC filter without reference to a paper, so unless someone got the paper back in the day, you may be out of luck. But I can tell you this: in general, when you're low-pass filtering noisy data, you need to _increase_ the bit depth of your filter, as the low-pass filtering lends increased precision to your answer. You can calculate this by treating the input to the filter as a stochastic process, and do the obvious calculations. If you don't know what the heck that means -- at best, a filter of length N will require that you add log_2(N) bits, at worst, it won't do you any good at all, and for white noise it'll require on the order of log_2(N)/2 bits. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html
>On 01/31/2011 07:36 AM, fabios84 wrote: >>> On 01/30/2011 10:28 AM, fabionucara wrote: >>>> Hi, I've read the Reference "IEEE Transaction on acoustics, and
signal
>>>> processing" about Cic filters for decimation and interpolation and I >> found >>>> out something not clear to me. >>>> >>>> Reading the paragraph about the decimation filter, the reference >> explain >>>> that the number of bits to discard at each stage, in order to make
the
>>>> variance from the first 2N sources less than or equal to the variance >> for >>>> the last error source are given by the formula: >>>> >>>> Bj = floor ( -log2(Fj) + log2(σT2N+1) + 0.5*log2(6/N) ) >>> >>> Without the specific article in hand, the above equation is nearly >>> meaningless -- what do the variables mean? >>> >>> It would also help to cite the specific article -- you give the name
of
>>> the journal, but you need to also give year, month, author and title
of
>>> the article. >>> >>>> I've implemented this formula on Matlab, and I found out that for
some
>>>> values of R,M,N(cic Parameters), the value of Bj became negative!! >>>> >>>> For example using these parameters: >>>> Bin = 8 bits >>>> Bout = 8 bits >>>> N=4 >>>> R=2 >>>> M=1 >>>> >>>> the values of Bj are for 2N stages: >>>> >>>> -1 0 0 -1 -1 0 1 2 >>>> >>>> >>>> Another Example: >>>> Bin = 8 bits >>>> Bout = 8 bits >>>> N=5 >>>> R=4 >>>> M=1 >>>> >>>> Bj values >>>> >>>> -1 2 1 1 1 0 1 1 1 0 >>>> >>>> >>>> >>>> What do negative values mean? >>> >>> You are giving values to variables that don't exist in your referenced >>> equation, and not giving values to variables that do. How can we say? >>> >>>> I maked my code with Matlab and I checked it with calculus on paper
and
>> I >>>> obtained same negative results, then I'm sure that values are
correct.
>>>> I have to consider them like not dicarding bits? >>> >>> Any time you low-pass filter a process you can effectively extend its >>> precision, and need to save more bits coming out of the filter than
went
>>> in. I suspect this is the case, but you've given so little
information
>>> here that it's hard to say. >>> >>> -- >>> >>> Tim Wescott >>> Wescott Design Services >>> http://www.wescottdesign.com >>> >>> Do you need to implement control loops in software? >>> "Applied Control Theory for Embedded Systems" was written for you. >>> See details at http://www.wescottdesign.com/actfes/actfes.html >> >> >> >> >> >> Thanks for reply to my post! >> >> The Hogenauer reference paper is: >> >> IEEE TRANSACTIONS ON ACOUSTICS, SPEECH, AND SIGNAL PROCESSING, VOL. >> ASSP-29, NO. 2, APRIL 1981 155 >> >> "An Economical Class of Digital Filters for Decimation >> and Interpolation" >> >> All Formulas are inside this paper and it's difficult to insert them
here
>> on the website because there are a lot of mathematical expression with >> summations and indexes. The problem is that it's not possible to find
this
>> reference for free on the web because is part of IEEE. >> >> I hope to find someone that has implemented cic filters following this >> reference or find out someone that use Hogenauer pruning bits method > >Academic papers tend to take a long time to reach application in the >real world, and when they do the folks implementing them often hold the >implementation details pretty tightly. > >Most of the regulars here know how to calculate the necessary bit depth >for the output of a CIC filter without reference to a paper, so unless >someone got the paper back in the day, you may be out of luck. > >But I can tell you this: in general, when you're low-pass filtering >noisy data, you need to _increase_ the bit depth of your filter, as the >low-pass filtering lends increased precision to your answer. You can >calculate this by treating the input to the filter as a stochastic >process, and do the obvious calculations. If you don't know what the >heck that means -- at best, a filter of length N will require that you >add log_2(N) bits, at worst, it won't do you any good at all, and for >white noise it'll require on the order of log_2(N)/2 bits. > >-- > >Tim Wescott >Wescott Design Services >http://www.wescottdesign.com > >Do you need to implement control loops in software? >"Applied Control Theory for Embedded Systems" was written for you. >See details at http://www.wescottdesign.com/actfes/actfes.html
OK! thanks for the time spent with me, I'll try to use your suggestions in the best way!
>
On Sun, 30 Jan 2011 12:28:46 -0600, "fabionucara"
<fabionucara@n_o_s_p_a_m.hotmail.it> wrote:

>Hi, I've read the Reference "IEEE Transaction on acoustics, and signal >processing" about Cic filters for decimation and interpolation and I found >out something not clear to me. > >Reading the paragraph about the decimation filter, the reference explain >that the number of bits to discard at each stage, in order to make the >variance from the first 2N sources less than or equal to the variance for >the last error source are given by the formula: > >Bj = floor ( -log2(Fj) + log2(&sigma;T2N+1) + 0.5*log2(6/N) ) > >I've implemented this formula on Matlab, and I found out that for some >values of R,M,N(cic Parameters), the value of Bj became negative!! > >For example using these parameters: >Bin = 8 bits >Bout = 8 bits >N=4 >R=2 >M=1 > >the values of Bj are for 2N stages: > >-1 0 0 -1 -1 0 1 2 > > >Another Example: >Bin = 8 bits >Bout = 8 bits >N=5 >R=4 >M=1 > >Bj values > >-1 2 1 1 1 0 1 1 1 0 > > > >What do negative values mean? >I maked my code with Matlab and I checked it with calculus on paper and I >obtained same negative results, then I'm sure that values are correct. >I have to consider them like not dicarding bits?
Hi fabionucara, I'm afraid I don't have an answer to explain the negative numbers you're coming up with, but I extend my compliments to you for trying to decypher the equations in that Hogenaur paper. If you're actually trying to implement a decimating CIC filter and you wish to minimize the accumulators' bit widths, then I can add something to this thread. You can avoid the unpleasant accumulator bit width growth in traditional decimating CIC filters *IF* your decimation rate (downsampling factor)is either: [1] a power of two, such as 4, 8, 16, 32, etc. or [2] the product of prime numbers, such as, say, 90 = 2*3*3*5. If your decimation rate meets either of the above two conditions, then the integrators (with their troublesome wide register widths) can be eliminated altogether. The schemes to do this are too involved to describe here. If you're interested, send me a private E-mail and I'll send you the information describing exactly what I'm talkin' about here. Good Luck, [-Rick-]
On Fri, 04 Feb 2011 04:49:05 -0800, Rick Lyons
<R.Lyons@_BOGUS_ieee.org> wrote:

   [Snipped by Lyons]
> >Hi fabionucara, > I'm afraid I don't have an answer to explain the >negative numbers you're coming up with, but I extend >my compliments to you for trying to decypher the equations >in that Hogenaur paper. > >If you're actually trying to implement a decimating >CIC filter and you wish to minimize the >accumulators' bit widths, then I can add something >to this thread. You can avoid the unpleasant >accumulator bit width growth in traditional decimating >CIC filters *IF* your decimation rate (downsampling >factor)is either: > > [1] a power of two, such as 4, 8, 16, 32, etc. > >or > > [2] the product of prime numbers, such as, > say, 90 = 2*3*3*5. > >If your decimation rate meets either of the above two >conditions, then the integrators (with their troublesome >wide register widths) can be eliminated altogether. >The schemes to do this are too involved to describe >here. If you're interested, send me a private E-mail >and I'll send you the information describing exactly >what I'm talkin' about here. > >Good Luck, >[-Rick-]
OK OK, before someone jumps on me. I just realized that all integer powers of two, greater than two, satisfy Condition [2] above. [-Rick-]
On Sun, 30 Jan 2011 12:28:46 -0600, "fabionucara"
<fabionucara@n_o_s_p_a_m.hotmail.it> wrote:

   [Snipped by Lyons]

Hi,
  You might also take a look at:

http://books.google.com/books?id=fnkX0N8W2WYC&pg=PA386&lpg=PA386&dq=%2B%22cic%22+%2B%22integrator+word+width&source=bl&ots=EmuB2_1Fm-&sig=Wku1m0Zp9X8drETVkxxd-b4dCM8&hl=en&ei=EmZMTa36I4_QsAO4y-TVCg&sa=X&oi=book_result&ct=result&resnum=5&sqi=2&ved=0CDcQ6AEwBA#v=onepage&q=%2B%22cic%22%20%2B%22integrator%20word%20width&f=false

for help.

[-Rick-]