This project implements odd-n majority generators in Mockturtle:
- exact methods (
popcount,popcount_strict,cancel_tree,cancel_tree_v2) - an approximate method (
approx_block3) that compresses input triples withmaj3and then runs exact majority on the compressed vector
The repository keeps the source tree plus a curated subset of paper-relevant CSVs/netlists. Bulk generated outputs such as full Vivado run directories, build products, and local logs are intentionally excluded from git.
cmake -S . -B build
cmake --build build -jctest --test-dir build --output-on-failureOr directly:
./build/test_cancel_treeThe test executable performs:
- Exhaustive checks for
n = 3,5,7,9,11 - Random checks (10k vectors each) for
n = 31,63,127 - Equivalence checks vs baseline exact
popcount - Debug summary dumps for
n=7andn=11 - DOT dump
artifacts/maj_7_cancel_tree.dot
./build/majgen --maj_impl cancel_tree --logic_repr xag --n 63 --out out/maj_63_cancel_tree_xag.v --format verilog --stats_json out/maj_63_cancel_tree_xag.jsonSupported methods:
cancel_tree(alias:boyermoore_tree)cancel_tree_v2(alias:boyermoore_tree_v2)popcountpopcount_strict(alias:baseline_strict; scaffolded baseline with CSA + threshold ripple carry)approx_block3(alias:approx_block3_popcount)
Supported output formats:
verilogblifaigdot
Supported internal logic representations:
xagaigmig
majgen now accepts:
--logic_repr <xag|aig|mig>to pick the representation used for emitted netlist andstats_json.
./scripts/run_cancel_tree_eval.py --n-min 5 --n-max 511 --methods popcount,approx_block3 --logic-reprs xag./scripts/run_cancel_tree_eval.py \
--n-min 5 --n-max 511 \
--methods popcount,approx_block3 \
--logic-reprs xag,aig,mig./scripts/run_cancel_tree_eval.py \
--n-min 5 --n-max 511 \
--methods popcount,popcount_strict,approx_block3 \
--logic-reprs xag,aig,migGenerates separate XAG/, AIG/, MIG/ run folders and a single merged CSV that includes:
- original network/device stats from
master_results.csv - ABC optimized stats (
dc2) - ABC mapped stats (
if -K 6)
./scripts/run_strict_vs_approx_sweep.sh 5 61Useful env overrides:
RUN_VIVADO=1(default) orRUN_VIVADO=0FLOW_MODES=synth_only(default) orFLOW_MODES=synth_only,post_routeLOGIC_REPRS=xag,aig,migMETHODS=popcount_strict,approx_block3OUT_PARENT=results/strict_vs_approx_eval
./scripts/run_cancel_tree_eval.py \
--n-min 5 --n-max 511 \
--methods popcount,approx_block3 \
--logic-reprs xag,aig,mig \
--run-vivado \
--vivado-subset 63,127,255,511./scripts/run_cancel_tree_eval.py \
--n-min 5 --n-max 511 \
--methods popcount,approx_block3 \
--logic-reprs xag,aig,mig \
--run-vivado \
--full-sweep-vivado./scripts/run_cancel_tree_eval.py \
--n-min 5 --n-max 511 \
--methods popcount,approx_block3 \
--logic-reprs xag,aig,mig \
--run-accuracy \
--accuracy-ps 0.10,0.25,0.50,0.55,0.75,0.90 \
--accuracy-trials 4000Outputs are written under:
results/cancel_tree_eval/run_<timestamp>/master_results.csvresults/cancel_tree_eval/run_<timestamp>/figures/*.png,*.pdfresults/cancel_tree_eval/run_<timestamp>/tables_cancel_tree.csvresults/cancel_tree_eval/run_<timestamp>/tables_cancel_tree.texresults/cancel_tree_eval/run_<timestamp>/tables_half_resource.csvresults/cancel_tree_eval/run_<timestamp>/tables_half_resource.texresults/cancel_tree_eval/run_<timestamp>/accuracy_results.csv(when--run-accuracy)results/cancel_tree_eval/run_<timestamp>/tables_accuracy.csv(when--run-accuracy)results/cancel_tree_eval/run_<timestamp>/tables_accuracy.tex(when--run-accuracy)results/cancel_tree_eval/run_<timestamp>/report_cancel_tree.md(+ PDF when pandoc is available)
Vivado part defaults to xc7a200tfbg484-1 and flow modes are synth_only and post_route.