code wiki / _hdl_build / nx_isa_run_sov.nx
nx_isa_run_sov.nx
buildroot/runtime/_hdl_build/nx_isa_run_sov.nx
about
nx_isa_run_sov.nx -- CLOSE THE LOOP (hardware -> derive -> hardware). A search-derived
RV64 program RUNS on the genesis sim rv64im_min_sim (god). The instruction sequence
MUL x3,x1,x2 ; ADD x3,x3,x1 is exactly what nx_evo_isa derives for f(a,b)=a*b+a; here we
ENCODE it to real RV64 machine code (the encoders -- rv_lui IS the search-derived enc_u),
wrap it to load a,b + write the result byte to the NS16550A UART + halt via the SiFive
finisher, LOAD it into the sim, RUN it, and VERIFY the captured UART byte == (a*b+a)&0xff.
Mirrors rv64im_min_sim_smoke's device setup. license_tier: ORIGINAL
dependencies 10 imports · 0 importers
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_sim.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
| 19 | const IR_MEM_BASE: i64 = 0x80000000 |
| 20 | const IR_MEM_SIZE: i64 = 4096 |
| 21 | const IR_TX_CAP: i64 = 256 |
functions
| 23 | func ir_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 28 | func ir_n(v: i64) -> i64 { nxi_out(v); return 0 } |
| 31 | func rv_addi(rd: i64, rs1: i64, imm: i64) -> i64 { return ((imm & 0xFFF) << 20) | (rs1 << 15) | (rd << 7) | 0x13 } called by 1: ir_emit |
| 32 | func rv_lui(rd: i64, imm20: i64) -> i64 { return ((imm20 & 0xFFFFF) << 12) | (rd << 7) | 0x37 } called by 1: ir_emit |
| 33 | func rv_rtype(f7: i64, rs2: i64, rs1: i64, f3: i64, rd: i64) -> i64 { return (f7 << 25) | (rs2 << 20) | (rs1 << 15) | (f3 << 12) | (rd << 7) | 0x33 } called by 1: ir_emit |
| 34 | func rv_store(rs2: i64, rs1: i64, f3: i64) -> i64 { return (rs2 << 20) | (rs1 << 15) | (f3 << 12) | 0x23 } // imm = 0 called by 1: ir_emit |
| 35 | func rv_w32(buf: *u8, off: i64, w: i64) -> i64 called by 1: ir_emit |
| 44 | func ir_emit(mem: *u8, a: i64, b: i64) -> i64 |
| 60 | func main() -> i64 |