# Why heliaDSP

CMSIS-DSP is Arm's C library of signal-processing and numerical functions for Cortex-M processors. A firmware team that adopts it as distributed by Arm meets four problems on Ambiq silicon, each shown below with the measurement or defect behind it and what heliaDSP does about it. Helium, or MVE, is the vector extension of the Cortex-M55 in Apollo510; CMSIS-DSP has handwritten Helium kernels for many of its functions and portable C kernels for all of them.

## 1. A vendor library is fixed at its vendor's release

Corrections to Arm's source reach a product when Arm accepts and releases them. Ambiq has found defects in Arm's source that matter on Apollo510:

- The Helium kernel of `arm_mat_vec_mult_f32` read up to 12 bytes past the end of each matrix row; the Q7, Q15 and Q31 kernels read past the row as well. On a matrix that ends at a memory-protection boundary the read faults.
- The Helium Q15 and Q31 forward real-FFT kernels read two elements past the end of the coefficient table.
- The Q15 and Q31 real FFT of a fixed length linked the 8192-point coefficient tables whatever the length: 32 KiB of Q15 coefficient data for a 256-point transform that needs 1,032 bytes.

heliaDSP builds CMSIS-DSP from Ambiq's upstream-tracking fork, [AmbiqAI/CMSIS-DSP](https://github.com/AmbiqAI/CMSIS-DSP), which carries a correction for each of these on top of an Arm commit, each with a regression test that fails on Arm's source and passes on the patched one. The upstream-tracking fork carries them without waiting for Arm; none has been submitted to Arm (see [Relationship to CMSIS-DSP](https://ambiqai.github.io/helia-dsp/guide/cmsis-dsp-relationship/)). The patches at the current qualified CMSIS-DSP commit are listed in [`PROVENANCE.toml`](https://github.com/AmbiqAI/helia-dsp/blob/4a7b7f054eafd96ae50c12050ad3ef3ec1ebaea1/PROVENANCE.toml).

## 2. Contracts change with build flags

A function's contract is what a caller must satisfy and may rely on: signature, types, buffer sizes, padding, coefficient layout, numerical behaviour. In CMSIS-DSP, preprocessor flags select among several implementations of one function in one source file, and some of those implementations have different contracts:

- In a Helium build, the f32 direct-form-I biquad cascade requires coefficients in an expanded layout prepared by `arm_biquad_cascade_df1_mve_init_f32`. An instance prepared by the ordinary `arm_biquad_cascade_df1_init_f32` produces Inf or NaN output with no error. This was observed on Apollo510 in August 2026.
- In a Helium build, the f32 FIR state buffer must be longer than in a scalar build, and the coefficient array must be zero-padded to a multiple of four.
- `DISABLEFLOAT16` removes the f16 declarations from the headers.

A static library is compiled once, with one set of flags. Every source file that includes the headers must be compiled with the same header-affecting flags, or the application and the library disagree about a structure's layout.

heliaDSP makes every header-affecting definition a usage requirement (a compile setting that CMake applies to the library and to every target that links it) of the `CMSISDSP` target, so the library and every target that links it are compiled with the same set. It allows one `CMSISDSP` target per build and stops the configure step when a second, differently configured `CMSISDSP` target is offered. It keeps Arm's types and contracts, and documents the configuration-dependent ones in one place: [Contracts](https://ambiqai.github.io/helia-dsp/guide/contracts/).

## 3. Defaults and compilers decide performance and correctness

heliaDSP v1.0.0 compiled CMSIS-DSP for NSX boards with `ARM_MATH_AUTOVECTORIZE`, which replaces every handwritten Helium kernel with portable C. It did so to avoid the biquad hazard above. Measured on an Apollo510 EVB in August 2026 (96.6 MHz, `-O2`, v1.0.0 source), the handwritten Helium kernels took 1.5 to 2.7 times fewer cycles than the portable kernels for the same compiler, across the real FFT, FIR, biquad, complex magnitude and matrix-vector product. From identical source, ATfE 22.1.0 (Arm Toolchain for Embedded, Arm's LLVM-based compiler) took up to 1.9 times fewer cycles than GCC 14.2.1. Against v1.0.0's default (GCC 14.2.1, portable kernels), the fastest measured configuration took 2.3 to 3.9 times fewer cycles. The full table is in [Measurements](https://ambiqai.github.io/helia-dsp/guide/measurements/).

The compiler also decides correctness. Arm GNU Toolchain 15.2.Rel1 miscompiles the Helium complex-FFT kernels: the FFTs return wrong output and write below the caller's buffer (helia-dsp issue #23). The real FFTs `arm_rfft_fast_f32`, `arm_rfft_q31` and `arm_rfft_q15` call these kernels. heliaDSP v1.1.0's CI built with that compiler and did not execute the result; v1.1.1 changed the kernels.

heliaDSP 2.0.0 builds the Helium kernels by default on MVE-capable NSX boards, names ATfE 22.1.0 as the compiler for Helium builds, and builds a CMSIS-DSP commit whose complex FFT GCC 15.2 compiles correctly (see [Toolchains](https://ambiqai.github.io/helia-dsp/guide/toolchains/)). Its qualification runs the kernels on the Corstone-300 simulator and on an Apollo510 EVB, in addition to link checks (see [Verification](https://ambiqai.github.io/helia-dsp/guide/verification/)).

## 4. The linker keeps what the source refers to

A linker keeps a function or table if something already kept refers to it; it does not evaluate run-time values. CMSIS-DSP's generic real-FFT initializer `arm_rfft_fast_init_f32(S, len)` selects the length with a `switch` that refers to the initializer and tables of every supported length. Measured on Cortex-M55 in August 2026 (GCC 14.2.1, `-O2`, unused sections removed), a program that initializes a 512-point f32 real FFT with the generic initializer occupies 87.6 KB of flash for the transform, against 9.3 KB with the per-length `arm_rfft_fast_init_512_f32`.

heliaDSP documents the cost at the point of use and, for its own operations, makes selection among implementations before the build: each variant has its own named entry point, and no process function branches at run time across variants.

## Where heliaDSP fits

Ambiq maintains four libraries for code that runs on its SoCs:

- heliaCORE ([AmbiqAI/ns-cmsis-nn](https://github.com/AmbiqAI/ns-cmsis-nn)) provides neural-network layer kernels, derived from Arm's CMSIS-NN, for model runtimes and compiled models.
- heliaDSP provides signal-processing and numerical operations, derived from Arm's CMSIS-DSP, for the processing around a model.
- heliaML ([AmbiqAI/helia-ml](https://github.com/AmbiqAI/helia-ml)) is a C runtime and offline exporter for classical machine-learning models. It builds against heliaDSP and refuses at configure time a heliaDSP version below a minimum (helia-dsp issue #26); the compile definitions `HELIA_DSP_VERSION_MAJOR`, `HELIA_DSP_VERSION_MINOR` and `HELIA_DSP_VERSION_PATCH` give that version to C code (see [API reference](https://ambiqai.github.io/helia-dsp/reference/)).
- compressionKIT provides codecs for physiological signals.

The proposed boundary with compressionKIT (helia-dsp issue #19) is that heliaDSP owns reusable numerical transforms and processing kernels, such as wavelet transforms, and compressionKIT owns codec composition, bitstream formats and coding decisions. Where SPIHT coding belongs is not decided.

## What heliaDSP does not yet do

- Its own operations begin with the wavelet transform in 2.1.0 (see [API reference](https://ambiqai.github.io/helia-dsp/reference/)), and no heliaDSP implementation replaces one of Arm's source files under its `arm_*` name.
- It has been executed on the Apollo510 EVB and the Corstone-300 simulator only. The other SoCs listed in `nsx/nsx-module.yaml` declare source compatibility; they have not been run.
- Arm's own CMSIS-DSP test suite is run neither in heliaDSP nor in the upstream-tracking fork.

## Next

- [Getting started](https://ambiqai.github.io/helia-dsp/getting-started/)
- [Measurements](https://ambiqai.github.io/helia-dsp/guide/measurements/)
- [Relationship to CMSIS-DSP](https://ambiqai.github.io/helia-dsp/guide/cmsis-dsp-relationship/)
