## CIC filter using prune width calculation

Started by 3 years ago8 replieslatest reply 3 years ago260 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

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

[ - ]

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.

[ - ]

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.

[ - ]

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

[ - ]

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

[ - ]

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.

[ - ]

Hi.

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

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."

[ - ]