pub fn emit_shared_divider_verilog() -> StringExpand description
Emit the SHARED ITERATIVE DIVIDER — one sequential restoring divider that computes signed
quotient AND remainder, replacing the ~24,600-cell COMBINATIONAL $signed(a)/$signed(b) +
$signed(a)%$signed(b) the ALU instantiates per-op (Div/Mod/FloorDiv). It costs 833 LUT / 204 FF
placed-and-routed on the ECP5-85K at ~100 MHz — a ~26× LUT drop vs the ~22,000-LUT combinational
divide, the lever that fits the full 113-op CPU under 83,640. Truncated (round-toward-zero)
semantics matching the VM: quotient sign = sign(a)^sign(b), remainder sign = sign(a); b==0 →
q=r=0. One 1-bit/cycle restoring loop over |a|/|b| (W cycles) then a sign fixup; the soft-core
pulses start and stalls until done. The module is Verilog-parameterized (default W=32;
instantiate #(.W(64)) for the BigInt lane), so this emitter is the single source for the on-disk
shared_divider.v, proven == the combinational oracle by iverilog (emit_shared_divider_testbench).