I have been trying to wrap my head around CIC filters.

Say that I want to do filtered decimation by a factor D.

Option#1: boxcar filter. Each output sample is formed by taking the sum of D input samples, and multiplying/shifting to get a proper average. D-1 adds per output sample.

Option#2: 1-stage CIC filter with an accumulator running at the input rate, and a comb filter running at the output rate. D adds per output sample.

So what is the fuzz about? Does CIC only make sense for higher orders? If order N CIC is like convolving the rect() function N-1 times, that would be a B-spline, right? I have seen authors praising B-splines for their functional benefits. Being able to do them efficiently might be handy.

Thanks for any input Knut

Edit: pseudo matlab code showing the alternatives as I understand them.

x = randn(N,1);    
D = 5;

%% decimated moving average, ~100 adds
for k = 1:N/D    
  y(k) = (1/D)*(x(k*D) + x(k*D-1) + ... + x(k*D-D+1));

 %% recursive moving average, ~200 adds 
y(1) = x(1);

for k = 2:N   
  y(k) = x(k) + y(k-1); 

for k = D:N
    z(k) = y(k) - y(k-D);  

z = z(1:D:end);

%% CIC, ~120 adds
y(1) = x(1);

for k = 2:N
  y(k) = x(k) + y(k-1);  

z = y(1:D:end);

for k = 2:N/D    
  w(k) = z(k) - z(k-1);   
  • $\begingroup$ Add an edit section at the bottom of your question and move the code there. It will be easier to understand. $\endgroup$ – Ben Feb 23 '20 at 1:01
  • $\begingroup$ Non-recursive moving average = 100 additions per sample $\endgroup$ – Ben Feb 23 '20 at 19:01
  • $\begingroup$ Recursive moving average = 2 additions per sample $\endgroup$ – Ben Feb 23 '20 at 19:01
  • 1
    $\begingroup$ Ok in that case, you don't have a moving- average filter $\endgroup$ – Ben Feb 24 '20 at 12:22
  • 1
    $\begingroup$ Say you average by 20 and downsample by 5. You'd need 120 additions for the CIC filter, while you'd need 400 additions with your method. No one said that the averaging factor and the downsampling factor needs to be the same. $\endgroup$ – Ben Feb 24 '20 at 21:03

It seems you mixed up CIC filters and recursive moving-average

A recursive moving-average uses a comb-filter and an accumulator.

$$ H(z) = \frac{1}{N}\frac{1-z^{-N}}{1-z^{-1}} $$

The numerator corresponds to a comb filter (i.e a delay line of N elements and 1 adder). The denominator corresponds to an accumulator. The 1/N factor is to get a moving-average, otherwise you'd have a moving-accumulator. You only need 2 additions, a delay line, an accumulator and a divider. With a non-recursive moving-average filter, you'd need N additions and you'd need a delay line anyway. A recursive moving-average is much less computionally expansive than a non-recursive moving-average filter.

Now the CIC filter combines the recursive moving-average filter with decimation and interpolation.

For a CIC decimation filter, you insert the rate transition block between the accumulator and the comb filter. Say you have a 16-sample moving average-filter (N=16) and you want to decimate by 8 (R = 8). You'd need a delay line of 16 elements. However, by inserting the decimation between the accumulator and the comb filter, you can reduce the number of elements in the delay line. You'd only need N/R elements, i.e. 2. You'd still need to subtract 2 numbers, however you would do it at sampling rate of fs/8.

I suggest you consult this site


Update: see this nice write-up by Richard Lyons- https://www.dsprelated.com/showarticle/1337.php


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.