CIRCT 23.0.0git
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | List of all members
circt::synth::LogicNetworkGate Struct Reference

Represents a single gate/node in the flat logic network. More...

#include <CutRewriter.h>

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

Public Types

enum  Kind : uint8_t {
  Constant = 0 , PrimaryInput = 1 , And2 = 2 , Xor2 = 3 ,
  Maj3 = 4 , Identity = 5
}
 Kind of logic gate. More...
 

Public Member Functions

 LogicNetworkGate ()
 
 LogicNetworkGate (Operation *op, Kind kind, llvm::ArrayRef< Signal > operands={})
 
Kind getKind () const
 Get the kind of this gate.
 
Operation * getOperation () const
 Get the operation pointer (nullptr for constants).
 
unsigned getNumFanins () const
 Get the number of fanin edges based on kind.
 
bool isLogicGate () const
 Check if this is a logic gate that can be part of a cut.
 
bool isAlwaysCutInput () const
 Check if this should always be a cut input (PI or constant).
 

Public Attributes

llvm::PointerIntPair< Operation *, 3, KindopAndKind
 Operation pointer and kind packed together.
 
Signal edges [3]
 Fanin edges (up to 3 inputs).
 

Detailed Description

Represents a single gate/node in the flat logic network.

This structure is designed to be cache-friendly and supports up to 3 inputs (sufficient for AND, XOR, MAJ gates). For nodes with fewer inputs, unused edges have index 0 (constant 0 node).

Special indices:

It uses 8 bytes for operation pointer + enum, 12 bytes for edges = 20 bytes per gate.

Definition at line 112 of file CutRewriter.h.

Member Enumeration Documentation

◆ Kind

Kind of logic gate.

Enumerator
Constant 

Constant 0/1 node (index 0 = const0, index 1 = const1)

PrimaryInput 

Primary input to the network.

And2 

AND gate (2-input, aig::AndInverterOp)

Xor2 

XOR gate (2-input)

Maj3 

Majority gate (3-input, mig::MajOp)

Identity 

Identity gate (used for 1-input inverter)

Definition at line 114 of file CutRewriter.h.

Constructor & Destructor Documentation

◆ LogicNetworkGate() [1/2]

circt::synth::LogicNetworkGate::LogicNetworkGate ( )
inline

Definition at line 132 of file CutRewriter.h.

◆ LogicNetworkGate() [2/2]

circt::synth::LogicNetworkGate::LogicNetworkGate ( Operation *  op,
Kind  kind,
llvm::ArrayRef< Signal operands = {} 
)
inline

Definition at line 133 of file CutRewriter.h.

Member Function Documentation

◆ getKind()

Kind circt::synth::LogicNetworkGate::getKind ( ) const
inline

Get the kind of this gate.

Definition at line 142 of file CutRewriter.h.

References opAndKind.

Referenced by getNumFanins(), isAlwaysCutInput(), and isLogicGate().

◆ getNumFanins()

unsigned circt::synth::LogicNetworkGate::getNumFanins ( ) const
inline

Get the number of fanin edges based on kind.

Definition at line 148 of file CutRewriter.h.

References And2, Constant, getKind(), Identity, Maj3, PrimaryInput, and Xor2.

◆ getOperation()

Operation * circt::synth::LogicNetworkGate::getOperation ( ) const
inline

Get the operation pointer (nullptr for constants).

Definition at line 145 of file CutRewriter.h.

References opAndKind.

Referenced by circt::synth::Cut::dump(), circt::synth::Cut::getOutputSize(), and circt::synth::CutEnumerator::visitLogicOp().

◆ isAlwaysCutInput()

bool circt::synth::LogicNetworkGate::isAlwaysCutInput ( ) const
inline

Check if this should always be a cut input (PI or constant).

Definition at line 171 of file CutRewriter.h.

References Constant, getKind(), and PrimaryInput.

Referenced by isAlwaysCutInput().

◆ isLogicGate()

bool circt::synth::LogicNetworkGate::isLogicGate ( ) const
inline

Check if this is a logic gate that can be part of a cut.

Definition at line 165 of file CutRewriter.h.

References And2, getKind(), Identity, Maj3, and Xor2.

Member Data Documentation

◆ edges

Signal circt::synth::LogicNetworkGate::edges[3]

Fanin edges (up to 3 inputs).

For AND gates, only edges[0] and edges[1] are used. For MAJ gates, all three are used. For PrimaryInput/Constant, none are used. The inversion bit is encoded in each edge.

Definition at line 130 of file CutRewriter.h.

Referenced by Python.support.BackedgeBuilder::__exit__(), and Python.support.BackedgeBuilder::_create().

◆ opAndKind

llvm::PointerIntPair<Operation *, 3, Kind> circt::synth::LogicNetworkGate::opAndKind

Operation pointer and kind packed together.

The kind is stored in the low bits of the pointer.

Definition at line 125 of file CutRewriter.h.

Referenced by getKind(), and getOperation().


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