code wiki / (root) / nx_simd_sat_test.nx

nx_simd_sat_test.nx

buildroot/runtime/nx_simd_sat_test.nx

6007 B148 linesdepth 6pulls 8 transitivereach 0 importersview sourcekind gate/prooftopic simd
docsdependenciesstructsconstsfunctions

about

nx_simd_sat_test.nx -- i16x16 signed saturating add/sub. Audio DSP requirement: when two 16-bit signed samples sum past INT16_MAX, the result must clip to INT16_MAX (32767), not wrap to a negative value (which would produce a pop/click). Same for INT16_MIN underflow. vpaddsw on x86 and vsadd.vv on RV-V do this in hardware -- previously callers needed manual clip(a+b, INT16_MIN, INT16_MAX) with branching that defeats SIMD.

dependencies 2 imports · 0 importers

nx_kernel_v2.nx nx_log.nx nx_simd_sat_test.nx

imports: nx_kernel_v2.nxnx_log.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main t1_sat_add_clipping_high pack4_i16 t2_sat_sub_clipping_low pack4_i16 ↻ t3_sat_in_range_unchanged pack4_i16 ↻ t4_sat_boundary_exact pack4_i16 ↻

structs

none

consts

none

functions

15func pack4_i16(a: i64, b: i64, c: i64, d: i64) -> i64
22func t1_sat_add_clipping_high() -> i64
called by 1: main calls 1: pack4_i16
53func t2_sat_sub_clipping_low() -> i64
called by 1: main calls 1: pack4_i16
83func t3_sat_in_range_unchanged() -> i64
called by 1: main calls 1: pack4_i16
110func t4_sat_boundary_exact() -> i64
called by 1: main calls 1: pack4_i16
135func main() -> nx_exit