Title: Gate EMA accumulator on data_ena for multiplexed-stream use cases#1
Open
Abraxas3d wants to merge 1 commit into
Open
Title: Gate EMA accumulator on data_ena for multiplexed-stream use cases#1Abraxas3d wants to merge 1 commit into
Abraxas3d wants to merge 1 commit into
Conversation
Previously, all internal state (alpha_signed, alpha_m, data_signed, mult_data, mult_sum, average) updated unconditionally each clock, treating data_ena only as a passthrough strobe to average_ena. This is correct for streaming inputs where every clock has valid data, but incorrect for multiplexed inputs where data_ena selects which clocks to integrate. This change wraps the EMA math in 'if data_ena = 1' so that the accumulator only advances on valid samples. average_ena remains outside the gate to faithfully mark output validity. Backward compatibility: for streaming inputs with data_ena tied high, behavior is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
data_ena = '1'gate around the EMA accumulator update insidelowpass_ema. data_ena now selects which clocks the EMA integrates, rather than only riding through as a passsthrough strobe to average_ena.Motivation
lowpass_emapreviously updated all internal state every clock and forwarded data_ena unchanged to average_ena. This is correct for streaming inputs (data valid every clock, data_ena tied high), but incorrect for any use case where data_ena selects which clocks have valid samples (like Haifuraiya).We discovered this while building a 64-channel polyphase-channelizer power monitor for Haifuraiya. The wrapper instantiates 64
power_detectorblocks sharing a single multiplexed I/Q data bus; each instance's data_ena selects which clocks correspond to its assigned channel. Without the data_ena gate, all 64 power_detector instances accumulated the same shared data stream and reported identical averages, regardless of which channel each one was supposed to monitor. Took a while to figure this out!Change
Wraps the existing accumulator assignments in
if data_ena = '1' then ... end if;inside theelse(non-reset) branch of the clocked process.average_ena <= data_ena;remains outside the gate so output validity is reported faithfully regardless of accumulator update.Backward compatibility
For streaming inputs with data_ena tied high, behavior is unchanged: the gate is always satisfied and every clock updates as before.
For users who tied data_ena permanently low, the EMA now holds state instead of overwriting with the input alpha/data. We believe this is the correct behavior (no data, no update) and are not aware of any user relying on the previous behavior.
pluto_mskdoes not.Testing
Verified in the Haifuraiya AXI wrapper testbench:
decaying through channels 63, 1, 2, 62, 3, 61, ... and deep
stopband in channels 17-46. Pre-fix: all 64 channels read
identical EMA values.
around bin 16. Pre-fix: all 64 channels read identical EMA
values.
Addendum!
Independently caught during the same session: the README port table states power_squared width is
2*DATA_W - 2but the actual range declaration(2*DATA_W - 2 downto 0)is2*DATA_W - 1bits wide.