|
CIRCT 23.0.0git
|
Represents a cut in the combinational logic network. More...
#include <CutRewriter.h>

Public Member Functions | |
| Cut ()=default | |
| Cut (uint32_t rootIndex, ArrayRef< uint32_t > inputs, uint64_t signature, ArrayRef< const Cut * > operandCuts={}, std::optional< BinaryTruthTable > truthTable=std::nullopt) | |
| bool | isTrivialCut () const |
| Check if this cut represents a trivial cut. | |
| uint32_t | getRootIndex () const |
| Get the root index in the LogicNetwork. | |
| void | setRootIndex (uint32_t idx) |
| Set the root index of this cut. | |
| uint64_t | getSignature () const |
| Get the signature of this cut. | |
| void | setSignature (uint64_t sig) |
| Set the signature of this cut. | |
| bool | dominates (const Cut &other) const |
| Check if this cut dominates another (i.e., this cut's inputs are a subset of the other's inputs). | |
| bool | dominates (ArrayRef< uint32_t > otherInputs, uint64_t otherSig) const |
| Check if this cut dominates a set of sorted inputs with the given signature. | |
| void | dump (llvm::raw_ostream &os, const LogicNetwork &network) const |
| unsigned | getInputSize () const |
| Get the number of inputs to this cut. | |
| unsigned | getOutputSize (const LogicNetwork &network) const |
| Get the number of outputs from root operation. | |
| const std::optional< BinaryTruthTable > & | getTruthTable () const |
| Get the truth table for this cut. | |
| void | computeTruthTableFromOperands (const LogicNetwork &network) |
| Compute truth table using fast incremental method from operand cuts. | |
| void | setTruthTable (BinaryTruthTable tt) |
| Set the truth table directly (used for incremental computation). | |
| void | setOperandCuts (ArrayRef< const Cut * > cuts) |
| Set operand cuts for lazy truth table computation. | |
| ArrayRef< const Cut * > | getOperandCuts () const |
| Get operand cuts (for fast TT computation). | |
| const NPNClass & | getNPNClass () const |
| Get the NPN canonical form for this cut. | |
| const NPNClass & | getNPNClass (const NPNTable *npnTable) const |
| void | getPermutatedInputIndices (const NPNTable *npnTable, const NPNClass &patternNPN, SmallVectorImpl< unsigned > &permutedIndices) const |
| Get the permutated inputs for this cut based on the given pattern NPN. | |
| LogicalResult | getInputArrivalTimes (CutEnumerator &enumerator, SmallVectorImpl< DelayType > &results) const |
| Get arrival times for each input of this cut. | |
| void | setMatchedPattern (MatchedPattern pattern) |
| Matched pattern for this cut. | |
| const std::optional< MatchedPattern > & | getMatchedPattern () const |
| Get the matched pattern for this cut. | |
Static Public Member Functions | |
| static Cut | getTrivialCut (uint32_t index) |
| Create a trivial cut for a value. | |
Public Attributes | |
| llvm::SmallVector< uint32_t, 6 > | inputs |
| External inputs to this cut (cut boundary). | |
Private Attributes | |
| std::optional< BinaryTruthTable > | truthTable |
| Cached truth table for this cut. | |
| std::optional< NPNClass > | npnClass |
| Cached NPN canonical form for this cut. | |
| std::optional< MatchedPattern > | matchedPattern |
| uint32_t | rootIndex = 0 |
| Root index in LogicNetwork (0 indicates no root for a trivial cut). | |
| uint64_t | signature = 0 |
| Signature bitset for fast cut size estimation. | |
| llvm::SmallVector< const Cut *, 3 > | operandCuts |
| Operand cuts used to create this cut (for lazy TT computation). | |
Represents a cut in the combinational logic network.
A cut is a subset of nodes in the combinational logic that forms a complete subgraph with a single output. It represents a portion of the circuit that can potentially be replaced with a single library gate or pattern.
The cut contains:
Cuts are used in combinational logic optimization to identify regions that can be optimized and replaced with more efficient implementations.
Definition at line 388 of file CutRewriter.h.
|
default |
|
inline |
Definition at line 416 of file CutRewriter.h.
| void Cut::computeTruthTableFromOperands | ( | const LogicNetwork & | network | ) |
Compute truth table using fast incremental method from operand cuts.
Trivial cuts are handled directly; non-trivial cuts require that operand cuts have already been set via setOperandCuts.
Definition at line 604 of file CutRewriter.cpp.
References assert(), circt::synth::LogicNetwork::getGate(), inputs, isTrivialCut(), operandCuts, rootIndex, and truthTable.
Referenced by circt::synth::CutSet::finalize().
| bool Cut::dominates | ( | ArrayRef< uint32_t > | otherInputs, |
| uint64_t | otherSig | ||
| ) | const |
Check if this cut dominates a set of sorted inputs with the given signature.
Definition at line 622 of file CutRewriter.cpp.
References getInputSize(), inputs, and signature.
| bool Cut::dominates | ( | const Cut & | other | ) | const |
Check if this cut dominates another (i.e., this cut's inputs are a subset of the other's inputs).
Uses signature pre-filtering for speed. Both cuts must have sorted inputs.
Definition at line 618 of file CutRewriter.cpp.
References dominates(), inputs, and signature.
Referenced by dominates().
| void Cut::dump | ( | llvm::raw_ostream & | os, |
| const LogicNetwork & | network | ||
| ) | const |
Definition at line 413 of file CutRewriter.cpp.
References circt::synth::LogicNetwork::getGate(), getInputSize(), getNPNClass(), circt::synth::LogicNetworkGate::getOperation(), circt::synth::LogicNetwork::getValue(), inputs, isTrivialCut(), npnClass, and rootIndex.
Referenced by circt::synth::CutRewriter::patternMatchCut(), and GenericLUT::rewrite().
| LogicalResult Cut::getInputArrivalTimes | ( | CutEnumerator & | enumerator, |
| SmallVectorImpl< DelayType > & | results | ||
| ) | const |
Get arrival times for each input of this cut.
Returns failure if any input doesn't have a valid matched pattern.
Definition at line 379 of file CutRewriter.cpp.
References assert(), circt::synth::CutEnumerator::getCutSet(), getInputSize(), circt::synth::CutEnumerator::getLogicNetwork(), inputs, isAlwaysCutInput(), and matchedPattern.
Referenced by circt::synth::CutRewriter::patternMatchCut().
| unsigned Cut::getInputSize | ( | ) | const |
Get the number of inputs to this cut.
Definition at line 449 of file CutRewriter.cpp.
References inputs.
Referenced by dominates(), dump(), circt::synth::CutSet::finalize(), getInputArrivalTimes(), GenericLUT::match(), circt::synth::CutRewriter::patternMatchCut(), removeDuplicateAndNonMinimalCuts(), GenericLUT::rewrite(), and circt::synth::CutEnumerator::visitLogicOp().
|
inline |
Get the matched pattern for this cut.
Definition at line 509 of file CutRewriter.h.
References matchedPattern.
Referenced by circt::synth::CutEnumerator::dump(), and circt::synth::CutSet::finalize().
| const NPNClass & Cut::getNPNClass | ( | ) | const |
Get the NPN canonical form for this cut.
This is used for efficient pattern matching against library components.
Definition at line 356 of file CutRewriter.cpp.
References getNPNClass().
Referenced by dump(), circt::synth::CutRewriter::getMatchingPatternsFromTruthTable(), getNPNClass(), getPermutatedInputIndices(), TechLibraryPattern::match(), and circt::synth::CutRewriter::patternMatchCut().
Definition at line 358 of file CutRewriter.cpp.
References circt::NPNClass::computeNPNCanonicalForm(), getTruthTable(), circt::NPNTable::lookup(), npnClass, and truthTable.
|
inline |
Get operand cuts (for fast TT computation).
Definition at line 484 of file CutRewriter.h.
References operandCuts.
| unsigned Cut::getOutputSize | ( | const LogicNetwork & | network | ) | const |
Get the number of outputs from root operation.
Definition at line 451 of file CutRewriter.cpp.
References circt::synth::LogicNetwork::getGate(), circt::synth::LogicNetworkGate::getOperation(), and rootIndex.
Referenced by GenericLUT::match(), and circt::synth::CutRewriter::patternMatchCut().
| void Cut::getPermutatedInputIndices | ( | const NPNTable * | npnTable, |
| const NPNClass & | patternNPN, | ||
| SmallVectorImpl< unsigned > & | permutedIndices | ||
| ) | const |
Get the permutated inputs for this cut based on the given pattern NPN.
Returns indices into the inputs vector.
Definition at line 371 of file CutRewriter.cpp.
References getNPNClass(), and npnClass.
Referenced by TechLibraryPattern::rewrite().
|
inline |
Get the root index in the LogicNetwork.
Definition at line 436 of file CutRewriter.h.
References rootIndex.
Referenced by TechLibraryPattern::rewrite(), and GenericLUT::rewrite().
|
inline |
Get the signature of this cut.
Definition at line 442 of file CutRewriter.h.
References signature.
Referenced by circt::synth::CutEnumerator::visitLogicOp().
|
static |
Create a trivial cut for a value.
Definition at line 634 of file CutRewriter.cpp.
References inputs, setSignature(), and setTruthTable().
Referenced by circt::synth::CutEnumerator::getCutSet(), and circt::synth::CutEnumerator::visitLogicOp().
|
inline |
Get the truth table for this cut.
The truth table represents the boolean function computed by this cut.
Definition at line 466 of file CutRewriter.h.
References truthTable.
Referenced by circt::synth::CutEnumerator::dump(), circt::synth::CutSet::finalize(), getNPNClass(), and GenericLUT::rewrite().
| bool Cut::isTrivialCut | ( | ) | const |
Check if this cut represents a trivial cut.
A trivial cut has no root operation and exactly one input.
Definition at line 350 of file CutRewriter.cpp.
References inputs, and rootIndex.
Referenced by computeTruthTableFromOperands(), dump(), and circt::synth::CutRewriter::patternMatchCut().
|
inline |
Matched pattern for this cut.
Definition at line 504 of file CutRewriter.h.
References matchedPattern, and pattern.
Referenced by circt::synth::CutSet::finalize().
|
inline |
Set operand cuts for lazy truth table computation.
Definition at line 479 of file CutRewriter.h.
References operandCuts.
|
inline |
|
inline |
Set the signature of this cut.
Definition at line 445 of file CutRewriter.h.
References signature.
Referenced by getTrivialCut().
|
inline |
Set the truth table directly (used for incremental computation).
Definition at line 476 of file CutRewriter.h.
References truthTable.
Referenced by getTrivialCut().
| llvm::SmallVector<uint32_t, 6> circt::synth::Cut::inputs |
External inputs to this cut (cut boundary).
Stored as LogicNetwork indices for efficient operations.
Definition at line 429 of file CutRewriter.h.
Referenced by computeTruthTableFromOperands(), dominates(), dominates(), circt::synth::CutEnumerator::dump(), dump(), getInputArrivalTimes(), getInputSize(), getTrivialCut(), isTrivialCut(), removeDuplicateAndNonMinimalCuts(), TechLibraryPattern::rewrite(), GenericLUT::rewrite(), and circt::synth::CutEnumerator::visitLogicOp().
|
private |
Definition at line 397 of file CutRewriter.h.
Referenced by getInputArrivalTimes(), getMatchedPattern(), and setMatchedPattern().
|
mutableprivate |
Cached NPN canonical form for this cut.
Computed lazily from the truth table when first accessed.
Definition at line 395 of file CutRewriter.h.
Referenced by dump(), getNPNClass(), and getPermutatedInputIndices().
|
private |
Operand cuts used to create this cut (for lazy TT computation).
Stored to enable fast incremental truth table computation after duplicate removal. Using raw pointers is safe since cuts are allocated via bump allocator and live for the duration of enumeration.
Definition at line 412 of file CutRewriter.h.
Referenced by computeTruthTableFromOperands(), getOperandCuts(), and setOperandCuts().
|
private |
Root index in LogicNetwork (0 indicates no root for a trivial cut).
The root node produces the output of the cut.
Definition at line 401 of file CutRewriter.h.
Referenced by computeTruthTableFromOperands(), dump(), getOutputSize(), getRootIndex(), isTrivialCut(), and setRootIndex().
|
private |
Signature bitset for fast cut size estimation.
Bit i is set if value with index i is in the cut's inputs. This enables O(1) estimation of merged cut size using popcount.
Definition at line 406 of file CutRewriter.h.
Referenced by dominates(), dominates(), getSignature(), and setSignature().
|
mutableprivate |
Cached truth table for this cut.
Computed lazily when first accessed to avoid unnecessary computation.
Definition at line 391 of file CutRewriter.h.
Referenced by computeTruthTableFromOperands(), getNPNClass(), getTruthTable(), and setTruthTable().