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)
 
bool match (const Cut &cut) const override
 Check if a cut matches this pattern.
 
llvm::FailureOr< Operation * > rewrite (mlir::OpBuilder &rewriter, Cut &cut) const override
 Return a new operation that replaces the matched cut.
 
double getArea (const Cut &cut) const override
 Get the area cost of this pattern.
 
DelayType getDelay (unsigned inputIndex, unsigned outputIndex) const override
 Get the delay between specific input and output.
 
unsigned getNumInputs () const override
 Get the number of inputs this pattern expects.
 
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
 

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 46 of file GenericLUTMapper.cpp.

Member Function Documentation

◆ getArea()

double GenericLUT::getArea ( const Cut cut) const
inlineoverridevirtual

Get the area cost of this pattern.

Implements circt::synth::CutRewritePattern.

Definition at line 86 of file GenericLUTMapper.cpp.

◆ getDelay()

DelayType GenericLUT::getDelay ( unsigned  inputIndex,
unsigned  outputIndex 
) const
inlineoverridevirtual

Get the delay between specific input and output.

NOTE: The input index is already permuted according to the pattern's input permutation, so it's not necessary to account for it here.

Implements circt::synth::CutRewritePattern.

Definition at line 91 of file GenericLUTMapper.cpp.

◆ getNumInputs()

unsigned GenericLUT::getNumInputs ( ) const
inlineoverridevirtual

Get the number of inputs this pattern expects.

Implements circt::synth::CutRewritePattern.

Definition at line 96 of file GenericLUTMapper.cpp.

References k.

◆ getNumOutputs()

unsigned GenericLUT::getNumOutputs ( ) const
inlineoverridevirtual

Get the number of outputs this pattern produces.

Implements circt::synth::CutRewritePattern.

Definition at line 98 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 100 of file GenericLUTMapper.cpp.

◆ match()

bool GenericLUT::match ( const Cut cut) const
inlineoverridevirtual

Check if a cut matches this pattern.

This method is called to determine if a cut can be replaced by this pattern. If useTruthTableMatcher() returns true, this method is only called for cuts with matching truth tables.

Implements circt::synth::CutRewritePattern.

Definition at line 49 of file GenericLUTMapper.cpp.

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

◆ rewrite()

llvm::FailureOr< Operation * > GenericLUT::rewrite ( mlir::OpBuilder &  builder,
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 54 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

◆ k

unsigned GenericLUT::k

Definition at line 44 of file GenericLUTMapper.cpp.

Referenced by getNumInputs(), match(), and rewrite().


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