Files
NawfalMotii79-PLFM_RADAR/9_Firmware
Jason bf83d35917 test(fpga): PR-M.4 — redesign T-6 drift invariants for scaled-FFT chain
Three sub-checks in compare_independent.py were red because the test
inputs assumed an UNSCALED FFT but PR-O moved both the RTL xFFT path
and fpga_model.FFTEngine to LogiCORE v9.1 Scaled mode (one >>>1 per
butterfly stage with conv-rounding, total /N applied across LOG2N
stages). At small input amplitudes the per-bin output rounded to zero
and the test invariants no longer described meaningful behaviour.

The fpga_reference.py side already mirrors the scaled-mode convention
(np.fft.fft(x)/n on forward, ifft on inverse — see line 104, 137-138,
207). The fix is purely in the test inputs:

  - FFT-2048(impulse): amp 1000 → 32000 (≈ Q15 max). Expected per-bin
    is now round(amp/N) = round(32000/2048) = 16 (banker's). The
    impulse has b=0 at every butterfly so there is no twiddle
    interaction; banker's rounding keeps every bin within ±1 LSB.
    Tightened tolerance from 5 to 2.

  - MF peak position + MF peak-to-median: amp 200 → 4000. Chain
    output peak under scaled-mode is correlation/N² ≈ pulse_len*amp²
    /N² = amp²/16384 (256 / 4_194_304). At amp=200 the peak collapsed
    to 2.4 (mostly Q15 quantization noise — argmax wandered to bin 2);
    at amp=4000 the peak rises to ≈ 977 with sidelobes near LSB
    floor. Peak-to-median ratio observed: 974 vs threshold 5.

Runtime verification: compare_independent.py 13/13 PASS standalone.
Full FPGA regression: 36/1/6 → 37/0/6 (the single FAIL was this test;
no other tests touched).
2026-05-05 12:37:26 +05:45
..