code wiki / _hdl_build / nx_alu_divider_floor_test.nx

nx_alu_divider_floor_test.nx

buildroot/runtime/_hdl_build/nx_alu_divider_floor_test.nx

3857 B87 linesdepth 8pulls 8 transitivereach 0 importersview sourcekind gate/prooftopic alu
docsdependenciesstructsconstsfunctions

about

nx_alu_divider_floor_test.nx -- COMPLETE THE FLOOR (honest step 0 toward the real divider exceed). The original floor was incomplete: it used a SIGNED compare for an unsigned remainder, so it broke for large operands (the rem<<1 overflow into the sign bit). Now the divider uses LTU (true unsigned compare), so it is correct over the FULL non-negative i64 range, INCLUDING the large-b overflow cases the signed compare got wrong. Verified here at width 63 over the whole non-negative range: 200000 randomized (a,b) in [0, 2^63) via an LCG -- which naturally exercises b in (2^62, 2^63) where rem<<1 overflows the sign bit and LTU is REQUIRED -- plus a few edges, each checked 1:1 vs behavioral a/b + a%b (signed `/` is a valid oracle since both operands are < 2^63). HONEST: this is heavy RANDOMIZED testing over the full range (exhaustive is impossible at 63-bit) -- a completed FLOOR, NOT yet the machine-checked-proof EXCEED (that needs a sovereign BMC/equivalence engine; full 64-bit unsigned with b>=2^63 needs >64-bit intermediates; signed division also still owed). Known answer (FAIL LOUD): "200003 200003 " (ok, total). exit 0 iff ok==total.

dependencies 1 imports · 0 importers

nx_alu_divider.nx nx_alu_divider_floor_test.nx

imports: nx_alu_divider.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nx_div_synth nx_sink_init_mem nx_div_synth_sink nx_sink_const nx_hdl_wire nx_hdl_signal_alloc nx_hdl_kind_is_valid nx_hdl_width_is_valid nx_sink_cell nx_hdl_wire ↻ sys_mmap nx_gsim_run nx_gsim_kind_supported nx_gsim_eval_cell _emit_num _nl

structs

none

consts

22const MASK63: i64 = 9223372036854775807 // 2^63 - 1
23const LCG_A: i64 = 6364136223846793005
24const LCG_C: i64 = 1442695040888963407

functions

26func _emit_num(v: i64) -> i64
called by 1: main
34func _nl() -> i64 { let z: *u8 = sys_mmap(2); z[0] = 10; sys_write(1, z, 1); return 0 }
called by 1: main
36func main() -> i64