|
CIRCT 23.0.0git
|
Flat logic network representation for efficient cut enumeration. More...
#include <CutRewriter.h>

Public Member Functions | |
| ArrayRef< LogicNetworkGate > | getGates () const |
| LogicNetwork () | |
| uint32_t | getOrCreateIndex (Value value) |
| Get or create an index for a value. | |
| uint32_t | getIndex (Value value) const |
| Get the raw index for a value. | |
| bool | hasIndex (Value value) const |
| Check if a value has been indexed. | |
| Value | getValue (uint32_t index) const |
| Get the value for a given raw index. | |
| void | getValues (ArrayRef< uint32_t > indices, SmallVectorImpl< Value > &values) const |
| Fill values for the given raw indices. | |
| Signal | getSignal (Value value, bool inverted) const |
| Get a Signal for a value. | |
| Signal | getOrCreateSignal (Value value, bool inverted) |
| Get or create a Signal for a value. | |
| Value | getValue (Signal signal) const |
| Get the value for a given Signal (extracts index from Signal). | |
| const LogicNetworkGate & | getGate (uint32_t index) const |
| Get the gate at a given index. | |
| LogicNetworkGate & | getGate (uint32_t index) |
| Get mutable reference to gate at index. | |
| size_t | size () const |
| Get the total number of nodes in the network. | |
| uint32_t | addPrimaryInput (Value value) |
| Add a primary input to the network. | |
| uint32_t | addGate (Operation *op, LogicNetworkGate::Kind kind, Value result, llvm::ArrayRef< Signal > operands={}) |
| Add a gate with explicit result value and operand signals. | |
| uint32_t | addGate (Operation *op, LogicNetworkGate::Kind kind, llvm::ArrayRef< Signal > operands={}) |
| Add a gate using op->getResult(0) as the result value. | |
| LogicalResult | buildFromBlock (Block *block) |
| Build the logic network from a region/block in topological order. | |
| void | clear () |
| Clear the network and reset to initial state. | |
Static Public Member Functions | |
| static Signal | getConstant0 () |
| Get a LogicEdge representing constant 0. | |
| static Signal | getConstant1 () |
| Get a LogicEdge representing constant 1 (constant 0 inverted). | |
Static Public Attributes | |
| static constexpr uint32_t | kConstant0 = 0 |
| Special constant indices. | |
| static constexpr uint32_t | kConstant1 = 1 |
Private Attributes | |
| llvm::DenseMap< Value, uint32_t > | valueToIndex |
| Map from MLIR Value to network index. | |
| llvm::SmallVector< Value > | indexToValue |
| Map from network index to MLIR Value. | |
| llvm::SmallVector< LogicNetworkGate > | gates |
| Vector of all gates in the network. | |
Flat logic network representation for efficient cut enumeration.
This class provides a mockturtle-style flat representation of the combinational logic network. Each value in the MLIR IR is assigned a unique index, and gates are stored in a contiguous vector for cache efficiency.
The network supports:
Special reserved indices:
Definition at line 191 of file CutRewriter.h.
|
inline |
Definition at line 199 of file CutRewriter.h.
References circt::synth::LogicNetworkGate::Constant, gates, and indexToValue.
|
inline |
Add a gate using op->getResult(0) as the result value.
Definition at line 265 of file CutRewriter.h.
| uint32_t circt::synth::LogicNetwork::addGate | ( | Operation * | op, |
| LogicNetworkGate::Kind | kind, | ||
| Value | result, | ||
| llvm::ArrayRef< Signal > | operands = {} |
||
| ) |
Add a gate with explicit result value and operand signals.
Referenced by buildFromBlock().
| uint32_t LogicNetwork::addPrimaryInput | ( | Value | value | ) |
Add a primary input to the network.
Definition at line 104 of file CutRewriter.cpp.
References gates, getOrCreateIndex(), and circt::synth::LogicNetworkGate::PrimaryInput.
Referenced by buildFromBlock().
| LogicalResult LogicNetwork::buildFromBlock | ( | Block * | block | ) |
Build the logic network from a region/block in topological order.
Returns failure if the IR is not in a valid form.
Definition at line 117 of file CutRewriter.cpp.
References addGate(), addPrimaryInput(), circt::synth::LogicNetworkGate::And2, gates, getOrCreateSignal(), hasIndex(), circt::synth::LogicNetworkGate::Identity, indexToValue, kConstant0, kConstant1, circt::synth::LogicNetworkGate::Maj3, valueToIndex, and circt::synth::LogicNetworkGate::Xor2.
Referenced by circt::synth::CutEnumerator::enumerateCuts().
| void LogicNetwork::clear | ( | ) |
Clear the network and reset to initial state.
Definition at line 232 of file CutRewriter.cpp.
References circt::synth::LogicNetworkGate::Constant, gates, indexToValue, and valueToIndex.
Referenced by circt::synth::CutEnumerator::clear().
|
inlinestatic |
Get a LogicEdge representing constant 0.
Definition at line 209 of file CutRewriter.h.
References kConstant0.
|
inlinestatic |
Get a LogicEdge representing constant 1 (constant 0 inverted).
Definition at line 212 of file CutRewriter.h.
References kConstant0.
|
inline |
Get mutable reference to gate at index.
Definition at line 252 of file CutRewriter.h.
References gates.
|
inline |
Get the gate at a given index.
Definition at line 249 of file CutRewriter.h.
References gates.
Referenced by circt::synth::Cut::dump(), circt::synth::Cut::getOutputSize(), isAlwaysCutInput(), simulateGate(), and circt::synth::CutEnumerator::visitLogicOp().
|
inline |
Definition at line 197 of file CutRewriter.h.
References gates.
Referenced by circt::synth::CutEnumerator::enumerateCuts().
| uint32_t LogicNetwork::getIndex | ( | Value | value | ) | const |
Get the raw index for a value.
Asserts if value is not found. Note: This returns only the index, not a Signal with inversion info. Use hasIndex() to check existence first, or use getOrCreateIndex().
Definition at line 74 of file CutRewriter.cpp.
References assert(), and valueToIndex.
Referenced by getSignal(), and simulateGate().
| uint32_t LogicNetwork::getOrCreateIndex | ( | Value | value | ) |
Get or create an index for a value.
If the value doesn't have an index yet, assigns one and returns the index.
Definition at line 65 of file CutRewriter.cpp.
References gates, indexToValue, and valueToIndex.
Referenced by addPrimaryInput(), and getOrCreateSignal().
|
inline |
Get or create a Signal for a value.
Definition at line 241 of file CutRewriter.h.
References getOrCreateIndex().
Referenced by buildFromBlock().
|
inline |
Get a Signal for a value.
Asserts if value not found - use hasIndex() first if unsure.
Definition at line 236 of file CutRewriter.h.
References getIndex().
|
inline |
Get the value for a given Signal (extracts index from Signal).
Definition at line 246 of file CutRewriter.h.
References circt::synth::Signal::getIndex(), and getValue().
Referenced by getValue().
| Value LogicNetwork::getValue | ( | uint32_t | index | ) | const |
Get the value for a given raw index.
Asserts if index is out of bounds. Returns null Value for constant indices (0 and 1).
Definition at line 86 of file CutRewriter.cpp.
References assert(), indexToValue, kConstant0, and kConstant1.
Referenced by circt::synth::CutEnumerator::dump(), circt::synth::Cut::dump(), and getValues().
| void LogicNetwork::getValues | ( | ArrayRef< uint32_t > | indices, |
| SmallVectorImpl< Value > & | values | ||
| ) | const |
Fill values for the given raw indices.
Definition at line 96 of file CutRewriter.cpp.
References getValue().
| bool LogicNetwork::hasIndex | ( | Value | value | ) | const |
Check if a value has been indexed.
Definition at line 82 of file CutRewriter.cpp.
References valueToIndex.
Referenced by buildFromBlock().
|
inline |
Get the total number of nodes in the network.
Definition at line 255 of file CutRewriter.h.
References gates.
Referenced by esiaccel.types.ArrayType::bit_width(), esiaccel.types.ArrayType::deserialize(), and esiaccel.types.ArrayType::is_valid().
|
private |
Vector of all gates in the network.
Definition at line 285 of file CutRewriter.h.
Referenced by addPrimaryInput(), buildFromBlock(), clear(), getGate(), getGate(), getGates(), getOrCreateIndex(), LogicNetwork(), and size().
|
private |
Map from network index to MLIR Value.
Definition at line 282 of file CutRewriter.h.
Referenced by buildFromBlock(), clear(), getOrCreateIndex(), getValue(), and LogicNetwork().
|
staticconstexpr |
Special constant indices.
Definition at line 194 of file CutRewriter.h.
Referenced by buildFromBlock(), getConstant0(), getConstant1(), getValue(), simulateGate(), and circt::synth::CutEnumerator::visitLogicOp().
|
staticconstexpr |
Definition at line 195 of file CutRewriter.h.
Referenced by buildFromBlock(), getValue(), and circt::synth::CutEnumerator::visitLogicOp().
|
private |
Map from MLIR Value to network index.
Definition at line 279 of file CutRewriter.h.
Referenced by buildFromBlock(), clear(), getIndex(), getOrCreateIndex(), and hasIndex().