Loading [MathJax]/extensions/tex2jax.js
CIRCT 22.0.0git
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Public Attributes | List of all members
circt::BinaryTruthTable Struct Reference

Represents a boolean function as a truth table. More...

#include <NPNClass.h>

Collaboration diagram for circt::BinaryTruthTable:
Collaboration graph
[legend]

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ BinaryTruthTable() [1/3]

circt::BinaryTruthTable::BinaryTruthTable ( )
inline

Default constructor creates an empty truth table.

Definition at line 44 of file NPNClass.h.

◆ BinaryTruthTable() [2/3]

circt::BinaryTruthTable::BinaryTruthTable ( unsigned  numInputs,
unsigned  numOutputs,
const llvm::APInt &  table 
)
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.

◆ BinaryTruthTable() [3/3]

circt::BinaryTruthTable::BinaryTruthTable ( unsigned  numInputs,
unsigned  numOutputs 
)
inline

Constructor for a truth table with given dimensions, initialized to zero.

Definition at line 55 of file NPNClass.h.

Member Function Documentation

◆ applyInputNegation()

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().

◆ applyOutputNegation()

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().

◆ applyPermutation()

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().

◆ dump()

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().

◆ getOutput()

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().

◆ isLexicographicallySmaller()

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().

◆ operator==()

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.

◆ setOutput()

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().

Member Data Documentation

◆ numInputs

unsigned circt::BinaryTruthTable::numInputs

◆ numOutputs

unsigned circt::BinaryTruthTable::numOutputs

◆ table

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().


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