CIRCT 22.0.0git
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
GenericLUT Struct Reference

A generic K-input LUT pattern that can implement any boolean function with up to K inputs using a lookup table. More...

Inheritance diagram for GenericLUT:
Inheritance graph
[legend]
Collaboration diagram for GenericLUT:
Collaboration graph
[legend]

Public Member Functions

 GenericLUT (mlir::MLIRContext *context, unsigned k)
 
std::optional< MatchResultmatch (CutEnumerator &enumerator, const Cut &cut) const override
 Check if a cut matches this pattern and compute area/delay metrics.
 
llvm::FailureOr< Operation * > rewrite (mlir::OpBuilder &rewriter, CutEnumerator &enumerator, const Cut &cut) const override
 Return a new operation that replaces the matched cut.
 
unsigned getNumOutputs () const override
 Get the number of outputs this pattern produces.
 
StringRef getPatternName () const override
 Get the name of this pattern. Used for debugging.
 
- Public Member Functions inherited from circt::synth::CutRewritePattern
 CutRewritePattern (mlir::MLIRContext *context)
 
virtual ~CutRewritePattern ()=default
 Virtual destructor for base class.
 
virtual bool useTruthTableMatcher (SmallVectorImpl< NPNClass > &matchingNPNClasses) const
 Specify truth tables that this pattern can match.
 
virtual LocationAttr getLoc () const
 Get location for this pattern(optional).
 
mlir::MLIRContext * getContext () const
 

Public Attributes

unsigned k
 
SmallVector< DelayType, 8 > cachedDelays
 

Detailed Description

A generic K-input LUT pattern that can implement any boolean function with up to K inputs using a lookup table.

Definition at line 43 of file GenericLUTMapper.cpp.

Constructor & Destructor Documentation

◆ GenericLUT()

GenericLUT::GenericLUT ( mlir::MLIRContext *  context,
unsigned  k 
)
inline

Definition at line 47 of file GenericLUTMapper.cpp.

Member Function Documentation

◆ getNumOutputs()

unsigned GenericLUT::getNumOutputs ( ) const
inlineoverridevirtual

Get the number of outputs this pattern produces.

Implements circt::synth::CutRewritePattern.

Definition at line 91 of file GenericLUTMapper.cpp.

◆ getPatternName()

StringRef GenericLUT::getPatternName ( ) const
inlineoverridevirtual

Get the name of this pattern. Used for debugging.

Reimplemented from circt::synth::CutRewritePattern.

Definition at line 93 of file GenericLUTMapper.cpp.

◆ match()

std::optional< MatchResult > GenericLUT::match ( CutEnumerator enumerator,
const Cut cut 
) const
inlineoverridevirtual

Check if a cut matches this pattern and compute area/delay metrics.

This method is called to determine if a cut can be replaced by this pattern. If the cut matches, it should return a MatchResult containing the area and per-input delays for this specific cut.

If useTruthTableMatcher() returns true, this method is only called for cuts with matching truth tables.

Implements circt::synth::CutRewritePattern.

Definition at line 50 of file GenericLUTMapper.cpp.

References cachedDelays, circt::synth::Cut::getInputSize(), circt::synth::Cut::getOutputSize(), and k.

◆ rewrite()

llvm::FailureOr< Operation * > GenericLUT::rewrite ( mlir::OpBuilder &  builder,
CutEnumerator enumerator,
const Cut cut 
) const
inlineoverridevirtual

Return a new operation that replaces the matched cut.

Unlike MLIR's RewritePattern framework which allows arbitrary in-place modifications, this method creates a new operation to replace the matched cut rather than modifying existing operations. This constraint exists because the cut enumerator maintains references to operations throughout the circuit, making it safe to only replace the root operation of each cut while preserving all other operations unchanged.

Implements circt::synth::CutRewritePattern.

Definition at line 61 of file GenericLUTMapper.cpp.

References circt::synth::Cut::dump(), circt::synth::Cut::getInputSize(), circt::synth::Cut::getRoot(), circt::synth::Cut::getTruthTable(), circt::synth::Cut::inputs, and k.

Member Data Documentation

◆ cachedDelays

SmallVector<DelayType, 8> GenericLUT::cachedDelays

Definition at line 45 of file GenericLUTMapper.cpp.

Referenced by match().

◆ k

unsigned GenericLUT::k

Definition at line 44 of file GenericLUTMapper.cpp.

Referenced by match(), and rewrite().


The documentation for this struct was generated from the following file: