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

8547 B175 linesdepth 9pulls 12 transitivereach 1 importersview sourcekind librarytopic alu
docsdependenciesstructsconstsfunctions

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

nx_alu_netlist_build.nx nx_alu_divider.nx rv64im_min_alu.nx nx_mul_wide.nx nx_alu_netlist_build_div.nx nx_alu_divider_alu_test.nx

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

22const NX_MAGIC_4294967295: i64 = 4294967295
23const NX_MAGIC_4294967296: i64 = 4294967296
25const NX_ALU_DIV_WIDTH: i64 = 64

functions

32func nxnl_mulh(g: *NxGsim, na: i64, nb: i64, do_a: i64, do_b: i64) -> i64
52func nxnl_sext32(g: *NxGsim, v: i64) -> i64
69func nxnl_wdiv_u(g: *NxGsim, na: i64, nb: i64, want_rem: i64) -> i64
94func nxnl_wdiv_s(g: *NxGsim, na: i64, nb: i64, want_rem: i64) -> i64
122func nx_alu_netlist_build_div(g: *NxGsim, info: *NxAluNetlist) -> i64