CIRCT 24.0.0git
Loading...
Searching...
No Matches
circt::synth::CutRewriter Class Reference

Main cut-based rewriting algorithm for combinational logic optimization. More...

#include <CutRewriter.h>

Collaboration diagram for circt::synth::CutRewriter:

Public Member Functions

 CutRewriter (const CutRewriterOptions &options, CutRewritePatternSet &patterns)
 Constructor for the cut rewriter.
LogicalResult run (Operation *topOp)
 Execute the complete cut-based rewriting algorithm.
const CutEnumeratorStats & getStats () const

Private Member Functions

LogicalResult enumerateCuts (Operation *topOp)
 Enumerate cuts for all nodes in the given module.
ArrayRef< std::pair< NPNClass, const CutRewritePattern * > > getMatchingPatternsFromTruthTable (const Cut &cut) const
 Find patterns that match a cut's truth table.
std::optional< MatchedPattern > patternMatchCut (const Cut &cut)
 Match a cut against available patterns and compute arrival time.
LogicalResult runBottomUpRewrite (Operation *topOp)
 Perform the actual circuit rewriting using selected patterns.

Private Attributes

const CutRewriterOptions & options
 Configuration options.
const CutRewritePatternSet & patterns
 Available rewriting patterns.
CutEnumerator cutEnumerator

Detailed Description

Main cut-based rewriting algorithm for combinational logic optimization.

The CutRewriter implements a cut-based rewriting algorithm that:

  1. Enumerates cuts in the combinational logic network using a priority cuts algorithm
  2. Matches cuts against available rewriting patterns
  3. Selects optimal patterns based on area or timing objectives
  4. Rewrites the circuit using the selected patterns

The algorithm processes the network in topological order, building up cut sets for each node and selecting the best implementation based on the specified optimization strategy.

Usage example:

options.strategy = OptimizationStrategy::Area;
options.maxCutInputSize = 4;
options.maxCutSizePerRoot = 8;
CutRewritePatternSet patterns(std::move(optimizationPatterns));
CutRewriter rewriter(module, options, patterns);
if (failed(rewriter.run())) {
// Handle rewriting failure
}
Manages a collection of rewriting patterns for combinational logic optimization.
const CutRewriterOptions & options
Configuration options.
const CutRewritePatternSet & patterns
Available rewriting patterns.
CutRewriter(const CutRewriterOptions &options, CutRewritePatternSet &patterns)
Constructor for the cut rewriter.
Configuration options for the cut-based rewriting algorithm.

Definition at line 851 of file CutRewriter.h.

Constructor & Destructor Documentation

◆ CutRewriter()

circt::synth::CutRewriter::CutRewriter ( const CutRewriterOptions & options,
CutRewritePatternSet & patterns )
inline

Constructor for the cut rewriter.

Definition at line 854 of file CutRewriter.h.

References cutEnumerator, and options.

Member Function Documentation

◆ enumerateCuts()

LogicalResult CutRewriter::enumerateCuts ( Operation * topOp)
private

Enumerate cuts for all nodes in the given module.

Note: This preserves module boundaries and does not perform rewriting across the hierarchy.

Definition at line 1322 of file CutRewriter.cpp.

References cutEnumerator, and patternMatchCut().

Referenced by run().

◆ getMatchingPatternsFromTruthTable()

ArrayRef< std::pair< NPNClass, const CutRewritePattern * > > CutRewriter::getMatchingPatternsFromTruthTable ( const Cut & cut) const
private

Find patterns that match a cut's truth table.

Definition at line 1333 of file CutRewriter.cpp.

References circt::synth::Cut::getNPNClass(), and options.

Referenced by patternMatchCut().

◆ getStats()

const CutEnumeratorStats & circt::synth::CutRewriter::getStats ( ) const
inline

◆ patternMatchCut()

◆ run()

LogicalResult CutRewriter::run ( Operation * topOp)

Execute the complete cut-based rewriting algorithm.

This method orchestrates the entire rewriting process:

  1. Enumerate cuts for all nodes in the combinational logic
  2. Match cuts against available patterns
  3. Select optimal patterns based on strategy
  4. Rewrite the circuit with selected patterns

Definition at line 1278 of file CutRewriter.cpp.

References cutEnumerator, enumerateCuts(), failure(), circt::synth::OptimizationStrategyArea, options, runBottomUpRewrite(), success(), and circt::synth::topologicallySortLogicNetwork().

Referenced by GenericLUTMapperPass::runOnOperation(), and SOPBalancingPass::runOnOperation().

◆ runBottomUpRewrite()

LogicalResult CutRewriter::runBottomUpRewrite ( Operation * topOp)
private

Perform the actual circuit rewriting using selected patterns.

Definition at line 1442 of file CutRewriter.cpp.

References cutEnumerator, circt::UnusedOpPruner::eraseNow(), failure(), isAlwaysCutInput(), options, and success().

Referenced by run().

Member Data Documentation

◆ cutEnumerator

CutEnumerator circt::synth::CutRewriter::cutEnumerator
private

◆ options

const CutRewriterOptions& circt::synth::CutRewriter::options
private

Configuration options.

Definition at line 887 of file CutRewriter.h.

Referenced by CutRewriter(), getMatchingPatternsFromTruthTable(), patternMatchCut(), run(), and runBottomUpRewrite().

◆ patterns

const CutRewritePatternSet& circt::synth::CutRewriter::patterns
private

Available rewriting patterns.

Definition at line 890 of file CutRewriter.h.


The documentation for this class was generated from the following files: