HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
netlist.cpp
Go to the documentation of this file.
2 
3 namespace hal
4 {
6  {
7  py::class_<Netlist, std::shared_ptr<Netlist>> py_netlist(m, "Netlist", R"(
8  Netlist class containing information about the netlist including its gates, modules, nets, and groupings as well as the underlying gate library.
9  )");
10 
11  py_netlist.def(py::self == py::self, R"(
12  Check whether two netlists are equal.
13  Does not check netlist IDs.
14 
15  :returns: ``True`` if both netlists are equal, ``False`` otherwise.
16  :rtype: bool
17  )");
18 
19  py_netlist.def(py::self != py::self, R"(
20  Check whether two netlists are unequal.
21  Does not check netlist IDs.
22 
23  :returns: ``True`` if both netlists are unequal, ``False`` otherwise.
24  :rtype: bool
25  )");
26 
27  py_netlist.def(py::init<GateLibrary*>(), py::arg("gate_library"), R"(
28  Construct a new netlist for the specified gate library.
29 
30  Warning: Use the netlist_factory to create instances!
31 
32  :param hal_py.GateLibrary gate_library: The gate library.
33  )");
34 
35  py_netlist.def_property("id", &Netlist::get_id, &Netlist::set_id, R"(
36  The ID of the netlist.
37  If not explicitly set, the ID defaults to 0.
38 
39  :type: int
40  )");
41 
42  py_netlist.def("get_id", &Netlist::get_id, R"(
43  Get the ID of the netlist.
44  If not explicitly set, the ID defaults to 0.
45 
46  :returns: The ID of the netlist.
47  :rtype: int
48  )");
49 
50  py_netlist.def("set_id", &Netlist::set_id, py::arg("id"), R"(
51  Set the ID of the netlist to the specified value.
52 
53  :param int id: The new ID of the netlist.
54  )");
55 
56  py_netlist.def_property("input_filename", &Netlist::get_input_filename, &Netlist::set_input_filename, R"(
57  The path to the input file.
58 
59  :type: str
60  )");
61 
62  py_netlist.def("get_input_filename", &Netlist::get_input_filename, R"(
63  Get the path to the input file.
64 
65  :returns: The path to the input file.
66  :rtype: pathlib.Path
67  )");
68 
69  py_netlist.def("set_input_filename", &Netlist::set_input_filename, py::arg("path"), R"(
70  Set the path to the input file.
71 
72  :param pathlib.Path path: The path to the input file.
73  )");
74 
75  py_netlist.def_property("design_name", &Netlist::get_design_name, &Netlist::set_design_name, R"(
76  The name of the design.
77 
78  :type: str
79  )");
80 
81  py_netlist.def("get_design_name", &Netlist::get_design_name, R"(
82  Get the name of the design.
83 
84  :returns: The name of the design.
85  :rtype: str
86  )");
87 
88  py_netlist.def("set_design_name", &Netlist::set_design_name, py::arg("design_name"), R"(
89  Set the name of the design.
90 
91  :param str design_name: The new name of the design.
92  )");
93 
94  py_netlist.def_property("device_name", &Netlist::get_device_name, &Netlist::set_device_name, R"(
95  The name of the target device.
96 
97  :type: str
98  )");
99 
100  py_netlist.def("get_device_name", &Netlist::get_device_name, R"(
101  Get the name of the target device.
102 
103  :returns: The name of the target device.
104  :rtype: str
105  )");
106 
107  py_netlist.def("set_device_name", &Netlist::set_device_name, py::arg("device_name"), R"(
108  Set the name of the target device.
109 
110  :param str device_name: The name of the target device.
111  )");
112 
113  py_netlist.def_property_readonly("gate_library", [](Netlist* nl) { return RawPtrWrapper<const GateLibrary>(nl->get_gate_library()); }, R"(
114  The gate library associated with the netlist.
115 
116  :type: hal_py.GateLibrary
117  )");
118 
119  py_netlist.def("get_gate_library", [](Netlist* nl) { return RawPtrWrapper<const GateLibrary>(nl->get_gate_library()); }, R"(
120  Get the gate library associated with the netlist.
121 
122  :returns: The gate library.
123  :rtype: hal_py.GateLibrary
124  )");
125 
126  py_netlist.def(
127  "copy",
128  [](Netlist* nl) -> std::shared_ptr<Netlist> {
129  auto res = nl->copy();
130  if (res.is_ok())
131  {
132  return std::shared_ptr<Netlist>(res.get());
133  }
134  else
135  {
136  log_error("python_context", "{}", res.get_error().get());
137  return nullptr;
138  }
139  },
140  R"(
141  Create a deep copy of the netlist.
142 
143  :returns: The copy of the netlist.
144  :rtype: hal_py.Netlist
145  )");
146 
147  py_netlist.def("clear_caches", &Netlist::clear_caches, R"(
148  Clear all internal caches of the netlist.
149  In a typical application, calling this function is not required.
150  )");
151 
152  py_netlist.def("get_unique_gate_id", &Netlist::get_unique_gate_id, R"(
153  Get a spare gate ID.
154  The value of 0 is reserved and represents an invalid ID.
155 
156  :returns: The gate ID.
157  :rtype: int
158  )");
159 
160  py_netlist.def("create_gate",
161  py::overload_cast<u32, GateType*, const std::string&, i32, i32>(&Netlist::create_gate),
162  py::arg("gate_id"),
163  py::arg("gate_type"),
164  py::arg("name"),
165  py::arg("x") = -1,
166  py::arg("y") = -1,
167  R"(
168  Create a new gate and add it to the netlist.
169 
170  :param int gate_id: The unique ID of the gate.
171  :param hal_py.GateType gate_type: The gate type.
172  :param str name: The name of the gate.
173  :param int x: The x-coordinate of the gate.
174  :param int y: The y-coordinate of the gate.
175  :returns: The new gate on success, ``None`` otherwise.
176  :rtype: hal_py.Gate or None
177  )");
178 
179  py_netlist.def("create_gate",
180  py::overload_cast<GateType*, const std::string&, i32, i32>(&Netlist::create_gate),
181  py::arg("gate_type"),
182  py::arg("name"),
183  py::arg("x") = -1,
184  py::arg("y") = -1,
185  R"(
186  Create a new gate and add it to the netlist.
187  The ID of the gate is set automatically.
188 
189  :param hal_py.GateType gate_type: The gate type.
190  :param str name: The name of the gate.
191  :param int x: The x-coordinate of the gate.
192  :param int y: The y-coordinate of the gate.
193  :returns: The new gate on success, ``None`` otherwise.
194  :rtype: hal_py.Gate or None
195  )");
196 
197  py_netlist.def("delete_gate", &Netlist::delete_gate, py::arg("gate"), R"(
198  Remove a gate from the netlist.
199 
200  :param hal_py.Gate gate: The gate.
201  :returns: ``True`` on success, ``False`` otherwise.
202  :rtype: bool
203  )");
204 
205  py_netlist.def("is_gate_in_netlist", &Netlist::is_gate_in_netlist, py::arg("gate"), R"(
206  Check whether the gate is registered in the netlist.
207 
208  :param hal_py.Gate gate: The gate to check.
209  :returns: ``True`` if the gate is in the netlist, ``False`` otherwise.
210  :rtype: bool
211  )");
212 
213  py_netlist.def("get_gate_by_id", &Netlist::get_gate_by_id, py::arg("gate_id"), R"(
214  Get the gate specified by the given ID.
215 
216  :param int gate_id: The unique ID of the gate.
217  :returns: The gate on success, ``None`` otherwise.
218  :rtype: hal_py.Gate or None
219  )");
220 
221  py_netlist.def_property_readonly("gates", py::overload_cast<>(&Netlist::get_gates, py::const_), R"(
222  All gates contained within the netlist.
223 
224  :type: list[hal_py.Gate]
225  )");
226 
227  py_netlist.def("get_gates", py::overload_cast<>(&Netlist::get_gates, py::const_), R"(
228  Get all gates contained within the netlist.
229 
230  :returns: A list of gates.
231  :rtype: list[hal_py.Gate]
232  )");
233 
234  py_netlist.def("get_gates", py::overload_cast<const std::function<bool(const Gate*)>&>(&Netlist::get_gates, py::const_), py::arg("filter"), R"(
235  Get all gates contained within the netlist.
236  The filter is evaluated on every gate such that the result only contains gates matching the specified condition.
237 
238  :param lambda filter: Filter function to be evaluated on each gate.
239  :returns: A list of gates.
240  :rtype: list[hal_py.Gate]
241  )");
242 
243  py_netlist.def("mark_vcc_gate", &Netlist::mark_vcc_gate, py::arg("gate"), R"(
244  Mark a gate as a global VCC gate.
245 
246  :param hal_py.Gate gate: The gate.
247  :returns: ``True`` on success, ``False`` otherwise.
248  :rtype: bool
249  )");
250 
251  py_netlist.def("mark_gnd_gate", &Netlist::mark_gnd_gate, py::arg("gate"), R"(
252  Mark a gate as a global GND gate.
253 
254  :param hal_py.Gate gate: The gate.
255  :returns: ``True`` on success, ``False`` otherwise.
256  :rtype: bool
257  )");
258 
259  py_netlist.def("unmark_vcc_gate", &Netlist::unmark_vcc_gate, py::arg("gate"), R"(
260  Unmark a global VCC gate.
261 
262  :param hal_py.Gate gate: The gate.
263  :returns: ``True`` on success, ``False`` otherwise.
264  :rtype: bool
265  )");
266 
267  py_netlist.def("unmark_gnd_gate", &Netlist::unmark_gnd_gate, py::arg("gate"), R"(
268  Unmark a global GND gate.
269 
270  :param hal_py.Gate gate: The gate.
271  :returns: ``True`` on success, ``False`` otherwise.
272  :rtype: bool
273  )");
274 
275  py_netlist.def("is_vcc_gate", &Netlist::is_vcc_gate, py::arg("gate"), R"(
276  Check whether a gate is a global VCC gate.
277 
278  :param hal_py.Gate gate: The gate to check.
279  :returns: ``True`` if the gate is a global VCC gate, ``False`` otherwise.
280  :rtype: bool
281  )");
282 
283  py_netlist.def("is_gnd_gate", &Netlist::is_gnd_gate, py::arg("gate"), R"(
284  Check whether a gate is a global GND gate.
285 
286  :param hal_py.Gate gate: The gate to check.
287  :returns: ``True`` if the gate is a global GND gate, ``False`` otherwise.
288  :rtype: bool
289  )");
290 
291  py_netlist.def_property_readonly("vcc_gates", &Netlist::get_vcc_gates, R"(
292  All global VCC gates.
293 
294  :type: list[hal_py.Gate]
295  )");
296 
297  py_netlist.def("get_vcc_gates", &Netlist::get_vcc_gates, R"(
298  Get all global VCC gates.
299 
300  :returns: A list of gates.
301  :rtype: list[hal_py.Gate]
302  )");
303 
304  py_netlist.def_property_readonly("gnd_gates", &Netlist::get_gnd_gates, R"(
305  All global GND gates.
306 
307  :type: list[hal_py.Gate]
308  )");
309 
310  py_netlist.def("get_gnd_gates", &Netlist::get_gnd_gates, R"(
311  Get all global GND gates.
312 
313  :returns: A list of gates.
314  :rtype: list[hal_py.Gate]
315  )");
316 
317  py_netlist.def_property_readonly("vcc_nets", &Netlist::get_vcc_nets, R"(
318  All global VCC nets.
319 
320  :type: list[hal_py.Net]
321  )");
322 
323  py_netlist.def("get_vcc_nets", &Netlist::get_vcc_nets, R"(
324  Get all global VCC nets.
325 
326  :returns: A list of nets.
327  :rtype: list[hal_py.Net]
328  )");
329 
330  py_netlist.def_property_readonly("gnd_nets", &Netlist::get_gnd_nets, R"(
331  All global GND nets.
332 
333  :type: list[hal_py.Net]
334  )");
335 
336  py_netlist.def("get_gnd_nets", &Netlist::get_gnd_nets, R"(
337  Get all GND nets in the netlist.
338 
339  :returns: A list of nets.
340  :rtype: list[hal_py.Net]
341  )");
342 
343  py_netlist.def("get_unique_net_id", &Netlist::get_unique_net_id, R"(
344  Get a spare net ID.
345  The value of 0 is reserved and represents an invalid ID.
346 
347  :returns: The net ID.
348  :rtype: int
349  )");
350 
351  py_netlist.def("create_net", py::overload_cast<const u32, const std::string&>(&Netlist::create_net), py::arg("net_id"), py::arg("name"), R"(
352  Create a new net and add it to the netlist.
353 
354  :param int net_id: The unique ID of the net.
355  :param str name: The name of the net.
356  :returns: The new net on success, ``None`` otherwise.
357  :rtype: hal_py.Net or None
358  )");
359 
360  py_netlist.def("create_net", py::overload_cast<const std::string&>(&Netlist::create_net), py::arg("name"), R"(
361  Create a new net and add it to the netlist.
362  The ID of the net is set automatically.
363 
364  :param str name: The name of the net.
365  :returns: The new net on success, ``None`` otherwise.
366  :rtype: hal_py.Net or None
367  )");
368 
369  py_netlist.def("delete_net", &Netlist::delete_net, py::arg("net"), R"(
370  Remove a net from the netlist.
371 
372  :param hal_py.Net net: The net.
373  :returns: ``True`` on success, ``False`` otherwise.
374  :rtype: bool
375  )");
376 
377  py_netlist.def("is_net_in_netlist", &Netlist::is_net_in_netlist, py::arg("net"), R"(
378  Check whether a net is registered in the netlist.
379 
380  :param hal_py.Net net: The net to check.
381  :returns: ``True`` if the net is in the netlist, ``False`` otherwise.
382  :rtype: bool
383  )");
384 
385  py_netlist.def("get_net_by_id", &Netlist::get_net_by_id, py::arg("net_id"), R"(
386  Get the net specified by the given ID.
387 
388  :param int net_id: The unique ID of the net.
389  :returns: The net on success, ``None`` otherwise.
390  :rtype: hal_py.Net or None
391  )");
392 
393  py_netlist.def_property_readonly("nets", py::overload_cast<>(&Netlist::get_nets, py::const_), R"(
394  All nets contained within the netlist.
395 
396  :type: list[hal_py.Net]
397  )");
398 
399  py_netlist.def("get_nets", py::overload_cast<>(&Netlist::get_nets, py::const_), R"(
400  Get all nets contained within the netlist.
401 
402  :returns: A list of nets.
403  :rtype: list[hal_py.Net]
404  )");
405 
406  py_netlist.def("get_nets", py::overload_cast<const std::function<bool(const Net*)>&>(&Netlist::get_nets, py::const_), py::arg("filter"), R"(
407  Get all nets contained within the netlist.<br>
408  The filter is evaluated on every net such that the result only contains nets matching the specified condition.
409 
410  :param lambda filter: Filter function to be evaluated on each net.
411  :returns: A list of nets.
412  :rtype: list[hal_py.Net]
413  )");
414 
415  py_netlist.def("mark_global_input_net", &Netlist::mark_global_input_net, py::arg("net"), R"(
416  Mark a net as a global input net.
417 
418  :param hal_py.Net net: The net.
419  :returns: ``True`` on success, ``False`` otherwise.
420  :rtype: bool
421  )");
422 
423  py_netlist.def("mark_global_output_net", &Netlist::mark_global_output_net, py::arg("net"), R"(
424  Mark a net as a global output net.
425 
426  :param hal_py.Net net: The net.
427  :returns: ``True`` on success, ``False`` otherwise.
428  :rtype: bool
429  )");
430 
431  py_netlist.def("unmark_global_input_net", &Netlist::unmark_global_input_net, py::arg("net"), R"(
432  Unmark a global input net.
433 
434  :param hal_py.Net net: The net.
435  :returns: ``True`` on success, ``False`` otherwise.
436  :rtype: bool
437  )");
438 
439  py_netlist.def("unmark_global_output_net", &Netlist::unmark_global_output_net, py::arg("net"), R"(
440  Unmark a global output net.
441 
442  :param hal_py.Net net: The net.
443  :returns: ``True`` on success, ``False`` otherwise.
444  :rtype: bool
445  )");
446 
447  py_netlist.def("is_global_input_net", &Netlist::is_global_input_net, py::arg("net"), R"(
448  Check whether a net is a global input net.
449 
450  :param hal_py.Net net: The net to check.
451  :returns: ``True`` if the net is a global input net, ``False`` otherwise.
452  :rtype: bool
453  )");
454 
455  py_netlist.def("is_global_output_net", &Netlist::is_global_output_net, py::arg("net"), R"(
456  Check whether a net is a global output net.
457 
458  :param hal_py.Net net: The net to check.
459  :returns: ``True`` if the net is a global output net, ``False`` otherwise.
460  :rtype: bool
461  )");
462 
463  py_netlist.def_property_readonly("global_input_nets", &Netlist::get_global_input_nets, R"(
464  All global input nets.
465 
466  :type: list[hal_py.Net]
467  )");
468 
469  py_netlist.def("get_global_input_nets", &Netlist::get_global_input_nets, R"(
470  Get all global input nets.
471 
472  :returns: A list of nets.
473  :rtype: list[hal_py.Net]
474  )");
475 
476  py_netlist.def_property_readonly("global_output_nets", &Netlist::get_global_output_nets, R"(
477  All global output nets.
478 
479  :type: list[hal_py.Net]
480  )");
481 
482  py_netlist.def("get_global_output_nets", &Netlist::get_global_output_nets, R"(
483  Get all global output nets.
484 
485  :returns: A list of nets.
486  :rtype: list[hal_py.Net]
487  )");
488 
489  py_netlist.def("enable_automatic_net_checks", &Netlist::enable_automatic_net_checks, py::arg("enable_checks") = true, R"(
490  Enables or disables automatic checks on nets that determine whether a net is an input or output of a module.
491 
492  WARNING: if disabled, the user is responsible to assign correct input and output nets and create respective module pins. Wrong usage may result in unknown behavior or crashes.
493 
494  :param bool enable_checks: Set ``True`` to enable automatic checks, ``False`` otherwise.
495  )");
496 
497  py_netlist.def("get_unique_module_id", &Netlist::get_unique_module_id, R"(
498  Get a spare module ID.
499  The value of 0 is reserved and represents an invalid ID.
500 
501  :returns: The module ID.
502  :rtype: int
503  )");
504 
505  py_netlist.def("create_module",
506  py::overload_cast<const u32, const std::string&, Module*, const std::vector<Gate*>&>(&Netlist::create_module),
507  py::arg("module_id"),
508  py::arg("name"),
509  py::arg("parent"),
510  py::arg("gates") = std::vector<Gate*>(),
511  R"(
512  Create a new module and add it to the netlist.
513 
514  :param int module_id: The unique ID of the module.
515  :param str name: The name of the module.
516  :param hal_py.Module parent: The parent module.
517  :param list gates: Gates to assign to the new module.
518  :returns: The new module on success, ``None`` otherwise.
519  :rtype: hal_py.Module or None
520  )");
521 
522  py_netlist.def("create_module",
523  py::overload_cast<const std::string&, Module*, const std::vector<Gate*>&>(&Netlist::create_module),
524  py::arg("name"),
525  py::arg("parent"),
526  py::arg("gates") = std::vector<Gate*>(),
527  R"(
528  Create a new module and add it to the netlist.
529  The ID of the module is set automatically.
530 
531  :param str name: The name of the module.
532  :param hal_py.Module parent: The parent module.
533  :param list gates: Gates to assign to the new module.
534  :returns: The new module on success, ``None`` otherwise.
535  :rtype: hal_py.Module or None
536  )");
537 
538  py_netlist.def("delete_module", &Netlist::delete_module, py::arg("module"), R"(
539  Remove a module from the netlist.
540  Submodules, gates and nets under this module will be moved to the parent of this module.
541 
542  :param hal_py.Module module: The module.
543  :returns: ``True`` on success, ``False`` otherwise.
544  :rtype: bool
545  )");
546 
547  py_netlist.def("is_module_in_netlist", &Netlist::is_module_in_netlist, py::arg("module"), R"(
548  Check whether a module is registered in the netlist.
549 
550  :param hal_py.Module module: The module to check.
551  :returns: ``True`` if the module is in the netlist, ``False`` otherwise.
552  :rtype: bool
553  )");
554 
555  py_netlist.def("get_module_by_id", &Netlist::get_module_by_id, py::arg("module_id"), R"(
556  Get the module specified by the given ID.
557 
558  :param int module_id: The unique ID of the module.
559  :returns: The module on success, ``None`` otherwise.
560  :rtype: hal_py.Module
561  )");
562 
563  py_netlist.def_property_readonly("modules", py::overload_cast<>(&Netlist::get_modules, py::const_), R"(
564  All modules contained within the netlist, including the top module.
565 
566  :type: list[hal_py.Module]
567  )");
568 
569  py_netlist.def("get_modules", py::overload_cast<>(&Netlist::get_modules, py::const_), R"(
570  Get all modules contained within the netlist, including the top module.
571 
572  :returns: A list of modules.
573  :rtype: list[hal_py.Module]
574  )");
575 
576  py_netlist.def("get_modules", py::overload_cast<const std::function<bool(const Module*)>&>(&Netlist::get_modules, py::const_), py::arg("filter"), R"(
577  Get all modules contained within the netlist, including the top module.
578  The filter is evaluated on every module such that the result only contains modules matching the specified condition.
579 
580  :param lambda filter: Filter function to be evaluated on each module.
581  :returns: A list of modules.
582  :rtype: list[hal_py.Module]
583  )");
584 
585  py_netlist.def_property_readonly("top_module", &Netlist::get_top_module, R"(
586  The top module of the netlist.
587 
588  :type: hal_py.Module
589  )");
590 
591  py_netlist.def("get_top_module", &Netlist::get_top_module, R"(
592  Get the top module of the netlist.
593 
594  :returns: The top module.
595  :rtype: hal_py.Module
596  )");
597 
598  py_netlist.def("get_unique_grouping_id", &Netlist::get_unique_grouping_id, R"(
599  Get a spare and unique grouping ID.
600  The value of 0 is reserved and represents an invalid ID.
601 
602  :returns: The grouping ID.
603  :rtype: int
604  )");
605 
606  py_netlist.def("create_grouping",
607  py::overload_cast<const u32, const std::string&>(&Netlist::create_grouping),
608  py::arg("grouping_id"),
609  py::arg("name"),
610  R"(
611  Create a new grouping and add it to the netlist.
612 
613  :param int grouping_id: The unique ID of the grouping.
614  :param str name: The name of the grouping.
615  :returns: The new grouping on success, ``None`` otherwise.
616  :rtype: hal_py.Grouping or None
617  )");
618 
619  py_netlist.def("create_grouping",
620  py::overload_cast<const std::string&>(&Netlist::create_grouping),
621  py::arg("name"),
622  R"(
623  Create a new grouping and add it to the netlist.
624  The ID of the grouping is set automatically.
625 
626  :param str name: The name of the grouping.
627  :returns: The new grouping on success, ``None`` otherwise.
628  :rtype: hal_py.Grouping or None
629  )");
630 
631  py_netlist.def("delete_grouping", &Netlist::delete_grouping, py::arg("grouping"), R"(
632  Remove a grouping from the netlist.
633 
634  :param hal_py.Grouping grouping: The grouping.
635  :returns: ``True`` on success, ``False`` otherwise.
636  :rtype: bool
637  )");
638 
639  py_netlist.def("is_grouping_in_netlist", &Netlist::is_grouping_in_netlist, py::arg("grouping"), R"(
640  Check whether the grouping is registered in the netlist.
641 
642  :param hal_py.Module grouping: The grouping to check.
643  :returns: ``True`` on success, ``False`` otherwise.
644  :rtype: bool
645  )");
646 
647  py_netlist.def("get_grouping_by_id", &Netlist::get_grouping_by_id, py::arg("grouping_id"), R"(
648  Get the grouping specified by the given ID.
649 
650  :param int grouping_id: The unique ID of the grouping.
651  :returns: The grouping on success, nullptr otherwise.
652  :rtype: hal_py.Grouping
653  )");
654 
655  py_netlist.def_property_readonly("groupings", py::overload_cast<>(&Netlist::get_groupings, py::const_), R"(
656  All groupings contained within the netlist.
657 
658  :type: list[hal_py.Grouping]
659  )");
660 
661  py_netlist.def("get_groupings", py::overload_cast<>(&Netlist::get_groupings, py::const_), R"(
662  Get all groupings contained within the netlist.
663 
664  :returns: A list of groupings.
665  :rtype: list[hal_py.Grouping]
666  )");
667 
668  py_netlist.def("get_groupings", py::overload_cast<const std::function<bool(const Grouping*)>&>(&Netlist::get_groupings, py::const_), py::arg("filter"), R"(
669  Get all groupings contained within the netlist.
670  The filter is evaluated on every grouping such that the result only contains groupings matching the specified condition.
671 
672  :param lambda filter: Filter function to be evaluated on each grouping.
673  :returns: A list of groupings.
674  :rtype: list[hal_py.Grouping]
675  )");
676 
677  py_netlist.def("get_next_gate_id", &Netlist::get_next_gate_id, R"(
678  Get the gate ID following the highest currently used ID.
679 
680  :returns: The next gate ID.
681  :rtype: int
682  )");
683 
684  py_netlist.def("set_next_gate_id", &Netlist::set_next_gate_id, py::arg("id"), R"(
685  Set the gate ID following the highest currently used ID.
686 
687  :param int id: The next gate ID.
688  )");
689 
690  py_netlist.def("get_used_gate_ids", &Netlist::get_used_gate_ids, R"(
691  Get a set of all currently used gate IDs.
692 
693  :returns: All used gate IDs.
694  :rtype: set[int]
695  )");
696 
697  py_netlist.def("set_used_gate_ids", &Netlist::set_used_gate_ids, py::arg("ids"), R"(
698  Set a set of all currently used gate IDs.
699 
700  :param set[int] ids: All used gate IDs.
701  )");
702 
703  py_netlist.def("get_free_gate_ids", &Netlist::get_free_gate_ids, R"(
704  Get a set of all gate IDs that have previously been used but been freed ever since.
705 
706  :returns: All freed gate IDs.
707  :rtype: set[int]
708  )");
709 
710  py_netlist.def("set_free_gate_ids", &Netlist::set_free_gate_ids, py::arg("ids"), R"(
711  Set a set of all gate IDs that have previously been used but been freed ever since.
712 
713  :param set[int] ids: All freed gate IDs.
714  )");
715 
716  py_netlist.def("get_next_net_id", &Netlist::get_next_net_id, R"(
717  Get the net ID following the highest currently used ID.
718 
719  :returns: The next net ID.
720  :rtype: int
721  )");
722 
723  py_netlist.def("set_next_net_id", &Netlist::set_next_net_id, py::arg("id"), R"(
724  Set the net ID following the highest currently used ID.
725 
726  :param int id: The next net ID.
727  )");
728 
729  py_netlist.def("get_used_net_ids", &Netlist::get_used_net_ids, R"(
730  Get a set of all currently used net IDs.
731 
732  :returns: All used net IDs.
733  :rtype: set[int]
734  )");
735 
736  py_netlist.def("set_used_net_ids", &Netlist::set_used_net_ids, py::arg("ids"), R"(
737  Set a set of all currently used net IDs.
738 
739  :param set[int] ids: All used net IDs.
740  )");
741 
742  py_netlist.def("get_free_net_ids", &Netlist::get_free_net_ids, R"(
743  Get a set of all net IDs that have previously been used but been freed ever since.
744 
745  :returns: All freed net IDs.
746  :rtype: set[int]
747  )");
748 
749  py_netlist.def("set_free_net_ids", &Netlist::set_free_net_ids, py::arg("ids"), R"(
750  Set a set of all net IDs that have previously been used but been freed ever since.
751 
752  :param set[int] ids: All freed net IDs.
753  )");
754 
755  py_netlist.def("get_next_module_id", &Netlist::get_next_module_id, R"(
756  Get the module ID following the highest currently used ID.
757 
758  :returns: The next module ID.
759  :rtype: int
760  )");
761 
762  py_netlist.def("set_next_module_id", &Netlist::set_next_module_id, py::arg("id"), R"(
763  Set the module ID following the highest currently used ID.
764 
765  :param int id: The next module ID.
766  )");
767 
768  py_netlist.def("get_used_module_ids", &Netlist::get_used_module_ids, R"(
769  Get a set of all currently used module IDs.
770 
771  :returns: All used module IDs.
772  :rtype: set[int]
773  )");
774 
775  py_netlist.def("set_used_module_ids", &Netlist::set_used_module_ids, py::arg("ids"), R"(
776  Set a set of all currently used module IDs.
777 
778  :param set[int] ids: All used module IDs.
779  )");
780 
781  py_netlist.def("get_free_module_ids", &Netlist::get_free_module_ids, R"(
782  Get a set of all module IDs that have previously been used but been freed ever since.
783 
784  :returns: All freed module IDs.
785  :rtype: set[int]
786  )");
787 
788  py_netlist.def("set_free_module_ids", &Netlist::set_free_module_ids, py::arg("ids"), R"(
789  Set a set of all module IDs that have previously been used but been freed ever since.
790 
791  :param set[int] ids: All freed module IDs.
792  )");
793 
794  py_netlist.def("get_next_grouping_id", &Netlist::get_next_grouping_id, R"(
795  Get the grouping ID following the highest currently used ID.
796 
797  :returns: The next grouping ID.
798  :rtype: int
799  )");
800 
801  py_netlist.def("set_next_grouping_id", &Netlist::set_next_grouping_id, py::arg("id"), R"(
802  Set the grouping ID following the highest currently used ID.
803 
804  :param int id: The next grouping ID.
805  )");
806 
807  py_netlist.def("get_used_grouping_ids", &Netlist::get_used_grouping_ids, R"(
808  Get a set of all currently used grouping IDs.
809 
810  :returns: All used grouping IDs.
811  :rtype: set[int]
812  )");
813 
814  py_netlist.def("set_used_grouping_ids", &Netlist::set_used_grouping_ids, py::arg("ids"), R"(
815  Set a set of all currently used grouping IDs.
816 
817  :param set[int] ids: All used grouping IDs.
818  )");
819 
820  py_netlist.def("get_free_grouping_ids", &Netlist::get_free_grouping_ids, R"(
821  Get a set of all grouping IDs that have previously been used but been freed ever since.
822 
823  :returns: All freed grouping IDs.
824  :rtype: set[int]
825  )");
826 
827  py_netlist.def("set_free_grouping_ids", &Netlist::set_free_grouping_ids, py::arg("ids"), R"(
828  Set a set of all grouping IDs that have previously been used but been freed ever since.
829 
830  :param set[int] ids: All freed grouping IDs.
831  )");
832 
833  py_netlist.def(
834  "load_gate_locations_from_data", &Netlist::load_gate_locations_from_data, py::arg("data_category") = std::string(), py::arg("data_identifiers") = std::pair<std::string, std::string>(), R"(
835  Load the locations of the gates in the netlist from their associated data using the specified category and identifier.
836  If no parameter is given, the data is querried using the default category and identifier stored with the gate library.
837 
838  :param str data_category: The data category.
839  :param tuple(str,str) data_identifiers: The data identifiers for the x- and y-coordinates.
840  :returns: ``True`` on success, ``False`` otherwise.
841  :rtype: bool
842  )");
843  }
844 } // namespace hal
Definition: gate.h:58
Definition: net.h:58
void set_input_filename(const std::filesystem::path &path)
Definition: netlist.cpp:95
Module * get_top_module() const
Definition: netlist.cpp:608
const std::vector< Gate * > & get_gates() const
Definition: netlist.cpp:204
std::vector< Net * > get_vcc_nets() const
Definition: netlist.cpp:546
u32 get_unique_gate_id()
Definition: netlist.cpp:160
bool mark_vcc_gate(Gate *gate)
Definition: netlist.cpp:228
const std::vector< Net * > & get_global_input_nets() const
Definition: netlist.cpp:519
bool mark_gnd_gate(Gate *gate)
Definition: netlist.cpp:244
void set_used_gate_ids(const std::set< u32 > ids)
Definition: netlist.cpp:746
u32 get_unique_grouping_id()
Definition: netlist.cpp:658
void set_used_net_ids(const std::set< u32 > ids)
Definition: netlist.cpp:776
Grouping * create_grouping(const u32 grouping_id, const std::string &name="")
Definition: netlist.cpp:671
bool is_gate_in_netlist(const Gate *gate) const
Definition: netlist.cpp:188
Gate * get_gate_by_id(const u32 gate_id) const
Definition: netlist.cpp:193
bool is_module_in_netlist(const Module *module) const
Definition: netlist.cpp:647
bool delete_grouping(Grouping *grouping)
Definition: netlist.cpp:681
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:862
void set_free_grouping_ids(const std::set< u32 > ids)
Definition: netlist.cpp:846
std::set< u32 > get_free_module_ids() const
Definition: netlist.cpp:811
u32 get_unique_module_id()
Definition: netlist.cpp:574
bool delete_net(Net *net)
Definition: netlist.cpp:343
bool is_gnd_gate(const Gate *gate) const
Definition: netlist.cpp:299
Net * create_net(const u32 net_id, const std::string &name)
Definition: netlist.cpp:333
std::vector< Net * > get_gnd_nets() const
Definition: netlist.cpp:529
const std::vector< Gate * > & get_gnd_gates() const
Definition: netlist.cpp:309
std::set< u32 > get_used_net_ids() const
Definition: netlist.cpp:771
void set_next_gate_id(const u32 id)
Definition: netlist.cpp:736
void set_free_module_ids(const std::set< u32 > ids)
Definition: netlist.cpp:816
void set_design_name(const std::string &name)
Definition: netlist.cpp:109
std::set< u32 > get_free_gate_ids() const
Definition: netlist.cpp:751
void enable_automatic_net_checks(bool enable_checks=true)
Definition: netlist.cpp:563
std::set< u32 > get_used_grouping_ids() const
Definition: netlist.cpp:831
bool delete_module(Module *module)
Definition: netlist.cpp:603
const std::vector< Gate * > & get_vcc_gates() const
Definition: netlist.cpp:304
bool unmark_gnd_gate(Gate *gate)
Definition: netlist.cpp:277
bool delete_gate(Gate *gate)
Definition: netlist.cpp:183
bool is_grouping_in_netlist(const Grouping *grouping) const
Definition: netlist.cpp:686
u32 get_next_net_id() const
Definition: netlist.cpp:761
u32 get_id() const
Definition: netlist.cpp:75
u32 get_next_module_id() const
Definition: netlist.cpp:791
Result< std::unique_ptr< Netlist > > copy() const
Definition: netlist.cpp:142
const std::vector< Module * > & get_modules() const
Definition: netlist.cpp:624
void set_id(const u32 id)
Definition: netlist.cpp:80
std::set< u32 > get_used_gate_ids() const
Definition: netlist.cpp:741
u32 get_unique_net_id()
Definition: netlist.cpp:320
bool unmark_vcc_gate(Gate *gate)
Definition: netlist.cpp:260
void set_free_net_ids(const std::set< u32 > ids)
Definition: netlist.cpp:786
const std::string & get_device_name() const
Definition: netlist.cpp:118
void clear_caches()
Definition: netlist.cpp:857
void set_next_module_id(const u32 id)
Definition: netlist.cpp:796
bool mark_global_input_net(Net *net)
Definition: netlist.cpp:387
bool is_net_in_netlist(const Net *net) const
Definition: netlist.cpp:348
std::set< u32 > get_used_module_ids() const
Definition: netlist.cpp:801
Module * get_module_by_id(u32 module_id) const
Definition: netlist.cpp:613
bool is_vcc_gate(const Gate *gate) const
Definition: netlist.cpp:294
Gate * create_gate(const u32 gate_id, GateType *gate_type, const std::string &name="", i32 x=-1, i32 y=-1)
Definition: netlist.cpp:173
void set_free_gate_ids(const std::set< u32 > ids)
Definition: netlist.cpp:756
bool mark_global_output_net(Net *net)
Definition: netlist.cpp:417
void set_next_grouping_id(const u32 id)
Definition: netlist.cpp:826
Net * get_net_by_id(u32 net_id) const
Definition: netlist.cpp:353
std::set< u32 > get_free_grouping_ids() const
Definition: netlist.cpp:841
void set_used_grouping_ids(const std::set< u32 > ids)
Definition: netlist.cpp:836
const std::string & get_design_name() const
Definition: netlist.cpp:104
const std::vector< Net * > & get_global_output_nets() const
Definition: netlist.cpp:524
const std::vector< Net * > & get_nets() const
Definition: netlist.cpp:364
bool unmark_global_output_net(Net *net)
Definition: netlist.cpp:478
void set_device_name(const std::string &name)
Definition: netlist.cpp:123
const std::vector< Grouping * > & get_groupings() const
Definition: netlist.cpp:702
bool is_global_input_net(const Net *net) const
Definition: netlist.cpp:509
void set_next_net_id(const u32 id)
Definition: netlist.cpp:766
void set_used_module_ids(const std::set< u32 > ids)
Definition: netlist.cpp:806
u32 get_next_grouping_id() const
Definition: netlist.cpp:821
u32 get_next_gate_id() const
Definition: netlist.cpp:731
std::filesystem::path get_input_filename() const
Definition: netlist.cpp:90
const GateLibrary * get_gate_library() const
Definition: netlist.cpp:132
Grouping * get_grouping_by_id(u32 grouping_id) const
Definition: netlist.cpp:691
std::set< u32 > get_free_net_ids() const
Definition: netlist.cpp:781
bool unmark_global_input_net(Net *net)
Definition: netlist.cpp:447
bool is_global_output_net(const Net *net) const
Definition: netlist.cpp:514
Module * create_module(const u32 module_id, const std::string &name, Module *parent, const std::vector< Gate * > &gates={})
Definition: netlist.cpp:587
uint32_t u32
Definition: defines.h:41
std::unique_ptr< T, py::nodelete > RawPtrWrapper
void netlist_init(py::module &m)
Definition: netlist.cpp:5
#define log_error(channel,...)
Definition: log.h:78
const Module * module(const Gate *g, const NodeBoxes &boxes)
Definition: defines.h:45