Contents

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 K is the integer value you specify for the Decimation factor parameter. To do so, the block implements a polyphase filter structure and performs the following operations:

  1. Filters the data in each channel of the input using a direct-form FIR filter.

  2. Downsamples each channel of filtered data by discarding K–1 consecutive samples following each sample that is retained.

The block uses a polyphase filter implementation because it is more efficient than straightforward filter-then-decimate algorithms. See Fliege [1] for more information.

You can use the FIR Decimation block inside triggered subsystems when you set the Rate options parameter to Enforce single-rate processing.

This block supports variable-size input. This means that while the block is simulating, the frame size (number of rows) can change. The output dimensions always equal those of the input signal.

Specifying the Filter Coefficients

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

  • Dialog parameters, you enter information about the filter such as structure and coefficients in the block dialog box.

  • Multirate filter object (MFILT), you specify the filter using an mfilt object.

When you select Dialog parameters, you use the FIR filter coefficients parameter to specify the numerator coefficients of the FIR filter transfer function H(z).

H(z)=B(z)=b1+b2z1++bmz(m1)

You can generate the FIR filter coefficient vector, [b(1) b(2) ... b(m)], using one of the Signal Processing Toolbox™ filter design functions (such as intfilt).

The filter you specify should be a lowpass filter with a normalized cutoff frequency no greater than 1/K. The block internally initializes all filter states to zero.

    Note:   You can use the block method to create your own filter blocks directly from your mfilt objects.

Frame-Based Processing

When you set the Input processing parameter to Columns as channels (frame based), the block resamples each column of the input over time. In this mode, the block can perform either single-rate or multirate processing. You can use the Rate options parameter to specify how the block resamples the input:

  • When you set the Rate options parameter to Enforce single-rate processing, the input and output of the block have the same sample rate. To decimate the output while maintaining the input sample rate, the block resamples the data in each column of the input such that the frame size of the output (Mo) is 1/K times that of the input (Mo = Mi/K),

    In this mode, the input frame size, Mi, must be a multiple of the Decimation factor, K.

    For an example of single-rate FIR Decimation, see Example 1 — Single-Rate Processing.

  • When you set the Rate options parameter to Allow multirate processing, the input and output of the FIR Decimation block are the same size, but the sample rate of the output is K times slower than that of the input. In this mode, the block treats an Mi-by-N matrix input as N independent channels. The block decimates each column of the input over time by keeping the frame size constant (Mi=Mo), and making the output frame period (Tfo) K times longer than the input frame period (Tfo = K*Tfi).

    See Example 2— Multirate Frame-Based Processing for an example that uses the FIR Decimation block in this mode.

Sample-Based Processing

When you set the Input processing parameter to Elements as channels (sample based), the block treats an M-by-N matrix input as M*N independent channels, and decimates each channel over time. The output sample period (Tso) is K times longer than the input sample period (Tso = K*Tsi), and the input and output sizes are identical.

Latency

When you use the FIR Decimation block in sample-based processing mode, the block always has zero-tasking latency. Zero-tasking latency means that the block propagates the first filtered input sample (received at time t= 0) as the first output sample. That first output sample is then followed by filtered input samples K+1, 2K+1, and so on.

When you use the FIR Decimation block in frame-based processing mode with a frame size greater than one, the block may exhibit one-frame latency. Cases of one-frame latency can occur when the input frame size is greater than one, and you set the Input processing and Rate options parameters of the FIR Decimation block as follows:

  • Input processing = Columns as channels (frame based)

  • Rate options = Allow multirate processing

In cases of one-frame latency, you can define the value of the first Mi output rows by setting the Output buffer initial conditions parameter. The default value of the Output buffer initial conditions parameter is 0. However, you can enter a matrix containing one value for each channel of the input, or a scalar value to be applied to all channels. The first filtered input sample (first filtered row of the input matrix) appears in the output as sample Mi+ 1. That sample is then 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 box as discussed in the Dialog Box section. This diagram shows that data is stored in the input buffer with the same data type and scaling as the input. The block stores filtered data and any initial conditions in the output buffer using the output data type and scaling that you set in the block dialog box.

When at least one of the inputs to the multiplier is real, the output of the multiplier is in the product output data type. When both inputs to the multiplier are complex, the result of the multiplication is in the accumulator data type. For details on the complex multiplication performed by this block, see Multiplication Data Types in the DSP System Toolbox User's Guide.

    Note:   When the block input is fixed point, all internal data types are signed fixed-point values.

Examples

Example 1 — Single-Rate Processing

In the ex_firdecimation_ref2ex_firdecimation_ref2 model, the FIR Decimation block decimates a single-channel input with a frame size of 64. Because the block is doing single-rate processing and the Decimation factor parameter is set to 4, the output of the FIR Decimation block has a frame size of 16. As shown in the following figure, the input and output of the FIR Decimation block have the same sample rate.

Example 2— Multirate Frame-Based Processing

In the ex_firdecimation_ref1ex_firdecimation_ref1 model, the FIR Decimation block decimates a single-channel input with a frame period of one second. Because the block is doing multirate frame-based processing and the Decimation factor parameter is set to 4, the frame period of the output is four seconds. As shown in the following figure, the input and output of the FIR Decimation block have the same frame size, but the sample rate of the output is four times that of the input.

Example 3

The ex_polyphasedecex_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 matches the output of the Polyphase Decimation Filter block.

Example 4

The ex_mrf_nlpex_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

  • Dialog parameters, you enter information about the filter such as structure and coefficients in the block mask.

  • Multirate filter object (MFILT), you specify the filter using an mfilt object.

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 you select Dialog parameters 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.

Input processing

Specify how the block should process the input. You can set this parameter to one of the following options:

  • Columns as channels (frame based) — When you select this option, the block treats each column of the input as a separate channel.

  • Elements as channels (sample based) — When you select this option, the block treats each element of the input as a separate channel.

    Note:   The Inherited (this choice will be removed - see release notes) option will be removed in a future release. See Frame-Based Processing in the DSP System Toolbox Release Notes for more information.

Rate options

Specify the method by which the block should decimate the input. You can select one of the following options:

  • Enforce single-rate processing — When you select this option, the block maintains the input sample rate and decimates the signal by decreasing the output frame size by a factor of K. To select this option, you must set the Input processing parameter to Columns as channels (frame based).

  • Allow multirate processing — When you select this option, the block decimates the signal such that the output sample rate is K times slower than the input sample rate.

Output buffer initial conditions

In the case of one-frame latency, this parameter specifies the output of the block 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 value to be applied to all signal channels. This parameter appears only when you configure the block to perform multirate processing.

See Latency for more information about latency in the FIR Decimation block.

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.

    Note:   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 Data Types pane of the FIR Decimation block dialog appears as follows when you select Dialog parameters 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.

    Note:   The Rounding mode and Overflow mode settings have no effect on numerical results when all the following conditions exist:

    • Product output data type is Inherit: Inherit via internal rule

    • Accumulator data type is Inherit: Inherit via internal rule

    • Output data type is Inherit: Same as accumulator

    With these data type settings, the block is effectively operating in full precision mode.

Overflow mode

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

Coefficients data type

Specify the coefficients data type. See Fixed-Point Data Types and Multiplication Data Types for illustrations depicting the use of the coefficients data type in this block. You can set it to:

  • A rule that inherits a data type, for example, Inherit: Same word length as input

  • An expression that evaluates to a valid data type, for example, fixdt(1,16,0)

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Coefficients data type parameter.

See Specify Data Types Using Data Type Assistant for more information.

Product output data type

Specify the product output data type. See Fixed-Point Data Types and Multiplication Data Types for illustrations depicting the use of the product output data type in this block. You can set it to:

  • A rule that inherits a data type, for example, Inherit: Inherit via internal rule

  • An expression that evaluates to a valid data type, for example, fixdt(1,16,0)

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Product output data type parameter.

See Specify Data Types Using Data Type Assistant for more information.

Accumulator data type

Specify the accumulator data type. See Fixed-Point Data Types for illustrations depicting the use of the accumulator data type in this block. You can set this parameter to:

  • A rule that inherits a data type, for example, Inherit: Inherit via internal rule

  • An expression that evaluates to a valid data type, for example, fixdt(1,16,0)

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Accumulator data type parameter.

See Specify Data Types Using Data Type Assistant for more information.

Output data type

Specify the output data type. See Fixed-Point Data Types for illustrations depicting the use of the output data type in this block. You can set it to:

  • A rule that inherits a data type, for example, Inherit: Same as accumulator

  • An expression that evaluates to a valid data type, for example, fixdt(1,16,0)

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Output data type parameter.

See Specify Block Output Data Types for more information.

Minimum

Specify the minimum value that the block should output. The default value is [] (unspecified). Simulink software uses this value to perform:

  • Simulation range checking (see Signal Ranges)

  • Automatic scaling of fixed-point data types

Maximum

Specify the maximum value that the block should output. The default value is [] (unspecified). Simulink software uses this value to perform:

  • Simulation range checking (see Signal Ranges)

  • Automatic scaling of fixed-point data types

Lock data type settings against changes by the fixed-point tools

Select this parameter to prevent the fixed-point tools from overriding the data types you specify on the block mask.

Specify Multirate Filter Object

The Main pane of the FIR Decimation block dialog appears as follows when you select Multirate filter object (MFILT) 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.

Input processing

Specify how the block should process the input. You can set this parameter to one of the following options:

  • Columns as channels (frame based) — When you select this option, the block treats each column of the input as a separate channel.

  • Elements as channels (sample based) — When you select this option, the block treats each element of the input as a separate channel.

    Note:   The Inherited (this choice will be removed - see release notes) option will be removed in a future release. See Frame-Based Processing in the DSP System Toolbox Release Notes for more information.

Rate options

Specify the method by which the block should decimate the input. You can select one of the following options:

  • Enforce single-rate processing — When you select this option, the block maintains the input sample rate, and decimates the signal by decreasing the input frame size by a factor of K. To select this option, you must set the Input processing parameter to Columns as channels (frame based).

  • Allow multirate processing — When you select this option, the block decimates the sample rate such that the output sample rate is K times slower than the input sample rate.

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:   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 Data Types pane of the FIR Decimation block dialog appears as follows when you select Multirate filter object (MFILT) in the Coefficient source group box.

The fixed-point settings of the filter object specified on the Main pane are displayed on the Data Types 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.

HDL Code Generation

This block supports HDL code generation using HDL Coder™. HDL Coder provides additional configuration options that affect HDL implementation and synthesized logic. For more information on implementations, properties, and restrictions for HDL code generation, see FIR Decimation.

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

DownsampleDSP System Toolbox
FIR InterpolationDSP System Toolbox
FIR Rate ConversionDSP System Toolbox
decimateSignal Processing Toolbox
fir1Signal Processing Toolbox
fir2Signal Processing Toolbox
firlsSignal Processing Toolbox

Was this topic helpful?