Cube data structure¶
The header <kitty/cube.hpp>
implements a cube data structure to
represent a cube with up to 32 literals. This data structure is used
by algorithms that find 2-level representations for truth tables,
e.g., isop
and esop_from_optimum_pkrm
.
The class kitty::cube
provides the following public
member functions.
Function |
Description |
---|---|
|
Constructs the empty cube |
|
Constructs a cube from bits and mask |
|
Constructs a cube from a string |
|
Returns number of literals |
|
Returns the difference to another cube |
|
Returns the distance to another cube |
|
Checks whether two cubes are equivalent |
|
Checks whether two cubes are not equivalent |
|
Default comparison operator |
|
Returns the negated cube |
|
Merges two cubes of distance-1 |
|
Add literal to cube |
|
Removes literal from cube |
|
Constructs the elementary cube representing a single variable |
|
Constructs the elementary cube containing the first k positive literals |
|
Constructs the elementary cube containing the first k negative literals |
|
Prints a cube |
|
Gets bit at index |
|
Gets mask at index |
|
Sets bit at index |
|
Sets mask at index |
|
Clears bit at index |
|
Clears mask at index |
|
Flips bit at index |
|
Flips mask at index |
Function
|
Description
|
---|---|
Prints all cubes in a vector.
|
You can use kitty::hash<cube>
to hash cubes, e.g., in a hash map or set.
-
class kitty::cube¶
Public Functions
-
inline cube()¶
Constructs the empty cube.
Represents the one-cube
-
inline cube(uint32_t bits, uint32_t mask)¶
Constructs a cube from bits and mask.
For a valid cube and to be consistent in the ternary values, we assume that whenever a bit in the care bitmask is set to 0, also the polarity bitmask must be 0.
- Parameters
bits – Polarity bitmask of variables (0: negative, 1: positive)
mask – Care bitmask of variables (1: part of cube, 0: not part of cube)
-
inline cube(const std::string &str)¶
Constructs a cube from a string.
Each character corresponds to one literal in the cube. Only up to first 32 characters of the string will be considered, since this data structure cannot represent cubes with more than 32 literals. A ‘1’ in the string corresponds to a postive literal, a ‘0’ corresponds to a negative literal. All other characters represent don’t care, but it is customary to use ‘-‘.
- Parameters
str – String representing a cube
-
inline int num_literals() const¶
Returns number of literals.
-
inline void add_literal(uint8_t var_index, bool polarity = true)¶
Adds literal to cube.
-
inline void remove_literal(uint8_t var_index)¶
Removes literal from cube.
-
inline void print(unsigned length = 32u, std::ostream &os = std::cout) const¶
Prints a cube.
-
inline bool get_bit(uint8_t index) const¶
Gets bit at index.
-
inline bool get_mask(uint8_t index) const¶
Gets mask at index.
-
inline void set_bit(uint8_t index)¶
Sets bit at index.
-
inline void set_mask(uint8_t index)¶
Sets mask at index.
-
inline void clear_bit(uint8_t index)¶
Clears bit at index.
-
inline void clear_mask(uint8_t index)¶
Clears mask at index.
-
inline void flip_bit(uint8_t index)¶
Flips bit at index.
-
inline void flip_mask(uint8_t index)¶
Flips mask at index.
-
inline cube()¶