Fix AGC attack path to never increase gain on saturation (#145)#154
Fix AGC attack path to never increase gain on saturation (#145)#154lekkalaharsha wants to merge 12 commits into
Conversation
Added GitHub badges for stars, forks, watchers, license, and hardware.
…79#145) The else branch of the attack guard could set agc_base_gain = min_gain even when min_gain > agc_base_gain, raising LNA gain during a saturation event. Replace with a saturating subtract that does nothing when already at or below the floor. Add configure() with min/max validation and agc_base_gain clamping. Two regression tests added (15/15 pass). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…le (NawfalMotii79#145) With holdoff_frames == 0 the recovery condition (holdoff_counter >= holdoff_frames) is permanently true, bypassing the intended throttle and causing gain-up on every non-saturated frame. configure() now rejects zero with DIAG_WARN and leaves all fields unchanged. Regression case added to test_configure_validation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Hi @soufianebouaddis, applied your What changed:
All 15/15 tests pass. |
NawfalMotii79#145) Three additional validation guards in configure() identified by @soufianebouaddis: - gain_step_down == 0: silently disables AGC attack (gain never decreases on saturation). Now rejected with DIAG_WARN and false return. - gain_step_up == 0: silently disables AGC recovery (gain never increases after saturation clears, AGC locks at floor permanently). Now rejected. - max_gain > 127: exceeds the 7-bit ADAR1000 VGA register range. Now rejected. All three guards follow the existing atomic-reject pattern: no fields are written on a rejected call, so partial configuration is impossible. Three regression tests added (tests 16/17/18 in test_agc_outer_loop.cpp): - test_configure_rejects_zero_step_down - test_configure_rejects_zero_step_up - test_configure_rejects_max_gain_out_of_range (boundary: 127 accepted, 128+ rejected) All 18/18 tests pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Hi @soufianebouaddis, applied all three guards — commit f05ab2c. Changes:
All three follow the existing atomic-reject pattern — no fields are written on a rejected call, so partial configuration is impossible regardless of call order. Three regression tests added ( 18/18 tests pass. PR #154 is ready for re-review. |
|
@NawfalMotii79 — @soufianebouaddis has approved this PR. All five configure() guards are verified, implementation and docstring agree, and the atomic-reject pattern is intact across every path. Ready to merge. Please squash merge into develop — the current PR title and description are suitable as the final commit message. |
Summary
Closes #145.
Changes
Test plan