Skip to main content

Module fixedpoint

Module fixedpoint 

Source
Expand description

Q16.16 fixed-point ingress path for FPGA and bare-metal deployment.

quantize_q16_16 / dequantize_q16_16, saturation arithmetic. Enables deployment on RISC-V RV32I, Cortex-M0, and custom FPGA pipelines without a hardware FPU. Mode label "fixed_q16_16" for SigMF provenance. Fixed-point ingress path for FPGA soft-core and bare-metal deployment.

§Context

While dsfb-rf is purely f32-based in the observer hot path, a number of deployment targets lack a hardware FPU:

  • RISC-V RV32I without the F extension (e.g., riscv32imac-unknown-none-elf)
  • Cortex-M0/M0+ (ARMv6-M — no FPU)
  • FPGA soft-cores (MicroBlaze without DSP48, PicoRV32)
  • Custom ASICs / VLSI pipelines in e.g. C-UAS / EW front-ends

In these contexts, the ADC lane residual arrives as a raw integer sample and converting to f32 before the observer introduces software FPU overhead. The Q16.16 fixed-point format provides:

  • 16 integer bits: supports residual norms up to 65535 (far beyond any normalised IQ residual)
  • 16 fractional bits: resolution of 2⁻¹⁶ ≈ 1.526 × 10⁻⁵ — comfortably below the 14-bit ADC quantisation step on typical SDRs
  • 32-bit arithmetic: fits in a single 32-bit ALU word; multiply in i64 then shift avoids overflow

§Format conventions

An i32 in Q16.16 format represents the real number x = raw / 2^16.

quantize(x)     = round(x × 2^16)     [f64 → Q16.16 i32]
dequantize(raw) = raw as f64 / 2^16   [Q16.16 i32 → f64]
to_f32(raw)     = raw as f32 / 65536.0 [Q16.16 i32 → f32 for observer]

Saturation on overflow prevents undefined behaviour and limits anomaly injection from wildly out-of-range inputs.

§DSFB-Semiotics-Engine source

The quantize_q16_16 / dequantize_q16_16 pair mirrors the reference implementation in dsfb-semiotics-engine/math/fixed_point.rs (de Beer 2026). The mode label "fixed_q16_16" is preserved for provenance traceability in SigMF annotations.

§Design

  • no_std, no_alloc, zero unsafe
  • All functions are #[inline] for zero-cost abstraction
  • No libm dependency — arithmetic is pure integer + bit-shift

Structs§

PeriodicResyncConfig
Configuration for periodic fixed-point accumulator resynchronisation.

Constants§

FRAC_BITS
Fractional bits in the Q16.16 format.
MAX_VALUE
Maximum representable value in Q16.16 as f64.
MIN_VALUE
Minimum representable value in Q16.16 as f64.
MODE_LABEL
Provenance mode label for SigMF annotation.
RESOLUTION
Resolution (1 LSB) of the Q16.16 format in real units.
SCALE
Scale factor: 2^FRAC_BITS.

Functions§

add_q16_16
Add two Q16.16 values with saturation.
apply_periodic_resync
Apply a periodic resynchronisation correction to one Q16.16 accumulator.
dequantize_q16_16
Dequantise a Q16.16 i32 back to f64.
mul_q16_16
Multiply two Q16.16 values and return a Q16.16 result.
q16_16_to_f32
Convert a Q16.16 i32 directly to an f32 for the observer hot path.
quantize_f32
Quantise an f32 into Q16.16.
quantize_q16_16
Quantise a f64 value into Q16.16 fixed-point format (i32).