Documentation |
On this page… |
---|
The following table summarizes the multirate filter properties and provides a brief description of each. Full descriptions of each property are given in the subsequent section.
Name | Values | Default | Description |
---|---|---|---|
BlockLength | Positive integers | 100 | Length of each block of data input to the FFT used in the filtering. fftfirinterp multirate filters include this property. |
DecimationFactor | Any positive integer | 2 | Amount to reduce the input sampling rate. |
DifferentialDelay | Any integer | 1 | Sets the differential delay for the filter. Usually a value of one or two is appropriate. |
FilterInternals | FullPrecision, | FullPrecision | Controls whether the filter sets the output word and fraction lengths, and the accumulator word and fraction lengths automatically to maintain the best precision results during filtering. The default value, FullPrecision, sets automatic word and fraction length determination by the filter. SpecifyPrecision exposes the output and accumulator related properties so you can set your own word and fraction lengths for them. |
FilterStructure | mfilt structure string | None | Describes the signal flow for the filter object, including all of the active elements that perform operations during filtering — gains, delays, sums, products, and input/output. You cannot set this property — it is always read only and results from your choice of mfilt object. |
InputOffset | Integers | 0 | Contains the number of input data samples processed without generating an output sample. InputOffset = mod(length(nx),m) where nx is the number of input samples that have been processed so far and m is the decimation factor. |
InterpolationFactor | Positive integers | 2 | Interpolation factor for the filter. l specifies the amount to increase the input sampling rate. |
NumberOfSections | Any positive integer | 2 | Number of sections used in the decimator, or in the comb and integrator portions of CIC filters. |
Numerator | Array of double values | No default values | Vector containing the coefficients of the FIR lowpass filter used for interpolation. |
OverflowMode | saturate, [wrap] | wrap | Sets the mode used to respond to overflow conditions in fixed-point arithmetic. Choose from either saturate (limit the output to the largest positive or negative representable value) or wrap (set overflowing values to the nearest representable value using modular arithmetic. The choice you make affects only the accumulator and output arithmetic. Coefficient and input arithmetic always saturates. Finally, products never overflow — they maintain full precision. |
PolyphaseAccum | Values depend on filter type. Either double, single, or fixed-point object | 0 | Stores the value remaining in the accumulator after the filter processes the last input sample. The stored value for PolyphaseAccum affects the next output when PersistentMemory is true and InputOffset is not equal to 0. Always provides full precision values. Compare the AccumWordLength and AccumFracLength. |
PersistentMemory | false or true | false | 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. PersistentMemory returns to zero any state that the filter changes during processing. States that the filter does not change are not affected. |
RateChangeFactors | [l,m] | [2,3] or [3,2] | Reports the decimation (m) and interpolation (l) factors for the filter object. Combining these factors results in the final rate change for the signal. The default changes depending on whether the filter decimates or interpolates. |
States | Any m+1-by-n matrix of double values | 2-by-2 matrix, int32 | Stored conditions for the filter, including values for the integrator and comb sections. n is the number of filter sections and m is the differential delay. Stored in a filtstates object. |
SpecifyWordLengths | Vector of integers | [16 16 16 16] bits | |
WordLengthPerSection | Any integer or a vector of length 2*n | 16 | Defines the word length used in each section while accumulating the data in the integrator sections or while subtracting the data during the comb sections (using 'wrap' arithmetic). Enter WordLengthPerSection as a scalar or vector of length 2*n, where n is the number of sections. When WordLengthPerSection is a scalar, the scalar value is applied to each filter section. The default is 16 for each section in the decimator. |
The following sections provide details about the properties that govern the way multirate filter work. Creating any multirate filter object puts in place a number of these properties. The following pages list the mfilt object properties in alphabetical order.
Any integer or a vector of length 2*n.
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 bps as a scalar or vector of length 2*n, where n is the number of sections. When bps is a scalar, the scalar value is applied to each filter section. The default is 16 for each section in the decimator.
Length of each block of input data used in the filtering.
mfilt.fftfirinterp objects process data in blocks whose length is determined by the value you set for the BlockLength property. By default the property value is 100. When you set the BlockLength value, try choosing a value so that [BlockLength + length(filter order)] is a power of two.
Larger block lengths generally reduce the computation time.
Decimation factor for the filter. m specifies the amount to reduce the sampling rate of the input signal. It must be an integer. You can enter any integer value. The default value is 2.
Sets the differential delay for the filter. Usually a value of one or two is appropriate. While you can set any value, the default is one and the maximum is usually two.
Similar to the FilterInternals pane in FDATool, this property controls whether the filter sets the output word and fraction lengths automatically, and the accumulator word and fraction lengths automatically as well, to maintain the best precision results during filtering. The default value, FullPrecision, sets automatic word and fraction length determination by the filter. Setting FilterInternals to SpecifyPrecision exposes the output and accumulator related properties so you can set your own word and fraction lengths for them.
About FilterInternals Mode. There are four usage modes for this that you set using the FilterInternals property in multirate filters.
FullPrecision — All word and fraction lengths set to B_{max} + 1, called B_{accum} by Fred Harris in [2]. Full precision is the default setting.
MinWordLengths — Minimum Word Lengths
SpecifyWordLengths — Specify Word Lengths
SpecifyPrecision — Specify Precision
Full Precision
In full precision mode, the word lengths of all sections and the output are set to B_{accum} as defined by
$${B}_{accum}=ceil({N}_{\mathrm{sec}s}(Lo{g}_{2}(D\times M))+InputWordLength)$$
where N_{secs} is the number of filter sections.
Section fraction lengths and the fraction length of the output are set to the input fraction length.
Here is the display looks for this mode.
FilterStructure: 'Cascaded Integrator-Comb Decimator' Arithmetic: 'fixed' DifferentialDelay: 1 NumberOfSections: 2 DecimationFactor: 4 PersistentMemory: false InputWordLength: 16 InputFracLength: 15 FilterInternals: 'FullPrecision'
Minimum Word Lengths
In minimum word length mode, you control the output word length explicitly. When the output word length is less than B_{accum}, roundoff noise is introduced at the output of the filter. Hogenauer's bit pruning theory (refer to [3] in the following References section) states that one valid design criterion is to make the word lengths of the different sections of the filter smaller than B_{accum} as well, so that the roundoff noise introduced by all sections does not exceed the roundoff noise introduced at the output.
In this mode, the design calculates the word lengths of each section to meet the Hogenauer criterion. The algorithm subtracts the number of bits computed using eq. 21 in Hogenauer's paper from B_{accum} to determine the word length each section.
To compute the fraction lengths of the different sections, the algorithm notes that the bits thrown out for this word length criterion are least significant bits (LSB), therefore each bit thrown out at a particular section decrements the fraction length of that section by one bit compared to the input fraction length. Setting the output word length for the filter automatically sets the output fraction length as well.
Here is the display for this mode:
FilterStructure: 'Cascaded Integrator-Comb Decimator' Arithmetic: 'fixed' DifferentialDelay: 1 NumberOfSections: 2 DecimationFactor: 4 PersistentMemory: false InputWordLength: 16 InputFracLength: 15 FilterInternals: 'MinWordLengths' OutputWordLength: 16
Specify Word Lengths
In this mode, the design algorithm discards the LSBs, adjusting the fraction length so that unrecoverable overflow does not occur, always producing a reasonable output.
You can specify the word lengths for all sections and the output, but you cannot control the fraction lengths for those quantities.
To specify the word lengths, you enter a vector of length 2*(NumberOfSections), where each vector element represents the word length for a section. If you specify a scalar, such as B_{accum}, the full-precision output word length, the algorithm expands that scalar to a vector of the appropriate size, applying the scalar value to each section.
The CIC design does not check that the specified word lengths are monotonically decreasing. There are some cases where the word lengths are not necessarily monotonically decreasing, for example
hcic=mfilt.cicdecim; hcic.FilterInternals='minwordlengths'; hcic.Outputwordlength=14;
which are valid CIC filters but the word lengths do not decrease monotonically across the sections.
Here is the display looks like for the SpecifyWordLengths mode.
FilterStructure: 'Cascaded Integrator-Comb Decimator' Arithmetic: 'fixed' DifferentialDelay: 1 NumberOfSections: 2 DecimationFactor: 4 PersistentMemory: false InputWordLength: 16 InputFracLength: 15 FilterInternals: 'SpecifyWordLengths' SectionWordLengths: [19 18 18 17] OutputWordLength: 16
Specify Precision
In this mode, you have full control over the word length and fraction lengths of all sections and the filter output.
When you elect the SpecifyPrecision mode, you must enter a vector of length 2*(NumberOfSections) with elements that represent the word length for each section. When you enter a scalar such as B_{accum}, the CIC algorithm expands that scalar to a vector of the appropriate size and applies the scalar value to each section and the output. The design does not check that this vector is monotonically decreasing.
Also, you must enter a vector of length 2*(NumberOfSections) with elements that represent the fraction length for each section as well. When you enter a scalar such as B_{accum}, the design applies scalar expansion as done for the word lengths.
Here is the SpecifyPrecision display.
FilterStructure: 'Cascaded Integrator-Comb Decimator' Arithmetic: 'fixed' DifferentialDelay: 1 NumberOfSections: 2 DecimationFactor: 4 PersistentMemory: false InputWordLength: 16 InputFracLength: 15 FilterInternals: 'SpecifyPrecision' SectionWordLengths: [19 18 18 17] SectionFracLengths: [14 13 13 12] OutputWordLength: 16 OutputFracLength: 11
Reports the type of filter object, such as a decimator or fractional integrator. You cannot set this property — it is always read only and results from your choice of mfilt object. Because of the length of the names of multirate filters, FilterStructure often returns a vector specification for the string. For example, when you use mfilt.firfracinterp to design a filter, FilterStructure returns as [1x49 char].
hm=mfilt.firfracinterp hm = FilterStructure: [1x49 char] Numerator: [1x72 double] RateChangeFactors: [3 2] PersistentMemory: false States: [24x1 double]
When you decimate signals whose length is not a multiple of the decimation factor M, the last samples — (nM +1) to [(n+1)(M) -1], where n is an integer — are processed and used to track where the filter stopped processing input data and when to expect the next output sample. If you think of the filtering process as generating an output for a block of input data, InputOffset contains a count of the number of samples in the last incomplete block of input data.
Note InputOffset applies only when you set PersistentMemory to true. Otherwise, InputOffset is not available for you to use. |
Two different cases can arise when you decimate a signal:
The input signal is a multiple of the filter decimation factor. In this case, the filter processes the input samples and generates output samples for all inputs as determined by the decimation factor. For example, processing 99 input samples with a filter that decimates by three returns 33 output samples.
The input signal is not a multiple of the decimation factor. When this occurs, the filter processes all of the input samples, generates output samples as determined by the decimation factor, and has one or more input samples that were processed but did not generate an output sample.
For example, when you filter 100 input samples with a filter which has decimation factor of 3, you get 33 output samples, and 1 sample that did not generate an output. In this case, InputOffset stores the value 1 after the filter run.
InputOffset equal to 1 indicates that, if you divide your input signal into blocks of data with length equal to your filter decimation factor, the filter processed one sample from a new (incomplete) block of data. Subsequent inputs to the filter are concatenated with this single sample to form the next block of length m.
One way to define the value stored in InputOffset is
InputOffset = mod(length(nx),m)
where nx is the number of input samples in the data set and m is the decimation factor.
Storing InputOffset in the filter allows you to stop filtering a signal at any point and start over from there, provided that the PersistentMemory property is set to true. Being able to resume filtering after stopping a signal lets you break large data sets in to smaller pieces for filtering. With PersistentMemory set to true and the InputOffset property in the filter, breaking a signal into sections of arbitrary length and filtering the sections is equivalent to filtering the entire signal at once.
xtot=[x,x]; ytot=filter(hm1,xtot) ytot = 0 -0.0003 0.0005 -0.0014 0.0028 -0.0054 0.0092 reset(hm1); % Clear history of the filter hm1.PersistentMemory='true'; ysec=[filter(hm1,x) filter(hm1,x)] ysec = 0 -0.0003 0.0005 -0.0014 0.0028 -0.0054 0.0092
This test verifies that ysec (the signal filtered by sections) is equal to ytot (the entire signal filtered at once).
Amount to increase the sampling rate. Interpolation factor for the filter. It specifies the amount to increase the input sampling rate. It must be an integer. Two is the default value. You may use any positive value.
Number of sections used in the multirate filter. By default multirate filters use two sections, but any positive integer works.
The OverflowMode property is specified as one of the following two strings indicating how to respond to overflows in fixed-point arithmetic:
'saturate' — saturate overflows.
When the values of data to be quantized lie outside of the range of the largest and smallest representable numbers (as specified by the applicable word length and fraction length properties), these values are quantized to the value of either the largest or smallest representable value, depending on which is closest.
'wrap' — wrap all overflows to the range of representable values.
When the values of data to be quantized lie outside of the range of the largest and smallest representable numbers (as specified by the data format properties), these values are wrapped back into that range using modular arithmetic relative to the smallest representable number. You can learn more about modular arithmetic in Fixed-Point Designer™ documentation.
These rules apply to the OverflowMode property.
Applies to the accumulator and output data only.
Does not apply to coefficients or input data. These always saturate the results.
Does not apply to products. Products maintain full precision at all times. Your filters do not lose precision in the products.
Default value
: 'saturate'
The idea behind PolyphaseAccum and AccumWordLength/AccumFracLength is to distinguish between the adders that always work in full precision (PolyphaseAccum) from the others [the adders that are controlled by the user (through AccumWordLength and AccumFracLength) and that may introduce quantization effects when you set property FilterInternals to SpecifyPrecision.
Given a product format determined by the input word and fraction lengths, and the coefficients word and fraction lengths, doing full precision accumulation means allowing enough guard bits to avoid overflows and underflows.
Property PolyphaseAccum stores the value that was in the accumulator the last time your filter ran out of input samples to process. The default value for PolyphaseAccum affects the next output only if PersistentMemory is true and InputOffset is not equal to 0.
PolyphaseAccum stores data in the format for the filter arithmetic. Double-precision filters store doubles in PolyphaseAccum. Single-precision filter store singles in PolyphaseAccum. Fixed-point filters store fi objects in PolyphaseAccum.
Determine 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. PersistentMemory returns to zero any state that the filter changes during processing. States that the filter does not change are not affected.
Determine 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 object. PersistentMemory returns to zero any state that the filter changes during processing. States that the filter does not change are not affected. Defaults to true — the filter retains memory about filtering operations from one to the next. Maintaining memory lets you filter large data sets as collections of smaller subsets and get the same result.
xtot=[x,x]; ytot=filter(hm1,xtot) ytot = 0 -0.0003 0.0005 -0.0014 0.0028 -0.0054 0.0092 reset(hm1); % Clear history of the filter hm1.PersistentMemory='true'; ysec=[filter(hm1,x) filter(hm1,x)] ysec = 0 -0.0003 0.0005 -0.0014 0.0028 -0.0054 0.0092
This test verifies that ysec (the signal filtered by sections) is equal to ytot (the entire signal filtered at once).
Reports the decimation (m) and interpolation (l) factors for the filter object when you create fractional integrators and decimators, although m and l are used as arguments to both decimators and integrators, applying the same meaning. Combining these factors as input arguments to the fractional decimator or integrator results in the final rate change for the signal.
For decimating filters, the default is [2,3]. For integrators, [3,2].
Stored conditions for the filter, including values for the integrator and comb sections. m is the differential delay and n is the number of sections in the filter.
About the States of Multirate Filters. In the states property you find the states for both the integrator and comb portions of the filter, stored in a filtstates object. states is a matrix of dimensions m+1-by-n, with the states in CIC filters 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.
In the state matrix, state values are specified and stored in double format.
States stores conditions for the delays between each interpolator phase, the filter states, and the states at the output of each phase in the filter, including values for the interpolator and comb states.
The number of states is (lh-1)*m+(l-1)*(lo+mo) where lh is the length of each subfilter, and l and m are the interpolation and decimation factors. lo and mo, the input and output delays between each interpolation phase, are integers from Euclid's theorem such that lo*l-mo*m = -1 (refer to the reference for more details). Use euclidfactors to get lo and mo for an mfilt.firfracdecim object.
States defaults to a vector of zeros that has length equal to nstates(hm)
[1] Fliege, N.J., Multirate Digital Signal Processing, John Wiley and Sons, 1994.
[2] Harris, Fredric J, Multirate Signal Processing for Communication Systems, Prentice Hall PTR, 2004.
[3] Hogenauer, E. B., "An Economical Class of Digital Filters for Decimation and Interpolation," IEEE Transactions on Acoustics, Speech, and Signal Processing, Vol. ASSP-29, No. 2, April 1981, pp. 155-162.
[4] Lyons, Richard G., Understanding Digital Signal Processing, Prentice Hall PTR, 2004
[5] Mitra, S.K., Digital Signal Processing, McGraw-Hill, 1998.
[6] Orfanidis, S.J., Introduction to Signal Processing, Prentice-Hall, Inc., 1996.