HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
register_candidate.cpp
Go to the documentation of this file.
2 
4 #include "hal_core/netlist/net.h"
5 namespace hal
6 {
7  namespace hawkeye
8  {
9  RegisterCandidate::RegisterCandidate(const std::set<Gate*>& round_reg) : m_in_reg(round_reg), m_out_reg(round_reg)
10  {
11  m_size = m_out_reg.size();
12  m_netlist = (*m_out_reg.begin())->get_netlist();
13  m_is_round_based = true;
14  }
15 
16  RegisterCandidate::RegisterCandidate(std::set<Gate*>&& round_reg) : m_in_reg(std::move(round_reg))
17  {
18  m_out_reg = m_in_reg;
19  m_size = m_out_reg.size();
20  m_netlist = (*m_out_reg.begin())->get_netlist();
21  m_is_round_based = true;
22  }
23 
24  RegisterCandidate::RegisterCandidate(const std::set<Gate*>& in_reg, const std::set<Gate*>& out_reg) : m_in_reg(in_reg), m_out_reg(out_reg)
25  {
26  m_size = m_out_reg.size();
27  m_netlist = (*m_out_reg.begin())->get_netlist();
28  m_is_round_based = m_in_reg == m_out_reg;
29  }
30 
31  RegisterCandidate::RegisterCandidate(std::set<Gate*>&& in_reg, std::set<Gate*>&& out_reg) : m_in_reg(std::move(in_reg)), m_out_reg(std::move(out_reg))
32  {
33  m_size = m_out_reg.size();
34  m_netlist = (*m_out_reg.begin())->get_netlist();
35  m_is_round_based = m_in_reg == m_out_reg;
36  }
37 
39  {
40  return (this->m_size == rhs.m_size) && (this->m_in_reg == rhs.m_in_reg) && (!m_is_round_based & (this->m_out_reg == rhs.m_out_reg));
41  }
42 
44  {
45  return (this->m_size > rhs.m_size) || (this->m_size == rhs.m_size && this->m_in_reg > rhs.m_in_reg)
46  || (!m_is_round_based & (this->m_size == rhs.m_size && this->m_in_reg == rhs.m_in_reg && this->m_out_reg > rhs.m_out_reg));
47  }
48 
50  {
51  return m_netlist;
52  }
53 
55  {
56  return m_size;
57  }
58 
60  {
61  return m_is_round_based;
62  }
63 
64  const std::set<Gate*>& RegisterCandidate::get_input_reg() const
65  {
66  return m_in_reg;
67  }
68 
69  const std::set<Gate*>& RegisterCandidate::get_output_reg() const
70  {
71  return m_out_reg;
72  }
73  } // namespace hawkeye
74 } // namespace hal
std::set< u32 > out_reg
std::set< u32 > in_reg
A register candidate discovered by HAWKEYE.
Netlist * get_netlist() const
Get the netlist associated with the candidate.
bool operator<(const RegisterCandidate &rhs) const
Less-than comparison operator for two register candidates.
bool is_round_based() const
Check if the candidate is round-based, i.e., input and output register are the same.
bool operator==(const RegisterCandidate &rhs) const
Equality comparison operator for two register candidates.
RegisterCandidate()=default
Default constructor for RegisterCandidate.
u32 get_size() const
Get the size of the candidate, i.e., the width of its registers.
const std::set< Gate * > & get_input_reg() const
Get the candidate's input register.
const std::set< Gate * > & get_output_reg() const
Get the candidate's output register.
uint32_t u32
Definition: defines.h:41
Definition: defines.h:45
This file contains the class that holds all information on a register candidate.