Skip to content

Fix Helium arm_fir_q15 and arm_fir_q7 with many taps - #372

Open
mdionisio wants to merge 2 commits into
ARM-software:mainfrom
mdionisio:fix_helium_fir_q15_q7
Open

mdionisio wants to merge 2 commits into
ARM-software:mainfrom
mdionisio:fix_helium_fir_q15_q7

Conversation

@mdionisio

Copy link
Copy Markdown

The generic Helium kernels, used by arm_fir_q15 for numTaps > 32 and by
arm_fir_q7 for numTaps > 64, give wrong results and access memory outside
the documented buffers. The existing FIR tests use at most 25 taps, so they
never reach these kernels.

Defects

  • Tail of the block (blockSize & 3 equal to 2 or 3) : outputs 1 and 2 were
    computed from the wrong delayed samples (offsets 2 and 4 for Q15, 4 and 8
    for Q7, instead of 1 and 2). For Q15, the tail of 3 samples also shifted
    the accumulators twice.
  • For each group of 4 outputs, a full vector of input samples (8 for Q15,
    16 for Q7) was copied into the state and both pointers were advanced by
    the vector length : pSrc was read past the end of the block and
    pState was written past its documented size
    (numTaps + blockSize - 1).
  • The final copy of the history copied numTaps samples instead of
    numTaps - 1, reading one sample past the documented state size.

mdionisio and others added 2 commits November 14, 2026 19:18
The existing FIR tests use at most 25 taps, so they never reach the
generic Helium kernels of arm_fir_q15 (numTaps > 32) and arm_fir_q7
(numTaps > 64).

New tests test_fir_long_q15 and test_fir_long_q7 in the FIR Q15 and
FIR Q7 suites:

- numTaps 34 to 200 (Q15) and 65 to 200 (Q7), blockSize 1 to 8, 13 and
  16 (all the values of blockSize & 3), 3 successive calls on the same
  instance
- references computed with an exact model of the fixed point FIR
  (PatternGeneration/FIR.py), compared bit exact
- guard samples after the documented size of the state buffer to
  detect writes beyond it

On Cortex-M55 these tests fail with the current Helium kernels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The generic Helium kernels, used by arm_fir_q15 for numTaps > 32 and by
arm_fir_q7 for numTaps > 64, had three defects:

- the tail of the block (blockSize & 3 equal to 2 or 3) computed the
  outputs 1 and 2 from the wrong delayed samples (offsets 2 and 4 for
  Q15, 4 and 8 for Q7, instead of 1 and 2), and the Q15 tail of 3
  samples shifted the accumulators twice
- for each group of 4 outputs, a full vector of input samples (8 for
  Q15, 16 for Q7) was copied into the state and both pointers were
  advanced by the vector length: pSrc was read past the end of the
  block and pState was written past its documented size
- the final copy of the history copied numTaps samples instead of
  numTaps - 1, reading one sample past the documented state size

Only the input samples consumed by the outputs are now copied, with
predicated loads and stores.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant