code wiki / _hdl_build / nx_rv64_qemu_fuzz.nx

nx_rv64_qemu_fuzz.nx

buildroot/runtime/_hdl_build/nx_rv64_qemu_fuzz.nx

15990 B230 linesdepth 5pulls 19 transitivereach 0 importersview sourcekind tooltopic rv64
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_itoa_lib.nx nishi_hdl_primitives.nx rv64im_min_decoder.nx rv64im_min_alu.nx rv64im_min_regfile.nx rv64im_min_csr.nx rv64im_min_clint.nx rv64im_min_uart.nx rv64im_min_virtio.nx nx_rv64_qemu_fuzz.nx

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

main g_puts sys_write g_pn nxi_out nxi_fd sys_mmap ccz_cat_num sys_write ↻ sys_munmap sys_mmap ↻ sys_openat_wr gen_program sys_mmap ↻ ra_put ra_u ra_i rnd gen_itype rnd ↻ ra_put ↻ ra_i ↻ gen_wtype rnd ↻ ra_put ↻ ra_i ↻ ra_r gen_rtype rnd ↻ ra_put ↻ ra_r ↻ ra_s gen_branch sys_mmap ↻ ra_put ↻ ra_u ↻ ra_i ↻ rnd ↻ ra_b gen_rtype ↻

structs

none

consts

29const DMEM_BASE: i64 = 0x80000000
30const DMEM_SIZE: i64 = 65536
31const NPROG: i64 = 60
32const NBRANCH: i64 = 60
33const NMEM: i64 = 60
34const NTOTAL: i64 = 180

functions

22func 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 1: main calls 1: sys_write
27func g_pn(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: main calls 1: nxi_out
36func rnd(st: *i64) -> i64 { st[0]=st[0]*6364136223846793005 + 1442695040888963407; return (st[0]>>16)&0x7FFFFFFF }
39func gen_rtype(st: *i64, out: *u8, po: *i64) -> i64
59func gen_itype(st: *i64, out: *u8, po: *i64) -> i64
called by 2: gen_programgen_branch calls 3: rndra_putra_i
69func gen_wtype(st: *i64, out: *u8, po: *i64) -> i64
called by 1: gen_program calls 4: rndra_putra_ira_r
85func gen_program(st: *i64, out: *u8) -> i64
107func gen_branch(st: *i64, out: *u8) -> i64
called by 1: main calls 9: sys_mmapra_putra_ura_irndra_b+3
139func gen_mem(st: *i64, out: *u8) -> i64
called by 1: main calls 8: sys_mmapra_putra_ura_irndra_s+2
165func build_path(buf: *u8, idx: i64) -> i64
called by 1: main
172func main() -> i64