HAL
hal::BooleanFunction::Node Struct Referencefinal

#include <boolean_function.h>

Collaboration diagram for hal::BooleanFunction::Node:
Collaboration graph

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< u64get_constant_value_u64 () const
 
bool is_index () const
 
bool has_index_value (u16 value) const
 
Result< u16get_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::Valueconstant {}
 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...
 

Detailed Description

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

Developer Note

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.

Member Function Documentation

◆ clone()

BooleanFunction::Node hal::BooleanFunction::Node::clone ( ) const

Clones the Boolean function node.

Returns
The cloned Boolean function node.

Definition at line 1645 of file boolean_function.cpp.

References hal::BooleanFunction::size(), and type.

Referenced by hal::boolean_function_init().

◆ Constant()

BooleanFunction::Node hal::BooleanFunction::Node::Constant ( const std::vector< BooleanFunction::Value value)
static

Constructs a 'constant' node.

Parameters
value- The constant value of the node.
Returns
The node.

Definition at line 1615 of file boolean_function.cpp.

References hal::BooleanFunction::NodeType::Constant.

Referenced by hal::boolean_function_init(), hal::BooleanFunction::Const(), and hal::BooleanFunctionParser::translate().

◆ get_arity()

u16 hal::BooleanFunction::Node::get_arity ( ) const

Returns the arity of the Boolean function node, i.e., the number of parameters.

Returns
The arity.

Definition at line 1730 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().

◆ get_arity_of_type()

◆ get_constant_value()

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.

Returns
The constant value on success, an error otherwise.

Definition at line 1782 of file boolean_function.cpp.

References ERR, hal::BooleanFunction::is_constant(), and OK.

Referenced by hal::BooleanFunction::get_constant_value().

◆ get_constant_value_u64()

Result< u64 > hal::BooleanFunction::Node::get_constant_value_u64 ( ) const

Get the constant value of the node of type Constant as long as it has a size <= 64-bit.

Returns
The constant value on success, an error otherwise.

Definition at line 1792 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_index_value()

Result< u16 > hal::BooleanFunction::Node::get_index_value ( ) const

Get the index value of node of type Index.

Returns
The index value on success, an error otherwise.

Definition at line 1829 of file boolean_function.cpp.

References ERR, hal::BooleanFunction::is_index(), and OK.

Referenced by hal::BooleanFunction::get_index_value().

◆ get_variable_name()

Result< std::string > hal::BooleanFunction::Node::get_variable_name ( ) const

Get the variable name of node of type Variable.

Returns
The variable name on success, an error otherwise.

Definition at line 1849 of file boolean_function.cpp.

References ERR, hal::BooleanFunction::is_variable(), and OK.

Referenced by hal::BooleanFunction::get_variable_name().

◆ has_constant_value() [1/2]

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.

Parameters
value- The value to check for.
Returns
true if the Boolean function node is of type Constant and holds the given value, false otherwise.

Definition at line 1761 of file boolean_function.cpp.

References hal::BooleanFunction::is_constant().

Referenced by hal::boolean_function_init(), and hal::BooleanFunction::has_constant_value().

◆ has_constant_value() [2/2]

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.

Parameters
value- The value to check for.
Returns
true if the Boolean function node is of type Constant and holds the given value, false otherwise.

Definition at line 1766 of file boolean_function.cpp.

References hal::BooleanFunction::is_constant(), and hal::BooleanFunction::size().

◆ has_index_value()

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.

Parameters
value- The value to check for.
Returns
true if the Boolean function node is of type Index and holds the given value, false otherwise.

Definition at line 1824 of file boolean_function.cpp.

References hal::BooleanFunction::is_index().

Referenced by hal::boolean_function_init(), and hal::BooleanFunction::has_index_value().

◆ has_variable_name()

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.

Parameters
variable_name- The variable name to check for.
Returns
true if the Boolean function node is of type Variable and holds the given variable name, false otherwise.

Definition at line 1844 of file boolean_function.cpp.

References hal::BooleanFunction::is_variable().

Referenced by hal::boolean_function_init(), and hal::BooleanFunction::has_variable_name().

◆ Index()

BooleanFunction::Node hal::BooleanFunction::Node::Index ( u16  index,
u16  size 
)
static

Constructs an 'index' node.

Parameters
index- The index value of the node.
size- The bit-size of the node.
Returns
The node.

Definition at line 1620 of file boolean_function.cpp.

References hal::BooleanFunction::NodeType::Index.

Referenced by hal::boolean_function_init(), and hal::BooleanFunction::Index().

◆ is()

bool hal::BooleanFunction::Node::is ( u16  type) const

Checks whether the Boolean function node is of a specific type.

Parameters
type- The type to check for.
Returns
true if the node is of the given type, false otherwise.

Definition at line 1751 of file boolean_function.cpp.

References type.

Referenced by hal::boolean_function_init(), and hal::BooleanFunction::is().

◆ is_commutative()

bool hal::BooleanFunction::Node::is_commutative ( ) const

Checks whether the Boolean function node is commutative.

Returns
true if the Boolean function node is commutative, false otherwise.

Definition at line 1869 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().

◆ is_constant()

bool hal::BooleanFunction::Node::is_constant ( ) const

Checks whether the Boolean function node is of type Constant.

Returns
true if the Boolean function node is of type Constant, false otherwise.

Definition at line 1756 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().

◆ is_index()

bool hal::BooleanFunction::Node::is_index ( ) const

Checks whether the Boolean function node is of type Index.

Returns
true if the Boolean function node is of type Index, false otherwise.

Definition at line 1819 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().

◆ is_operand()

bool hal::BooleanFunction::Node::is_operand ( ) const

Checks whether the Boolean function node is an operand node.

Returns
true if the Boolean function node is an operand node, false otherwise.

Definition at line 1864 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().

◆ is_operation()

bool hal::BooleanFunction::Node::is_operation ( ) const

Checks whether the Boolean function node is an operation node.

Returns
true if the Boolean function node is an operation node, false otherwise.

Definition at line 1859 of file boolean_function.cpp.

Referenced by hal::boolean_function_init().

◆ is_variable()

bool hal::BooleanFunction::Node::is_variable ( ) const

Checks whether the Boolean function node is of type Variable.

Returns
true if the Boolean function node is of type Variable, false otherwise.

Definition at line 1839 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().

◆ Operation()

◆ operator!=()

bool hal::BooleanFunction::Node::operator!= ( const Node other) const

Checks whether two Boolean function nodes are unequal.

Parameters
[in]other- The other Boolean function node.
Returns
true if the Boolean function nodes are unequal, false otherwise.

Definition at line 1635 of file boolean_function.cpp.

◆ operator<()

bool hal::BooleanFunction::Node::operator< ( const Node other) const

Checks whether this Boolean function node is 'smaller' than the other Boolean function node.

Parameters
[in]other- The other Boolean function node.
Returns
true if this Boolean function node is 'smaller', false otherwise.

Definition at line 1640 of file boolean_function.cpp.

References constant, index, hal::BooleanFunction::size(), size, type, type, and variable.

◆ operator==()

bool hal::BooleanFunction::Node::operator== ( const Node other) const

Checks whether two Boolean function nodes are equal.

Parameters
[in]other- The other Boolean function node.
Returns
true if the Boolean function nodes are equal, false otherwise.

Definition at line 1630 of file boolean_function.cpp.

References constant, index, hal::BooleanFunction::size(), size, type, type, and variable.

◆ to_string()

◆ Variable()

BooleanFunction::Node hal::BooleanFunction::Node::Variable ( const std::string  variable,
u16  size 
)
static

Constructs a 'variable' node.

Parameters
variable- The variable name of the node.
size- The bit-size of the node.
Returns
The node.

Definition at line 1625 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().

Member Data Documentation

◆ constant

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

◆ index

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

◆ size

u16 hal::BooleanFunction::Node::size

◆ type

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

◆ variable

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


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