code wiki / _hdl_build / nx_alu_netlist_build.nx

nx_alu_netlist_build.nx

buildroot/runtime/_hdl_build/nx_alu_netlist_build.nx

3447 B102 linesdepth 6pulls 8 transitivereach 3 importersview sourcekind librarytopic alu
docsdependenciesstructsconstsfunctions

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

nx_nxgate_sim.nx nx_alu_op_kind.nx rv64im_min_alu.nx nx_alu_netlist_build.nx nx_alu_netlist_build_div.nx nx_alu_netlist_full_test.nx

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

33struct NxAluNetlist

consts

29const NX_ALUNL_A: i64 = 0
30const NX_ALUNL_B: i64 = 1
31const NX_ALUNL_OPIN: i64 = 2

functions

39func nx_alu_nl_set(cells: *NxGsimCell, idx: i64, kind: i64,
50func nx_alu_netlist_build(cells: *NxGsimCell, info: *NxAluNetlist) -> i64