DSPRelated.com
Forums

CIC filter using prune width calculation

Started by singh2426v 5 years ago8 replieslatest reply 5 years ago305 views

Hi All,


I am trying to calculate Bits width for each stage of a cic filter using prune method. I came across @Rick Lyons Matlab script to calculate Bit width for CIC prune(https://www.dsprelated.com/showcode/269.php). However, I see Bj (Number of least significant bits that can be truncated at the input of a filter stage) to be negative. Can some one suggest why this happening? Below are the details of the filter configurations and the result obtained from the Matlab script:

N = 5,   R = 128,   M = 1,   Bin = 8,   Bout = 24

Num of Bits Growth Due To CIC Filter Gain = 35

Num of Accumulator Bits With No Truncation = 43

 Stage(j)   Bj   Accum (adder) width

   1   -14      57

   2    -7      50

   3    -1      44

   4     5      38

   5    10      33

   6    13      30

   7    14      29

   8    15      28

   9    16      27

  1e+01    16      27

  1e+01    19      24 (final truncation)



Regards,

Vikas Singh

[ - ]
Reply by gretzteamOctober 18, 2019

I haven't looked a Rick'code but you certainly don't need more bits than 43 at any given stage. I would guess a negative Bj value is really a 0, so here your first 3 accumulators would be the full 43 bit long. 

[ - ]
Reply by singh2426vOctober 18, 2019

Hi Gretzteam, 


Thank you for the reply. I tried with full 43 bits for stages where Bj is negative. I see a difference of 1LSB between a pruning and CIC filter designed without prune.

[ - ]
Reply by gretzteamOctober 18, 2019

1 lsb error is probably what you should expect. You'll always get up to 1 lsb since there is truncation. 


[ - ]
Reply by singh2426vOctober 18, 2019

So, if truncation is replaced by rounding would they match?

[ - ]
Reply by gretzteamOctober 18, 2019

This is discussed in the original Hogenauer paper. If I remember right some of the stages benefit from rounding, but for others floor() was just as good (or something along those lines). 

However you'll always get up to 1-lsb error. This isn't much different than implementing the CIC as an FIR where you would truncate inside the accumulators.

[ - ]
Reply by Rick LyonsOctober 18, 2019

Hi.

gretzteam is correct in his first Oct. 17th comment. At the end of my text accompanying my MATLAB code at:

https://www.dsprelated.com/showcode/269.php

I wrote:

"Warning: It's possible, for certain combinations of N, R, M, Bin, and Bout, that negative values of Bj are computed, particularly when the product RM is a small number, and Bout>Bin. When using the following Matlab code, if you compute a negative value of Bj then that value should be ignored and no truncation should performed at that jth stage."

[ - ]
Reply by singh2426vOctober 18, 2019

Thank Rick Lyons.

[ - ]
Reply by Rick LyonsOctober 18, 2019

Hi singh2426v. You're welcome, and Good Luck with your CIC filter work.