メインコンテンツ

FIR Interpolator

Finite impulse response (FIR) interpolation filter

Since R2022a

  • FIR Interpolator block

Libraries:
DSP HDL Toolbox / Filtering

Description

The FIR Interpolator block implements a single-rate polyphase FIR interpolation filter that is optimized for HDL code generation. The block provides a hardware-friendly interface with input and output control signals. To provide a cycle-accurate simulation of the generated HDL code, the block models architectural latency including pipeline registers and resource sharing.

The block accepts scalar or vector input and outputs a scalar or vector depending on the interpolation factor and the number of cycles between input samples. The block implements a polyphase decomposition with InterpolationFactor subfilters. The filter can implement a serial architecture if there is regular spacing between input samples.

The block provides two filter structures. The direct form systolic architecture provides an implementation that makes efficient use of Intel® and Xilinx® DSP blocks. This architecture can be fully-parallel or serial. To use a serial architecture, the input samples must be spaced out with a regular number of invalid cycles between the valid samples. The direct form transposed architecture is a fully parallel implementation that is suitable for FPGA and ASIC applications. For a filter implementation that matches multipliers, pipeline registers, and pre-adders to the DSP configuration of your FPGA vendor, specify your target device when you generate HDL code.

For scalar input, all filter structures optimize hardware resources by sharing multipliers for symmetric or antisymmetric filters and by removing the multipliers for zero-valued coefficients such as in half-band filters and Hilbert transforms. When your input is a vector, the filter structure removes the multipliers for zero-valued coefficients but does not optimize for symmetric coefficients.

Note

You can also generate HDL code for this hardware-optimized algorithm, without creating a Simulink® model, by using the DSP HDL IP Designer app. The app provides the same interface and configuration options as the Simulink block.

Examples

Ports

Input

expand all

Input data, specified as a real or complex scalar or vector. The vector size must be less than or equal to 64.

The block has an output ready signal that indicates when the block is ready to process new input data. Your design can react to the ready signal to provide the next input sample, or you can space your input data with enough cycles in between that the block can process each sample. For more information, see Backpressure Signal.

When the input data type is an integer type or a fixed-point type, the block uses fixed-point arithmetic for internal calculations and provides parameters on the Data Types tab to customize the data types. When the input data type is a floating-point type, the block uses that input floating-point type for internal calculations and the output data type.

The software supports double and single data types for simulation, but not for HDL code generation.

Data Types: fixed point | single | double | int8 | int16 | int32 | uint8 | uint16 | uint32
Complex Number Support: Yes

Control signal that indicates if the input data is valid. When valid is 1 (true), the block captures the values from the input data port. When valid is 0 (false), the block ignores the values from the input data port.

Data Types: Boolean

Since R2025a

Filter coefficients, specified as a row vector of real or complex values. You can change the input coefficients at any time. The size of the coefficient vector must match the size of the sample coefficients specified in the Coefficients prototype parameter. The prototype specifies a sample coefficient vector that is representative of the zero-valued locations of the expected input coefficients. The block uses the prototype to optimize the filter by removing multipliers for zero-valued coefficients.

If the input data is a fixed-point type, the coeff values must also be of a fixed point type. If the input data is a floating-point data type, the coeff values must be of the same data type.

The software supports double and single data types for simulation, but not for HDL code generation.

Dependencies

To enable this port, set Coefficients source to Input port (Parallel interface).

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | fixed point

Since R2026a

Filter coefficients, specified as a real or complex scalar value to write to internal memory. To load a single coefficient value to internal memory, specify a coeff value with a corresponding address on the caddr port and an enable signal on the cwren port. You can change the input coefficients at any time.

Waveform that shows writing a set of coefficients to the filter by using the memory interface

While you write new coefficients into memory, the block ignores any input data, but still returns dataOut with validOut until it clears the filter pipeline. The block resumes accepting input the cycle after cdone is set to 1 (true).

Waveform that shows the filter stops processing input data while receiving new coefficients on the memory interface

The coefficient memory has the same number of addresses as the size of the Coefficients prototype parameter. The prototype specifies a sample coefficient vector that is representative of the zero-valued locations of the expected input coefficients. When you use scalar input data, the block uses the prototype to optimize the filter by sharing multipliers for symmetric or antisymmetric coefficients, and by removing multipliers for zero-valued coefficients. You must write the entire set of coefficients to memory, including symmetric or zero-value coefficients. For example, if you set the Coefficients prototype parameter to a symmetric 14-tap filter, you must write 14 values to the memory interface.

When you use frame-based input data, the block does not optimize the filter for coefficient symmetry. The block still uses the Coefficients prototype parameter to remove multipliers for zero-valued coefficients. The coefficient memory has the same number of locations as the size of the prototype.

If the input data is a fixed-point type, the coeff values must also be of a fixed point type. If the input data is a floating-point data type, the coeff values must be of the same data type.

The software supports double and single data types for simulation, but not for HDL code generation.

Dependencies

To enable this port, set Coefficients source to Input port (Memory interface).

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | fixed point

Since R2026a

Specify the filter coefficient address as a scalar integer value represented as an unsigned fixed-point type with zero fractional bits. The block derives the size of this integer value, and the size of the internal memory, from the number of unique coefficients in the Coefficients prototype parameter value.

Dependencies

To enable this port, set Coefficients source to Input port (Memory interface).

Data Types: fixdt(0,N,0)

Since R2026a

Set this input to 1 (true) to write the value on the coeff port into the caddr location in internal memory.

Dependencies

To enable this port, set Coefficients source to Input port (Memory interface).

Data Types: Boolean

Since R2026a

Set this input to 1 (true) to indicate that writing coefficients to memory is complete. You can set this input to 1 (true) along with the last coefficient write, or on a later cycle with no active write.

Dependencies

To enable this port, set Coefficients source to Input port (Memory interface).

Data Types: Boolean

Control signal that clears internal states. When reset is 1 (true), the block stops the current calculation and clears internal states. When the reset is 0 (false) and the input valid is 1 (true), the block captures data for processing.

For more reset considerations, see the Reset Signal section on the Hardware Control Signals page.

Dependencies

To enable this port, on the Control Ports tab, select Enable reset input port.

Data Types: Boolean

Output

expand all

Interpolated output data, returned as a real or complex scalar or vector. The vector size is InputSize * InterpolationFactor. When NumCycles is greater than InterpolationFactor, scalar output samples are spaced with floor(NumCycles/InterpolationFactor) invalid cycles, and the output valid signal indicates which samples are valid after interpolation.

When the input data type is a floating-point type, the output data inherits the data type of the input data. When the input data type is an integer type or a fixed-point type, the Output parameter on the Data Types tab controls the output data type.

Data Types: fixed point | single | double | int8 | int16 | int32 | uint8 | uint16 | uint32
Complex Number Support: Yes

Control signal that indicates if the data from the output data port is valid. When valid is 1 (true), the block returns valid data from the output data port. When valid is 0 (false), the values from the output data port are not valid.

Data Types: Boolean

Control signal that indicates the block can accept new input data. The block sets this output to 1 (true) when it can accept data, and to 0 (false) when it is processing and cannot accept more data. For more information, see Backpressure Signal.

Data Types: Boolean

Parameters

expand all

Note

These parameters apply when configuring a block in Simulink or an algorithm in the DSP HDL IP Designer app.

Main

Since R2025a

You can enter constant filter coefficients as a parameter or provide time-varying filter coefficients by using an input port.

When you select Input port (Parallel interface), the coeff port appears on the block.

When you select Input port (Memory interface), a memory-style interface appears on the block. This interface includes the coeff, caddr, cwren, and cdone ports. For parallel filter architectures, the memory interface does not support filters with more than InterpFactor*128 coefficients. For serial filters with a memory interface, InterpFactor*NumCoeffs/NumCycles must be less than or equal to 128.

Selecting Input port (Parallel interface) or Input port (Memory interface) enables the Coefficients prototype parameter. Specify a prototype to enable the block to optimize the filter implementation according to the values of the coefficients.

When you use programmable coefficients with frame-based input, the output after a change of coefficient values might not match the output in the scalar case exactly. This difference occurs because the subfilter calculations are performed at different times relative to the input coefficient values, compared with the scalar implementation.

FIR filter coefficients, specified as a real- or complex-valued vector. You can specify the vector as a workspace variable or as a call to a filter design function. When the input data type is a floating-point type, the block casts the coefficients to the same data type as the input. When the input data type is an integer type or a fixed-point type, set the data type for the coefficients on the Data Types tab.

Example: firpm(30,[0 0.1 0.2 0.5]*2,[1 1 0 0]) defines coefficients by using a linear-phase filter design function.

Dependencies

To enable this parameter, set Coefficients source to Property.

Complex Number Support: Yes

Since R2025a

Prototype filter coefficients, specified as a vector of real or complex values. The prototype specifies a sample coefficient vector that is representative of the zero-valued locations of the expected input coefficients. If all input coefficient vectors have the same zero-valued coefficient locations, set Coefficients prototype to one of those vectors. The block uses the prototype to optimize the filter by removing multipliers for zero-valued coefficients.

Coefficient SourceInput SizeIf No Prototype
Input port (Parallel interface)

When you use scalar input data, coefficient optimizations affect the expected size of the vector on the coeff port. Provide only the nonduplicate coefficients at the port. For example, if you set the Coefficients prototype parameter to a symmetric 14-tap filter, the block shares one multiplier between each pair of duplicate coefficients, so the block expects a vector of 7 values on the coeff port. You must still provide zeros in the input coeff vector for the nonduplicate zero-valued coefficients.

When you use frame-based input data, specify a coeff vector that is the same size as the prototype.

If your coefficients are unknown or not expected to share symmetry or zero-valued locations, you can set Coefficients prototype to [].

Input port (Memory interface)

Write the same number of coefficient values as the size of the prototype.

For parallel filter architectures, the memory interface does not support filters with more than InterpFactor*128 coefficients. For serial filters with a memory interface, InterpFactor*NumCoeffs/NumCycles must be less than or equal to 128.

Coefficients prototype cannot be empty. The block uses the prototype to determine the size of the coefficient memory. If your coefficients are unknown or not expected to share symmetry or zero-valued locations, set Coefficients prototype to a vector with the same length as your expected coefficients, which does not contain symmetry or zero values, for example [1:1:NumCoeffs].

Dependencies

To enable this parameter, set Coefficients source to Input port (Parallel interface) or Input port (Memory interface).

Specify the HDL filter architecture as one of these structures:

  • Direct form systolic — This architecture provides a parallel or partly serial filter implementation that makes efficient use of Intel and Xilinx DSP HDL blocks. For a partly serial implementation, specify a value greater than 1 for the Minimum number of cycles between valid input samples parameter. You cannot use frame-based input with the partly serial architecture.

  • Direct form transposed — This architecture is a fully parallel implementation that is suitable for FPGA and ASIC applications.

The block implements a polyphase decomposition filter by using Discrete FIR Filter blocks. Each filter phase shares resources internally where coefficients and serial options allow. For architecture details, see FIR Filter Architectures for FPGAs and ASICs. When you use a partly-serial systolic architecture and Minimum number of cycles between valid input samples is larger than the filter length divided by the interpolation factor, the block interleaves each phase of coefficients over a single FIR filter to share resources between phases.

Specify an integer interpolation factor greater than two. The output vector size is InputSize * InterpolationFactor. The output vector size must be less than 64 samples.

Serialization requirement for input timing, specified as a positive integer. This parameter represents N, the minimum number of cycles between valid input samples. When you set Minimum number of cycles between valid input samples greater than the filter length, L, and the input and coefficients are both real, the filter uses a single multiplier.

Because the block applies coefficient optimizations before serialization, the sharing factor of the final filter can be lower than the number of cycles that you specified.

Dependencies

To enable this parameter, set Filter structure to Direct form systolic.

You cannot use frame-based input with Minimum number of cycles between valid input samples greater than 1.

Since R2024b

Enable sharing multipliers across symmetric coefficients in the polyphase filter architecture. This optimization reduces latency and halves the number of multipliers. This option is supported only with scalar input.

Polyphase decomposition of symmetric filter coefficients does not result in symmetry in each polyphase branch. For example, if the filter coefficients are [1 2 3 4 4 3 2 1], after decomposition the two polyphase branches are [1 3 4 2] and [2 4 3 1]. Symmetric pairs optimization refactors the coefficients to restore symmetry on the polyphase branches. The implementation includes a post-adder to combine output samples for the refactored polyphase branches. The filter output is the same as the output of the non-optimized implementation.

Dependencies

To enable this parameter, set Coefficients source to Property.

Data Types

Rounding mode for type-casting the output to the data type specified by the Output parameter. When the input data type is floating point, the block ignores this parameter. For more details, see Rounding Modes.

Overflow handling for type-casting the output to the data type specified by the Output parameter. When the input data type is floating point, the block ignores this parameter. For more details, see Overflow Handling.

When the input is a fixed-point or integer type, the block casts the filter coefficients using the rule or data type in this parameter. The quantization rounds to the nearest representable value and saturates on overflow. When the input data type is a floating-point type, the block ignores this parameter and all internal arithmetic uses the same data type as the input.

The recommended data type for this parameter is Inherit: Same word length as input.

If you provide coefficients that have an unsigned data type, or if you specify an unsigned data type for this parameter, the filter uses the unsigned values and converts them to a signed data type. The signed data type is required to map the design onto DSP slices on an FPGA.

The block returns a warning or error if either of these conditions occur.

  • The coefficients data type does not have enough fractional length to represent the coefficients accurately.

  • The coefficients data type is unsigned, and the coefficients include negative values.

When the input is a fixed-point or integer type, the block casts the output of the filter using the rule or data type in this parameter. The quantization uses the settings of the Rounding mode and Overflow mode parameters. When the input data type is floating point, the block ignores this parameter and returns output in the same data type as the input.

The block increases the word length for full precision inside each filter tap and casts the final output to the specified type. The maximum final internal data type (WF) depends on the input data type (WI), the coefficient data type (WC), and the number of coefficients (L) and is given by

WF = WI + WC + ceil(log2(L)).

Because the coefficient values limit the potential growth, usually the actual full-precision internal word length is smaller than WF.

Control Ports

Select this check box to enable the reset input port. The reset signal implements a local synchronous reset of the data path registers.

For more reset considerations, see the Reset Signal section on the Hardware Control Signals page.

Select this check box to connect the generated HDL global reset signal to the data path registers. This parameter does not change the appearance of the block or modify simulation behavior in Simulink. When you clear this check box, the generated HDL global reset clears only the control path registers. The generated HDL global reset can be synchronous or asynchronous depending on the HDL Code Generation > Global Settings > Reset type parameter in the model Configuration Parameters.

For more reset considerations, see the Reset Signal section on the Hardware Control Signals page.

Algorithms

expand all

The block implements a polyphase filter bank where the filter coefficients are decomposed into InterpolationFactor subfilters. If the filter length is not divisible by the Interpolation factor parameter value, then the block zero-pads the coefficients. When your input is regularly spaced, with two or more cycles between valid samples, as indicated by the Minimum number of cycles between valid input samples parameter, the filter can share multiplier resources in time.

This flow chart shows which filter architectures result from your parameter settings. It also shows the number of multipliers used by the filter implementation. The filter architecture depends on the input frame size, V, the interpolation factor, R, the number of cycles between valid input samples, N, and the number of filter coefficients, L. The architectures are in order from lowest resource use on the left, to higher resources on the right. The higher resource architectures are trading off resource use for higher throughput. Each architecture is described below the flow chart.

If the filter is symmetric and you select Optimize symmetric coefficients, the architecture shares multipliers for matching coefficients. In that case the number of filter coefficients, L, in the flow chart represents NumCoeffs/2. This option is supported only with scalar input. (since R2024b)

The number of multipliers shown in the flow chart is for filters with real input and real coefficients. For complex input, the filter uses three times as many multipliers.

Flow chart of filter architectures and optimizations for various settings of decimation factor, input size, input spacing, and filter size

  • Architectures 1 and 2 — Serial polyphase interleaved filter bank.

    When NumCycles is greater than FilterLength/InterpolationFactor, the block interleaves each phase of coefficients over a single FIR filter to share resources between phases. The single FIR filter has a serial architecture and uses the NumCycles value to share multipliers over time. A partly serial filter uses FilterLength/NumCycles multipliers. When NumCycles is greater than the filter length, the filter becomes fully serial and uses one multiplier. The diagram shows a filter with an interpolation factor of 4 and at least FilterLength/4 cycles between input samples.

    Serial polyphase interleaved filter bank architecture diagram

    When you select Optimize symmetric coefficients, the decomposed sets of coefficients may not have the same symmetry and zero locations, which means the architecture cannot share the subfilter. In this case, the filter uses architecture 3/4, where each set of coefficients has its own subfilter.

  • Architectures 3 and 4 — Partly serial polyphase filter bank.

    Each subfilter of the polyphase decomposition uses the NumCycles value to implement a serial filter. When NumCycles is FilterLength/InterpolationFactor, each phase uses a single multiplier, for a total of InterpolationFactor multipliers. The output is a vector if NumCycles < InterpolationFactor and a scalar if NumCyclesInterpolationFactor.

    The diagram shows a polyphase filter bank with scalar input and InterpolationFactor is set to 4. NumCycles is 2. Each subfilter is partly serial and has FilterLength/(4*2) multipliers, for a total of FilterLength/2 multipliers. The output is a vector because the interpolation factor is larger than the number of cycles between input samples.

    Partly serial polyphase filter bank architecture diagram

  • Architectures 5 and 6 — Fully parallel polyphase filter bank.

    The diagram shows the polyphase filter bank with scalar input and InterpolationFactor is set to 4. The NumCycles value is 1, so the output must be a vector and each subfilter contributes one sample to the output vector. Each subfilter is a fully parallel FIR filter, with L/4 multipliers, for a total of L multipliers.

    Fully parallel polyphase filter bank architecture diagram for scalar input

    When the input is a vector, each subfilter is a frame-based filter that contains one parallel filter for each input sample. This diagram shows the polyphase filter bank for an input vector of two values and InterpolationFactor is set to 4. Each of the four subfilters generates two samples of the output vector and contains L/4*2 multipliers, for a total of L*2 multipliers.

    Fully parallel polyphase filter bank architecture diagram for vector input

Each subfilter is implemented with a Discrete FIR Filter block. For architecture details, see FIR Filter Architectures for FPGAs and ASICs.

Extended Capabilities

expand all

Version History

Introduced in R2022a

expand all