code wiki / _hdl_build / nx_alu_netlist_build.nx
nx_alu_netlist_build.nx
buildroot/runtime/_hdl_build/nx_alu_netlist_build.nx
about
nx_alu_netlist_build.nx -- builds the ALU op-select netlist IN MEMORY as the
ONE source the gate-sim (nx_nxgate_sim.nx) verifies.
Mirrors synth_emit_alu_gates.nx's topology exactly:
per op K in 1..NX_RV64IM_ALU_N-1:
CONST(K) opcode literal
subnet = KIND(a, b) KIND = nx_alu_op_to_gate_kind(K) <-- SHARED
match = EQ(op_in, CONST(K))
cascade:
prev0 = CONST(0) the INVALID branch
prev = MUX(match_K, subnet_K, prev) for K = 1..N-1
result = last MUX fanout
Because the per-op subnet KIND comes from the SAME nx_alu_op_to_gate_kind the
text emitter uses, nx_gsim_run over this netlist verifies the emitter's ACTUAL
op->kind decisions. This is the SIL-3 closure: one source, two consumers
(text serializer + functional sim), no hand-kept copy.
Cells are emitted in topological order (every fanin net is driven by an
earlier cell), which nx_gsim_run (combinational, single forward pass) needs.
Caller allocates cells[] (>= 128 NxGsimCell) and a vals[] net array
(>= n_nets i64). Net ids 0/1/2 are reserved for a / b / op_in primary inputs.
dependencies 3 imports · 2 importers
imports: nx_nxgate_sim.nxnx_alu_op_kind.nxrv64im_min_alu.nx
imported by: nx_alu_netlist_build_div.nxnx_alu_netlist_full_test.nx
structs
| 33 | struct NxAluNetlist |
consts
| 29 | const NX_ALUNL_A: i64 = 0 |
| 30 | const NX_ALUNL_B: i64 = 1 |
| 31 | const NX_ALUNL_OPIN: i64 = 2 |
functions
| 39 | func nx_alu_nl_set(cells: *NxGsimCell, idx: i64, kind: i64, called by 1: nx_alu_netlist_build |
| 50 | func nx_alu_netlist_build(cells: *NxGsimCell, info: *NxAluNetlist) -> i64 |