Problem implementing Sharpened CIC filters

Started by hirnprinz 5 years ago4 replieslatest reply 5 years ago296 views

I want to compare different implementations of CIC decimation filters and came across the following question here in the forum: Polyphase CIC. In one of the answers Rick posted a link to a thesis (A POWER EFFICIENT POLYPHASE SHARPENED CIC DECIMATION FILTER FOR SIGMA-DELTA ADCs). 

Now I want to implement a sharpened CIC (SCIC) filter myself and play with the parameters to get a better understanding of its behaviour. I am focusing on the following equation (2.16 in the thesis):


Where D is the group delay of the filter H(z) (in this case a first order CIC filter with the decimation factor N).


The magnitude response of such a SCIC with order K=1 is given by:


So far so good.

Now, I am attempting to implement equation 2.16 directly. Additionally I want to compare the magnitude response of my implementation with 2.18. However, in the case N=16, the group delay D is 7.5 and I am not sure how to implement this. Here is my approach so far (in Matlab):

%length of H filter
% impulse response of H (here a cic first order)

% H^2
cic_2nd= conv(h,h);
%Group Delay of H
%Delay line with gain

% temporary impulse response

% final impulse responses</code><code>

% final frequency responses

%Theoratical Response (2.18)
G = (sin(omega*N/2)./sin(omega/2))/N;
H_tr = abs(3*G.^(2*K) - 2*G.^(3*K));</code>

As you can see I have to round D by taking the ceil of (N1)/2. Comparing now the theoretical magnitude response with my approach I can see a deviation in the passband (0 to 30Hz):

magnitude response_30464.png

So my question is, how do I have to adapt my code to implement a SCIC wiht order K=1 and the theoretical D which has to be a non-integer (D=7.5) in the given situation? 

[ - ]
Reply by Rick LyonsJune 14, 2018

Hi hirnprinz. My congratulations to you on your very clearly written question. 

The delay 'D' must be an integer when using the standard "Filter Sharpening" scheme shown below (copied from Chapter 13 of my "Understanding DSP" book):


Because the above 'Delay' element must be an integer number of unit delays, to keep the two sequences applied to the adder synchronized in time the group delay of the h(k) filter must be an integer. This means your MATLAB value 'N' must be an odd number.
[ - ]
Reply by hirnprinzJune 14, 2018

Hi Rick, thanks for your answers. 

I already assumed that the 'Delay' limits the choice of the filter (the length of the filter). However, I was not sure about it as the author of the thesis did not make any statements about that. But reading your answer makes it obvious.

[ - ]
Reply by Rick LyonsJune 14, 2018

Hi hirnprinz. I posted my original reply and then a minute or two later realized that the second part of my reply was incorrect. So I deleted the second part of my reply. But you saw my original reply BEFORE I made my deletion. Sorry for the confusion!!

I think your MATLAB code is computing what you intended and contains no errors. But keep in mind, to model a correctly-sharpened 'moving average' filter you need set N to an odd number.

[ - ]
Reply by hirnprinzJune 14, 2018

Once again, thank you very much. I will adapt my code regarding the parameter 'N' and hopefully extend it succesfully to a polyphase version.