code wiki / _hdl_build / nx_emit_kat.nx
nx_emit_kat.nx source
↩ module page · 14 lines · 802 B
1// nx_emit_kat.nx -- the portable arithmetic KAT, compiled by the SOVEREIGN x86_64 chain
2// (nx_cc_sovereign -> nxasm_x86, NO gcc, NO qemu) and executed natively. main returns 42 IFF the
3// backend computes (a*b)+(a-b) correctly for THREE distinct input pairs (37, 10, 81) -- so a
4// constant-folding, miscompiled, or hollow backend cannot reach 42 (it would return 1/2/3 pointing
5// at the first wrong KAT). This is the run-proof KAT the per-ISA emit gates execute on each
6// hardware target's SOVEREIGN emulator (nx_emu_rv64/arm64/mips64/ppc64le/...), replacing qemu.
7// license_tier: ORIGINAL
8func kat(a: i64, b: i64) -> i64 { return (a * b) + (a - b) }
9func main() -> i64 {
10 if kat(7, 5) != 37 { return 1 }
11 if kat(4, 2) != 10 { return 2 }
12 if kat(9, 9) != 81 { return 3 }
13 return 42
14}