code wiki / _hdl_build / nx_rv64_difftest.nx

nx_rv64_difftest.nx

buildroot/runtime/_hdl_build/nx_rv64_difftest.nx

8740 B113 linesdepth 7pulls 8 transitivereach 0 importersview sourcekind tooltopic rv64
docsdependenciesstructsconstsfunctions

about

nx_rv64_difftest.nx -- DIFFERENTIAL FUZZER for the RV64 emulator stack (the SOTA way to validate a JIT: V8/QEMU do exactly this). Generates hundreds of RANDOM, terminating-by-construction RV64 programs (random arithmetic/shift/ memory ops + a bounded counting loop) with a FIXED SEED (reproducible), and asserts the GOLDEN INTERPRETER, the JIT (whole-program compile+run), and the TIERED ENGINE all produce BIT-IDENTICAL final state (registers XOR memory). This turns "equivalence-validated" from a handful of hand-written KATs into broad evidence -- and any divergence is a real bug (reproducible from the seed). expect_exit: 0

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_rv64_fast.nx nx_rv64_jit.nx nx_rv64_tier.nx nx_rv64_difftest.nx

imports: nx_syscalls.nxnx_rv64_fast.nxnx_rv64_jit.nxnx_rv64_tier.nx

imported by: nobody (leaf or entry point)

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

main g_puts sys_write sys_mmap gen_program rndn rnd gen_op rndn ↻ zero32 fk_run sys_mmap ↻ fk_step fk_amo fk_memok fk_ld fk_sext32 fk_sext fk_st fk_ltu fk_srlmask mulh64 mulhu64 mulhu64 ↻ mulhsu64 mulhu64 ↻ sdiv64 srem64 udiv_mod fk_ltu ↻ fk_sext32 ↻ fk_ltu ↻ fk_mmio_hit nx_virtio_read32 nx_virtio_addr_in_range fk_sext ↻ fk_memok ↻ fk_ld ↻ nx_virtio_write32 nx_virtio_addr_in_range ↻

structs

none

consts

16const MEMSZ: i64 = 4096
17const NPROG: i64 = 500
18const BIGSTEPS: i64 = 4000000

functions

12func g_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 2: ckmain calls 1: sys_write
13func g_pn(v: i64) -> i64 { let b: *u8=sys_mmap(28); var x: i64=v; if x<0{b[0]=45;sys_write(1,b,1);x=0-x} if x==0{b[0]=48;sys_write(1,b,1);return 0} var d: i64=0; var y: i64=x; while y>0{d=d+1;y=y/10} var i: i64=d-1; y=x; while i>=0{b[i]=(48+(y%10)) as u8;y=y/10;i=i-1} sys_write(1,b,d); return 0 }
called by 1: main calls 2: sys_mmapsys_write
14func ck(name: *u8, c: i64) -> i64 { if c==1 { g_puts(" PASS " as *u8) } else { g_puts(" FAIL " as *u8) } g_puts(name); g_puts("\n" as *u8); return c }
called by 1: main calls 1: g_puts
21func rnd(st: *i64) -> i64 { st[0]=st[0]*6364136223846793005 + 1442695040888963407; return (st[0]>>16)&0xFFFFFF }
called by 1: rndn
22func rndn(st: *i64, n: i64) -> i64 { return rnd(st)%n }
called by 2: gen_opgen_program calls 1: rnd
26func gen_op(st: *i64, opk: *i64, rd: *i64, rs1: *i64, rs2: *i64, imm: *i64, idx: i64) -> i64
called by 1: gen_program calls 1: rndn
47func gen_program(st: *i64, opk: *i64, rd: *i64, rs1: *i64, rs2: *i64, imm: *i64) -> i64
called by 1: main calls 2: rndngen_op
59func ck_reg(reg: *i64) -> i64 { var h: i64=1469598103934665603; var i: i64=1; while i<32 { h=(h^reg[i])*1099511628211; i=i+1 } return h }
called by 1: main
60func ck_mem(mem: *u8, n: i64) -> i64 { var h: i64=1469598103934665603; var i: i64=0; while i<n { h=(h^(mem[i] as i64))*1099511628211; i=i+1 } return h }
called by 1: main
61func zero32(r: *i64) -> i64 { var i: i64=0; while i<32 { r[i]=0; i=i+1 } return 0 }
called by 1: main
63func main() -> i64