-
Notifications
You must be signed in to change notification settings - Fork 383
[Synth] Add Priority Cuts Enumerator #8818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e044ee4 to
a3c70ab
Compare
This is the first commit introducing a cut-based rewriting framework for combinational logic optimization. Cut-based rewriting is a fundamental technique in logic synthesis which are used for not only technology mapping/LUT mappping but also logic optimization by identifying and replacing subgraphs (cuts) in combinational circuits with functionally equivalent but more optimal implementations. This initial implementation focuses specifically on priority cuts enumeration as the foundation for future cut-based optimization passes. The framework includes a Cut data structure for representing logical cuts with truth tables, a CutEnumerator implementing the priority cuts algorithm with configurable limits, cut enumeration with size constraints and deduplication, truth table computation and NPN canonical form matching, support for AIG operations with comprehensive error handling, and test infrastructure for priority cuts validation. The priority cuts algorithm maintains a bounded set of promising cuts per node to avoid exponential explosion while preserving optimization quality. This foundation enables future development of technology mapping, LUT mapping, and other cut-based combinational optimization passes.
a3c70ab to
2b80560
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very very cool! Only a few nits here and there. The test pass is a great idea. Makes this whole thing a lot more hackable and interactive.
| // CHECK-LABEL: Enumerating cuts for module: trivial | ||
| hw.module @trivial(in %a : i1, out result : i1) { | ||
| // CHECK: a 1 cuts: {a}@t2d0 | ||
| // CHECK-NEXT: out0 2 cuts: {out0}@t2d0 {a}@t2d1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool that this already gives you the minimal truth table 😍
| // Simulate the operations in the cut | ||
| for (auto *op : operations) | ||
| simulateLogicOp(op, eval); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool idea to generate these input truth table vectors and then flow them through the ops, essentially vectorizing the circuit evaluation using bitwise logic ops. 🥳
| // Schedule cut set finalization when exiting this scope | ||
| auto prune = llvm::make_scope_exit([&]() { | ||
| // Finalize cut set: remove duplicates, limit size, and match patterns | ||
| resultCutSet->finalize(options); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clever!
db359c6 to
a4adb18
Compare
a4adb18 to
9241902
Compare
|
Sorry I couldn't get to this quickly enough - but looks really interesting - did have two questions though:
|
|
Thank you for taking a look! Sorry I was a bit rush to merge :)
|
This is the first commit introducing a cut-based rewriting framework for combinational logic optimization. Cut-based rewriting is a fundamental technique in logic synthesis which are used for not only technology mapping/LUT mappping but also logic optimization by identifying and replacing subgraphs (cuts) in combinational circuits with functionally equivalent but more optimal implementations (ABC's rewrite and lazy man's synthesis etc, mockturtle's cut rewriting )
This initial implementation focuses specifically on priority cuts enumeration as the foundation for future cut-based optimization passes. The framework includes a Cut data structure for representing logical cuts with truth tables, a CutEnumerator implementing the priority cuts algorithm with configurable limits, cut enumeration with size constraints and deduplication, truth table computation and NPN canonical form matching, support for AIG operations.
The implementation is based on ABC's priority cuts paper https://people.eecs.berkeley.edu/~alanmi/publications/2007/iccad07_map.pdf
The priority cuts algorithm maintains a bounded set of promising cuts per node to avoid exponential explosion while preserving optimization quality. This foundation enables future development of technology mapping, LUT mapping, and other cut-based combinational optimization passes.
CutRewriter.h and CutRewriter.cpp are actual implementations of cut enumeration.