Decimate signal using cascaded integrator-comb filter — optimized for HDL code generation


The dsp.HDLCICDecimation System object™ decimates an input signal by using a cascaded integrator-comb (CIC) decimation filter. CIC filters are a class of linear phase FIR filters comprised of a comb part and an integrator part. The CIC decimation filter structure consists of N sections of cascaded integrators, a rate change factor of R, and then N sections of cascaded comb filters. For more information about CIC decimation filter, see Algorithms.

The System object supports fixed decimation rate. It provides an architecture suitable for HDL code generation and hardware deployment.

The System object supports real and complex fixed-point inputs.

To filter input data with an HDL-optimized CIC decimation filter:

  1. Create the dsp.HDLCICDecimation object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects? (MATLAB).



cicDecFilt = dsp.HDLCICDecimation creates an HDL-optimized CIC decimation filter System object, cicDecFilt, with default properties.


cicDecFilt = dsp.HDLCICDecimation(Name,Value) creates the filter with properties set using one or more name-value pairs. Enclose each property name in single quotes.


expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects (MATLAB).

Specify the decimation factor as an integer from 2 to 2048. This value represents the rate with which you want to decimate the block input.

Specify the differential delay used in the comb part of the filter as either 1 or 2 cycles.

Specify the number of sections in the comb part or integrator part of the filter as an integer from 1 to 6.

Choose the data type of the filtered output data.

  • 'Full precision' — The output data type has a word length equal to the input word length plus gain bits.

  • 'Same word length as input' — The output data type has a word length equal to the input word length.

  • 'Minimum section word lengths' — The output data type uses the word length you specify in the OutputWordLength property. When you choose this option, the System object applies a pruning algorithm internally. For more information about pruning, see Output Data Type.

Word length of the output, specified as an integer from 2 to 104.


To enable this property, set the OutputDataType property to 'Minimum section word lengths'.


When the Output word length value entered is in the range 2 to 6, there are chances of output data getting overflowed.

When you set this property to true, the System object expects a reset input argument.



[dataOut,validOut] = cicDecFilt(dataIn,validIn) filters and decimates the input data using a fixed decimation factor only when validIn is true.

[dataOut,validOut] = cicDecFilt(dataIn,validIn,reset) filters the input data when reset is false and clears filter internal states when reset is true. The System object expects the reset argument only when you set the ResetIn property to true.

Input Arguments

expand all

Input data, specified as a signed integer or signed fixed-point value with a word length less than or equal to 32.

Data Types: int8 | int16 | int32 | fi
Complex Number Support: Yes

Control signal that indicate if the input data is valid.

When validIn is 1 (true), the System object captures the value from the dataIn input argument. When validIn is 0 (false), the System object ignores the dataIn input value.

Data Types: logical

Clears internal states, specified as a logical scalar.

When this value is 1 (true), the System object stops the current calculation and clears all internal states. When this value is 0 (false) and validIn is 1 (true), the System object starts a new filtering operation.


To enable this argument, set the ResetIn property to true.

Data Types: logical

Output Arguments

expand all

CIC decimated output data, returned as a scalar.

The OutputDataType property sets the output data type. See OutputDataType.

Data Types: int8 | int16 | int32 | fi
Complex Number Support: Yes

Control signal that indicates if the data from the dataOut output argument is valid. When this value is 1 (true), the System object returns valid data from the dataOut output argument. When this value is 0 (false), the values of the dataOut output argument are not valid.

Data Types: logical

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:


expand all

getLatencyLatency of CIC decimation filter
stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object


expand all

This example shows how to use the dsp.HDLCICDecimation System object™ to filter and downsample data. The example performs these steps:

  1. Generate a frame of random input samples.

  2. Generate reference output data from the dsp.CICDecimation System object™.

  3. Run a function that contains the dsp.HDLCICDecimation System object™. This function operates on a stream of data samples rather than a frame.

  4. Compare the output of the function with the reference data.

You can generate HDL code from the function.

Set up input data parameters.

R = 8; % Decimation factor
M = 1; % Differential delay
N = 3; % Number of sections

numFrames = 2;
dataSamples = cell(1,numFrames);
refOutput = [];

Generate a frame of random input samples. To generate reference output data for comparison, apply the samples to the dsp.CICDecimation System object.

totalsamples = 0;
for i = 1:numFrames
    framesize(i) = R*randi([5 20],1,1);
    dataSamples{i} = fi(randn(framesize(i),1),1,16,8);
    ref_cic = dsp.CICDecimator('DifferentialDelay',M,...
    refOutput = [refOutput,ref_cic(dataSamples{i}).'];

Write a function that creates and calls the dsp.HDLCICDecimation System object™. You can generate HDL from this function. Set the properties of the object to match the input data parameters.

function [dataOut,validOut] = HDLCIC_R8(dataIn,validIn,resetIn)
% Performs CIC decimation with a decimation factor of 8. 
% dataIn is a scalar fixed-point value.
% validIn is a logical scalar value.
% resetIn is a logical scalar value.
% You can generate HDL code from this function.

  persistent cic8;
  if isempty(cic8)
    cic8 = dsp.HDLCICDecimation('DecimationFactor',8,...
  [dataOut,validOut] = step(cic8,dataIn,validIn,resetIn);

Initialize the output vectors to a size large enough to accommodate the output data. The final size will be smaller than totalsamples due to decimation. The object has a latency of 3+N cycles. To clear previous output of function, reset is used.

latency = 3+N;
dataOut = zeros(1,totalsamples+numFrames*latency);
validOut = zeros(1,totalsamples+numFrames*latency);
idx = 0;
for ij = 1:numFrames
    for ii = 1:length(dataSamples{ij})
        idx = idx+1;
        [dataOut(idx),validOut(idx)] = HDLCIC_R8(...
    for ii = 1:latency
        idx = idx+1;
        [dataOut(idx),validOut(idx)] = HDLCIC_R8(...

Compare the results against the output from the dsp.CICDecimation object.

cicOutput = dataOut(validOut==1);

fprintf('\nHDL CIC Decimation\n');
difference = (abs(cicOutput-refOutput(1:length(cicOutput)))>0);
fprintf('\nTotal number of samples differed between Behavioral and HDL simulation: %d \n',sum(difference));
HDL CIC Decimation

Total number of samples differed between Behavioral and HDL simulation: 0 

The latency of the dsp.HDLCICDecimation System object™ varies depending on how many integrator and comb sections your filter has. Use the getLatency function to find the latency of a particular filter configuration. The latency is the number of cycles between the first valid input and the first valid output, assuming the input is continuously valid.

Create a dsp.HDLCICDecimation System object™ and request the latency. The default filter has two sections.

hdlcic = dsp.HDLCICDecimation
hdlcic = 
  dsp.HDLCICDecimation with properties:

     DecimationFactor: 2
    DifferentialDelay: 1
          NumSections: 2
       OutputDataType: 'Full precision'
              ResetIn: false

L_def = getLatency(hdlcic)
L_def = 5

Modify the filter object to have three integrator and comb sections. Check the resulting change in latency.

hdlcic.NumSections = 3;
L_3sec = getLatency(hdlcic)
L_3sec = 6


expand all


[1] Hogenauer, E.B. “An Economical Class of Digital Filters for Decimation and Interpolation.” IEEE Transactions on Acoustics, Speech and Signal Processing. Vol. 29, Number 2, 1981, pp. 155–162.

Introduced in R2019b