code wiki / (root) / nx_nxgate_sim.nx

nx_nxgate_sim.nx

buildroot/runtime/nx_nxgate_sim.nx

7030 B155 linesdepth 5pulls 5 transitivereach 69 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_nxgate_sim.nx -- gate-level FUNCTIONAL simulator: the VERIFIER organ's hardware oracle (closes SIL-3, "no gate-level functional verification"). The .nxgate netlist (nishi_synth_gates.nx) is word-level cells: each cell is a kind (ADD/SUB/MUX/EQ/AND/...) with a fanout net + fanin nets. This module evaluates such a netlist over input vectors so we can assert it computes 1:1 what the behavioral RTL (rv64im_min_alu.nx) computes. WHY this matters: the ALU gate emitter currently emits an ADD cell for DIV/REM (the SIL-1 stub), so a faithful functional sim will DIVERGE from behavioral DIV -- i.e. it CATCHES the silent gate-emit miscompile that today's structural-only smokes miss. V1: combinational, word-level, 64-bit (i64) values; cells assumed in topological order (the synth emitter builds sub-results before consumers). LOUD on any unsupported/sequential kind -- never silently miscomputes (Cardinal: build intelligence, fail loud). Reuses the real NX_GATE_KIND_* enum from nishi_synth_gates.nx (single source of truth -- DRY). 5W1H feedback hook: nx_gsim_diff returns the mismatch count; a future variant records WHICH vector + WHICH net diverged + the expected-vs-got, the actionable diagnostic the invention loop's Generator consumes.

dependencies 1 imports · 9 importers

nishi_synth_gates.nx nx_nxgate_sim.nx nx_alu_divider.nx nx_alu_netlist_build.nx nx_alu_netlist_test.nx nx_cell_sink.nx nx_eqsat.nx nx_gate_energy_test.nx nx_gsim_seq_test.nx nx_latency_metric.nx nx_nxgate_sim_test.nx

imports: nishi_synth_gates.nx

imported by: nx_alu_divider.nxnx_alu_netlist_build.nxnx_alu_netlist_test.nxnx_cell_sink.nxnx_eqsat.nxnx_gate_energy_test.nxnx_gsim_seq_test.nxnx_latency_metric.nxnx_nxgate_sim_test.nx

structs

24struct NxGsimCell
33struct NxGsim

consts

40const NX_GSIM_OK: i64 = 0
41const NX_GSIM_BAD_KIND: i64 = 1

functions

46func nx_gsim_kind_supported(k: i64) -> i64
74func nx_gsim_eval_cell(kind: i64, a: i64, b: i64, c: i64) -> i64
110func nx_gsim_run(g: *NxGsim) -> i64
140func nx_gsim_tick(g: *NxGsim, dtmp: *i64) -> i64
called by 1: main calls 1: nx_gsim_run