code wiki / _hdl_build / nx_f32_bricks_hw_gate.nx

nx_f32_bricks_hw_gate.nx

buildroot/runtime/_hdl_build/nx_f32_bricks_hw_gate.nx

7620 B133 linesdepth 6pulls 11 transitivereach 0 importersview sourcekind gate/prooftopic f32
docsdependenciesstructsconstsfunctions

about

nx_f32_bricks_hw_gate.nx -- DIFFERENTIAL gate for the hardware twins of three f32 tower bricks (nx_f32_gelu, nx_f32_layernorm, nx_f32_softmax, 2026-09-14): each twin must return the IDENTICAL bits to the software oracle it replaced (the _sw body kept verbatim in the same file) over a dense grid and over pseudo-random rows, so "IEEE round-to-nearest on both sides" is measured, never assumed. Planted controls prove the comparator can fail: one input nudged by one ulp must change the answer, and a perturbed gamma must change a LayerNorm row. Declared in organ_gate.conf. expect_exit: 0 license_tier: ORIGINAL

dependencies 7 imports · 0 importers

nx_gate_verdict.nx nx_f32.nx nx_f32_cvt.nx nx_f32_div.nx nx_f32_gelu.nx nx_f32_layernorm.nx nx_f32_softmax.nx nx_f32_bricks_hw_gate.nx

imports: nx_gate_verdict.nxnx_f32.nxnx_f32_cvt.nxnx_f32_div.nxnx_f32_gelu.nxnx_f32_layernorm.nxnx_f32_softmax.nx

imported by: nobody (leaf or entry point)

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

main gv_puts sys_write gv_ctr sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ nx_f32_div nx_f32_classify nx_f32_exp_field nx_f32_mant_field nx_f32_sign nx_f32_mant_field ↻ nx_f32_exp_field ↻ nx_i32_to_f32 nx_f32_sub nx_f32_add nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_mant_field ↻ nx_f32_exp_field ↻ nx_f32_neg nx_f32_mul nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_mant_field ↻ nx_f32_exp_field ↻ nx_f32_gelu

structs

none

consts

15const BH_GRID: i64 = 4096 // grid points across the range below
16const BH_RANGE: i64 = 16 // gelu/erf grid spans -8..+8, the region where erf is not saturated
17const BH_HALF_RANGE: i64 = 8
18const BH_ROWS: i64 = 16
19const BH_DIM: i64 = 64
20const BH_NOISE_MUL: i64 = 1103515245 // LCG multiplier (Knuth/glibc), a published PRNG constant, not a tunable
21const BH_NOISE_INC: i64 = 12345
22const BH_NOISE_MASK: i64 = 0x7fffffff
23const BH_NOISE_SPAN: i64 = 1000 // pseudo-random values land in -4.000 .. +4.000 (thousandths)
24const BH_NOISE_CENTER: i64 = 4000
25const BH_MILLI: i64 = 1000
26const BH_EPS_MICRO: i64 = 1 // LayerNorm eps 1e-6 as micro units
27const BH_MICRO: i64 = 1000000

functions

30func bh_noise() -> i64 { g_bh_seed = (g_bh_seed * BH_NOISE_MUL + BH_NOISE_INC) & BH_NOISE_MASK; return g_bh_seed }
called by 1: bh_rand_f32
32func bh_rand_f32() -> i64
37func main() -> i64