code wiki / _hdl_build / nx_alu_netlist_build_div.nx
nx_alu_netlist_build_div.nx
buildroot/runtime/_hdl_build/nx_alu_netlist_build_div.nx
about
nx_alu_netlist_build_div.nx -- the ALU op-select netlist with the PROVEN
restoring divider (nx_div_synth) wired into the DIV/DIVU/REM/REMU subnets,
in place of the ADD stub. This is the loop's FIRST hardware invention
COMPOSED into context: the Generator (nx_div_synth) emits a divider gate-
network, the Verifier (nx_gsim_run) proves it matches behavioral div/rem
INSIDE the full ALU op-select cascade -- not just in isolation.
Same topology as nx_alu_netlist_build (CONST opcode + subnet + EQ match;
cascade MUX), built in nx_nxgate_sim's append convention (div_const/div_op2/
div_mux from nx_alu_divider.nx) so the divider sub-network slots in directly.
Non-div ops still use the SINGLE-SOURCE nx_alu_op_to_gate_kind (one cell).
DIV/DIVU take the divider's quotient; REM/REMU take its remainder.
Width 64 (full RV64). Operands assumed non-negative + small enough that the
signed LT in the restoring loop equals the unsigned compare -- the documented
V1 envelope of nx_div_synth; the full 64-bit unsigned widening is mechanical.
dependencies 4 imports · 1 importers
imports: nx_alu_netlist_build.nxnx_alu_divider.nxrv64im_min_alu.nxnx_mul_wide.nx
imported by: nx_alu_divider_alu_test.nx
structs
| none |
consts
| 22 | const NX_MAGIC_4294967295: i64 = 4294967295 |
| 23 | const NX_MAGIC_4294967296: i64 = 4294967296 |
| 25 | const NX_ALU_DIV_WIDTH: i64 = 64 |
functions
| 32 | func nxnl_mulh(g: *NxGsim, na: i64, nb: i64, do_a: i64, do_b: i64) -> i64 |
| 52 | func nxnl_sext32(g: *NxGsim, v: i64) -> i64 |
| 69 | func nxnl_wdiv_u(g: *NxGsim, na: i64, nb: i64, want_rem: i64) -> i64 |
| 94 | func nxnl_wdiv_s(g: *NxGsim, na: i64, nb: i64, want_rem: i64) -> i64 |
| 122 | func nx_alu_netlist_build_div(g: *NxGsim, info: *NxAluNetlist) -> i64 called by 1: main calls 8: div_constnx_div_synthnxnl_mulhnxnl_wdiv_unxnl_wdiv_snx_alu_op_to_gate_kind+2 |