![]() |
HAL
|
#include <boolean_function.h>
Public Member Functions | |
bool | operator== (const Node &other) const |
bool | operator!= (const Node &other) const |
bool | operator< (const Node &other) const |
Node | clone () const |
std::string | to_string () const |
u16 | get_arity () const |
bool | is (u16 type) const |
bool | is_constant () const |
bool | has_constant_value (const std::vector< Value > &value) const |
bool | has_constant_value (u64 value) const |
Result< std::vector< Value > > | get_constant_value () const |
Result< u64 > | get_constant_value_u64 () const |
bool | is_index () const |
bool | has_index_value (u16 value) const |
Result< u16 > | get_index_value () const |
bool | is_variable () const |
bool | has_variable_name (const std::string &variable_name) const |
Result< std::string > | get_variable_name () const |
bool | is_operation () const |
bool | is_operand () const |
bool | is_commutative () const |
Static Public Member Functions | |
static Node | Operation (u16 type, u16 size) |
static Node | Constant (const std::vector< BooleanFunction::Value > value) |
static Node | Index (u16 index, u16 size) |
static Node | Variable (const std::string variable, u16 size) |
static u16 | get_arity_of_type (u16 type) |
Public Attributes | |
u16 | type |
The type of the node. More... | |
u16 | size |
The bit-size of the node. More... | |
std::vector< BooleanFunction::Value > | constant {} |
The (optional) constant value of the node. More... | |
u16 | index {} |
The (optional) index value of the node. More... | |
std::string | variable {} |
The (optional) variable name of the node. More... | |
Node refers to an abstract syntax tree node of a Boolean function. A node is an abstract base class for either an operation (e.g., AND, XOR) or an operand (e.g., a signal name variable).
We deliberately opted to have a single (littered) memory space for a node i.e. no separation from operation / operand nodes via inheritance, due to optimization reasons to keep node data closely together and prevent the use of smart pointers to manage memory safely.
Definition at line 986 of file boolean_function.h.
BooleanFunction::Node hal::BooleanFunction::Node::clone | ( | ) | const |
Clones the Boolean function node.
Definition at line 1644 of file boolean_function.cpp.
References hal::BooleanFunction::size(), and type.
Referenced by hal::boolean_function_init().
|
static |
Constructs a 'constant' node.
value | - The constant value of the node. |
Definition at line 1614 of file boolean_function.cpp.
References hal::BooleanFunction::NodeType::Constant.
Referenced by hal::boolean_function_init(), hal::BooleanFunction::Const(), and hal::BooleanFunctionParser::translate().
u16 hal::BooleanFunction::Node::get_arity | ( | ) | const |
Returns the arity of the Boolean function node, i.e., the number of parameters.
Definition at line 1729 of file boolean_function.cpp.
References get_arity_of_type(), and type.
Referenced by hal::boolean_function_init(), hal::SMT::Translator::reduce_to_smt2(), and hal::BooleanFunction::to_string().
Returns the arity for a Boolean function node of the given type, i.e., the number of parameters.
Definition at line 1734 of file boolean_function.cpp.
References hal::BooleanFunction::NodeType::Add, hal::BooleanFunction::NodeType::And, hal::BooleanFunction::NodeType::Ashr, hal::BooleanFunction::NodeType::Concat, hal::BooleanFunction::NodeType::Constant, hal::BooleanFunction::NodeType::Eq, hal::BooleanFunction::NodeType::Index, hal::BooleanFunction::NodeType::Ite, hal::BooleanFunction::NodeType::Lshr, hal::BooleanFunction::NodeType::Mul, hal::BooleanFunction::NodeType::Not, hal::BooleanFunction::NodeType::Or, hal::BooleanFunction::NodeType::Rol, hal::BooleanFunction::NodeType::Ror, hal::BooleanFunction::NodeType::Sdiv, hal::BooleanFunction::NodeType::Sext, hal::BooleanFunction::NodeType::Shl, hal::BooleanFunction::NodeType::Sle, hal::BooleanFunction::NodeType::Slice, hal::BooleanFunction::NodeType::Slt, hal::BooleanFunction::NodeType::Srem, hal::BooleanFunction::NodeType::Sub, type, hal::BooleanFunction::NodeType::Udiv, hal::BooleanFunction::NodeType::Ule, hal::BooleanFunction::NodeType::Ult, hal::BooleanFunction::NodeType::Urem, hal::BooleanFunction::NodeType::Variable, hal::BooleanFunction::NodeType::Xor, and hal::BooleanFunction::NodeType::Zext.
Referenced by hal::boolean_function_init(), and get_arity().
Result< std::vector< BooleanFunction::Value > > hal::BooleanFunction::Node::get_constant_value | ( | ) | const |
Get the constant value of the node of type Constant
as a vector of BooleanFunction::Value
.
Definition at line 1781 of file boolean_function.cpp.
References ERR, hal::BooleanFunction::is_constant(), and OK.
Referenced by hal::BooleanFunction::get_constant_value().
Get the constant value of the node of type Constant
as long as it has a size <= 64-bit.
Definition at line 1791 of file boolean_function.cpp.
References ERR, hal::BooleanFunction::is_constant(), OK, and hal::BooleanFunction::size().
Referenced by hal::BooleanFunction::get_constant_value_u64().
Get the index value of node of type Index
.
Definition at line 1828 of file boolean_function.cpp.
References ERR, hal::BooleanFunction::is_index(), and OK.
Referenced by hal::BooleanFunction::get_index_value().
Result< std::string > hal::BooleanFunction::Node::get_variable_name | ( | ) | const |
Get the variable name of node of type Variable
.
Definition at line 1848 of file boolean_function.cpp.
References ERR, hal::BooleanFunction::is_variable(), and OK.
Referenced by hal::BooleanFunction::get_variable_name().
bool hal::BooleanFunction::Node::has_constant_value | ( | const std::vector< Value > & | value | ) | const |
Checks whether the Boolean function node is of type Constant
and holds a specific value.
value | - The value to check for. |
true
if the Boolean function node is of type Constant
and holds the given value, false
otherwise. Definition at line 1760 of file boolean_function.cpp.
References hal::BooleanFunction::is_constant().
Referenced by hal::boolean_function_init(), and hal::BooleanFunction::has_constant_value().
bool hal::BooleanFunction::Node::has_constant_value | ( | u64 | value | ) | const |
Checks whether the Boolean function node is of type Constant
and holds a specific value.
value | - The value to check for. |
true
if the Boolean function node is of type Constant
and holds the given value, false
otherwise. Definition at line 1765 of file boolean_function.cpp.
References hal::BooleanFunction::is_constant(), and hal::BooleanFunction::size().
bool hal::BooleanFunction::Node::has_index_value | ( | u16 | value | ) | const |
Checks whether the Boolean function node is of type Index
and holds a specific value.
value | - The value to check for. |
true
if the Boolean function node is of type Index
and holds the given value, false
otherwise. Definition at line 1823 of file boolean_function.cpp.
References hal::BooleanFunction::is_index().
Referenced by hal::boolean_function_init(), and hal::BooleanFunction::has_index_value().
bool hal::BooleanFunction::Node::has_variable_name | ( | const std::string & | variable_name | ) | const |
Checks whether the Boolean function node is of type Variable
and holds a specific variable name.
variable_name | - The variable name to check for. |
true
if the Boolean function node is of type Variable
and holds the given variable name, false
otherwise. Definition at line 1843 of file boolean_function.cpp.
References hal::BooleanFunction::is_variable().
Referenced by hal::boolean_function_init(), and hal::BooleanFunction::has_variable_name().
|
static |
Constructs an 'index' node.
index | - The index value of the node. |
size | - The bit-size of the node. |
Definition at line 1619 of file boolean_function.cpp.
References hal::BooleanFunction::NodeType::Index.
Referenced by hal::boolean_function_init(), and hal::BooleanFunction::Index().
bool hal::BooleanFunction::Node::is | ( | u16 | type | ) | const |
Checks whether the Boolean function node is of a specific type.
type | - The type to check for. |
true
if the node is of the given type, false
otherwise. Definition at line 1750 of file boolean_function.cpp.
References type.
Referenced by hal::boolean_function_init(), and hal::BooleanFunction::is().
bool hal::BooleanFunction::Node::is_commutative | ( | ) | const |
Checks whether the Boolean function node is commutative.
true
if the Boolean function node is commutative, false
otherwise. Definition at line 1868 of file boolean_function.cpp.
References hal::BooleanFunction::NodeType::Add, hal::BooleanFunction::NodeType::And, hal::BooleanFunction::NodeType::Eq, hal::BooleanFunction::NodeType::Mul, hal::BooleanFunction::NodeType::Or, type, and hal::BooleanFunction::NodeType::Xor.
Referenced by hal::boolean_function_init().
bool hal::BooleanFunction::Node::is_constant | ( | ) | const |
Checks whether the Boolean function node is of type Constant
.
true
if the Boolean function node is of type Constant
, false
otherwise. Definition at line 1755 of file boolean_function.cpp.
References hal::BooleanFunction::NodeType::Constant, and hal::BooleanFunction::is().
Referenced by hal::boolean_function_init(), and hal::BooleanFunction::is_constant().
bool hal::BooleanFunction::Node::is_index | ( | ) | const |
Checks whether the Boolean function node is of type Index
.
true
if the Boolean function node is of type Index
, false
otherwise. Definition at line 1818 of file boolean_function.cpp.
References hal::BooleanFunction::NodeType::Index, and hal::BooleanFunction::is().
Referenced by hal::boolean_function_init(), and hal::BooleanFunction::is_index().
bool hal::BooleanFunction::Node::is_operand | ( | ) | const |
Checks whether the Boolean function node is an operand node.
true
if the Boolean function node is an operand node, false
otherwise. Definition at line 1863 of file boolean_function.cpp.
References hal::BooleanFunction::is_constant(), hal::BooleanFunction::is_index(), and hal::BooleanFunction::is_variable().
Referenced by hal::boolean_function_init().
bool hal::BooleanFunction::Node::is_operation | ( | ) | const |
Checks whether the Boolean function node is an operation node.
true
if the Boolean function node is an operation node, false
otherwise. Definition at line 1858 of file boolean_function.cpp.
Referenced by hal::boolean_function_init().
bool hal::BooleanFunction::Node::is_variable | ( | ) | const |
Checks whether the Boolean function node is of type Variable
.
true
if the Boolean function node is of type Variable
, false
otherwise. Definition at line 1838 of file boolean_function.cpp.
References hal::BooleanFunction::is(), and hal::BooleanFunction::NodeType::Variable.
Referenced by hal::boolean_function_init(), and hal::BooleanFunction::is_variable().
|
static |
Constructs an 'operation' node.
type | - The type of the operation. |
size | - The bit-size of the operation. |
Definition at line 1609 of file boolean_function.cpp.
Referenced by hal::BooleanFunction::Add(), hal::BooleanFunction::And(), hal::BooleanFunction::Ashr(), hal::boolean_function_init(), hal::BooleanFunction::Concat(), hal::BooleanFunction::Eq(), hal::BooleanFunction::Ite(), hal::BooleanFunction::Lshr(), hal::BooleanFunction::Mul(), hal::BooleanFunction::Not(), hal::BooleanFunction::Or(), hal::BooleanFunction::Rol(), hal::BooleanFunction::Ror(), hal::BooleanFunction::Sdiv(), hal::BooleanFunction::Sext(), hal::BooleanFunction::Shl(), hal::BooleanFunction::Sle(), hal::BooleanFunction::Slice(), hal::BooleanFunction::Slt(), hal::BooleanFunction::Srem(), hal::BooleanFunction::Sub(), hal::BooleanFunctionParser::translate(), hal::BooleanFunction::Udiv(), hal::BooleanFunction::Ule(), hal::BooleanFunction::Ult(), hal::BooleanFunction::Urem(), hal::BooleanFunction::Xor(), and hal::BooleanFunction::Zext().
bool hal::BooleanFunction::Node::operator!= | ( | const Node & | other | ) | const |
Checks whether two Boolean function nodes are unequal.
[in] | other | - The other Boolean function node. |
true
if the Boolean function nodes are unequal, false
otherwise. Definition at line 1634 of file boolean_function.cpp.
bool hal::BooleanFunction::Node::operator< | ( | const Node & | other | ) | const |
Checks whether this Boolean function node is 'smaller' than the other
Boolean function node.
[in] | other | - The other Boolean function node. |
true
if this Boolean function node is 'smaller', false
otherwise. Definition at line 1639 of file boolean_function.cpp.
References constant, index, hal::BooleanFunction::size(), size, type, type, and variable.
bool hal::BooleanFunction::Node::operator== | ( | const Node & | other | ) | const |
Checks whether two Boolean function nodes are equal.
[in] | other | - The other Boolean function node. |
true
if the Boolean function nodes are equal, false
otherwise. Definition at line 1629 of file boolean_function.cpp.
References constant, index, hal::BooleanFunction::size(), size, type, type, and variable.
std::string hal::BooleanFunction::Node::to_string | ( | ) | const |
Translates the Boolean function node into its string representation.
Definition at line 1649 of file boolean_function.cpp.
References hal::BooleanFunction::NodeType::Add, hal::BooleanFunction::NodeType::And, hal::BooleanFunction::NodeType::Ashr, hal::BooleanFunction::NodeType::Concat, hal::BooleanFunction::NodeType::Constant, hal::enum_to_string(), hal::BooleanFunction::NodeType::Eq, hal::BooleanFunction::NodeType::Index, hal::BooleanFunction::NodeType::Ite, hal::BooleanFunction::NodeType::Lshr, hal::BooleanFunction::NodeType::Mul, hal::BooleanFunction::NodeType::Not, hal::BooleanFunction::NodeType::Or, hal::BooleanFunction::NodeType::Rol, hal::BooleanFunction::NodeType::Ror, hal::BooleanFunction::NodeType::Sdiv, hal::BooleanFunction::NodeType::Sext, hal::BooleanFunction::NodeType::Shl, hal::BooleanFunction::NodeType::Sle, hal::BooleanFunction::NodeType::Slice, hal::BooleanFunction::NodeType::Slt, hal::BooleanFunction::NodeType::Srem, control::str, hal::BooleanFunction::NodeType::Sub, type, hal::BooleanFunction::NodeType::Udiv, hal::BooleanFunction::NodeType::Ule, hal::BooleanFunction::NodeType::Ult, hal::BooleanFunction::NodeType::Urem, hal::BooleanFunction::NodeType::Variable, hal::BooleanFunction::NodeType::Xor, and hal::BooleanFunction::NodeType::Zext.
Referenced by hal::SMT::Translator::reduce_to_smt2(), and hal::BooleanFunction::to_string().
|
static |
Constructs a 'variable' node.
variable | - The variable name of the node. |
size | - The bit-size of the node. |
Definition at line 1624 of file boolean_function.cpp.
References hal::BooleanFunction::NodeType::Variable.
Referenced by hal::boolean_function_init(), hal::BooleanFunction::substitute(), hal::BooleanFunctionParser::translate(), and hal::BooleanFunction::Var().
std::vector<BooleanFunction::Value> hal::BooleanFunction::Node::constant {} |
The (optional) constant value of the node.
Definition at line 997 of file boolean_function.h.
Referenced by hal::boolean_function_init(), operator<(), operator==(), and hal::SMT::Translator::reduce_to_smt2().
u16 hal::BooleanFunction::Node::index {} |
The (optional) index value of the node.
Definition at line 999 of file boolean_function.h.
Referenced by hal::boolean_function_init(), operator<(), operator==(), and hal::SMT::Translator::reduce_to_smt2().
u16 hal::BooleanFunction::Node::size |
The bit-size of the node.
Definition at line 995 of file boolean_function.h.
Referenced by hal::boolean_function_init(), operator<(), operator==(), hal::SMT::Translator::reduce_to_smt2(), and hal::BooleanFunction::size().
u16 hal::BooleanFunction::Node::type |
The type of the node.
Definition at line 993 of file boolean_function.h.
Referenced by hal::boolean_function_init(), operator<(), operator==(), and hal::SMT::Translator::reduce_to_smt2().
std::string hal::BooleanFunction::Node::variable {} |
The (optional) variable name of the node.
Definition at line 1001 of file boolean_function.h.
Referenced by hal::boolean_function_init(), operator<(), operator==(), and hal::SMT::Translator::reduce_to_smt2().