code wiki / _hdl_build / nx_boolsynth.nx
nx_boolsynth.nx
buildroot/runtime/_hdl_build/nx_boolsynth.nx
about
nx_boolsynth.nx -- a NEW search space: minimal straight-line BOOLEAN circuits for a
3-input function, where verification is EXACT and free. The trick: drive the inputs with
the truth-table columns a=0xAA, b=0xCC, c=0xF0 (the 8 bit positions enumerate all 8 input
combinations in parallel), so a program's output BYTE *is* its truth table. A candidate
matches the target iff (output & 0xFF) == target -- one word op covers ALL inputs, no
execution, no loop. Iterative deepening over op count gives the PROVABLY-MINIMAL circuit
over {AND, OR, XOR, NOT}. This is the class where exhaustive search can beat a heuristic
compiler (the compiler emits the literal expression; the superoptimizer finds the floor).
license_tier: ORIGINAL Refs: Knuth TAOCP 4A 7.1.2 (boolean evaluation); STOKE; souper.
dependencies 1 imports · 10 importers
imports: nx_syscalls.nx
imported by: nx_alu_from_gates_test.nxnx_boolhunt.nxnx_boolsynth_test.nxnx_horizontal_test.nxnx_layer_campaign.nxnx_levels_test.nxnx_multsynth.nxnx_parallel_ingest.nxnx_search_governor_test.nxnx_team_tick.nx
structs
| none |
consts
| 13 | const BL_AND: i64 = 0 |
| 14 | const BL_OR: i64 = 1 |
| 15 | const BL_XOR: i64 = 2 |
| 16 | const BL_NOT: i64 = 3 // unary: ~a |
| 19 | const BL_A: i64 = 170 // 0xAA |
| 20 | const BL_B: i64 = 204 // 0xCC |
| 21 | const BL_C: i64 = 240 // 0xF0 |
functions
| 23 | func bl_is_unary(op: i64) -> i64 { if op == BL_NOT { return 1 } return 0 } |
| 24 | func bl_eval(op: i64, va: i64, vb: i64) -> i64 |
| 33 | func bl_enum(op: *i64, a: *i64, b: *i64, t: i64, L: i64, sv: *i64, target: i64) -> i64 |
| 67 | func bl_find(target: i64, op: *i64, a: *i64, b: *i64, maxL: i64) -> i64 |
| 82 | func bl_opname(o: i64) -> *u8 called by 1: bt_one |