Products & Services Solutions Academia Support User Community Company

Learn more about Signal Processing Blockset   

FIR Decimation - Filter and downsample input signals

Library

Filtering / Multirate Filters

dspmlti4

Description

The FIR Decimation block resamples the discrete-time input at a rate K times slower than the input sample rate, where the integer K is specified by the Decimation factor parameter. This process consists of two steps:

The FIR Decimation block implements the above FIR filtering and downsampling steps together using a polyphase filter structure, which is more efficient than straightforward filter-then-decimate algorithms. See Fliege [1] for more information.

The FIR filter coefficients parameter specifies the numerator coefficients of the FIR filter transfer function H(z).

The length-m coefficient vector, [b(1) b(2) ... b(m)], can be generated by one of the filter design functions in Signal Processing Toolbox software, such as the fir1 function used in Example 1 below. The filter should be lowpass with normalized cutoff frequency no greater than 1/K. All filter states are internally initialized to zero.

The FIR Decimation block supports real and complex floating-point and fixed-point inputs, except for complex unsigned fixed-point inputs. This block supports triggered subsystems when you select Maintain input frame rate for the Framing parameter.

Sample-Based Operation

An M-by-N sample-based matrix input is treated as M*N independent channels, and the block decimates each channel over time. The output sample period is K times longer than the input sample period (Tso = KTsi), and the input and output sizes are identical.

Frame-Based Operation

An Mi-by-N frame-based matrix input is treated as N independent channels, and the block decimates each channel over time. The Framing parameter determines how the block adjusts the rate at the output to accommodate the reduced number of samples. There are two available options:

Latency

The FIR Decimation block has zero-tasking latency for all single-tasking and multitasking cases, except one:

Sample-Based LatencyFrame-Based Latency —
Maintain input frame rate
Frame-Based Latency —
Maintain input frame size

None

None

One frame (Mi samples)

Zero-tasking latency means that the block propagates the first filtered input sample (received at t=0) as the first output sample, followed by filtered input samples K+1, 2K+1, and so on.

In cases of one-frame latency, the value of the first Mi output rows is defined by the Output buffer initial conditions parameter, where Mi is the input frame size. The default value of the Output buffer initial conditions parameter is 0, but you can enter a matrix containing one value for each channel, or a scalar to be applied to all signal channels. The first filtered input sample (first filtered row of the input matrix) appears in the output as sample Mi+1, followed by filtered input samples K+1, 2K+1, and so on.

Fixed-Point Data Types

The following diagram shows the data types used within the FIR Decimation block for fixed-point signals.

You can set the coefficient, product output, accumulator, and output data types in the block dialog as discussed in Dialog Box. This diagram shows that data is stored in the input buffer in the same data type and scaling as the input. Filtered data is stored in the output buffer in the output data type and scaling that you set in the block dialog. Any initial conditions are also stored in the output buffer in the output data type and scaling you set in the block dialog.

The output of the multiplier is in the product output data type when at least one of the inputs to the multiplier is real. When both of the inputs to the multiplier are complex, the result of the multiplication is in the accumulator data type. For details on the complex multiplication performed, see Multiplication Data Types.

Examples

Example 1

Construct the following frame-based model.

Adjust the block parameters as follows:

This model is multirate because there are at least two distinct sample rates, as shown by the two Probe blocks. To run this model in the Simulink multitasking mode, make the following settings in the Solver pane of the Configuration Parameters dialog box:

Run the model and look at the output, yout. The first few samples of each channel are shown below.

yout =
         0         0
         0         0
         0         0
         0         0
    0.0386   -0.0386
    1.5000   -1.5000
    3.5000   -3.5000
    5.5000   -5.5000
    7.5000   -7.5000
    9.5000   -9.5000
   11.5000  -11.5000

Since this is a frame-based multirate model, the first four (Mi) output rows are zero. The first filtered input matrix row appears in the output as sample 5 (that is, sample Mi+1).

Example 2

The doc_polyphasedec model illustrates the underlying polyphase implementations of the FIR Decimation block. Run the model and view the results on the scope. The output of the FIR Decimation block is the same as the output of the Polyphase Decimation Filter block.

Example 3

The doc_mrf_nlp model illustrates the use of the FIR Decimation block in a number of multistage multirate filters.

Dialog Box

Coefficient Source

The FIR Decimation block can operate in two different modes. Select the mode in the Coefficient source group box. If you select

Different items appear on the FIR Decimation block dialog depending on whether you select Dialog parameters or Multirate filter object (MFILT) in the Coefficient source group box. See the following sections for details:

Specify Filter Characteristics in Dialog

The Main pane of the FIR Decimation block dialog appears as follows when Dialog parameters is selected in the Coefficient source group box.

FIR filter coefficients

Specify the lowpass FIR filter coefficients, in descending powers of z.

Decimation factor

Specify the integer factor, K, by which to decrease the sample rate of the input sequence.

Filter Structure

Choose whether to implement a Direct form or Direct form transposed filter.

Framing

For frame-based operation, specify the method by which to implement the decimation; reduce the output frame rate, or reduce the output frame size. This parameter cannot be set to Maintain input frame rate for sample-based signals.

Output buffer initial conditions

For the case of one-frame latency, this parameter specifies the output at the output port until the first filtered input sample is available. The default value of this parameter is 0, but you can enter a matrix containing one value for each channel, or a scalar to be applied to all signal channels.

View filter response

This button opens the Filter Visualization Tool (fvtool) from the Signal Processing Toolbox product and displays the filter response of the filter defined in the block. For more information on FVTool, see the Signal Processing Toolbox documentation.

The Fixed point pane of the FIR Decimation block dialog appears as follows when Dialog parameters is specified in the Coefficient source group box.

Rounding mode

Select the rounding mode for fixed-point operations. The filter coefficients do not obey this parameter; they always round to Nearest.

Overflow mode

Select the overflow mode for fixed-point operations. The filter coefficients do not obey this parameter; they are always saturated.

Coefficients

Choose how you specify the word length and the fraction length of the filter coefficients:

  • When you select Same word length as input, the word length of the filter coefficients match that of the input to the block. In this mode, the fraction length of the coefficients is automatically set to the binary-point only scaling that provides you with the best precision possible given the value and word length of the coefficients.

  • When you select Specify word length, you can enter the word length of the coefficients, in bits. In this mode, the fraction length of the coefficients is automatically set to the binary-point only scaling that provides you with the best precision possible given the value and word length of the coefficients.

  • When you select Binary point scaling, you can enter the word length and the fraction length of the coefficients, in bits.

  • When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the coefficients. This block requires power-of-two slope and a bias of zero.

The filter coefficients do not obey the Rounding mode and the Overflow mode parameters; they are always saturated and rounded to Nearest.

Product output

Use this parameter to specify how you would like to designate the product output word and fraction lengths. See Fixed-Point Data Types and Multiplication Data Types for illustrations depicting the use of the product output data type in this block:

  • When you select Inherit via internal rule, the product output word length and fraction length are calculated automatically. For information about how the product output word and fraction lengths are calculated when an internal rule is used, see Inherit via Internal Rule.

  • When you select Same as input, these characteristics match those of the input to the block.

  • When you select Binary point scaling, you can enter the word length and the fraction length of the product output, in bits.

  • When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the product output. This block requires power-of-two slope and a bias of zero.

Accumulator

As depicted in this graphic, inputs to the accumulator are cast to the accumulator data type. The output of the adder remains in the accumulator data type as each element of the input is added to it. Use this parameter to specify how you would like to designate this accumulator word and fraction lengths.

You also use this parameter to specify the accumulator word and fraction lengths resulting from a complex-complex multiplication in the block. See Multiplication Data Types for more information.

  • When you select Inherit via internal rule, the accumulator word length and fraction length are calculated automatically. For information about how the accumulator word and fraction lengths are calculated when an internal rule is used, see Inherit via Internal Rule.

  • When you select Same as product output, these characteristics match those of the product output.

  • When you select Same as input, these characteristics match those of the input to the block.

  • When you select Binary point scaling, you can enter the word length and the fraction length of the accumulator, in bits.

  • When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the accumulator. This block requires power-of-two slope and a bias of zero.

Output

Choose how you specify the output word length and fraction length:

  • When you select Same as accumulator, these characteristics match those of the accumulator.

    A special case occurs when Inherit via internal rule is specified for Accumulator, and block inputs and coefficients are complex. In that case, the output word length is one less than the accumulator word length.

  • When you select Same as product output, these characteristics match those of the product output.

  • When you select Same as input, these characteristics match those of the input to the block.

  • When you select Binary point scaling, you can enter the word length and the fraction length of the output, in bits.

  • When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the output. This block requires power-of-two slope and a bias of zero.

Lock scaling against changes by the autoscaling tool

Select this parameter to prevent any fixed-point scaling you specify in this block mask from being overridden by the autoscaling tool in the Fixed-Point Tool.

Specify Multirate Filter Object

The Main pane of the FIR Decimation block dialog appears as follows when Multirate filter object (MFILT) is specified in the Coefficient source group box.

Multirate filter variable

Specify the multirate filter object (mfilt) that you would like the block to implement. You can do this in one of three ways:

  • You can fully specify the mfilt object in the block mask.

  • You can enter the variable name of a mfilt object that is defined in any workspace.

  • You can enter a variable name for a mfilt object that is not yet defined, as shown in the default value.

For more information on creating mfilt objects, see the mfilt function reference page in the Filter Design Toolbox documentation.

Framing

For frame-based operation, specify the method by which to implement the decimation; reduce the output frame rate, or reduce the output frame size. This parameter cannot be set to Maintain input frame rate for sample-based signals.

View filter response

This button opens the Filter Visualization Tool (fvtool) from the Signal Processing Toolbox product and displays the filter response of the mfilt object specified in the Multirate filter variable parameter. For more information on FVTool, see the Signal Processing Toolbox documentation.

    Note   This button is only available when the Filter Design Toolbox product is installed. If you specify a filter in the Multirate filter variable parameter, you must apply the filter by clicking the Apply button before using the View filter response button.

The Fixed-point pane of the FIR Decimation block dialog appears as follows when Multirate filter object (MFILT) is specified in the Coefficient source group box.

The fixed-point settings of the filter object specified on the Main pane are displayed on the Fixed-point pane. You cannot change these settings directly on the block mask. To change the fixed-point settings you must edit the filter object directly.

For more information on multirate filter objects, see the mfilt function reference page in the Filter Design Toolbox documentation.

References

[1] Fliege, N. J. Multirate Digital Signal Processing: Multirate Systems, Filter Banks, Wavelets. West Sussex, England: John Wiley & Sons, 1994.

Supported Data Types

PortSupported Data Types

Input

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

Output

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

See Also

DownsampleSignal Processing Blockset
FIR InterpolationSignal Processing Blockset
FIR Rate ConversionSignal Processing Blockset
decimateSignal Processing Toolbox
fir1Signal Processing Toolbox
fir2Signal Processing Toolbox
firlsSignal Processing Toolbox

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS