main content

decimate signal using cascaded integrator-凯发k8网页登录

decimate signal using cascaded integrator-comb (cic) filter

description

the dsp.cicdecimator system object™ decimates an input signal using a cascaded integrator-comb (cic) decimation filter. the cic decimation filter structure consists of n sections of cascaded integrators, followed by a rate change by a factor of r, followed by n sections of cascaded comb filters. for details, see algorithms. the numsections property specifies n, the number of sections in the cic filter. the decimationfactor property specifies r, the decimation factor. the function returns the word lengths and fraction lengths of the fixed-point sections and the output for the dsp.cicdecimator system object. you can also generate hdl code for this system object using the function.

note

this object requires a fixed-point designer™ license.

to decimate a signal using a cic filter:

  1. create the dsp.cicdecimator 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?

creation

description

example

cicdecim = dsp.cicdecimator creates a cic decimation system object that applies a cic decimation filter to the input signal.

example

cicdecim = dsp.cicdecimator(r,m,n) creates a cic decimation object with the decimationfactor property set to r, the differentialdelay property set to m, and the numsections property set to n.

cicdecim = dsp.cicdecimator(name,value) creates a cic decimation object with each specified property set to the specified value. enclose each property name in single quotes. you can use this syntax with any previous input argument combination.

properties

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 function unlocks them.

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

for more information on changing property values, see .

factor by which the input signal is decimated, specified as a positive integer.

data types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

differential delay value used in each of the comb sections of the filter, specified as a positive integer. for details, see algorithms. if the differential delay is a built-in integer data type, the decimation factor must be the same integer data type or double. for example, if the differential delay is an int8, then the decimation factor must be an int8 or double.

data types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

number of integrator and comb sections of the cic filter, specified as a positive integer. this number indicates the number of sections in either the comb part or the integrator part of the filter. the total number of sections in the cic filter is twice the number of sections given by this property.

data types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

fixed-point property designations, specified as one of the following:

  • full precision – the word length and fraction length of the cic filter sections and the object output operate in full precision.

  • minimum section word lengths – specify the output word length through the outputwordlength property. the object determines the filter section data type and the output fraction length that give the best possible precision. for details, see and cicdecimout argument.

  • specify word lengths – specify the word lengths of the cic filter sections and the object output through the sectionwordlengths and outputwordlength properties. the object determines the corresponding fraction lengths to give the best possible precision. for details, see and the cicdecimout argument.

  • specify word and fraction lengths – specify the word length and fraction length of the cic filter sections and the object output through the sectionwordlengths, sectionfractionlengths, outputwordlength, and outputfractionlength properties.

fixed-point word lengths to use for each filter section, specified as a scalar or a row vector of integers. the word length must be greater than or equal to 2. if you specify a scalar, the value applies to all the sections of the filter. if you specify a vector, the vector must be of length 2 × numsections.

example: 32

example: [32 32 32 32]

dependencies

this property applies when you set the fixedpointdatatype property to 'specify word lengths' or 'specify word and fraction lengths'.

data types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

fixed-point fraction lengths to use for each filter section, specified as a scalar or a row vector of integers. the fraction length can be negative, 0, or positive. if you specify a scalar, the value applies to all the sections of the filter. if you specify a vector, the vector must be of length 2 × numsections.

example: -2

example: [-2 0 5 8]

dependencies

this property applies when you set the fixedpointdatatype property to 'specify word and fraction lengths'.

data types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

fixed-point word length to use for the filter output, specified as a scalar integer greater than or equal to 2.

dependencies

this property applies when you set the fixedpointdatatype property to 'minimum section word lengths', 'specify word lengths', or 'specify word and fraction lengths'.

data types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

fixed-point fraction length to use for the filter output, specified as a scalar integer.

dependencies

this property applies when you set fixedpointdatatype property to 'specify word and fraction lengths'.

data types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

usage

description

example

cicdecimout = cicdecim(input) decimates the input using a cic decimator.

input arguments

data input, specified as a vector or matrix. the number of rows in the input must be a multiple of the decimationfactor. if the input is of single or double data type, property settings related to the fixed-point data types are ignored.

data types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi
complex number support: yes

output arguments

decimated output, returned as a vector or a matrix. the output frame size equals (1 ∕ decimationfactor) × input frame size. the complexity of the output data matches that of the input data. if the input is single or double, the output data type matches the input data type.

if the input is of built-in integer data type or of fixed-point data type, the output word length and fraction length depend on the fixed-point data type setting you choose through the fixedpointdatatype property.

full precision

when the fixedpointdatatype is set to 'full precision', the following relationship applies:

wloutput=wlinput numsectfloutput=flinput

where,

  • wloutput –– word length of the output data.

  • floutput –– fraction length of the output data.

  • wlinput –– word length of the input data.

  • flinput –– fraction length of the input data.

  • numsect –– number of sections in the cic filter specified through the numsections property.

the wlinput and flinput are inherited from the data input you pass to the object algorithm. for built-in integer inputs, the fraction length is 0.

minimum section word lengths

when the fixedpointdatatype property is set to 'minimum section word lengths', the output word length is the value you specify in the outputwordlength property. the output fraction length, floutput, is given by:

floutput=wloutput(wlinputflinput numsect)

specify word and fraction lengths

when the fixedpointdatatype property is set to 'specify word and fraction lengths', the output word length and fraction length are the values you specify in the outputwordlength and outputfractionlength properties.

specify word lengths

when the fixedpointdatatype property is set to 'specify word lengths', the output word length is the value you specify in the outputwordlength property. the output fraction length, floutput, is given by:

floutput=wloutput(wlinputflinput numsect)

data types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi
complex number support: yes

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:

release(obj)
generate hdl code for quantized dsp filter (requires filter design hdl coder)
impulse response of discrete-time filter system object
frequency response of discrete-time filter system object
phase response of discrete-time filter system object (unwrapped)
visualize frequency response of dsp filters
gain of cic filter system object
get fixed-point word and fraction lengths
information about filter system object
run system object algorithm
release resources and allow changes to system object property values and input characteristics
reset internal states of system object

for a list of filter analysis methods this object supports, type dsp.cicdecimator.helpfilteranalysis in the matlab® command prompt. for the corresponding function reference pages, see .

examples

create a dsp.cicdecimator system object™ with decimationfactor set to 4. decimate a signal from 44.1 khz to 11.025 khz.

cicdec = dsp.cicdecimator(4);  
cicdec.fixedpointdatatype = 'minimum section word lengths'; 
cicdec.outputwordlength = 16;

create a fixed-point sinusoidal input signal of 1024 samples, with a sampling frequency of 44.1e3 hz.

fs = 44.1e3;       
% 0.0232 sec signal
n = (0:1023)';            
x = fi(sin(2*pi*1e3/fs*n),true,16,15);

create a dsp.signalsource object.

src = dsp.signalsource(x,64);

decimate the output with 16 samples per frame.

y = zeros(16,16);
for ii = 1:16
     y(ii,:) = cicdec(src());   
end

plot the first frame of the original and decimated signals. output latency is 2 samples.

d = cicdec.decimationfactor;
diffdelay = cicdec.differentialdelay;
numsect = cicdec.numsections;
gaincic = ...
   (d*diffdelay)^numsect;
stem(n(1:56)/fs,double(x(4:59))) 
hold on;     
stem(n(1:14)/(fs/d),double(y(1,3:end))/gaincic,...
    'r','filled')
xlabel('time (sec)')
ylabel('signal amplitude')
legend('original signal',...
    'decimated signal',...
    'location','north')
hold off;

figure contains an axes object. the axes object with xlabel time (sec), ylabel signal amplitude contains 2 objects of type stem. these objects represent original signal, decimated signal.

using the info method in 'long' format, obtain the word lengths and fraction lengths of the fixed-point filter sections and the filter output.

info(cicdec,'long')
ans = 
    'discrete-time fir multirate filter (real)               
     -----------------------------------------               
     filter structure    : cascaded integrator-comb decimator
     decimation factor   : 4                                 
     differential delay  : 1                                 
     number of sections  : 2                                 
     stable              : yes                               
     linear phase        : yes (type 1)                      
                                                             
                                                             
     implementation cost                                     
     number of multipliers            : 0                    
     number of adders                 : 4                    
     number of states                 : 4                    
     multiplications per input sample : 0                    
     additions per input sample       : 2.5                  
     
     
     fixed-point info
     section word lengths     : 20  19  19  18
     section fraction lengths : 15  14  14  13
     output  word length      : 16
     output  fraction length  : 11
     '

using the getfixedpointinfo function, you can determine the word lengths and fraction lengths of the fixed-point sections and the output of the dsp.cicdecimator and dsp.cicinterpolator system objects. the data types of the filter sections and the output depend on the fixedpointdatatype property of the filter system object™.

full precision

create a dsp.cicdecimator object. the default value of the numsections property is 2. this value indicates that there are two integrator and comb sections. the wls and fls vectors returned by the getfixedpointinfo function contain five elements each. the first two elements represent the two integrator sections. the third and fourth elements represent the two comb sections. the last element represents the filter output.

cicd = dsp.cicdecimator
cicd = 
  dsp.cicdecimator with properties:
      decimationfactor: 2
     differentialdelay: 1
           numsections: 2
    fixedpointdatatype: 'full precision'

by default, the fixedpointdatatype property of the object is set to 'full precision'. calling the getfixedpointinfo function on this object with the input numeric type, nt, yields the following word length and fraction length vectors.

nt = numerictype(1,16,15)
nt =
          datatypemode: fixed-point: binary point scaling
            signedness: signed
            wordlength: 16
        fractionlength: 15
[wls,fls] = getfixedpointinfo(cicd,nt) %#ok
wls = 1×5
    18    18    18    18    18
fls = 1×5
    15    15    15    15    15

for details on how the word lengths and fraction lengths are computed, see the description for output arguments.

if you lock the cicd object by passing an input to its algorithm, you do not need to pass the nt argument to the getfixedpointinfo function.

input = int64(randn(8,1))
input = 8x1 int64 column vector
    1
    2
   -2
    1
    0
   -1
    0
    0
output = cicd(input)
output = 
     0
     1
     3
     0
          datatypemode: fixed-point: binary point scaling
            signedness: signed
            wordlength: 66
        fractionlength: 0
[wls,fls] = getfixedpointinfo(cicd) %#ok
wls = 1×5
    66    66    66    66    66
fls = 1×5
     0     0     0     0     0

the output and section word lengths are the sum of input word length, 64 in this case, and the number of sections, 2. the output and section fraction lengths are 0 since the input is a built-in integer.

minimum section word lengths

release the object and change the fixedpointdatatype property to 'minimum section word lengths'. determine the section and output fixed-point information when the input is fixed-point data, fi(randn(8,2),1,24,15).

release(cicd);
cicd.fixedpointdatatype = 'minimum section word lengths'
cicd = 
  dsp.cicdecimator with properties:
      decimationfactor: 2
     differentialdelay: 1
           numsections: 2
    fixedpointdatatype: 'minimum section word lengths'
      outputwordlength: 32
inputf = fi(randn(8,2),1,24,15)
inputf = 
    3.5784   -0.1241
    2.7694    1.4897
   -1.3499    1.4090
    3.0349    1.4172
    0.7254    0.6715
   -0.0630   -1.2075
    0.7148    0.7172
   -0.2050    1.6302
          datatypemode: fixed-point: binary point scaling
            signedness: signed
            wordlength: 24
        fractionlength: 15
[wls, fls] = getfixedpointinfo(cicd,numerictype(inputf)) %#ok
wls = 1×5
    26    26    26    26    32
fls = 1×5
    15    15    15    15    21

specify word and fraction lengths

change the fixedpointdatatype property to 'specify word and fraction lengths'. determine the fixed-point information using the getfixedpointinfo function.

cicd.fixedpointdatatype = 'specify word and fraction lengths'
cicd = 
  dsp.cicdecimator with properties:
          decimationfactor: 2
         differentialdelay: 1
               numsections: 2
        fixedpointdatatype: 'specify word and fraction lengths'
        sectionwordlengths: [16 16 16 16]
    sectionfractionlengths: 0
          outputwordlength: 32
      outputfractionlength: 0
[wls, fls] = getfixedpointinfo(cicd,numerictype(inputf)) %#ok
wls = 1×5
    16    16    16    16    32
fls = 1×5
     0     0     0     0     0

the section and output word lengths and fraction lengths are assigned as per the respective fixed-point properties of the cicd object. these values are not determined by the input numeric type. to confirm, call the getfixedpointinfo function without passing the numerictype input argument.

[wls, fls] = getfixedpointinfo(cicd) %#ok
wls = 1×5
    16    16    16    16    32
fls = 1×5
     0     0     0     0     0

specify word lengths

to specify the word lengths of the filter section and output, set the fixedpointdatatype property to 'specify word lengths'.

cicd.fixedpointdatatype = 'specify word lengths'
cicd = 
  dsp.cicdecimator with properties:
      decimationfactor: 2
     differentialdelay: 1
           numsections: 2
    fixedpointdatatype: 'specify word lengths'
    sectionwordlengths: [16 16 16 16]
      outputwordlength: 32

the getfixedpointinfo function requires the input numeric type because that information is used to compute the section and word fraction lengths.

[wls, fls] = getfixedpointinfo(cicd,numerictype(inputf))
wls = 1×5
    16    16    16    16    32
fls = 1×5
     5     5     5     5    21

for more details on how the function computes the word and fraction lengths, see the description for output arguments.

more about

algorithms

references

[1] hogenauer, e.b. "an economical class of digital filters for decimation and interpolation." ieee transactions on acoustics, speech and signal processing. volume 29, number 2, 1981, 155–162.

[2] meyer-baese, u. digital signal processing with field programmable gate arrays. new york: springer, 2001.

[3] harris, fredric j. multirate signal processing for communication systems. indianapolis, in: prentice hall ptr, 2004.

extended capabilities

version history

introduced in r2012a

see also

functions

  • | | | | | | |

objects

blocks

topics

    网站地图