Skip to content

olo_fix_mov_avg

Back to Entity List

Status Information

VHDL Source: olo_fix_mov_avg
Bit-true Model: olo_fix_mov_avg

Description

This entity implements a moving average filter. For each input sample, it computes the average over the last Taps_g samples.

Latency of this entity is 3 clock cycles for the core computation, plus optional rounding and saturation registers from the output stage. The default generics lead to a latency of 5 clock cycles.

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

Gain Handling

The moving sum has an inherent gain of Taps_g relative to the input signal. The gain is corrected according to GainCorrType_g:

  • "NONE": No gain correction is applied. The output represents the sum of the last Taps_g samples.
  • "SHIFT": A bit-shift of ceil(log2(Taps_g)) is applied to correct the gain into the range (0.5, 1.0]. This is exact for power-of-two Taps_g values and introduces a small systematic error otherwise.
  • "EXACT": For power-of-two Taps_g, a shift is sufficient for exact gain correction and no multiplier is used. For non-power-of-two Taps_g, the shift is followed by a multiplier to achieve an exact gain of 1.0.

Generics

Name Type Default Description
InFmt_g string - Input data format
String representation of an en_cl_fix Format_t (e.g. "(1,1,15)")
OutFmt_g string - Output data format
String representation of an en_cl_fix Format_t (e.g. "(1,1,15)")
Taps_g positive - Number of taps (samples averaged)
GainCorrType_g string "EXACT" Gain correction mode
"EXACT": Exact gain correction (shift for power-of-two Taps_g, shift + multiplier otherwise)
"SHIFT": Shift-only gain correction (gain corrected into range (0.5, 1.0])
"NONE": No gain correction (output is the moving sum)
GainCorrCoefFmt_g string "(0, 1, 16)" Gain correction coefficient format
Must be of the form (0, 1, x)
String representation of an en_cl_fix Format_t
Only relevant for GainCorrType_g="EXACT" with non-power-of-two Taps_g
GainCorrDataFmt_g string "AUTO" Format of the data input to the gain correction multiplier
"AUTO": Automatically determined as (OutFmt_g.S, InFmt_g.I, OutFmt_g.F+3)
String representation of an en_cl_fix Format_t
Only relevant for GainCorrType_g="EXACT" with non-power-of-two Taps_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.
RoundReg_g string "YES" Presence of rounding pipeline stage
"YES": Always implement register
"NO": Never implement register
"AUTO": Implement register if rounding is needed according to the formats chosen
SatReg_g string "YES" Presence of saturation pipeline stage
"YES": Always implement register
"NO": Never implement register
"AUTO": Implement register if saturation is needed according to the formats chosen
RamBehavior_g string "RBW" Resource control for the tap delay line mapped to RAM. Normally not used except for large Taps_g
"RBW" = read-before-write, "WBR" = write-before-read
For details refer to olo_base_delay
RamStyle_g string "auto" Resource control for the tap delay line mapped to RAM. Normally not used except for large Taps_g
For details refer to olo_base_delay
Resource_g string "AUTO" Resource control for the tap delay line. Normally not used except for large Taps_g
For details refer to olo_base_delay

The following generics normally do not need to be changed from their default values. They are only relevant for specific resource optimiation scenarios:

  • GainCorrCoefFmt_g
  • GainCorrDataFmt_g
  • RamBehavior_g
  • RamStyle_g
  • Resource_g

Interfaces

Control

Name In/Out Length Default Description
Clk in 1 '0' Clock
Not required if all registers are disabled (RoundReg_g="NO", SatReg_g="NO")
Rst in 1 '0' Reset input (high-active, synchronous to Clk)
Not required if all registers are disabled (RoundReg_g="NO", SatReg_g="NO")

Input Data

Name In/Out Length Default Description
In_Valid in 1 '1' AXI4-Stream handshaking signal for In_Data
In_Data in width(InFmt_g) - Input data
Format: InFmt_g

Output Data

Name In/Out Length Default Description
Out_Valid out 1 N/A AXI4-Stream handshaking signal for Out_Result
Out_Result out width(OutFmt_g) N/A Result data
Format: OutFmt_g

Detail

Architecture

Below figure shows the internal architecture of the moving average filter. The different gain correction types are shown in colors (red for "NONE", blue for "SHIFT" and yellow for "EXACT").

Architecture