Represents a truth table. More...
Public Types | |
typedef T | value_type |
Typedef reference to the given template type. More... | |
typedef std::vector< T > | cube_type |
Type representing a cube. More... | |
typedef std::map< cube_type, cube_type > | cube_vector |
Represents a map from input to output cube. More... | |
typedef cube_type::const_iterator | in_const_iterator |
Constant Iterator of input cubes. More... | |
typedef boost::permutation_iterator < typename cube_type::const_iterator, std::vector< unsigned > ::const_iterator > | out_const_iterator |
Constant Iterator of output cubes. More... | |
typedef boost::transform_iterator < transform_cube< T > , typename cube_vector::const_iterator > | const_iterator |
Truth Table's constant iterator. More... | |
Public Member Functions | |
unsigned | num_inputs () const |
Returns the number of inputs. More... | |
unsigned | num_outputs () const |
Returns the number of outputs. More... | |
const_iterator | begin () const |
Returns constant begin iterator of the cube list. More... | |
const_iterator | end () const |
Returns constant end iterator of the cube list. More... | |
bool | add_entry (const cube_type &input, const cube_type &output) |
Adds a new entry to the truth table. More... | |
void | clear () |
Clears the truth table. More... | |
const std::vector< unsigned > & | permutation () const |
Returns current permutation. More... | |
bool | set_permutation (const std::vector< unsigned > &perm) |
Sets the permutation. More... | |
bool | permute () |
Permutes the current permutation. More... | |
void | set_inputs (const std::vector< std::string > &ins) |
Sets the inputs of the specification. More... | |
const std::vector< std::string > & | inputs () const |
Returns the inputs of the specification. More... | |
void | set_outputs (const std::vector< std::string > &outs) |
Sets the outputs of the specification. More... | |
std::vector< std::string > | outputs () const |
Returns the outputs of the specification. More... | |
void | set_constants (const std::vector< constant > &constants) |
Sets the constant lines of the specification. More... | |
const std::vector< constant > & | constants () const |
Returns the constant line information of the specification. More... | |
void | set_garbage (const std::vector< bool > &garbage) |
Sets the garbage lines of the specification. More... | |
std::vector< bool > | garbage () const |
Returns the garbage line information of the specification. More... | |
Represents a truth table.
This class helps mapping input assignments to their corresponding output assignments.
Assignments are thereby cubes (type truth_table<T>::cube_type) are vectors of values T, which type is given as template parameter to the class.
For the tristate value 1, 0, and don't care the type binary_truth_table is predefined with T = boost::optional<bool>.
You can use read_specification(binary_truth_table&, const std::string&, std::string*) for reading a RevLib specification file into a truth_table.
This example shows how to iterate through the values of a binary_truth_table, which is not that convenient on the first sight. This code works also for a generic truth_table.
typedef boost::transform_iterator<transform_cube<T>, typename cube_vector::const_iterator> const_iterator |
Truth Table's constant iterator.
A transform iterator which transforms the cube_tuple objects to a pair of iterator pairs of each input and output cube.
typedef std::vector<T> cube_type |
Type representing a cube.
Implemented as a vector over the basic type T
typedef std::map<cube_type, cube_type> cube_vector |
Represents a map from input to output cube.
Implemented as a tuple
typedef cube_type::const_iterator in_const_iterator |
Constant Iterator of input cubes.
Default constant iterator is used.
typedef boost::permutation_iterator<typename cube_type::const_iterator, std::vector<unsigned>::const_iterator> out_const_iterator |
Constant Iterator of output cubes.
A permutation iterator from Boost.Iterators is used which makes use of the truth table's permutation.
typedef T value_type |
Typedef reference to the given template type.
Adds a new entry to the truth table.
With adding the first entry the dimension of inputs and outputs is set. When adding further entries it has to make sure that the dimensions fit, else an assertion is thrown and false is returned.
input | Input assignment |
output | Output assignment |
|
inline |
Returns constant begin iterator of the cube list.
|
inline |
Clears the truth table.
Clears the truth table, as well as the current permutation and constant and garbage information.
|
inline |
Returns the constant line information of the specification.
Use copy_metadata to assign specification meta-data to a circuit.
|
inline |
Returns constant end iterator of the cube list.
|
inline |
Returns the garbage line information of the specification.
The garbage line information is permuted in respect to the current permutation.
Use copy_metadata to assign specification meta-data to a circuit.
|
inline |
Returns the inputs of the specification.
Use copy_metadata to assign specification meta-data to a circuit.
|
inline |
Returns the number of inputs.
If the truth table contains no cube tuple, then 0 is returned, otherwise the length of the first input assignment is returned.
|
inline |
Returns the number of outputs.
If the truth table contains no cube tuple, then 0 is returned, otherwise the length of the first output assignment is returned.
|
inline |
Returns the outputs of the specification.
The outputs are permuted in respect to the current permutation.
Use copy_metadata to assign specification meta-data to a circuit.
|
inline |
Returns current permutation.
The permutation is initializes when the first entry is added to the truth table and is initially the sequence from 0 to n - 1, where n is the size of the output cubes.
|
inline |
Permutes the current permutation.
This methods calls std::next_permutation
on the current permutation. It returns false, when all permutations were considered.
|
inline |
Sets the constant lines of the specification.
Use copy_metadata to assign specification meta-data to a circuit.
constants | Vector of constant values |
|
inline |
Sets the garbage lines of the specification.
Use copy_metadata to assign specification meta-data to a circuit.
garbage | Vector of garbage values |
|
inline |
Sets the inputs of the specification.
Use copy_metadata to assign specification meta-data to a circuit.
ins | Vector of input names |
|
inline |
Sets the outputs of the specification.
Use copy_metadata to assign specification meta-data to a circuit.
outs | Vector of output names |
|
inline |
Sets the permutation.
This method can set a specific permutation. This method should not be used in combination with permute which provides a dynamic change of the permutation.
perm | New permutation |