CIRCT 22.0.0git
|
Represents a boolean function as a truth table. More...
#include <NPNClass.h>
Public Member Functions | |
BinaryTruthTable () | |
Default constructor creates an empty truth table. | |
BinaryTruthTable (unsigned numInputs, unsigned numOutputs, const llvm::APInt &table) | |
Constructor for a truth table with given dimensions and evaluation data. | |
BinaryTruthTable (unsigned numInputs, unsigned numOutputs) | |
Constructor for a truth table with given dimensions, initialized to zero. | |
llvm::APInt | getOutput (const llvm::APInt &input) const |
Get the output value for a given input combination. | |
void | setOutput (const llvm::APInt &input, const llvm::APInt &output) |
Set the output value for a given input combination. | |
BinaryTruthTable | applyPermutation (ArrayRef< unsigned > permutation) const |
Apply input permutation to create a new truth table. | |
BinaryTruthTable | applyInputNegation (unsigned mask) const |
Apply input negation to create a new truth table. | |
BinaryTruthTable | applyOutputNegation (unsigned negation) const |
Apply output negation to create a new truth table. | |
bool | isLexicographicallySmaller (const BinaryTruthTable &other) const |
Check if this truth table is lexicographically smaller than another. | |
bool | operator== (const BinaryTruthTable &other) const |
Equality comparison for truth tables. | |
void | dump (llvm::raw_ostream &os=llvm::errs()) const |
Debug dump method for truth tables. | |
Public Attributes | |
unsigned | numInputs |
Number of inputs for this boolean function. | |
unsigned | numOutputs |
Number of outputs for this boolean function. | |
llvm::APInt | table |
Truth table data as a packed bit vector. | |
Represents a boolean function as a truth table.
A truth table stores the output values for all possible input combinations of a boolean function. For a function with n inputs and m outputs, the truth table contains 2^n entries, each with m output bits.
Example: For a 2-input AND gate:
Definition at line 38 of file NPNClass.h.
|
inline |
Default constructor creates an empty truth table.
Definition at line 44 of file NPNClass.h.
|
inline |
Constructor for a truth table with given dimensions and evaluation data.
Definition at line 47 of file NPNClass.h.
References assert(), numInputs, numOutputs, and table.
|
inline |
Constructor for a truth table with given dimensions, initialized to zero.
Definition at line 55 of file NPNClass.h.
BinaryTruthTable BinaryTruthTable::applyInputNegation | ( | unsigned | mask | ) | const |
Apply input negation to create a new truth table.
This negates selected input variables based on the mask.
Definition at line 63 of file NPNClass.cpp.
References getOutput(), numInputs, numOutputs, and setOutput().
Referenced by circt::NPNClass::computeNPNCanonicalForm().
BinaryTruthTable BinaryTruthTable::applyOutputNegation | ( | unsigned | negation | ) | const |
Apply output negation to create a new truth table.
This negates selected output variables based on the mask.
Definition at line 79 of file NPNClass.cpp.
References getOutput(), numInputs, numOutputs, and setOutput().
Referenced by circt::NPNClass::computeNPNCanonicalForm().
BinaryTruthTable BinaryTruthTable::applyPermutation | ( | ArrayRef< unsigned > | permutation | ) | const |
Apply input permutation to create a new truth table.
This reorders the input variables according to the given permutation.
Definition at line 43 of file NPNClass.cpp.
References assert(), getOutput(), numInputs, numOutputs, and setOutput().
Referenced by circt::NPNClass::computeNPNCanonicalForm().
void BinaryTruthTable::dump | ( | llvm::raw_ostream & | os = llvm::errs() | ) | const |
Debug dump method for truth tables.
Definition at line 106 of file NPNClass.cpp.
References getOutput(), numInputs, numOutputs, and table.
Referenced by circt::NPNClass::dump().
llvm::APInt BinaryTruthTable::getOutput | ( | const llvm::APInt & | input | ) | const |
Get the output value for a given input combination.
Definition at line 27 of file NPNClass.cpp.
References assert(), numInputs, numOutputs, and table.
Referenced by applyInputNegation(), applyOutputNegation(), applyPermutation(), and dump().
bool BinaryTruthTable::isLexicographicallySmaller | ( | const BinaryTruthTable & | other | ) | const |
Check if this truth table is lexicographically smaller than another.
Used for canonical ordering of truth tables.
Definition at line 95 of file NPNClass.cpp.
References assert(), numInputs, numOutputs, and table.
Referenced by circt::NPNClass::isLexicographicallySmaller().
bool BinaryTruthTable::operator== | ( | const BinaryTruthTable & | other | ) | const |
Equality comparison for truth tables.
Definition at line 101 of file NPNClass.cpp.
References numInputs, numOutputs, and table.
void BinaryTruthTable::setOutput | ( | const llvm::APInt & | input, |
const llvm::APInt & | output | ||
) |
Set the output value for a given input combination.
Definition at line 32 of file NPNClass.cpp.
References assert(), numInputs, numOutputs, and table.
Referenced by applyInputNegation(), applyOutputNegation(), and applyPermutation().
unsigned circt::BinaryTruthTable::numInputs |
Number of inputs for this boolean function.
Definition at line 39 of file NPNClass.h.
Referenced by applyInputNegation(), applyOutputNegation(), applyPermutation(), BinaryTruthTable(), circt::NPNClass::computeNPNCanonicalForm(), dump(), circt::NPNClass::dump(), getOutput(), isLexicographicallySmaller(), operator==(), and setOutput().
unsigned circt::BinaryTruthTable::numOutputs |
Number of outputs for this boolean function.
Definition at line 40 of file NPNClass.h.
Referenced by applyInputNegation(), applyOutputNegation(), applyPermutation(), BinaryTruthTable(), circt::NPNClass::computeNPNCanonicalForm(), dump(), circt::NPNClass::dump(), getOutput(), isLexicographicallySmaller(), operator==(), and setOutput().
llvm::APInt circt::BinaryTruthTable::table |
Truth table data as a packed bit vector.
Definition at line 41 of file NPNClass.h.
Referenced by BinaryTruthTable(), dump(), getOutput(), isLexicographicallySmaller(), circt::NPNClass::isLexicographicallySmaller(), operator==(), and setOutput().