|
CIRCT 22.0.0git
|
Represents a boolean function as a truth table. More...
#include <TruthTable.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:
TODO: Rename this to MultiOutputTruthTable since for single-output functions we can just use llvm::APInt directly.
Definition at line 39 of file TruthTable.h.
|
inline |
Default constructor creates an empty truth table.
Definition at line 45 of file TruthTable.h.
|
inline |
Constructor for a truth table with given dimensions and evaluation data.
Definition at line 48 of file TruthTable.h.
References assert(), numInputs, numOutputs, and table.
|
inline |
Constructor for a truth table with given dimensions, initialized to zero.
Definition at line 56 of file TruthTable.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 64 of file TruthTable.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 80 of file TruthTable.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 44 of file TruthTable.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 107 of file TruthTable.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 28 of file TruthTable.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 96 of file TruthTable.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 102 of file TruthTable.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 33 of file TruthTable.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 40 of file TruthTable.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 41 of file TruthTable.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 42 of file TruthTable.h.
Referenced by BinaryTruthTable(), dump(), getOutput(), isLexicographicallySmaller(), circt::NPNClass::isLexicographicallySmaller(), operator==(), and setOutput().