Main Content

FIR Decimation HDL Optimized

Finite impulse response (FIR) decimation filter—optimized for HDL code generation

  • Library:
  • DSP System Toolbox HDL Support / Filtering

  • FIR Decimation Filter HDL Optimized block

Description

The FIR Decimation HDL Optimized block implements a polyphase FIR decimation 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. When you use vector input, the decimation factor must be an integer multiple of the vector size. The block uses a single-rate implementation. The output is scalar and a valid signal indicates which samples are valid after decimation. The waveform shows an input vector of four samples and a decimation factor of eight. The output sample is valid every second cycle.

The block provides two filter structures. The direct form systolic architecture provides a fully parallel implementation that makes efficient use of Intel® and Xilinx® DSP blocks. 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.

The block implements one filter for each sample in the input vector. The block then shares this filter between the polyphase subfilters by interleaving the subfilter coefficients in time.

For a FIR decimation filter with an input size greater the decimation factor or a serial HDL implementation (scalar input only), use the FIR Decimation block instead of this block.

Ports

Input

expand all

Input data must be a real- or complex-valued scalar or vector. When you use vector input, the decimation factor must be an integer multiple of the vector size. The vector size must be less than or equal to 64.

When the input data type is an integer type or a fixed-point type, the block uses fixed-point arithmetic for internal calculations.

double and single data types are supported for simulation, but not for HDL code generation.

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

When valid is 1, the block captures the data from the data input port.

Data Types: Boolean

When reset is 1, the block stops the current calculation and clears the internal state of the filter. The reset signal is synchronous and clears the data path and control path states. For more reset considerations, see Tips.

Dependencies

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

Data Types: Boolean

Output

expand all

Filtered output data, returned as a real- or complex-valued scalar. 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 specifies the output data type.

The output valid signal indicates which samples are valid after decimation.

Data Types: fixed point | single | double
Complex Number Support: Yes

The block sets valid to 1 with each valid data returned on the data output port.

Data Types: Boolean

Parameters

expand all

Main

Discrete 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, you can 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])

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

Specify the HDL filter architecture as one of these structures:

  • Direct form systolic — This architecture provides a fully parallel filter implementation that makes efficient use of Intel and Xilinx DSP blocks.

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

Both implementations share resources by interleaving the subfilter coefficients over one filter implementation for each sample in the input vector.

The block implements a polyphase decomposition filter using Discrete FIR Filter HDL Optimized blocks. For architecture details, see the Fully Parallel Systolic Architecture and the Fully Parallel Transposed Architecture sections on the Discrete FIR Filter HDL Optimized block reference page.

Specify an integer decimation factor greater than two. When you use vector input, the decimation factor must be an integer multiple of the vector size.

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.

The block casts the filter coefficients to this data type. The quantization rounds to the nearest representable value and saturates on overflow. When the input data type is floating point, the block ignores this parameter.

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

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.

You can disable or control the severity of these data type messages from the model Configuration Parameters, by modifying the Diagnostics > Type Conversion > Detect precision loss parameter.

The block casts the output of the filter to this data type. 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.

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 parameter to enable the reset input port. The reset signal implements a local synchronous reset of the data path registers.

For more reset considerations, see Tips.

Select this parameter 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 parameter, 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 Tips.

Tips

Reset Behavior

  • By default, the FIR Decimation HDL Optimized block connects the generated HDL global reset to only the control path registers. The two reset parameters, Enable reset input port and Use HDL global reset, connect a reset signal to the data path registers. Because of the additional routing and loading on the reset signal, resetting data path registers can reduce synthesis performance .

  • The Enable reset input port parameter enables the reset port on the block. The reset signal implements a local synchronous reset of the data path registers. For optimal use of FPGA resources, this option does not connect the reset signal to registers targeted to the DSP blocks of the FPGA.

  • The Use HDL global reset parameter connects 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. 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. Depending on your device, using the global reset might move registers out of the DSP blocks and increase resource use.

  • When you select the Enable reset input port and Use HDL global reset parameters together, the global and local reset signals clear the control and data path registers.

Reset Considerations for Generated Test Benches

  • FPGA-in-the-loop initialization provides a global reset but does not automatically provide a local reset. With the default reset parameters, the data path registers that are not reset can result in FPGA-in-the-loop (FIL) mismatches if you run the FIL model more than once without resetting the board. Select Use HDL global reset to reset the data path registers automatically, or select Enable reset input port and assert the local reset in your model so the reset signal becomes part of the Simulink FIL test bench.

  • The generated HDL test bench provides a global reset but does not automatically provide a local reset. With the default reset parameters and the default register reset Configuration Parameters, the generated HDL code includes an initial simulation value for the data path registers. However, if you are concerned about X-propagation in your design, you can set the HDL Code Generation > Global Settings > Coding style > No-reset register initialization parameter in Configuration Parameters to Do not initialize. In this case, with the default block reset parameters, the data path registers that are not reset can cause X-propagation on the data path at the start of HDL simulation. Select Use HDL global reset to reset the data path registers automatically, or select Enable reset input port and assert the local reset in your model so the reset signal becomes part of the generated HDL test bench.

Algorithms

expand all

The block implements a polyphase filter bank where the filter coefficients are decomposed into Decimation factor subfilters. If the filter length is not divisible by the Decimation factor parameter value, then the block zero-pads the coefficients.

The diagram shows the polyphase filter bank with scalar input and the Decimation factor parameter set to four. The four sets of decomposed coefficients are interleaved in time over a single subfilter.

The next diagram shows the polyphase filter bank for an input vector of four values and the Decimation factor parameter set to eight. Each of the four subfilters has two sets of coefficients interleaved in time.

Each subfilter is implemented with a Discrete FIR Filter HDL Optimized block. The adder at the output is pipelined to accommodate higher synthesis frequencies. For architecture details, see the Fully Parallel Systolic Architecture, Fully Parallel Transposed Architecture, and Complex Multipliers sections on the Discrete FIR Filter HDL Optimized block reference page.

Note

The output of the FIR Decimation HDL Optimized block does not match the output from the FIR Decimation block sample-for-sample. This difference is mainly because of the phase that the samples are applied across the subfilters. To match the FIR Decimation block, apply Decimation factor – 1 zeroes to the FIR Decimation HDL Optimized block at the start of the data stream.

The FIR Decimation block also uses slightly different data types for full-precision calculations. The different data types can also introduce differences in output values if the values overflow the internal data types.

Extended Capabilities

Introduced in R2020b