CIRCT 22.0.0git
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
circt::synth::CutRewriter Class Reference

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

#include <CutRewriter.h>

Collaboration diagram for circt::synth::CutRewriter:
Collaboration graph
[legend]

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.
 

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< MatchedPatternpatternMatchCut (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 CutRewriterOptionsoptions
 Configuration options.
 
const CutRewritePatternSetpatterns
 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;
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.
Main cut-based rewriting algorithm for combinational logic optimization.
const CutRewriterOptions & options
Configuration options.
const CutRewritePatternSet & patterns
Available rewriting patterns.
Configuration options for the cut-based rewriting algorithm.
unsigned maxCutInputSize
Maximum number of inputs allowed for any cut.
unsigned maxCutSizePerRoot
Maximum number of cuts to maintain per logic node.
OptimizationStrategy strategy
Optimization strategy (area vs. timing).

Definition at line 456 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 459 of file CutRewriter.h.

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 906 of file CutRewriter.cpp.

References cutEnumerator, circt::synth::CutEnumerator::enumerateCuts(), 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 917 of file CutRewriter.cpp.

References circt::synth::Cut::getNPNClass().

Referenced by patternMatchCut().

◆ patternMatchCut()

std::optional< MatchedPattern > CutRewriter::patternMatchCut ( const Cut cut)
private

◆ 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 861 of file CutRewriter.cpp.

References cutEnumerator, circt::synth::CutEnumerator::dump(), enumerateCuts(), circt::synth::CutRewriterOptions::maxCutInputSize, circt::synth::CutRewriterOptions::maxCutSizePerRoot, circt::synth::OptimizationStrategyArea, options, pattern, runBottomUpRewrite(), circt::synth::CutRewriterOptions::strategy, circt::synth::CutRewriterOptions::testPriorityCuts, and circt::synth::topologicallySortLogicNetwork().

Referenced by GenericLUTMapperPass::runOnOperation().

◆ runBottomUpRewrite()

LogicalResult CutRewriter::runBottomUpRewrite ( Operation *  topOp)
private

Member Data Documentation

◆ cutEnumerator

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

Definition at line 493 of file CutRewriter.h.

Referenced by enumerateCuts(), patternMatchCut(), run(), and runBottomUpRewrite().

◆ options

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

Configuration options.

Definition at line 488 of file CutRewriter.h.

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

◆ patterns

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

Available rewriting patterns.

Definition at line 491 of file CutRewriter.h.


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