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.
N=100;
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));
end
%% recursive moving average, ~200 adds
y(1) = x(1);
for k = 2:N
y(k) = x(k) + y(k-1);
end
for k = D:N
z(k) = y(k) - y(k-D);
end
z = z(1:D:end);
%% CIC, ~120 adds
y(1) = x(1);
for k = 2:N
y(k) = x(k) + y(k-1);
end
z = y(1:D:end);
for k = 2:N/D
w(k) = z(k) - z(k-1);
end