HAL  v4.5.0-124-g47ab54673
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
netlist.cpp
Go to the documentation of this file.
2 
4 
9 #include "hal_core/netlist/net.h"
11 #include "hal_core/utilities/log.h"
12 
13 namespace hal
14 {
15  Netlist::Netlist(const GateLibrary* library) : m_gate_library(gate_library_manager::get_owning(library))
16  {
17  m_event_handler = std::make_unique<EventHandler>();
18  m_manager = new NetlistInternalManager(this, m_event_handler.get());
19  m_netlist_id = 1;
20  m_next_gate_id = 1;
21  m_next_net_id = 1;
22  m_next_module_id = 1;
23  m_next_grouping_id = 1;
24  m_top_module = nullptr; // this triggers the internal manager to allow creation of a module without parent
25  m_top_module = create_module("top_module", nullptr);
26  }
27 
29  {
30  delete m_manager;
31  }
32 
33  bool Netlist::operator==(const Netlist& other) const
34  {
35  if (m_file_name != other.get_input_filename() || m_design_name != other.get_design_name() || m_device_name != other.get_device_name())
36  {
37  log_info("netlist", "the netlists with IDs {} and {} are not equal due to an unequal file name, design name, or device name.", m_netlist_id, other.get_id());
38  return false;
39  }
40 
41  if (m_gate_library.get() != other.get_gate_library())
42  {
43  log_info("netlist", "the netlists with IDs {} and {} are not equal due to an unequal gate library.", m_netlist_id, other.get_id());
44  return false;
45  }
46 
47  if (m_gates.size() != other.get_gates().size() || m_nets.size() != other.get_nets().size() || m_modules.size() != other.get_modules().size())
48  {
49  log_info("netlist", "the netlists with IDs {} and {} are not equal due to an unequal number of gates, nets, or modules.", m_netlist_id, other.get_id());
50  return false;
51  }
52 
53  for (const Net* net : other.get_nets())
54  {
55  if (const auto it = m_nets_map.find(net->get_id()); it == m_nets_map.end() || *it->second != *net)
56  {
57  log_info("netlist", "the netlists with IDs {} and {} are not equal due to unequal nets.", m_netlist_id, other.get_id());
58  return false;
59  }
60  }
61 
62  // modules are checked recursively
63  if (*m_top_module != *other.get_top_module())
64  {
65  log_info("netlist", "the netlists with IDs {} and {} are not equal due to unequal modules.", m_netlist_id, other.get_id());
66  return false;
67  }
68 
69  return true;
70  }
71 
72  bool Netlist::operator!=(const Netlist& other) const
73  {
74  return !operator==(other);
75  }
76 
78  {
79  return m_netlist_id;
80  }
81 
82  void Netlist::set_id(const u32 id)
83  {
84  if (id != m_netlist_id)
85  {
86  auto old_id = m_netlist_id;
87  m_netlist_id = id;
88  m_event_handler->notify(NetlistEvent::event::id_changed, this, old_id);
89  }
90  }
91 
92  std::filesystem::path Netlist::get_input_filename() const
93  {
94  return m_file_name;
95  }
96 
97  void Netlist::set_input_filename(const std::filesystem::path& input_filename)
98  {
99  if (input_filename != m_file_name)
100  {
101  m_file_name = input_filename;
102  m_event_handler->notify(NetlistEvent::event::input_filename_changed, this);
103  }
104  }
105 
106  const std::string& Netlist::get_design_name() const
107  {
108  return m_design_name;
109  }
110 
111  void Netlist::set_design_name(const std::string& design_name)
112  {
113  if (design_name != m_design_name)
114  {
115  m_design_name = design_name;
116  m_event_handler->notify(NetlistEvent::event::design_name_changed, this);
117  }
118  }
119 
120  const std::string& Netlist::get_device_name() const
121  {
122  return m_device_name;
123  }
124 
125  void Netlist::set_device_name(const std::string& device_name)
126  {
127  if (device_name != m_device_name)
128  {
129  m_device_name = device_name;
130  m_event_handler->notify(NetlistEvent::event::device_name_changed, this);
131  }
132  }
133 
135  {
136  return m_gate_library.get();
137  }
138 
140  {
141  return m_event_handler.get();
142  }
143 
145  {
146  if (auto res = m_manager->copy_netlist(this); res.is_error())
147  {
148  return ERR(res.get_error());
149  }
150  else
151  {
152  return res;
153  }
154  }
155 
156  /*
157  * ################################################################
158  * gate functions
159  * ################################################################
160  */
161 
163  {
164  if (!m_free_gate_ids.empty())
165  {
166  return *(m_free_gate_ids.begin());
167  }
168  while (m_used_gate_ids.find(m_next_gate_id) != m_used_gate_ids.end())
169  {
170  m_next_gate_id++;
171  }
172  return m_next_gate_id;
173  }
174 
175  Gate* Netlist::create_gate(const u32 id, GateType* gt, const std::string& name, i32 x, i32 y)
176  {
177  return m_manager->create_gate(id, gt, name, x, y);
178  }
179 
180  Gate* Netlist::create_gate(GateType* gt, const std::string& name, i32 x, i32 y)
181  {
182  return create_gate(get_unique_gate_id(), gt, name, x, y);
183  }
184 
186  {
187  return m_manager->delete_gate(gate);
188  }
189 
190  bool Netlist::is_gate_in_netlist(const Gate* gate) const
191  {
192  return gate != nullptr && m_gates_set.find(gate) != m_gates_set.end();
193  }
194 
195  Gate* Netlist::get_gate_by_id(const u32 gate_id) const
196  {
197  if (auto it = m_gates_map.find(gate_id); it != m_gates_map.end())
198  {
199  return it->second.get();
200  }
201 
202  log_debug("netlist", "there is no gate with ID {} in the netlist with ID {}.", gate_id, m_netlist_id);
203  return nullptr;
204  }
205 
206  const std::vector<Gate*>& Netlist::get_gates() const
207  {
208  return m_gates;
209  }
210 
211  std::vector<Gate*> Netlist::get_gates(const std::function<bool(const Gate*)>& filter) const
212  {
213  if (!filter)
214  {
215  return m_gates;
216  }
217  std::vector<Gate*> res;
218  for (Gate* g : m_gates)
219  {
220  if (!filter(g))
221  {
222  continue;
223  }
224  res.push_back(g);
225  }
226 
227  return res;
228  }
229 
231  {
232  if (!is_gate_in_netlist(gate))
233  {
234  return false;
235  }
236  if (is_vcc_gate(gate))
237  {
238  log_debug("netlist", "gate '{}' with ID {} is already registered as global VCC gate in the netlist with ID {}.", gate->get_name(), gate->get_id(), m_netlist_id);
239  return true;
240  }
241  m_vcc_gates.push_back(gate);
242  m_event_handler->notify(NetlistEvent::event::marked_global_vcc, this, gate->get_id());
243  return true;
244  }
245 
247  {
248  if (!is_gate_in_netlist(gate))
249  {
250  return false;
251  }
252  if (is_gnd_gate(gate))
253  {
254  log_debug("netlist", "gate '{}' with ID {} is already registered as global GND gate in the netlist with ID {}.", gate->get_name(), gate->get_id(), m_netlist_id);
255  return true;
256  }
257  m_gnd_gates.push_back(gate);
258  m_event_handler->notify(NetlistEvent::event::marked_global_gnd, this, gate->get_id());
259  return true;
260  }
261 
263  {
264  if (!is_gate_in_netlist(gate))
265  {
266  return false;
267  }
268  auto it = std::find(m_vcc_gates.begin(), m_vcc_gates.end(), gate);
269  if (it == m_vcc_gates.end())
270  {
271  log_debug("netlist", "gate '{}' with ID {} is not registered as global VCC gate in the netlist with ID {}.", gate->get_name(), gate->get_id(), m_netlist_id);
272  return false;
273  }
274  m_vcc_gates.erase(it);
275  m_event_handler->notify(NetlistEvent::event::unmarked_global_vcc, this, gate->get_id());
276  return true;
277  }
278 
280  {
281  if (!is_gate_in_netlist(gate))
282  {
283  return false;
284  }
285  auto it = std::find(m_gnd_gates.begin(), m_gnd_gates.end(), gate);
286  if (it == m_gnd_gates.end())
287  {
288  log_debug("netlist", "gate '{}' with ID {} is not registered as global GND gate in the netlist with ID {}.", gate->get_name(), gate->get_id(), m_netlist_id);
289  return false;
290  }
291  m_gnd_gates.erase(it);
292  m_event_handler->notify(NetlistEvent::event::unmarked_global_gnd, this, gate->get_id());
293  return true;
294  }
295 
296  bool Netlist::is_vcc_gate(const Gate* gate) const
297  {
298  return (std::find(m_vcc_gates.begin(), m_vcc_gates.end(), gate) != m_vcc_gates.end());
299  }
300 
301  bool Netlist::is_gnd_gate(const Gate* gate) const
302  {
303  return (std::find(m_gnd_gates.begin(), m_gnd_gates.end(), gate) != m_gnd_gates.end());
304  }
305 
306  const std::vector<Gate*>& Netlist::get_vcc_gates() const
307  {
308  return m_vcc_gates;
309  }
310 
311  const std::vector<Gate*>& Netlist::get_gnd_gates() const
312  {
313  return m_gnd_gates;
314  }
315 
316  /*
317  * ################################################################
318  * net functions
319  * ################################################################
320  */
321 
323  {
324  if (!m_free_net_ids.empty())
325  {
326  return *(m_free_net_ids.begin());
327  }
328  while (m_used_net_ids.find(m_next_net_id) != m_used_net_ids.end())
329  {
330  m_next_net_id++;
331  }
332  return m_next_net_id;
333  }
334 
335  Net* Netlist::create_net(const u32 id, const std::string& name)
336  {
337  return m_manager->create_net(id, name);
338  }
339 
340  Net* Netlist::create_net(const std::string& name)
341  {
342  return m_manager->create_net(get_unique_net_id(), name);
343  }
344 
346  {
347  return m_manager->delete_net(n);
348  }
349 
350  bool Netlist::is_net_in_netlist(const Net* n) const
351  {
352  return n != nullptr && m_nets_set.find(n) != m_nets_set.end();
353  }
354 
356  {
357  if (auto it = m_nets_map.find(net_id); it != m_nets_map.end())
358  {
359  return it->second.get();
360  }
361 
362  log_debug("netlist", "there is no net with ID {} in the netlist with ID {}.", net_id, m_netlist_id);
363  return nullptr;
364  }
365 
366  const std::vector<Net*>& Netlist::get_nets() const
367  {
368  return m_nets;
369  }
370 
371  std::vector<Net*> Netlist::get_nets(const std::function<bool(const Net*)>& filter) const
372  {
373  if (!filter)
374  {
375  return m_nets;
376  }
377  std::vector<Net*> res;
378  for (auto net : m_nets)
379  {
380  if (!filter(net))
381  {
382  continue;
383  }
384  res.push_back(net);
385  }
386  return res;
387  }
388 
390  {
391  if (!is_net_in_netlist(n))
392  {
393  return false;
394  }
395  if (is_global_input_net(n))
396  {
397  log_debug("netlist", "net '{}' with ID {} is already registered as global input net in the netlist with ID {}.", n->get_name(), n->get_id(), m_netlist_id);
398  return true;
399  }
400  m_global_input_nets.push_back(n);
401 
402  // update internal nets and port nets
403  if (m_manager->m_net_checks_enabled)
404  {
405  for (Endpoint* ep : n->get_sources())
406  {
407  m_manager->module_check_net(ep->get_gate()->get_module(), n, true);
408  }
409  for (Endpoint* ep : n->get_destinations())
410  {
411  m_manager->module_check_net(ep->get_gate()->get_module(), n, true);
412  }
413  }
414 
415  m_event_handler->notify(NetlistEvent::event::marked_global_input, this, n->get_id());
416  return true;
417  }
418 
420  {
421  if (!is_net_in_netlist(n))
422  {
423  return false;
424  }
425  if (is_global_output_net(n))
426  {
427  log_debug("netlist", "net '{}' with ID {} is already registered as global output net in the netlist with ID {}.", n->get_name(), n->get_id(), m_netlist_id);
428  return true;
429  }
430  m_global_output_nets.push_back(n);
431 
432  // update internal nets and port nets
433  if (m_manager->m_net_checks_enabled)
434  {
435  for (Endpoint* ep : n->get_sources())
436  {
437  m_manager->module_check_net(ep->get_gate()->get_module(), n, true);
438  }
439  for (Endpoint* ep : n->get_destinations())
440  {
441  m_manager->module_check_net(ep->get_gate()->get_module(), n, true);
442  }
443  }
444 
445  m_event_handler->notify(NetlistEvent::event::marked_global_output, this, n->get_id());
446  return true;
447  }
448 
450  {
451  if (!is_net_in_netlist(n))
452  {
453  return false;
454  }
455  auto it = std::find(m_global_input_nets.begin(), m_global_input_nets.end(), n);
456  if (it == m_global_input_nets.end())
457  {
458  log_debug("netlist", "net '{}' with ID {} is not registered as global input net in the netlist with ID {}.", n->get_name(), n->get_id(), m_netlist_id);
459  return false;
460  }
461  m_global_input_nets.erase(it);
462 
463  // update internal nets and port nets
464  if (m_manager->m_net_checks_enabled)
465  {
466  for (Endpoint* ep : n->get_sources())
467  {
468  m_manager->module_check_net(ep->get_gate()->get_module(), n, true);
469  }
470  for (Endpoint* ep : n->get_destinations())
471  {
472  m_manager->module_check_net(ep->get_gate()->get_module(), n, true);
473  }
474  }
475 
476  m_event_handler->notify(NetlistEvent::event::unmarked_global_input, this, n->get_id());
477  return true;
478  }
479 
481  {
482  if (!is_net_in_netlist(n))
483  {
484  return false;
485  }
486  auto it = std::find(m_global_output_nets.begin(), m_global_output_nets.end(), n);
487  if (it == m_global_output_nets.end())
488  {
489  log_debug("netlist", "net '{}' with ID {} is not registered as global output net in the netlist with ID {}.", n->get_name(), n->get_id(), m_netlist_id);
490  return false;
491  }
492  m_global_output_nets.erase(it);
493 
494  // update internal nets and port nets
495  if (m_manager->m_net_checks_enabled)
496  {
497  for (Endpoint* ep : n->get_sources())
498  {
499  m_manager->module_check_net(ep->get_gate()->get_module(), n, true);
500  }
501  for (Endpoint* ep : n->get_destinations())
502  {
503  m_manager->module_check_net(ep->get_gate()->get_module(), n, true);
504  }
505  }
506 
507  m_event_handler->notify(NetlistEvent::event::unmarked_global_output, this, n->get_id());
508  return true;
509  }
510 
511  bool Netlist::is_global_input_net(const Net* n) const
512  {
513  return (std::find(m_global_input_nets.begin(), m_global_input_nets.end(), n) != m_global_input_nets.end());
514  }
515 
516  bool Netlist::is_global_output_net(const Net* n) const
517  {
518  return (std::find(m_global_output_nets.begin(), m_global_output_nets.end(), n) != m_global_output_nets.end());
519  }
520 
521  const std::vector<Net*>& Netlist::get_global_input_nets() const
522  {
523  return m_global_input_nets;
524  }
525 
526  const std::vector<Net*>& Netlist::get_global_output_nets() const
527  {
528  return m_global_output_nets;
529  }
530 
531  std::vector<Net*> Netlist::get_gnd_nets() const
532  {
533  std::vector<Net*> gnd_nets;
534  for (const auto& gnd_gate : m_gnd_gates)
535  {
536  for (const auto& o_net : gnd_gate->get_fan_out_nets())
537  {
538  if (o_net->is_gnd_net())
539  {
540  gnd_nets.push_back(o_net);
541  }
542  }
543  }
544 
545  return gnd_nets;
546  }
547 
548  std::vector<Net*> Netlist::get_vcc_nets() const
549  {
550  std::vector<Net*> vcc_nets;
551  for (const auto& vcc_gate : m_vcc_gates)
552  {
553  for (const auto& o_net : vcc_gate->get_fan_out_nets())
554  {
555  if (o_net->is_vcc_net())
556  {
557  vcc_nets.push_back(o_net);
558  }
559  }
560  }
561 
562  return vcc_nets;
563  }
564 
565  void Netlist::enable_automatic_net_checks(bool enable_checks)
566  {
567  m_manager->m_net_checks_enabled = enable_checks;
568  }
569 
570  /*
571  * ################################################################
572  * module functions
573  * ################################################################
574  */
575 
577  {
578  if (!m_free_module_ids.empty())
579  {
580  return *(m_free_module_ids.begin());
581  }
582  while (m_used_module_ids.find(m_next_module_id) != m_used_module_ids.end())
583  {
584  m_next_module_id++;
585  }
586  return m_next_module_id;
587  }
588 
589  Module* Netlist::create_module(const u32 id, const std::string& name, Module* parent, const std::vector<Gate*>& gates)
590  {
591  auto m = m_manager->create_module(id, parent, name);
592  if (m == nullptr)
593  {
594  return nullptr;
595  }
596  m->assign_gates(gates);
597  return m;
598  }
599 
600  Module* Netlist::create_module(const std::string& name, Module* parent, const std::vector<Gate*>& gates)
601  {
602  return create_module(get_unique_module_id(), name, parent, gates);
603  }
604 
606  {
607  return m_manager->delete_module(module);
608  }
609 
611  {
612  return m_top_module;
613  }
614 
616  {
617  if (auto it = m_modules_map.find(id); it != m_modules_map.end())
618  {
619  return it->second.get();
620  }
621 
622  log_debug("netlist", "there is no module with ID {} in the netlist with ID {}.", id, m_netlist_id);
623  return nullptr;
624  }
625 
626  const std::vector<Module*>& Netlist::get_modules() const
627  {
628  return m_modules;
629  }
630 
631  std::vector<Module*> Netlist::get_modules(const std::function<bool(const Module*)>& filter) const
632  {
633  if (!filter)
634  {
635  return m_modules;
636  }
637  std::vector<Module*> res;
638  for (auto module : m_modules)
639  {
640  if (!filter(module))
641  {
642  continue;
643  }
644  res.push_back(module);
645  }
646  return res;
647  }
648 
650  {
651  return (module != nullptr) && (m_modules_set.find(module) != m_modules_set.end());
652  }
653 
654  /*
655  * ################################################################
656  * grouping functions
657  * ################################################################
658  */
659 
661  {
662  if (!m_free_grouping_ids.empty())
663  {
664  return *(m_free_grouping_ids.begin());
665  }
666  while (m_used_grouping_ids.find(m_next_grouping_id) != m_used_grouping_ids.end())
667  {
668  m_next_grouping_id++;
669  }
670  return m_next_grouping_id;
671  }
672 
673  Grouping* Netlist::create_grouping(const u32 id, const std::string& name)
674  {
675  return m_manager->create_grouping(id, name);
676  }
677 
679  {
680  return m_manager->create_grouping(get_unique_grouping_id(), name);
681  }
682 
684  {
685  return m_manager->delete_grouping(g);
686  }
687 
689  {
690  return n != nullptr && m_groupings_set.find(n) != m_groupings_set.end();
691  }
692 
694  {
695  if (auto it = m_groupings_map.find(grouping_id); it != m_groupings_map.end())
696  {
697  return it->second.get();
698  }
699 
700  log_debug("netlist", "there is no grouping with ID {} in the netlist with ID {}.", grouping_id, m_netlist_id);
701  return nullptr;
702  }
703 
704  const std::vector<Grouping*>& Netlist::get_groupings() const
705  {
706  return m_groupings;
707  }
708 
709  std::vector<Grouping*> Netlist::get_groupings(const std::function<bool(const Grouping*)>& filter) const
710  {
711  if (!filter)
712  {
713  return m_groupings;
714  }
715  std::vector<Grouping*> res;
716  for (auto grouping : m_groupings)
717  {
718  if (!filter(grouping))
719  {
720  continue;
721  }
722  res.push_back(grouping);
723  }
724  return res;
725  }
726 
727  /*
728  * ################################################################
729  * getter/setter for ID tracking
730  * ################################################################
731  */
732 
734  {
735  return m_next_gate_id;
736  }
737 
739  {
740  m_next_gate_id = id;
741  }
742 
743  std::set<u32> Netlist::get_used_gate_ids() const
744  {
745  return m_used_gate_ids;
746  }
747 
748  void Netlist::set_used_gate_ids(const std::set<u32> ids)
749  {
750  m_used_gate_ids = ids;
751  }
752 
753  std::set<u32> Netlist::get_free_gate_ids() const
754  {
755  return m_free_gate_ids;
756  }
757 
758  void Netlist::set_free_gate_ids(const std::set<u32> ids)
759  {
760  m_free_gate_ids = ids;
761  }
762 
764  {
765  return m_next_net_id;
766  }
767 
769  {
770  m_next_net_id = id;
771  }
772 
773  std::set<u32> Netlist::get_used_net_ids() const
774  {
775  return m_used_net_ids;
776  }
777 
778  void Netlist::set_used_net_ids(const std::set<u32> ids)
779  {
780  m_used_net_ids = ids;
781  }
782 
783  std::set<u32> Netlist::get_free_net_ids() const
784  {
785  return m_free_net_ids;
786  }
787 
788  void Netlist::set_free_net_ids(const std::set<u32> ids)
789  {
790  m_free_net_ids = ids;
791  }
792 
794  {
795  return m_next_module_id;
796  }
797 
799  {
800  m_next_module_id = id;
801  }
802 
803  std::set<u32> Netlist::get_used_module_ids() const
804  {
805  return m_used_module_ids;
806  }
807 
808  void Netlist::set_used_module_ids(const std::set<u32> ids)
809  {
810  m_used_module_ids = ids;
811  }
812 
813  std::set<u32> Netlist::get_free_module_ids() const
814  {
815  return m_free_module_ids;
816  }
817 
818  void Netlist::set_free_module_ids(const std::set<u32> ids)
819  {
820  m_free_module_ids = ids;
821  }
822 
824  {
825  return m_next_grouping_id;
826  }
827 
829  {
830  m_next_grouping_id = id;
831  }
832 
833  std::set<u32> Netlist::get_used_grouping_ids() const
834  {
835  return m_used_grouping_ids;
836  }
837 
838  void Netlist::set_used_grouping_ids(const std::set<u32> ids)
839  {
840  m_used_grouping_ids = ids;
841  }
842 
843  std::set<u32> Netlist::get_free_grouping_ids() const
844  {
845  return m_free_grouping_ids;
846  }
847 
848  void Netlist::set_free_grouping_ids(const std::set<u32> ids)
849  {
850  m_free_grouping_ids = ids;
851  }
852 
853  /*
854  * ################################################################
855  * utility functions
856  * ################################################################
857  */
858 
860  {
861  m_manager->clear_caches();
862  }
863 
864  bool Netlist::load_gate_locations_from_data(const std::string& data_category, const std::pair<std::string, std::string>& data_identifiers)
865  {
866  std::string category;
867  std::pair<std::string, std::string> identifiers;
868 
869  if (data_category.empty())
870  {
871  category = m_gate_library->get_gate_location_data_category();
872  identifiers = m_gate_library->get_gate_location_data_identifiers();
873  }
874  else
875  {
876  category = data_category;
877  identifiers = data_identifiers;
878  }
879 
880  u32 failed = 0;
881  for (Gate* gate : m_gates)
882  {
883  if (gate->has_data(category, identifiers.first))
884  {
885  try
886  {
887  i32 x_loc = std::stoi(std::get<1>(gate->get_data(category, identifiers.first)));
888  i32 y_loc = std::stoi(std::get<1>(gate->get_data(category, identifiers.second)));
889 
890  gate->set_location(std::make_pair(x_loc, y_loc));
891 
892  continue;
893  }
894  catch (const std::exception& e)
895  {
896  log_error("netlist", "{}", e.what());
897  return false;
898  }
899  }
900 
901  failed++;
902  }
903 
904  if (failed > 0)
905  {
906  log_warning("netlist", "failed to load locations of {} gates.", failed);
907  }
908 
909  return true;
910  }
911 
912 } // namespace hal
Definition: gate.h:58
const std::string & get_name() const
Definition: gate.cpp:105
u32 get_id() const
Definition: gate.cpp:95
bool assign_gates(const std::vector< Gate * > &gates)
Definition: module.cpp:329
Definition: net.h:58
u32 get_id() const
Definition: net.cpp:88
const std::string & get_name() const
Definition: net.cpp:98
std::vector< Endpoint * > get_destinations(const std::function< bool(Endpoint *ep)> &filter=nullptr) const
Definition: net.cpp:450
std::vector< Endpoint * > get_sources(const std::function< bool(Endpoint *ep)> &filter=nullptr) const
Definition: net.cpp:276
@ marked_global_gnd
associated_data = id of gate
@ unmarked_global_output
associated_data = id of net
@ id_changed
associated_data = old id
@ device_name_changed
no associated_data
@ unmarked_global_gnd
associated_data = id of gate
@ input_filename_changed
no associated_data
@ unmarked_global_vcc
associated_data = id of gate
@ marked_global_vcc
associated_data = id of gate
@ unmarked_global_input
associated_data = id of net
@ design_name_changed
no associated_data
@ marked_global_output
associated_data = id of net
@ marked_global_input
associated_data = id of net
bool operator!=(const Netlist &other) const
Definition: netlist.cpp:72
void set_input_filename(const std::filesystem::path &path)
Definition: netlist.cpp:97
Module * get_top_module() const
Definition: netlist.cpp:610
const std::vector< Gate * > & get_gates() const
Definition: netlist.cpp:206
std::vector< Net * > get_vcc_nets() const
Definition: netlist.cpp:548
u32 get_unique_gate_id()
Definition: netlist.cpp:162
bool mark_vcc_gate(Gate *gate)
Definition: netlist.cpp:230
const std::vector< Net * > & get_global_input_nets() const
Definition: netlist.cpp:521
bool mark_gnd_gate(Gate *gate)
Definition: netlist.cpp:246
void set_used_gate_ids(const std::set< u32 > ids)
Definition: netlist.cpp:748
u32 get_unique_grouping_id()
Definition: netlist.cpp:660
void set_used_net_ids(const std::set< u32 > ids)
Definition: netlist.cpp:778
Grouping * create_grouping(const u32 grouping_id, const std::string &name="")
Definition: netlist.cpp:673
bool is_gate_in_netlist(const Gate *gate) const
Definition: netlist.cpp:190
Gate * get_gate_by_id(const u32 gate_id) const
Definition: netlist.cpp:195
bool is_module_in_netlist(const Module *module) const
Definition: netlist.cpp:649
bool delete_grouping(Grouping *grouping)
Definition: netlist.cpp:683
bool load_gate_locations_from_data(const std::string &data_category="", const std::pair< std::string, std::string > &data_identifiers=std::pair< std::string, std::string >())
Definition: netlist.cpp:864
void set_free_grouping_ids(const std::set< u32 > ids)
Definition: netlist.cpp:848
std::set< u32 > get_free_module_ids() const
Definition: netlist.cpp:813
u32 get_unique_module_id()
Definition: netlist.cpp:576
bool delete_net(Net *net)
Definition: netlist.cpp:345
bool is_gnd_gate(const Gate *gate) const
Definition: netlist.cpp:301
Net * create_net(const u32 net_id, const std::string &name)
Definition: netlist.cpp:335
std::vector< Net * > get_gnd_nets() const
Definition: netlist.cpp:531
const std::vector< Gate * > & get_gnd_gates() const
Definition: netlist.cpp:311
std::set< u32 > get_used_net_ids() const
Definition: netlist.cpp:773
void set_next_gate_id(const u32 id)
Definition: netlist.cpp:738
void set_free_module_ids(const std::set< u32 > ids)
Definition: netlist.cpp:818
void set_design_name(const std::string &name)
Definition: netlist.cpp:111
std::set< u32 > get_free_gate_ids() const
Definition: netlist.cpp:753
void enable_automatic_net_checks(bool enable_checks=true)
Definition: netlist.cpp:565
std::set< u32 > get_used_grouping_ids() const
Definition: netlist.cpp:833
bool delete_module(Module *module)
Definition: netlist.cpp:605
const std::vector< Gate * > & get_vcc_gates() const
Definition: netlist.cpp:306
bool unmark_gnd_gate(Gate *gate)
Definition: netlist.cpp:279
friend class NetlistInternalManager
Definition: netlist.h:57
bool delete_gate(Gate *gate)
Definition: netlist.cpp:185
bool is_grouping_in_netlist(const Grouping *grouping) const
Definition: netlist.cpp:688
u32 get_next_net_id() const
Definition: netlist.cpp:763
bool operator==(const Netlist &other) const
Definition: netlist.cpp:33
u32 get_id() const
Definition: netlist.cpp:77
u32 get_next_module_id() const
Definition: netlist.cpp:793
Result< std::unique_ptr< Netlist > > copy() const
Definition: netlist.cpp:144
const std::vector< Module * > & get_modules() const
Definition: netlist.cpp:626
void set_id(const u32 id)
Definition: netlist.cpp:82
std::set< u32 > get_used_gate_ids() const
Definition: netlist.cpp:743
u32 get_unique_net_id()
Definition: netlist.cpp:322
bool unmark_vcc_gate(Gate *gate)
Definition: netlist.cpp:262
void set_free_net_ids(const std::set< u32 > ids)
Definition: netlist.cpp:788
const std::string & get_device_name() const
Definition: netlist.cpp:120
void clear_caches()
Definition: netlist.cpp:859
void set_next_module_id(const u32 id)
Definition: netlist.cpp:798
bool mark_global_input_net(Net *net)
Definition: netlist.cpp:389
bool is_net_in_netlist(const Net *net) const
Definition: netlist.cpp:350
std::set< u32 > get_used_module_ids() const
Definition: netlist.cpp:803
Module * get_module_by_id(u32 module_id) const
Definition: netlist.cpp:615
bool is_vcc_gate(const Gate *gate) const
Definition: netlist.cpp:296
Gate * create_gate(const u32 gate_id, GateType *gate_type, const std::string &name="", i32 x=-1, i32 y=-1)
Definition: netlist.cpp:175
void set_free_gate_ids(const std::set< u32 > ids)
Definition: netlist.cpp:758
bool mark_global_output_net(Net *net)
Definition: netlist.cpp:419
void set_next_grouping_id(const u32 id)
Definition: netlist.cpp:828
Net * get_net_by_id(u32 net_id) const
Definition: netlist.cpp:355
std::set< u32 > get_free_grouping_ids() const
Definition: netlist.cpp:843
void set_used_grouping_ids(const std::set< u32 > ids)
Definition: netlist.cpp:838
const std::string & get_design_name() const
Definition: netlist.cpp:106
const std::vector< Net * > & get_global_output_nets() const
Definition: netlist.cpp:526
const std::vector< Net * > & get_nets() const
Definition: netlist.cpp:366
bool unmark_global_output_net(Net *net)
Definition: netlist.cpp:480
void set_device_name(const std::string &name)
Definition: netlist.cpp:125
const std::vector< Grouping * > & get_groupings() const
Definition: netlist.cpp:704
bool is_global_input_net(const Net *net) const
Definition: netlist.cpp:511
void set_next_net_id(const u32 id)
Definition: netlist.cpp:768
void set_used_module_ids(const std::set< u32 > ids)
Definition: netlist.cpp:808
u32 get_next_grouping_id() const
Definition: netlist.cpp:823
u32 get_next_gate_id() const
Definition: netlist.cpp:733
std::filesystem::path get_input_filename() const
Definition: netlist.cpp:92
const GateLibrary * get_gate_library() const
Definition: netlist.cpp:134
Netlist(const GateLibrary *gate_library)
Definition: netlist.cpp:15
Grouping * get_grouping_by_id(u32 grouping_id) const
Definition: netlist.cpp:693
std::set< u32 > get_free_net_ids() const
Definition: netlist.cpp:783
EventHandler * get_event_handler() const
Definition: netlist.cpp:139
bool unmark_global_input_net(Net *net)
Definition: netlist.cpp:449
bool is_global_output_net(const Net *net) const
Definition: netlist.cpp:516
Module * create_module(const u32 module_id, const std::string &name, Module *parent, const std::vector< Gate * > &gates={})
Definition: netlist.cpp:589
uint32_t u32
Definition: defines.h:41
int32_t i32
Definition: defines.h:36
#define log_error(channel,...)
Definition: log.h:78
#define log_debug(channel,...)
Definition: log.h:74
#define log_info(channel,...)
Definition: log.h:70
#define log_warning(channel,...)
Definition: log.h:76
#define ERR(message)
Definition: result.h:60
const Module * module(const Gate *g, const NodeBoxes &boxes)
std::shared_ptr< GateLibrary > get_owning(const GateLibrary *gate_lib)
Definition: defines.h:45
Net * net
std::string name
i32 id
std::unique_ptr< RuntimeLibrary > library