CIRCT 22.0.0git
Loading...
Searching...
No Matches
Functions | Variables
TruthTable.cpp File Reference
#include "circt/Support/TruthTable.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/MathExtras.h"
#include <algorithm>
#include <cassert>
Include dependency graph for TruthTable.cpp:

Go to the source code of this file.

Functions

template<bool positive>
static APInt createVarMaskImpl (unsigned numVars, unsigned varIndex)
 Create a mask for a variable in the truth table.
 

Variables

static constexpr uint64_t kVarMasks [2][6]
 Precomputed masks for variables in truth tables up to 6 variables (64 bits).
 

Function Documentation

◆ createVarMaskImpl()

template<bool positive>
static APInt createVarMaskImpl ( unsigned  numVars,
unsigned  varIndex 
)
static

Create a mask for a variable in the truth table.

For positive=true: mask has 1s where var=1 in the truth table encoding For positive=false: mask has 1s where var=0 in the truth table encoding

Definition at line 299 of file TruthTable.cpp.

References assert(), kVarMasks, and pattern.

Variable Documentation

◆ kVarMasks

constexpr uint64_t kVarMasks[2][6]
staticconstexpr
Initial value:
= {
{0x5555555555555555ULL, 0x3333333333333333ULL, 0x0F0F0F0F0F0F0F0FULL,
0x00FF00FF00FF00FFULL, 0x0000FFFF0000FFFFULL,
0x00000000FFFFFFFFULL},
{0xAAAAAAAAAAAAAAAAULL, 0xCCCCCCCCCCCCCCCCULL, 0xF0F0F0F0F0F0F0F0ULL,
0xFF00FF00FF00FF00ULL, 0xFFFF0000FFFF0000ULL,
0xFFFFFFFF00000000ULL},
}

Precomputed masks for variables in truth tables up to 6 variables (64 bits).

In a truth table, bit position i represents minterm i, where the binary representation of i gives the variable values. For example, with 3 variables (a,b,c), bit 5 (binary 101) represents minterm a=1, b=0, c=1.

These masks identify which minterms have a particular variable value:

  • Masks[0][var] = minterms where var=0 (for negative literal !var)
  • Masks[1][var] = minterms where var=1 (for positive literal var)

Definition at line 286 of file TruthTable.cpp.

Referenced by createVarMaskImpl().