olo_fix_mov_avg¶
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.
The entity supports one or multiple channels (time-division-multiplexed, TDM). For Channels_g > 1, the input samples of all channels are applied in a round-robin fashion (channel 0, channel 1, ... channel Channels_g-1, channel 0, ...) and the moving average is computed separately for each channel. The output is in the same TDM order. For details about the TDM signal format, refer to the conventions.
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 |
|---|---|---|---|
| Channels_g | positive | 1 | Number of TDM channels |
| 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 |
| In_Last | in | 1 | '0' | Marks the last channel of a TDM sample-group Only used for checking in simulation. Can be omitted for single-channel use |
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 |
| Out_Last | out | 1 | N/A | Marks the last channel of a TDM sample-group For Channels_g=1, Out_Last is constantly high |
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").

For Channels_g > 1, the architecture is extended as follows:
- The tap delay line is Taps_g * Channels_g samples long, so it delivers the sample of the same channel from Taps_g samples ago.
- The moving sum register is extended by a delay line of Channels_g-1 samples. Together, they store the moving sum of each channel. For Channels_g=1, this delay line is empty and the architecture is the same as shown in the figure.
Resource usage of these delay lines (SRL or BRAM) can be controlled through Resource_g, RamBehavior_g and RamStyle_g.