Fixedpoint CIC interpolator
mfilt.cicinterp
will be removed in a future
release. Use dsp.CICInterpolator
instead.
hm = mfilt.cicinterp(R,M,N,ILW,OWL,WLPS)
hm = mfilt.cicinterp
hm = mfilt.cicinterp(R,...)
hm = mfilt.cicinterp(R,M,N,ILW,OWL,WLPS)
constructs
a cascaded integratorcomb (CIC) interpolation filter object that
uses fixedpoint arithmetic.
All of the input arguments are optional. To enter any optional value, you must include all optional values to the left of your desired value.
When you omit one or more input options, the omitted option applies the default values shown in the table below.
The following table describes the input arguments for creating hm
.
Input Arguments  Description 

 Interpolation factor applied to the input signal. Sharpens
the response curve to let you change the shape of the response. 
 Differential delay. Changes the shape, number, and location
of nulls in the filter response. Increasing 
 Number of sections. Deepens the nulls in the response curve. Note that this is the number of either comb or integrator sections, not the total section count. By default, the filter has two sections. 
 Word length of the input signal. Use any integer number of bits. The default value is 16 bits. 
 Word length of the output signal. It can be any positive
integer number of bits. By default, 
 Defines the number of bits per word in each filter section
while accumulating the data in the integrator sections or while subtracting
the data during the comb sections (using 'wrap' arithmetic). Enter When you elect
to specify 
hm = mfilt.cicinterp
constructs
the CIC interpolator using the default values for the optional input
arguments.
hm = mfilt.cicinterp(R,...)
constructs
the CIC interpolator applying the values you provide for R
and
any other values you specify as input arguments.
In Hogenauer [1], the author describes the constraints on CIC interpolator
filters. mfilt.cicinterp
enforces a constraint—the
word lengths of the filter sections must be nondecreasing. That is,
the word length of each filter section must be the same size as, or
greater than, the word length of the previous filter section.
The formula for W_{j}, the minimum register width, is derived in [1]. The formula for W_{j} is given by
$${W}_{j}=ceil({B}_{in}+{\mathrm{log}}_{2}{G}_{j})$$
where G_{j}, the maximum register growth up to the jth section, is given by
$${G}_{j}=\{\begin{array}{ll}{2}^{j},\hfill & j=1,2,\dots ,N\hfill \\ \frac{{2}^{2Nj}{(RM)}^{jN}}{R},\hfill & j=N+1,\dots ,2N\hfill \end{array}$$
When the differential delay, M, is 1, there is also a special condition for the register width of the last comb, W_{N}, that is given by
$$\begin{array}{ccc}{W}_{N}={B}_{in}+N1& if& M=1\end{array}$$
The conversions denoted by the cast blocks in the integrator
diagrams in Algorithms perform
the changes between the word lengths of each section. When you specify
word lengths that do not follow the constraints described in this
section, mfilt.cicinterp
returns an error.
The fraction lengths and scalings of the filter sections do not change. At each section the word length is either staying the same or increasing. The signal scaling can change at the output after the final filter section if you choose the output word length to be less than the word length of the final filter section.
The following table lists the properties for the filter with a description of each.
Name  Values  Default  Description 



 Reports the kind of arithmetic the filter uses. CIC interpolators are always fixedpoint filters. 
 Any positive integer  2  Amount to increase the input sampling rate. 
 Any positive integer  1  Sets the differential delay for the filter. Usually a value of one or two is appropriate. 

 None  Reports the type of filter object, such as a interpolator
or fractional integrator. You cannot set this property — it
is always read only and results from your choice of 


 Set the usage mode for the filter. Refer to Usage Modes below for details. 
 Any positive integer  16  The number of bits applied as the fraction length to interpret the input data to the filter. 
 Any positive integer  16  The number of bits applied to the word length to interpret the input data to the filter. 
 Any positive integer  2  Number of sections used in the interpolator. Generally
called 
 Any positive integer  15  The number of bits applied to the fraction length to interpret the output data from the filter. Readonly. 
 Any positive integer  16  The number of bits applied to the word length to interpret the output data from the filter. 


 Determines whether the filter states get restored to
their starting values for each filtering operation. The starting values
are the values in place when you create the filter if you have not
changed the filter since you constructed it. 
 Any integer or a vector of length 2^{N}, where N is a positive integer. This
property only applies when the  16  Defines the bits per section used while accumulating
the data in the integrator sections or while subtracting the data
during the comb sections (using 'wrap' arithmetic). Enter 


 Stored conditions for the filter, including values for
the integrator and comb sections before and after filtering. 
There are usage modes which are set using the FilterInternals
property:
FullPrecision
— In this
mode, the word and fraction lengths of the filter sections and outputs
are automatically selected for you. The output and last section word
lengths are set to:
$$\text{wordlength}=\text{ceil}({\mathrm{log}}_{2}({(RM)}^{N}/R))+I,$$
where R is the interpolation factor, M is the differential delay, N is the number of filter sections, and I denotes the input word length.
MinWordLengths
— In this
mode, you specify the word length of the filter output in the OutputWordLength
property.
The word lengths of the filter sections are automatically set in the
same way as in the FullPrecision
mode. The section
fraction lengths are set to the input fraction length. The output
fraction length is set to the input fraction length minus the difference
between the last section and output word lengths.
SpecifyWordLengths
— In
this mode, you specify the word lengths of the filter sections and
output in the SectionWordLengths
and OutputWordLength
properties.
The fraction lengths of the filter sections are set such that the
spread between word length and fraction length is the same as in fullprecision
mode. The output fraction length is set to the input fraction length
minus the difference between the last section and output word lengths.
SpecifyPrecision
— In this
mode, you specify the word and fraction lengths of the filter sections
and output in the SectionWordLengths
, SectionFracLengths
, OutputWordLength
,
and OutputFracLength
properties.
In the states
property you find the states
for both the integrator and comb portions of the filter. states
is
a matrix of dimensions m
+1byn
,
with the states apportioned as follows:
States for the integrator portion of the filter are stored in the first row of the state matrix.
States for the comb portion fill the remaining rows in the state matrix.
To review the states of a CIC filter, use the int
method
to assign the states. As an example, here are the states for a CIC
interpolator hm
before and after filtering data:
x = fi(cos(pi/4*[0:99]),true,16,0); % Fixedpoint input data hm = mfilt.cicinterp(2,1,2,16,16,16); % get initial statesall zero sts=int(hm.states) set(hm,'InputFracLength',0); % Integer input specified y=filter(hm,x); sts=int(hm.states) %sts = % % 1 1 % 1 1
When you design your CIC interpolation filter, remember the following general points:
The filter output spectrum has nulls at ω = k * 2π/rm
radians, k =
1,2,3....
Aliasing and imaging occur in the vicinity of the nulls.
n
, the number of sections in the
filter, determines the passband attenuation. Increasing n
improves
the filter ability to reject aliasing and imaging, but it also increases
the droop or rolloff in the filter passband. Using an appropriate
FIR filter in series after the CIC interpolation filter can help you
compensate for the induced droop.
The DC gain for the filter is a function of the interpolation factor. Raising the interpolation factor increases the DC gain.
Demonstrate interpolation by a factor of two, in this case from
22.05 kHz to 44.1 kHz. Note the scaling required to see the results
in the stem plot and to use the full range of the int16
data
type.
R = 2; % Interpolation factor. hm = mfilt.cicinterp(R); % Use default NumberOfSections and % DifferentialDelay property values. fs = 22.05e3; % Original sample frequency:22.05 kHz. n = 0:5119; % 5120 samples, .232 second long signal. x = sin(2*pi*1e3/fs*n); % Original signal, sinusoid at 1 kHz. y_fi = filter(hm,x); % 5120 samples, still 0.232 seconds. % Scale the output to overlay stem plots correctly. x = double(x); y = double(y_fi); y = y/max(abs(y)); stem(n(1:22)/fs,x(1:22),'filled'); % Plot original signal sampled % at 22.05 kHz. hold on; stem(n(1:44)/(fs*R),y(4:47),'r'); % Plot interpolated signal % (44.1 kHz) in red. xlabel('Time (sec)');ylabel('Signal Value');
As you expect, the plot shows that the interpolated signal matches the input sine shape, with additional samples between each original sample.
Use the filter visualization tool (FVTool) to plot the response of the interpolator object. For example, to plot the response of an interpolator with an interpolation factor of 7, 4 sections, and 1 differential delay, do something like the following:
hm = mfilt.cicinterp(7,1,4) fvtool(hm)
[1] Hogenauer, E. B., "An Economical Class of Digital Filters for Decimation and Interpolation," IEEE Transactions on Acoustics, Speech, and Signal Processing, ASSP29(2): pp. 155162, 1981
[2] MeyerBaese, Uwe, "Hogenauer CIC Filters," in Digital Signal Processing with Field Programmable Gate Arrays, Springer, 2001, pp. 155172
[3] Harris, Fredric J., Multirate Signal Processing for Communication Systems, PrenticeHall PTR, 2004 , pp. 343