code wiki / _hdl_build / nx_boolsynth.nx

nx_boolsynth.nx

buildroot/runtime/_hdl_build/nx_boolsynth.nx

3639 B87 linesdepth 2pulls 2 transitivereach 13 importersview sourcekind library
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_boolsynth.nx nx_alu_from_gates_test.nx nx_boolhunt.nx nx_boolsynth_test.nx nx_horizontal_test.nx nx_layer_campaign.nx nx_levels_test.nx nx_multsynth.nx nx_parallel_ingest.nx nx_search_governor_test.nx nx_team_tick.nx

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

13const BL_AND: i64 = 0
14const BL_OR: i64 = 1
15const BL_XOR: i64 = 2
16const BL_NOT: i64 = 3 // unary: ~a
19const BL_A: i64 = 170 // 0xAA
20const BL_B: i64 = 204 // 0xCC
21const BL_C: i64 = 240 // 0xF0

functions

23func bl_is_unary(op: i64) -> i64 { if op == BL_NOT { return 1 } return 0 }
24func bl_eval(op: i64, va: i64, vb: i64) -> i64
33func bl_enum(op: *i64, a: *i64, b: *i64, t: i64, L: i64, sv: *i64, target: i64) -> i64
67func bl_find(target: i64, op: *i64, a: *i64, b: *i64, maxL: i64) -> i64
82func bl_opname(o: i64) -> *u8
called by 1: bt_one