code wiki / _hdl_build / synth_emit_alu_gates.nx

synth_emit_alu_gates.nx

buildroot/runtime/_hdl_build/synth_emit_alu_gates.nx

5342 B136 linesdepth 10pulls 12 transitivereach 2 importersview sourcekind librarytopic synth
docsdependenciesstructsconstsfunctions

about

synth_emit_alu_gates.nx -- per-module ALU emitter for .nxgate. First per-RTL-module emitter in the SOVEREIGN canonical chain. Pairs with synth_emit_alu.nx (Wheeler-only Verilog emit, commit d43fbb4) but emits the .nxgate format from nishi_synth_gates.nx (commit 04bca84) instead. Verilog version stays as a test comparator; THIS is the path that ships. Strategy: 29-way cascade MUX over per-op sub-networks. For each op kind K in NX_RV64IM_ALU_*: sub_K = result of K's compute (one cell each for ADD/SUB/...) match_K = (op_in == K_constant) Cascade MUX (associative): intermediate_0 = sub_INVALID (= 64'b0) intermediate_K = mux(match_K, sub_K, intermediate_K-1) result = intermediate_LAST Cell count: ~29 sub-networks + ~29 match constants + ~29 EQ cells + ~29 MUX cells + small overhead = ~150 cells. Trivial for nishi-synth to place on ECP5 BRAM-rich fabric (each ECP5 slice has 4 LUT4 + 4 DFF; 150 cells fits in <50 slices). Status: SEED. 2026-05-26. Covers all 29 NX_RV64IM_ALU_* ops. Multiply-high (mulh/mulhsu/mulhu) emits the cell but downstream synth needs to implement the 64x64->128 multiplier (TODO_SILICON in rv64im_min_alu.nx already noted).

dependencies 6 imports · 2 importers

nx_syscalls.nx nishi_hdl_primitives.nx nishi_synth_gates.nx rv64im_min_alu.nx nx_alu_op_kind.nx nx_alu_select.nx synth_emit_alu_gates.nx nx_alu_emit_text_test.nx synth_emit_alu_gates_smoke.nx

imports: nx_syscalls.nxnishi_hdl_primitives.nxnishi_synth_gates.nxrv64im_min_alu.nxnx_alu_op_kind.nxnx_alu_select.nx

imported by: nx_alu_emit_text_test.nxsynth_emit_alu_gates_smoke.nx

structs

95struct NxAluGateBuild

consts

none

functions

39func nx_alu_alloc_wire(m: *NxHdlModule, width: i64) -> i64
44func nx_alu_emit_const_u8(s: *NxSynthSink, m: *NxHdlModule, value: i64, cell_id: i64) -> i64
52func nx_alu_emit_op_match(s: *NxSynthSink, m: *NxHdlModule,
64func nx_alu_emit_binop(s: *NxSynthSink, m: *NxHdlModule,
76func nx_alu_emit_mux_step(s: *NxSynthSink, m: *NxHdlModule,
102func nx_emit_alu_gates(s: *NxSynthSink, m: *NxHdlModule,