[Synth] Add MajorityInverterOp (synth.mig.maj_inv) to Synth dialect #8912
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Towards #8786, this commit introduces a new MajorityInverterOp operation to represent majority-inverter gates in Majority-Inverter Graphs (MIG) for synthesis (https://ieeexplore.ieee.org/document/7293649). Majority-Inverter Graphs have become a prominent representation for logic synthesis in recent years, offering advantages in certain optimization scenarios alongside And-Inverter Graphs (AIG).
The implementation provides a synth.mig.maj_inv operation that computes the majority function of its inputs with optional inversion per operand. The operation requires an odd number of operands to avoid ties in majority computation and uses a custom assembly format with 'not' keyword prefix for inverted inputs.
The majority function returns 1 when more than half of the inputs are 1. For three inputs, it's equivalent to: (a & b) | (a & c) | (b & c).
This addition aligns with the goal of making the circt-synth pipeline handle both AIG and MIG representations seamlessly, providing flexibility in choosing the most appropriate intermediate representation (or mix them). Also MIG can represent and/or/carry in a single depth (and-inverter takes 2 depth for or/carry) so would be slightly accurate metric as logic depth.
Example usage: