HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
simulation.cpp
Go to the documentation of this file.
2 
4 #include "hal_core/netlist/net.h"
5 
6 namespace hal
7 {
9  {
10  BooleanFunction::Value result = BooleanFunction::Value::X;
11 
12  if (auto it = m_events.find(net); it != m_events.end())
13  {
14  for (const WaveEvent& e : it->second)
15  {
16  if (e.time > time)
17  {
18  break;
19  }
20  result = e.new_value;
21  }
22  }
23  return result;
24  }
25 
26  void Simulation::add_event(const WaveEvent &event)
27  {
28  m_events[event.affected_net].push_back(event);
29  }
30 
31  std::unordered_map<const Net*, std::vector<WaveEvent>> Simulation::get_events() const
32  {
33  return m_events;
34  }
35 
36  std::vector<WaveEvent> Simulation::get_events_by_net_id(u32 netId, bool* found) const
37  {
38  for (auto it=m_events.begin(); it!=m_events.end(); ++it)
39  if (it->first->get_id() == netId)
40  {
41  if (found) *found = true;
42  return it->second;
43  }
44  if (found) *found = false;
45  return std::vector<WaveEvent>();
46  }
47 
48 } // namespace hal
Value
represents the type of the node
Definition: net.h:58
std::vector< WaveEvent > get_events_by_net_id(u32 netId, bool *found=nullptr) const
Definition: simulation.cpp:36
BooleanFunction::Value get_net_value(const Net *net, u64 time) const
Definition: simulation.cpp:8
std::unordered_map< const Net *, std::vector< WaveEvent > > get_events() const
Definition: simulation.cpp:31
void add_event(const WaveEvent &event)
Definition: simulation.cpp:26
uint64_t u64
Definition: defines.h:42
uint32_t u32
Definition: defines.h:41
Definition: defines.h:45
Net * net
BooleanFunction::Value new_value
Definition: wave_event.h:46