Skip to content

olo_fix_fir_dec_par_chtdm

Back to Entity List

Status Information

VHDL Source: olo_fix_fir_dec_par_chtdm.vhd
Bit-true Model: olo_fix_fir_dec.py

Description

This entity implements a FIR filter for one or more TDM (time-division-multiplexed) channels. All channels share the same coefficients. The filter taps are computed fully parallel: Each tap has its own multiplier and all multipliers are chained in a MACC (multiply-accumulate) chain that maps onto the cascade paths of DSP blocks.

As a result, the filter accepts one input sample on every clock cycle, independently of the number of taps and channels. It never generates backpressure and no rate limiting is required.

A single channel (Channels_g = 1) is supported as well.

The filter can decimate (Ratio_g > 1) by dropping output samples. This does not save any multipliers, because all taps are computed for all samples. olo_fix_fir_dec_semi_chtdm saves multipliers but depending on configuration may consume more logic.

For details about the fixed-point number format used in Open Logic, refer to the fixed point principles.

Latency

The latency from In_Valid to Out_Valid is Taps_g + MultRegs_g + 4 clock cycles.

For IsSymmetric_g = true, the latency is ceil(Taps_g/2) + MultRegs_g + 4 clock cycles.

For Ratio_g > 1, this applies to the input samples for which an output sample is produced. The first frame after reset and every Ratio_g-th frame after it produce an output sample.

Generics

Name Type Default Description
InFmt_g string - Input format
String representation of an en_cl_fix FixFormat_t
OutFmt_g string - Output format
String representation of an en_cl_fix FixFormat_t
CoefFmt_g string - Coefficient format
String representation of an en_cl_fix FixFormat_t
Channels_g positive 1 Number of TDM channels (>= 1; single- or multi-channel)
Ratio_g positive 1 Decimation ratio (one output per Ratio_g input sample sets)
Taps_g positive - Number of filter taps (must be >= 2)
IsSymmetric_g boolean false false - No assumption about the coefficients, one multiplier per tap
true - Coefficients are symmetric, one multiplier per pair of taps. See Symmetric Coefficients.
GuardBits_g natural 1 Number of integer guard bits in the accumulator above OutFmt_g
Round_g string "Trunc_s" Rounding mode
String representation of an en_cl_fix FixRound_t
Saturate_g string "Warn_s" Saturation mode
String representation of an en_cl_fix FixSaturate_t
MultRegs_g positive 1 Number of pipeline registers in each multiplier
CoefInit_g string "0.0" Comma-separated coefficient values (real numbers, quantized to CoefFmt_g)
Taps without a value are set to zero
Example: "0.3, 0.55, 0.2"
CoefWritable_g boolean false false - Coefficients are fixed to CoefInit_g.
true - Coefficients can be written at runtime. See Coefficients.
DataRamBehavior_g string "RBW" Data RAM behavior: "RBW" = read-before-write, "WBR" = write-before-read
Only relevant for delay lines implemented in block RAM (large Channels_g)
See olo_base_delay
DataMemStyle_g string "auto" Synthesis attribute for the delay line memory style
See olo_base_delay

Interfaces

Control

Name In/Out Length Default Description
Clk in 1 - Clock
Rst in 1 - Reset (synchronous, active high)

Coefficient Configuration

Name In/Out Length Default Description
Coef_Addr in log2ceil(Taps_g) 0 Coefficient address
Address 0 is the coefficient applied to the newest input sample (first value in CoefInit_g), address Taps_g-1 the one applied to the oldest sample
Writes above Taps_g-1 are ignored
For IsSymmetric_g = true, writes above ceil(Taps_g/2)-1 are ignored
Coef_WrEna in 1 '0' Coefficient write enable
Coef_WrData in width(CoefFmt_g) 0 Coefficient write data

All Coef_* ports are only used for CoefWritable_g = true and can be left unconnected otherwise.

There is intentionally no coefficient readback. It would prevent mapping the coefficients into the input registers of DSP blocks, which cannot be read back.

Input Data

Name In/Out Length Default Description
In_Valid in 1 - Input valid
In_Data in width(InFmt_g) - Input data (TDM: channels interleaved, ch0 first)
In_Last in 1 '0' TDM frame boundary (optional)
see TDM Conventions

Output Data

Name In/Out Length Default Description
Out_Valid out 1 N/A Output valid
Out_Data out width(OutFmt_g) N/A Output data (TDM: channels interleaved, ch0 first)
Out_Last out 1 N/A TDM frame boundary, asserted on the last channel
see TDM Conventions

Details

Example Instantiation

The example below shows a simple instantiation of a two channel filter with fixed coefficients and no decimation. The coefficient configuration ports and In_Last are omitted.

i_fir : entity olo.olo_fix_fir_dec_par_chtdm
    generic map (
        InFmt_g    => "(1,0,15)",
        OutFmt_g   => "(1,0,15)",
        CoefFmt_g  => "(1,0,17)",
        Channels_g => 2,
        Taps_g     => 4,
        CoefInit_g => "0.1, 0.4, 0.4, 0.1"
    )
    port map (
        Clk       => Clk,
        Rst       => Rst,
        In_Valid  => In_Valid,
        In_Data   => In_Data,
        Out_Valid => Out_Valid,
        Out_Data  => Out_Data
    );

Architecture

The datapath consists of Taps_g olo_fix_madd stages using the A cascade (ACascade_g = true).

architecture

For Channels_g > 1, an olo_base_delay adds the remaining Channels_g - 1 samples, so that each stage sees the sample of the same channel one sampling period earlier. For Channels_g = 1, this delay is not required and omitted.

For Channels_g = 1, the delay between stages can use the dedicated data cascade of the DSP blocks. For Channels_g > 1, the data must leave the DSP blocks to pass through the delay line, so noticeably more logic registers are required per tap.

The sum of the last stage is decimated, then rounded and saturated to OutFmt_g using olo_fix_resize.

Symmetric Coefficients

Linear-phase FIR filters have symmetric coefficients: Coefficient i equals coefficient Taps_g-1-i. For IsSymmetric_g = true, this property is exploited to compute both taps with one multiplier. As a result, a filter with Taps_g taps only requires ceil(Taps_g/2) multipliers. Even and odd values of Taps_g are supported.

architecture symmetric

The delay line is folded: All samples pass through one chain of Taps_g-1 olo_base_delay instances of Channels_g samples each. Each stage adds the two samples sharing a coefficient in the pre-adder of its olo_fix_madd. Because stage i is i clock cycles late due to the registers in the adder chain, its two samples pass through a delay of i clock cycles first.

The figure shows an odd number of taps, where the center tap has no partner. It is computed by a stage without pre-adder but with the same latency. For an even number of taps, there are two center taps and they form a normal pair in the last stage. The two ends of the delay line are then connected through one more delay of Channels_g samples.

The output is bit-true to a filter with IsSymmetric_g = false and the same coefficients. The pre-adder does not lose any bits, it has one integer bit more than InFmt_g. This must be taken into account for mapping to DSP blocks: The pre-adder output must fit the multiplier input (e.g. 25 bits, hence InFmt_g up to 24 bits).

The savings in multipliers come at the cost of logic for the delays that align the samples. The two delays of stage i take 2 * i registers per bit. For long filters, this is a noticeable amount of logic, which however maps to SRLs on devices that support them.

The coefficients are handled as follows:

  • For CoefWritable_g = false, CoefInit_g must contain all Taps_g coefficients. After quantization to CoefFmt_g they must be symmetric, otherwise an assertion fires in simulation.
  • For CoefWritable_g = true, only the lower half of the coefficients including the center tap(s) is stored (addresses 0 to ceil(Taps_g/2)-1). Writes to the upper half and values in the upper half of CoefInit_g are ignored, no assertion fires for them.

Coefficients

For CoefWritable_g = false, the coefficients are constants given by CoefInit_g. Synthesis tools may optimize the multipliers according to the coefficient values.

Taps with a coefficient that is zero after quantization to CoefFmt_g do not contain a multiplier for CoefWritable_g = false. They only contain the registers required to keep the timing, so latency and behavior do not change. This saves DSP blocks for filters with many zero coefficients (e.g. half-band filters).

For CoefWritable_g = true, each coefficient is stored in the input B registers of its olo_fix_madd stage:

Rst loads the values from CoefInit_g as long as no coefficient was written. Hence Rst must be asserted before the filter is used and before the first coefficient is written.

For IsSymmetric_g = true, there is one coefficient per stage. See Symmetric Coefficients.

Coefficients must only be written while no calculation is ongoing, which means that no samples are applied to the input and no output samples are outstanding. The entity does not synchronize coefficient updates to the data, so a write during operation leads to output samples computed from a mix of old and new coefficients.

Reset

Rst clears the delay lines, which are built from registers and olo_base_delay. Unlike olo_fix_fir_dec_semi_chtdm, no flushing is required after a reset. The output after a reset is bit-true to the Python model, which initializes its delay line to zero.

Accumulator Format

The adder chain operates in AccuFmt, which keeps all fractional bits of the multiplier results:

  • AccuFmt = (1, Out.I + GuardBits_g, MultFmt.F)
  • MultFmt = cl_fix_mult_fmt(InFmt_g, CoefFmt_g)

GuardBits_g integer guard bits above OutFmt_g allow the result to exceed the output range, so that it can be saturated correctly. With the default of one guard bit, results of up to twice the OutFmt_g maximum are supported. The user is responsible for choosing GuardBits_g, the coefficients and the formats accordingly. Otherwise the result wraps.

Intermediate sums in the adder chain may wrap, as this does not affect the final result. Only the final result must fit into AccuFmt.

The adder chain only maps to the cascade paths of DSP blocks if AccuFmt is not wider than the DSP block adder (e.g. 48 bits for many AMD devices). Otherwise it is implemented in logic, which is much more expensive.

Last Handling

On the input, In_Last is not required for operation. It is only used in simulation to detect incorrect TDM framing: an error is reported if In_Last is asserted on a sample that does not belong to the last channel (Channels_g-1). It has no functional effect on the computation.

On the output, Out_Last is generated by the entity itself and is always asserted together with Out_Valid on the last channel (Channels_g-1) of every output sample set.