HAL
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 filename: 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 divice_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 gate: The gate.
201  :type gate: hal_py.Gate
202  :returns: True on success, false otherwise.
203  :rtype: bool
204  )");
205 
206  py_netlist.def("is_gate_in_netlist", &Netlist::is_gate_in_netlist, py::arg("gate"), R"(
207  Check whether the gate is registered in the netlist.
208 
209  :param gate: The gate to check.
210  :type gate: hal_py.Gate
211  :returns: True if the gate is in the netlist, false otherwise.
212  :rtype: bool
213  )");
214 
215  py_netlist.def("get_gate_by_id", &Netlist::get_gate_by_id, py::arg("gate_id"), R"(
216  Get the gate specified by the given ID.
217 
218  :param int gate_id: The unique ID of the gate.
219  :returns: The gate on success, None otherwise.
220  :rtype: hal_py.Gate or None
221  )");
222 
223  py_netlist.def_property_readonly("gates", py::overload_cast<>(&Netlist::get_gates, py::const_), R"(
224  All gates contained within the netlist.
225 
226  :type: list[hal_py.Gate]
227  )");
228 
229  py_netlist.def("get_gates", py::overload_cast<>(&Netlist::get_gates, py::const_), R"(
230  Get all gates contained within the netlist.
231 
232  :returns: A list of gates.
233  :rtype: list[hal_py.Gate]
234  )");
235 
236  py_netlist.def("get_gates", py::overload_cast<const std::function<bool(const Gate*)>&>(&Netlist::get_gates, py::const_), py::arg("filter"), R"(
237  Get all gates contained within the netlist.
238  The filter is evaluated on every gate such that the result only contains gates matching the specified condition.
239 
240  :param lambda filter: Filter function to be evaluated on each gate.
241  :returns: A list of gates.
242  :rtype: list[hal_py.Gate]
243  )");
244 
245  py_netlist.def("mark_vcc_gate", &Netlist::mark_vcc_gate, py::arg("gate"), R"(
246  Mark a gate as global VCC gate.
247 
248  :param hal_py.Gate gate: The gate.
249  :returns: True on success, false otherwise.
250  :rtype: bool
251  )");
252 
253  py_netlist.def("mark_gnd_gate", &Netlist::mark_gnd_gate, py::arg("gate"), R"(
254  Mark a gate as global GND gate.
255 
256  :param hal_py.Gate gate: The gate.
257  :returns: True on success, false otherwise.
258  :rtype: bool
259  )");
260 
261  py_netlist.def("unmark_vcc_gate", &Netlist::unmark_vcc_gate, py::arg("gate"), R"(
262  Unmark a global VCC gate.
263 
264  :param hal_py.Gate gate: The gate.
265  :returns: True on success, false otherwise.
266  :rtype: bool
267  )");
268 
269  py_netlist.def("unmark_gnd_gate", &Netlist::unmark_gnd_gate, py::arg("gate"), R"(
270  Unmark a global GND gate.
271 
272  :param hal_py.Gate gate: The gate.
273  :returns: True on success, false otherwise.
274  :rtype: bool
275  )");
276 
277  py_netlist.def("is_vcc_gate", &Netlist::is_vcc_gate, py::arg("gate"), R"(
278  Check whether a gate is a global VCC gate.
279 
280  :param gate: The gate to check.
281  :type gate: hal_py.Gate
282  :returns: True if the gate is a global VCC gate, false otherwise.
283  :rtype: bool
284  )");
285 
286  py_netlist.def("is_gnd_gate", &Netlist::is_gnd_gate, py::arg("gate"), R"(
287  Check whether a gate is a global GND gate.
288 
289  :param gate: The gate to check.
290  :type gate: hal_py.Gate
291  :returns: True if the gate is a global GND gate, false otherwise.
292  :rtype: bool
293  )");
294 
295  py_netlist.def_property_readonly("vcc_gates", &Netlist::get_vcc_gates, R"(
296  All global VCC gates.
297 
298  :type: list[hal_py.Gate]
299  )");
300 
301  py_netlist.def("get_vcc_gates", &Netlist::get_vcc_gates, R"(
302  Get all global VCC gates.
303 
304  :returns: A list of gates.
305  :rtype: list[hal_py.Gate]
306  )");
307 
308  py_netlist.def_property_readonly("gnd_gates", &Netlist::get_gnd_gates, R"(
309  All global GND gates.
310 
311  :type: list[hal_py.Gate]
312  )");
313 
314  py_netlist.def("get_gnd_gates", &Netlist::get_gnd_gates, R"(
315  Get all global GND gates.
316 
317  :returns: A list of gates.
318  :rtype: list[hal_py.Gate]
319  )");
320 
321  py_netlist.def_property_readonly("vcc_nets", &Netlist::get_vcc_nets, R"(
322  All global VCC nets.
323 
324  :type: list[hal_py.Net]
325  )");
326 
327  py_netlist.def("get_vcc_nets", &Netlist::get_vcc_nets, R"(
328  Get all global VCC nets.
329 
330  :returns: A list of nets.
331  :rtype: list[hal_py.Net]
332  )");
333 
334  py_netlist.def_property_readonly("gnd_nets", &Netlist::get_gnd_nets, R"(
335  All global GND nets.
336 
337  :type: list[hal_py.Net]
338  )");
339 
340  py_netlist.def("get_gnd_nets", &Netlist::get_gnd_nets, R"(
341  Get all global GND nets.
342 
343  :returns: A list of nets.
344  :rtype: list[hal_py.Net]
345  )");
346 
347  py_netlist.def("get_unique_net_id", &Netlist::get_unique_net_id, R"(
348  Get a spare net ID.
349  The value of 0 is reserved and represents an invalid ID.
350 
351  :returns: The net ID.
352  :rtype: int
353  )");
354 
355  py_netlist.def("create_net", py::overload_cast<const u32, const std::string&>(&Netlist::create_net), py::arg("net_id"), py::arg("name"), R"(
356  Create a new net and add it to the netlist.
357 
358  :param int net_id: The unique ID of the net.
359  :param str name: The name of the net.
360  :returns: The new net on success, None otherwise.
361  :rtype: hal_py.Net or None
362  )");
363 
364  py_netlist.def("create_net", py::overload_cast<const std::string&>(&Netlist::create_net), py::arg("name"), R"(
365  Create a new net and add it to the netlist.
366  The ID of the net is set automatically.
367 
368  :param str name: The name of the net.
369  :returns: The new net on success, None otherwise.
370  :rtype: hal_py.Net or None
371  )");
372 
373  py_netlist.def("delete_net", &Netlist::delete_net, py::arg("net"), R"(
374  Removes a net from the netlist.
375 
376  :param hal_py.Net net: The net.
377  :returns: True on success, false otherwise.
378  :rtype: bool
379  )");
380 
381  py_netlist.def("is_net_in_netlist", &Netlist::is_net_in_netlist, py::arg("net"), R"(
382  Check whether a net is registered in the netlist.
383 
384  :param hal_py.Net net: The net to check.
385  :returns: True if the net is in the netlist, false otherwise.
386  :rtype: bool
387  )");
388 
389  py_netlist.def("get_net_by_id", &Netlist::get_net_by_id, py::arg("net_id"), R"(
390  Get the net specified by the given ID.
391 
392  :param int net_id: The unique ID of the net.
393  :returns: The net on success, None otherwise.
394  :rtype: hal_py.Net or None
395  )");
396 
397  py_netlist.def_property_readonly("nets", py::overload_cast<>(&Netlist::get_nets, py::const_), R"(
398  All nets contained within the netlist.
399 
400  :type: list[hal_py.Net]
401  )");
402 
403  py_netlist.def("get_nets", py::overload_cast<>(&Netlist::get_nets, py::const_), R"(
404  Get all nets contained within the netlist.
405 
406  :returns: A list of nets.
407  :rtype: list[hal_py.Net]
408  )");
409 
410  py_netlist.def("get_nets", py::overload_cast<const std::function<bool(const Net*)>&>(&Netlist::get_nets, py::const_), py::arg("filter"), R"(
411  Get all nets contained within the netlist.<br>
412  The filter is evaluated on every net such that the result only contains nets matching the specified condition.
413 
414  :param lambda filter: Filter function to be evaluated on each net.
415  :returns: A list of nets.
416  :rtype: list[hal_py.Net]
417  )");
418 
419  py_netlist.def("mark_global_input_net", &Netlist::mark_global_input_net, py::arg("net"), R"(
420  Mark a net as a global input net.
421 
422  :param hal_py.Net net: The net.
423  :returns: True on success, false otherwise.
424  :rtype: bool
425  )");
426 
427  py_netlist.def("mark_global_output_net", &Netlist::mark_global_output_net, py::arg("net"), R"(
428  Mark a net as a global output net.
429 
430  :param hal_py.Net net: The net.
431  :returns: True on success, false otherwise.
432  :rtype: bool
433  )");
434 
435  py_netlist.def("unmark_global_input_net", &Netlist::unmark_global_input_net, py::arg("net"), R"(
436  Unmark a global input net.
437 
438  :param hal_py.Net net: The net.
439  :returns: True on success, false otherwise.
440  :rtype: bool
441  )");
442 
443  py_netlist.def("unmark_global_output_net", &Netlist::unmark_global_output_net, py::arg("net"), R"(
444  Unmark a global output net.
445 
446  :param hal_py.Net net: The net.
447  :returns: True on success, false otherwise.
448  :rtype: bool
449  )");
450 
451  py_netlist.def("is_global_input_net", &Netlist::is_global_input_net, py::arg("net"), R"(
452  Check whether a net is a global input net.
453 
454  :param hal_py.Net net: The net to check.
455  :returns: True if the net is a global input net, false otherwise.
456  :rtype: bool
457  )");
458 
459  py_netlist.def("is_global_output_net", &Netlist::is_global_output_net, py::arg("net"), R"(
460  Check whether a net is a global output net.
461 
462  :param hal_py.Net net: The net to check.
463  :returns: True if the net is a global output net, false otherwise.
464  :rtype: bool
465  )");
466 
467  py_netlist.def_property_readonly("global_input_nets", &Netlist::get_global_input_nets, R"(
468  All global input nets.
469 
470  :type: list[hal_py.Net]
471  )");
472 
473  py_netlist.def("get_global_input_nets", &Netlist::get_global_input_nets, R"(
474  Get all global input nets.
475 
476  :returns: A list of nets.
477  :rtype: list[hal_py.Net]
478  )");
479 
480  py_netlist.def_property_readonly("global_output_nets", &Netlist::get_global_output_nets, R"(
481  All global output nets.
482 
483  :type: list[hal_py.Net]
484  )");
485 
486  py_netlist.def("get_global_output_nets", &Netlist::get_global_output_nets, R"(
487  Get all global output nets.
488 
489  :returns: A list of nets.
490  :rtype: list[hal_py.Net]
491  )");
492 
493  py_netlist.def("enable_automatic_net_checks", &Netlist::enable_automatic_net_checks, py::arg("enable_checks") = true, R"(
494  Enables or disables automatic checks on nets that determine whether a net is an input or output of a module.
495 
496  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.
497 
498  :param bool enable_checks: Set True to enable automatic checks, False otherwise.
499  )");
500 
501  py_netlist.def("get_unique_module_id", &Netlist::get_unique_module_id, R"(
502  Get a spare module ID.
503  The value of 0 is reserved and represents an invalid ID.
504 
505  :returns: The module ID.
506  :rtype: int
507  )");
508 
509  py_netlist.def("create_module",
510  py::overload_cast<const u32, const std::string&, Module*, const std::vector<Gate*>&>(&Netlist::create_module),
511  py::arg("module_id"),
512  py::arg("name"),
513  py::arg("parent"),
514  py::arg("gates") = std::vector<Gate*>(),
515  R"(
516  Create a new module and add it to the netlist.
517 
518  :param int module_id: The unique ID of the module.
519  :param str name: The name of the module.
520  :param hal_py.Module parent: The parent module.
521  :param list gates: Gates to assign to the new module.
522  :returns: The new module on succes, None on error.
523  :rtype: hal_py.Module or None
524  )");
525 
526  py_netlist.def("create_module",
527  py::overload_cast<const std::string&, Module*, const std::vector<Gate*>&>(&Netlist::create_module),
528  py::arg("name"),
529  py::arg("parent"),
530  py::arg("gates") = std::vector<Gate*>(),
531  R"(
532  Create a new module and add it to the netlist.
533  The ID of the module is set automatically.
534 
535  :param str name: The name of the module.
536  :param hal_py.Module parent: The parent module.
537  :param list gates: Gates to assign to the new module.
538  :returns: The new module on succes, None on error.
539  :rtype: hal_py.Module or None
540  )");
541 
542  py_netlist.def("delete_module", &Netlist::delete_module, py::arg("module"), R"(
543  Remove a module from the netlist.
544  Submodules, gates and nets under this module will be moved to the parent of this module.
545 
546  :param module: The module.
547  :type module: hal_py.Module
548  :returns: True on success, false otherwise.
549  :rtype: bool
550  )");
551 
552  py_netlist.def("is_module_in_netlist", &Netlist::is_module_in_netlist, py::arg("module"), R"(
553  Check whether a module is registered in the netlist.
554 
555  :param hal_py.Module module: The module to check.
556  :returns: True if the module is in the netlist, false otherwise.
557  :rtype: bool
558  )");
559 
560  py_netlist.def("get_module_by_id", &Netlist::get_module_by_id, py::arg("module_id"), R"(
561  Get the module specified by the given ID.
562 
563  :param int module_id: The unique ID of the module.
564  :returns: The module on success, None otherwise.
565  :rtype: hal_py.Module
566  )");
567 
568  py_netlist.def_property_readonly("modules", py::overload_cast<>(&Netlist::get_modules, py::const_), R"(
569  All modules contained within the netlist, including the top module.
570 
571  :type: list[hal_py.Module]
572  )");
573 
574  py_netlist.def("get_modules", py::overload_cast<>(&Netlist::get_modules, py::const_), R"(
575  Get all modules contained within the netlist, including the top module.
576 
577  :returns: A list of modules.
578  :rtype: list[hal_py.Module]
579  )");
580 
581  py_netlist.def("get_modules", py::overload_cast<const std::function<bool(const Module*)>&>(&Netlist::get_modules, py::const_), py::arg("filter"), R"(
582  Get all modules contained within the netlist, including the top module.
583  The filter is evaluated on every module such that the result only contains modules matching the specified condition.
584 
585  :param lambda filter: Filter function to be evaluated on each module.
586  :returns: A list of modules.
587  :rtype: list[hal_py.Module]
588  )");
589 
590  py_netlist.def_property_readonly("top_module", &Netlist::get_top_module, R"(
591  The top module of the netlist.
592 
593  :type: hal_py.Module
594  )");
595 
596  py_netlist.def("get_top_module", &Netlist::get_top_module, R"(
597  Get the top module of the netlist.
598 
599  :returns: The top module.
600  :rtype: hal_py.Module
601  )");
602 
603  py_netlist.def("get_unique_grouping_id", &Netlist::get_unique_grouping_id, R"(
604  Get a spare and unique grouping ID.
605  The value of 0 is reserved and represents an invalid ID.
606 
607  :returns: The grouping ID.
608  :rtype: int
609  )");
610 
611  py_netlist.def("create_grouping",
612  py::overload_cast<const u32, const std::string&>(&Netlist::create_grouping),
613  py::arg("grouping_id"),
614  py::arg("name"),
615  R"(
616  Create a new grouping and add it to the netlist.
617 
618  :param int grouping_id: The unique ID of the grouping.
619  :param str name: The name of the grouping.
620  :returns: The new grouping on success, None otherwise.
621  :rtype: hal_py.Grouping or None
622  )");
623 
624  py_netlist.def("create_grouping",
625  py::overload_cast<const std::string&>(&Netlist::create_grouping),
626  py::arg("name"),
627  R"(
628  Create a new grouping and add it to the netlist.
629  The ID of the grouping is set automatically.
630 
631  :param str name: The name of the grouping.
632  :returns: The new grouping on success, None otherwise.
633  :rtype: hal_py.Grouping or None
634  )");
635 
636  py_netlist.def("delete_grouping", &Netlist::delete_grouping, py::arg("grouping"), R"(
637  Remove a grouping from the netlist.
638 
639  :param hal_py.Grouping grouping: The grouping.
640  :returns: True on success, false otherwise.
641  :rtype: bool
642  )");
643 
644  py_netlist.def("is_grouping_in_netlist", &Netlist::is_grouping_in_netlist, py::arg("grouping"), R"(
645  Check whether the grouping is registered in the netlist.
646 
647  :param hal_py.Module grouping: The grouping to check.
648  :returns: True on success, false otherwise.
649  :rtype: bool
650  )");
651 
652  py_netlist.def("get_grouping_by_id", &Netlist::get_grouping_by_id, py::arg("grouping_id"), R"(
653  Get the grouping specified by the given ID.
654 
655  :param int grouping_id: The unique ID of the grouping.
656  :returns: The grouping on success, nullptr otherwise.
657  :rtype: hal_py.Grouping
658  )");
659 
660  py_netlist.def_property_readonly("groupings", py::overload_cast<>(&Netlist::get_groupings, py::const_), R"(
661  All groupings contained within the netlist.
662 
663  :type: list[hal_py.Grouping]
664  )");
665 
666  py_netlist.def("get_groupings", py::overload_cast<>(&Netlist::get_groupings, py::const_), R"(
667  Get all groupings contained within the netlist.
668 
669  :returns: A list of groupings.
670  :rtype: list[hal_py.Grouping]
671  )");
672 
673  py_netlist.def("get_groupings", py::overload_cast<const std::function<bool(const Grouping*)>&>(&Netlist::get_groupings, py::const_), py::arg("filter"), R"(
674  Get all groupings contained within the netlist.
675  The filter is evaluated on every grouping such that the result only contains groupings matching the specified condition.
676 
677  :param lambda filter: Filter function to be evaluated on each grouping.
678  :returns: A list of groupings.
679  :rtype: list[hal_py.Grouping]
680  )");
681 
682  py_netlist.def("get_next_gate_id", &Netlist::get_next_gate_id, R"(
683  Get the gate ID following the highest currently used ID.
684 
685  :returns: The next gate ID.
686  :rtype: int
687  )");
688 
689  py_netlist.def("set_next_gate_id", &Netlist::set_next_gate_id, py::arg("id"), R"(
690  Set the gate ID following the highest currently used ID.
691 
692  :param int id: The next gate ID.
693  )");
694 
695  py_netlist.def("get_used_gate_ids", &Netlist::get_used_gate_ids, R"(
696  Get a set of all currently used gate IDs.
697 
698  :returns: All used gate IDs.
699  :rtype: set[int]
700  )");
701 
702  py_netlist.def("set_used_gate_ids", &Netlist::set_used_gate_ids, py::arg("ids"), R"(
703  Set a set of all currently used gate IDs.
704 
705  :param set[int] ids: All used gate IDs.
706  )");
707 
708  py_netlist.def("get_free_gate_ids", &Netlist::get_free_gate_ids, R"(
709  Get a set of all gate IDs that have previously been used but been freed ever since.
710 
711  :returns: All freed gate IDs.
712  :rtype: set[int]
713  )");
714 
715  py_netlist.def("set_free_gate_ids", &Netlist::set_free_gate_ids, py::arg("ids"), R"(
716  Set a set of all gate IDs that have previously been used but been freed ever since.
717 
718  :param set[int] ids: All freed gate IDs.
719  )");
720 
721  py_netlist.def("get_next_net_id", &Netlist::get_next_net_id, R"(
722  Get the net ID following the highest currently used ID.
723 
724  :returns: The next net ID.
725  :rtype: int
726  )");
727 
728  py_netlist.def("set_next_net_id", &Netlist::set_next_net_id, py::arg("id"), R"(
729  Set the net ID following the highest currently used ID.
730 
731  :param int id: The next net ID.
732  )");
733 
734  py_netlist.def("get_used_net_ids", &Netlist::get_used_net_ids, R"(
735  Get a set of all currently used net IDs.
736 
737  :returns: All used net IDs.
738  :rtype: set[int]
739  )");
740 
741  py_netlist.def("set_used_net_ids", &Netlist::set_used_net_ids, py::arg("ids"), R"(
742  Set a set of all currently used net IDs.
743 
744  :param set[int] ids: All used net IDs.
745  )");
746 
747  py_netlist.def("get_free_net_ids", &Netlist::get_free_net_ids, R"(
748  Get a set of all net IDs that have previously been used but been freed ever since.
749 
750  :returns: All freed net IDs.
751  :rtype: set[int]
752  )");
753 
754  py_netlist.def("set_free_net_ids", &Netlist::set_free_net_ids, py::arg("ids"), R"(
755  Set a set of all net IDs that have previously been used but been freed ever since.
756 
757  :param set[int] ids: All freed net IDs.
758  )");
759 
760  py_netlist.def("get_next_module_id", &Netlist::get_next_module_id, R"(
761  Get the module ID following the highest currently used ID.
762 
763  :returns: The next module ID.
764  :rtype: int
765  )");
766 
767  py_netlist.def("set_next_module_id", &Netlist::set_next_module_id, py::arg("id"), R"(
768  Set the module ID following the highest currently used ID.
769 
770  :param int id: The next module ID.
771  )");
772 
773  py_netlist.def("get_used_module_ids", &Netlist::get_used_module_ids, R"(
774  Get a set of all currently used module IDs.
775 
776  :returns: All used module IDs.
777  :rtype: set[int]
778  )");
779 
780  py_netlist.def("set_used_module_ids", &Netlist::set_used_module_ids, py::arg("ids"), R"(
781  Set a set of all currently used module IDs.
782 
783  :param set[int] ids: All used module IDs.
784  )");
785 
786  py_netlist.def("get_free_module_ids", &Netlist::get_free_module_ids, R"(
787  Get a set of all module IDs that have previously been used but been freed ever since.
788 
789  :returns: All freed module IDs.
790  :rtype: set[int]
791  )");
792 
793  py_netlist.def("set_free_module_ids", &Netlist::set_free_module_ids, py::arg("ids"), R"(
794  Set a set of all module IDs that have previously been used but been freed ever since.
795 
796  :param set[int] ids: All freed module IDs.
797  )");
798 
799  py_netlist.def("get_next_grouping_id", &Netlist::get_next_grouping_id, R"(
800  Get the grouping ID following the highest currently used ID.
801 
802  :returns: The next grouping ID.
803  :rtype: int
804  )");
805 
806  py_netlist.def("set_next_grouping_id", &Netlist::set_next_grouping_id, py::arg("id"), R"(
807  Set the grouping ID following the highest currently used ID.
808 
809  :param int id: The next grouping ID.
810  )");
811 
812  py_netlist.def("get_used_grouping_ids", &Netlist::get_used_grouping_ids, R"(
813  Get a set of all currently used grouping IDs.
814 
815  :returns: All used grouping IDs.
816  :rtype: set[int]
817  )");
818 
819  py_netlist.def("set_used_grouping_ids", &Netlist::set_used_grouping_ids, py::arg("ids"), R"(
820  Set a set of all currently used grouping IDs.
821 
822  :param set[int] ids: All used grouping IDs.
823  )");
824 
825  py_netlist.def("get_free_grouping_ids", &Netlist::get_free_grouping_ids, R"(
826  Get a set of all grouping IDs that have previously been used but been freed ever since.
827 
828  :returns: All freed grouping IDs.
829  :rtype: set[int]
830  )");
831 
832  py_netlist.def("set_free_grouping_ids", &Netlist::set_free_grouping_ids, py::arg("ids"), R"(
833  Set a set of all grouping IDs that have previously been used but been freed ever since.
834 
835  :param set[int] ids: All freed grouping IDs.
836  )");
837 
838  py_netlist.def(
839  "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"(
840  Load the locations of the gates in the netlist from their associated data using the specified category and identifier.
841  If no parameter is given, the data is querried using the default category and identifier stored with the gate library.
842 
843  :param str data_category: The data category.
844  :param tuple(str,str) data_identifiers: The data identifiers for the x- and y-coordinates.
845  :returns: True on success, False otherwise.
846  :rtype: bool
847  )");
848  }
849 } // 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
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)
quint32 u32