code wiki / _hdl_build / nx_rv64_qemu_fuzz.nx
nx_rv64_qemu_fuzz.nx
buildroot/runtime/_hdl_build/nx_rv64_qemu_fuzz.nx
about
nx_rv64_qemu_fuzz.nx -- DIFFERENTIAL FUZZER AGAINST REAL QEMU (broadens the single-program QEMU oracle into a fleet;
the honest completion of external validation). Generates NPROG random straight-line RV64IM programs (random lui+addi
register init + random ALU/M-ext ops + emit 5 result bytes to the UART + halt via the SiFive finisher), runs EACH on
the golden behavioral sim (rv64im_min_sim) capturing its UART bytes, writes each program as a flat binary + a
manifest of the sim's expected output. A bash harness then runs each SAME binary in qemu-system-riscv64 and diffs.
If all match, my emulator's execution == the reference RISC-V implementation across HUNDREDS of random programs, not
just one -- eating the debt that the single-program oracle was thin evidence. Fixed seed => reproducible. expect_exit:0
dependencies 13 imports · 0 importers
diagram shows first 10 each side; +3 more imports, +0 more importers in the complete lists below.
imports: nx_syscalls.nxnx_itoa_lib.nxnishi_hdl_primitives.nxrv64im_min_decoder.nxrv64im_min_alu.nxrv64im_min_regfile.nxrv64im_min_csr.nxrv64im_min_clint.nxrv64im_min_uart.nxrv64im_min_virtio.nxrv64im_min_sim.nxnx_rv64_asm.nxnx_rv64_fast.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 29 | const DMEM_BASE: i64 = 0x80000000 |
| 30 | const DMEM_SIZE: i64 = 65536 |
| 31 | const NPROG: i64 = 60 |
| 32 | const NBRANCH: i64 = 60 |
| 33 | const NMEM: i64 = 60 |
| 34 | const NTOTAL: i64 = 180 |
functions
| 22 | func 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 } |
| 27 | func g_pn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 36 | func rnd(st: *i64) -> i64 { st[0]=st[0]*6364136223846793005 + 1442695040888963407; return (st[0]>>16)&0x7FFFFFFF } |
| 39 | func gen_rtype(st: *i64, out: *u8, po: *i64) -> i64 |
| 59 | func gen_itype(st: *i64, out: *u8, po: *i64) -> i64 |
| 69 | func gen_wtype(st: *i64, out: *u8, po: *i64) -> i64 |
| 85 | func gen_program(st: *i64, out: *u8) -> i64 |
| 107 | func gen_branch(st: *i64, out: *u8) -> i64 |
| 139 | func gen_mem(st: *i64, out: *u8) -> i64 |
| 165 | func build_path(buf: *u8, idx: i64) -> i64 called by 1: main |
| 172 | func main() -> i64 |