CIRCT 22.0.0git
|
A boolean function expressed as a truth table. More...
#include <DeseqUtils.h>
Public Member Functions | |
unsigned | getNumTerms () const |
Get the number of terms in the truth table. | |
bool | isPoison () const |
bool | isTrue () const |
bool | isFalse () const |
TruthTable | operator~ () const |
TruthTable | operator& (const TruthTable &other) const |
TruthTable | operator| (const TruthTable &other) const |
TruthTable | operator^ (const TruthTable &other) const |
TruthTable & | invert () |
TruthTable & | operator&= (const TruthTable &other) |
TruthTable & | operator|= (const TruthTable &other) |
TruthTable & | operator^= (const TruthTable &other) |
bool | operator== (const TruthTable &other) const |
bool | operator!= (const TruthTable &other) const |
DNF | canonicalize () const |
Convert the truth table into its canonical disjunctive normal form. | |
Static Public Member Functions | |
static TruthTable | getPoison () |
static TruthTable | getConst (unsigned numTerms, bool value) |
Create a boolean expression with a constant true or false value. | |
static TruthTable | getTerm (unsigned numTerms, unsigned term) |
Create a boolean expression consisting of a single term. | |
Public Attributes | |
APInt | bits |
The value of the boolean function for each possible combination of input term assignments. | |
Private Member Functions | |
APInt | getTermMask (unsigned term) const |
void | fixupUnknown () |
Static Private Member Functions | |
static APInt | getTermMask (unsigned bitWidth, unsigned term) |
Return a mask that has a 1 in all truth table rows where term is 1, and a 0 otherwise. | |
A boolean function expressed as a truth table.
The first term is treated as a special "unknown" value marker with special semantics. Truth tables have exponential memory requirements. They are only useful to track a small number of terms, say up to 16, which already requires 64 kB of memory.
Definition at line 62 of file DeseqUtils.h.
DNF TruthTable::canonicalize | ( | ) | const |
Convert the truth table into its canonical disjunctive normal form.
Definition at line 141 of file DeseqUtils.cpp.
References circt::llhd::deseq::DNFTerm::andTerms, bits, getNumTerms(), getTermMask(), invert(), isFalse(), isPoison(), isTrue(), and circt::llhd::deseq::DNF::orTerms.
Referenced by circt::llhd::deseq::operator<<().
|
private |
Definition at line 207 of file DeseqUtils.cpp.
References bits, and getTermMask().
Referenced by invert().
|
inlinestatic |
Create a boolean expression with a constant true or false value.
Definition at line 84 of file DeseqUtils.h.
References assert().
|
inline |
Get the number of terms in the truth table.
Since the width of bits
corresponds to 2**numInputs
, we count the number of trailing zeros in the width of bits
to determine numInputs
.
Definition at line 72 of file DeseqUtils.h.
References bits, and isPoison().
Referenced by canonicalize().
|
inlinestatic |
Definition at line 78 of file DeseqUtils.h.
Referenced by operator&=(), operator^=(), and operator|=().
|
inlinestatic |
Create a boolean expression consisting of a single term.
Definition at line 91 of file DeseqUtils.h.
References assert(), and getTermMask().
|
inlinestaticprivate |
Return a mask that has a 1 in all truth table rows where term
is 1, and a 0 otherwise.
This is equivalent to the truth table of a boolean expression consisting of a single term.
Definition at line 118 of file DeseqUtils.h.
Referenced by canonicalize(), fixupUnknown(), getTerm(), and getTermMask().
|
inlineprivate |
Definition at line 122 of file DeseqUtils.h.
References bits, and getTermMask().
TruthTable & TruthTable::invert | ( | ) |
Definition at line 90 of file DeseqUtils.cpp.
References bits, fixupUnknown(), and isPoison().
Referenced by canonicalize(), operator^=(), and operator~().
|
inline |
Definition at line 81 of file DeseqUtils.h.
References bits.
Referenced by canonicalize(), and operator^=().
|
inline |
Definition at line 79 of file DeseqUtils.h.
References bits.
Referenced by canonicalize(), getNumTerms(), invert(), operator&=(), operator^=(), and operator|=().
|
inline |
Definition at line 80 of file DeseqUtils.h.
References bits.
Referenced by canonicalize(), and operator^=().
|
inline |
Definition at line 109 of file DeseqUtils.h.
TruthTable TruthTable::operator& | ( | const TruthTable & | other | ) | const |
Definition at line 72 of file DeseqUtils.cpp.
TruthTable & TruthTable::operator&= | ( | const TruthTable & | other | ) |
Definition at line 98 of file DeseqUtils.cpp.
References bits, getPoison(), and isPoison().
|
inline |
Definition at line 108 of file DeseqUtils.h.
References bits.
TruthTable TruthTable::operator^ | ( | const TruthTable & | other | ) | const |
Definition at line 84 of file DeseqUtils.cpp.
TruthTable & TruthTable::operator^= | ( | const TruthTable & | other | ) |
Definition at line 118 of file DeseqUtils.cpp.
References getPoison(), invert(), isFalse(), isPoison(), and isTrue().
TruthTable TruthTable::operator| | ( | const TruthTable & | other | ) | const |
Definition at line 78 of file DeseqUtils.cpp.
TruthTable & TruthTable::operator|= | ( | const TruthTable & | other | ) |
Definition at line 108 of file DeseqUtils.cpp.
References bits, getPoison(), and isPoison().
TruthTable TruthTable::operator~ | ( | ) | const |
Definition at line 66 of file DeseqUtils.cpp.
References invert().
APInt circt::llhd::deseq::TruthTable::bits |
The value of the boolean function for each possible combination of input term assignments.
If the boolean function has N input terms, this APInt
lists all 2**N
possible combinations. The special "poison" value is represented as a zero-width bits
.
Definition at line 67 of file DeseqUtils.h.
Referenced by canonicalize(), fixupUnknown(), getNumTerms(), getTermMask(), invert(), isFalse(), isPoison(), isTrue(), operator&=(), operator==(), and operator|=().