HAL
gate.cpp
Go to the documentation of this file.
2 
3 namespace hal
4 {
6  {
7  py::class_<Gate, DataContainer, RawPtrWrapper<Gate>> py_gate(m, "Gate", R"(Gate class containing information about a gate including its location, functions, and module.)");
8 
9  py_gate.def(py::self == py::self, R"(
10  Check whether two gates are equal.
11  Does not check for connected nets or containing module.
12 
13  :returns: True if both gates are equal, false otherwise.
14  :rtype: bool
15  )");
16 
17  py_gate.def(py::self != py::self, R"(
18  Check whether two gates are unequal.
19  Does not check for connected nets or containing module.
20 
21  :returns: True if both gates are unequal, false otherwise.
22  :rtype: bool
23  )");
24 
25  py_gate.def("__hash__", &Gate::get_hash, R"(
26  Python requires hash for set and dict container.
27 
28  :returns: The hash.
29  :rtype: Py_hash_t
30  )");
31 
32  py_gate.def_property_readonly("id", &Gate::get_id, R"(
33  The unique ID of the gate.
34 
35  :type: int
36  )");
37 
38  py_gate.def("get_id", &Gate::get_id, R"(
39  Get the unique ID of the gate.
40 
41  :returns: The unique id.
42  :type: int
43  )");
44 
45  py_gate.def_property_readonly("netlist", [](Gate* g) { return RawPtrWrapper<Netlist>(g->get_netlist()); }, R"(
46  The netlist this gate is associated with.
47 
48  :type: hal_py.Netlist
49  )");
50 
51  py_gate.def("get_netlist", [](Gate* g) { return RawPtrWrapper<Netlist>(g->get_netlist()); }, R"(
52  Get the netlist this gate is associated with.
53 
54  :returns: The netlist.
55  :rtype: hal_py.Netlist
56  )");
57 
58  py_gate.def_property("name", &Gate::get_name, &Gate::set_name, R"(
59  The name of the gate.
60 
61  :type: str
62  )");
63 
64  py_gate.def("get_name", &Gate::get_name, R"(
65  Get the name of the gate.
66 
67  :returns: The name.
68  :rtype: str
69  )");
70 
71  py_gate.def("set_name", &Gate::set_name, py::arg("name"), R"(
72  Set the name of the gate.
73 
74  :param str name: The new name.
75  )");
76 
77  py_gate.def_property_readonly("type", &Gate::get_type, R"(
78  The type of the gate
79 
80  :type: hal_py.Gate_type
81  )");
82 
83  py_gate.def("get_type", &Gate::get_type, R"(
84  Get the type of the gate.
85 
86  :returns: The gate's type.
87  :rtype: hal_py.Gate_type
88  )");
89 
90  py_gate.def("has_location", &Gate::has_location, R"(
91  Checks whether the gate's location in the layout is available.
92 
93  :returns: True if valid location data is available, false otherwise.
94  :rtype: bool
95  )");
96 
97  py_gate.def_property("location_x", &Gate::get_location_x, &Gate::set_location_x, R"(
98  The x-coordinate of the physical location of the gate in the layout. Only positive values are valid, negative values will be regarded as no location assigned.
99 
100  :type: int
101  )");
102 
103  py_gate.def("get_location_x", &Gate::get_location_x, R"(
104  Get the physical location x-coordinate of the gate in the layout.
105  If no valid physical location x-coordinate is assigned, a negative value is returned.
106 
107  :returns: The gate's x-coordinate.
108  :rtype: int
109  )");
110 
111  py_gate.def("set_location_x", &Gate::set_location_x, py::arg("x"), R"(
112  Set the physical location x-coordinate of the gate in the layout.
113  Only positive values are valid, negative values will be regarded as no location assigned.
114 
115  :param int x: The gate's x-coordinate.
116  )");
117 
118  py_gate.def_property("location_y", &Gate::get_location_y, &Gate::set_location_y, R"(
119  The y-coordinate of the physical location of the gate in the layout.
120  Only positive values are valid, negative values will be regarded as no location assigned.
121 
122  :type: int
123  )");
124 
125  py_gate.def("get_location_y", &Gate::get_location_y, R"(
126  Get the physical location y-coordinate of the gate in the layout.
127  If no valid physical location y-coordinate is assigned, a negative value is returned.
128 
129  :returns: The gate's y-coordinate.
130  :rtype: int
131  )");
132 
133  py_gate.def("set_location_y", &Gate::set_location_y, py::arg("y"), R"(
134  Set the physical location y-coordinate of the gate in the layout.
135  Only positive values are valid, negative values will be regarded as no location assigned.
136 
137  :param int y: The gate's y-coordinate.
138  )");
139 
140  py_gate.def_property("location", &Gate::get_location, &Gate::set_location, R"(
141  The physical location of the gate in the layout.
142  Only positive values are valid, negative values will be regarded as no location assigned.
143 
144  :type: tuple(int,int)
145  )");
146 
147  py_gate.def("get_location", &Gate::get_location, R"(
148  Get the physical location of the gate in the layout.
149  If no valid physical location coordinate is assigned, a negative value is returned for the respective coordinate.
150 
151  :returns: A tuple <x-coordinate, y-coordinate>.
152  :rtype: tuple(int,int)
153  )");
154 
155  py_gate.def("set_location", &Gate::set_location, py::arg("location"), R"(
156  Set the physical location of the gate in the layout.
157  Only positive coordinates are valid, negative values will be regarded as no location assigned.
158 
159  :param tuple(int,int) location: A tuple <x-coordinate, y-coordinate>.
160  )");
161 
162  py_gate.def_property_readonly("module", &Gate::get_module, R"(
163  The module in which contains this gate.
164 
165  :type: hal_py.Module
166  )");
167 
168  py_gate.def("get_module", &Gate::get_module, R"(
169  Get the module which contains this gate.
170 
171  :returns: The module.
172  :rtype: hal_py.Module
173  )");
174 
175  py_gate.def_property_readonly("modules", [](Gate* g) { return g->get_modules(); }, R"(
176  A list of all modules that contain this gate, either directly or as parent of another module.
177 
178  :type: list[hal_py.Module]
179  )");
180 
181  py_gate.def("get_modules", &Gate::get_modules, py::arg("filter") = nullptr, py::arg("recursive") = true, R"(
182  Get all modules that contain this gate, either directly or as parent of another module.
183  If recursive is set to True, indirect parent modules are also included. Otherwise, only the module containing the gate directly is returned.
184  The optional filter is evaluated on every candidate such that the result only contains those matching the specified condition.
185 
186  :param lambda filter: An optional filter.
187  :param bool recursive: Set True to include indirect parents as well, False otherwise.
188  :returns: A list of modules.
189  :rtype: list[hal_py.Module]
190  )");
191 
192  py_gate.def("get_grouping", &Gate::get_grouping, R"(
193  Gets the grouping in which this gate is contained.
194  If no grouping contains this gate, *None* is returned.
195 
196  :returns: The grouping.
197  :rtype: hal_py.Grouping
198  )");
199 
200  py_gate.def("get_boolean_function", py::overload_cast<const std::string&>(&Gate::get_boolean_function, py::const_), py::arg("name"), R"(
201  Get the Boolean function specified by the given name.
202  This name can for example be an output pin of the gate or any other user-defined function name.
203 
204  :param str name: The name.
205  :returns: The Boolean function on success, an empty Boolean function otherwise.
206  :rtype: hal_py.BooleanFunction
207  )");
208 
209  py_gate.def("get_boolean_function", py::overload_cast<const GatePin*>(&Gate::get_boolean_function, py::const_), py::arg("pin") = nullptr, R"(
210  Get the Boolean function corresponding to the given output pin.
211  If pin is None, the Boolean function of the first output pin is returned.
212 
213  :param hal_py.GatePin pin: The pin.
214  :returns: The Boolean function on success, an empty Boolean function otherwise.
215  :rtype: hal_py.BooleanFunction
216  )");
217 
218  py_gate.def(
219  "get_resolved_boolean_function",
220  [](const Gate& self, const GatePin* pin, const bool use_net_variables = false) -> std::optional<BooleanFunction> {
221  auto res = self.get_resolved_boolean_function(pin, use_net_variables);
222  if (res.is_ok())
223  {
224  return res.get();
225  }
226  else
227  {
228  log_error("python_context", "{}", res.get_error().get());
229  return std::nullopt;
230  }
231  },
232  py::arg("pin"),
233  py::arg("use_net_variables") = false,
234  R"(
235  Get the resolved Boolean function corresponding to the given output pin, i.e., a Boolean function that only depends on input pins (or nets) and no internal or output pins.
236  If fan-in nets are used to derive variable names, the variable names are generated using the ``BooleanFunctionNetDecorator``.
237 
238  :param hal_py.GatePin pin: The output pin.
239  :param bool use_net_variables: Set ``True`` to use variable names derived from fan-in nets of the gate, ``False`` to use input pin names instead. Defaults to ``False``.
240  :returns: The Boolean function on success, ``None`` otherwise.
241  :rtype: hal_py.BooleanFunction or None
242  )");
243 
244  py_gate.def_property_readonly("boolean_functions", [](Gate* g) { return g->get_boolean_functions(); }, R"(
245  A dictionary from function name to Boolean function for all boolean functions associated with this gate.
246 
247  :rtype: dict[str,hal_py.BooleanFunction]
248  )");
249 
250  py_gate.def("get_boolean_functions", &Gate::get_boolean_functions, py::arg("only_custom_functions") = false, R"(
251  Get a dictionary from function name to Boolean function for all boolean functions associated with this gate.
252 
253  :param bool only_custom_functions: If true, this returns only the functions which were set via :func:`add_boolean_function`.
254  :returns: A map from function name to function.
255  :rtype: dict[str,hal_py.BooleanFunction]
256  )");
257 
258  py_gate.def("add_boolean_function", &Gate::add_boolean_function, py::arg("name"), py::arg("func"), R"(
259  Add a Boolean function with the given name to the gate.
260 
261  :param str name: The name.
262  :param hal_py.BooleanFunction func: The function.
263  :returns: True on success, False otherwise.
264  :rtype: bool
265  )");
266 
267  py_gate.def("mark_vcc_gate", &Gate::mark_vcc_gate, R"(
268  Mark this gate as a global vcc gate.
269 
270  :returns: True on success, False otherwise.
271  :rtype: bool
272  )");
273 
274  py_gate.def("mark_gnd_gate", &Gate::mark_gnd_gate, R"(
275  Mark this gate as a global gnd gate.
276 
277  :returns: True on success, False otherwise.
278  :rtype: bool
279  )");
280 
281  py_gate.def("unmark_vcc_gate", &Gate::unmark_vcc_gate, R"(
282  Unmark this gate as a global vcc gate.
283 
284  :returns: True on success, False otherwise.
285  :rtype: bool
286  )");
287 
288  py_gate.def("unmark_gnd_gate", &Gate::unmark_gnd_gate, R"(
289  Unmark this gate as a global gnd gate.
290 
291  :returns: True on success, False otherwise.
292  :rtype: bool
293  )");
294 
295  py_gate.def("is_vcc_gate", &Gate::is_vcc_gate, R"(
296  Checks whether this gate is a global vcc gate.
297 
298  :returns: True if the gate is a global vcc gate, False otherwise.
299  :rtype: bool
300  )");
301 
302  py_gate.def("is_gnd_gate", &Gate::is_gnd_gate, R"(
303  Checks whether this gate is a global gnd gate.
304 
305  :returns: True if the gate is a global gnd gate, False otherwise.
306  :rtype: bool
307  )");
308 
309  py_gate.def_property_readonly("fan_in_nets", py::overload_cast<>(&Gate::get_fan_in_nets, py::const_), R"(
310  A list of all fan-in nets of the gate, i.e., all nets that are connected to one of the input pins.
311 
312  :type: list[hal_py.Net]
313  )");
314 
315  py_gate.def("get_fan_in_nets", py::overload_cast<>(&Gate::get_fan_in_nets, py::const_), R"(
316  Get a list of all fan-in nets of the gate, i.e., all nets that are connected to one of the input pins.
317 
318  :returns: A list of all fan-in nets.
319  :rtype: list[hal_py.Net]
320  )");
321 
322  py_gate.def("get_fan_in_nets", py::overload_cast<const std::function<bool(Net*)>&>(&Gate::get_fan_in_nets, py::const_), py::arg("filter"), R"(
323  Get a list of all fan-in nets of the gate, i.e., all nets that are connected to one of the input pins.
324  The filter is evaluated on every candidate such that the result only contains those matching the specified condition.
325 
326  :param lambda filter: Filter function to be evaluated on each net.
327  :returns: A list of all fan-in nets.
328  :rtype: list[hal_py.Net]
329  )");
330 
331  py_gate.def("get_fan_in_net", py::overload_cast<const std::string&>(&Gate::get_fan_in_net, py::const_), py::arg("pin_name"), R"(
332  Get the fan-in net corresponding to the input pin specified by name.
333 
334  :param str pin_name: The input pin name.
335  :returns: The fan-in net on success, None otherwise.
336  :rtype: hal_py.Net or None
337  )");
338 
339  py_gate.def("get_fan_in_net", py::overload_cast<const GatePin*>(&Gate::get_fan_in_net, py::const_), py::arg("pin"), R"(
340  Get the fan-in net corresponding to the specified input pin.
341 
342  :param hal_py.GatePin pin: The input pin.
343  :returns: The fan-in net on success, None otherwise.
344  :rtype: hal_py.Net or None
345  )");
346 
347  py_gate.def("is_fan_in_net", &Gate::is_fan_in_net, py::arg("net"), R"(
348  Check whether the given net is a fan-in of the gate.
349 
350  :param hal_py.Net net: The net.
351  :returns: True if the net is a fan-in of the gate, False otherwise.
352  :rtype: bool
353  )");
354 
355  py_gate.def_property_readonly("fan_in_endpoints", py::overload_cast<>(&Gate::get_fan_in_endpoints, py::const_), R"(
356  A list of all fan-in endpoints of the gate, i.e., all endpoints associated with an input pin of the gate.
357 
358  :type: list[hal_py.Endpoint]
359  )");
360 
361  py_gate.def("get_fan_in_endpoints", py::overload_cast<>(&Gate::get_fan_in_endpoints, py::const_), R"(
362  Get a list of all fan-in endpoints of the gate, i.e., all endpoints associated with an input pin of the gate.
363 
364  :returns: A list of all fan-in endpoints.
365  :rtype: list[hal_py.Endpoint]
366  )");
367 
368  py_gate.def("get_fan_in_endpoints", py::overload_cast<const std::function<bool(Endpoint*)>&>(&Gate::get_fan_in_endpoints, py::const_), py::arg("filter"), R"(
369  Get a list of all fan-in endpoints of the gate, i.e., all endpoints associated with an input pin of the gate.
370  The filter is evaluated on every candidate such that the result only contains those matching the specified condition.
371 
372  :param lambda filter: Filter function to be evaluated on each endpoint.
373  :returns: A list of all fan-in endpoints.
374  :rtype: list[hal_py.Endpoint]
375  )");
376 
377  py_gate.def("get_fan_in_endpoint", py::overload_cast<const std::string&>(&Gate::get_fan_in_endpoint, py::const_), py::arg("pin_name"), R"(
378  Get the fan-in endpoint corresponding to the input pin specified by name.
379 
380  :param str pin_name: The input pin name.
381  :returns: The endpoint on success, None otherwise.
382  :rtype: hal_py.Endpoint or None
383  )");
384 
385  py_gate.def("get_fan_in_endpoint", py::overload_cast<const GatePin*>(&Gate::get_fan_in_endpoint, py::const_), py::arg("pin"), R"(
386  Get the fan-in endpoint corresponding to the specified input pin.
387 
388  :param hal_py.GatePin pin: The input pin.
389  :returns: The endpoint on success, None otherwise.
390  :rtype: hal_py.Endpoint or None
391  )");
392 
393  py_gate.def("get_fan_in_endpoint", py::overload_cast<const Net*>(&Gate::get_fan_in_endpoint, py::const_), py::arg("net"), R"(
394  Get the fan-in endpoint connected to the specified input net.
395 
396  :param hal_py.Net net: The input net.
397  :returns: The endpoint on success, None otherwise.
398  :rtype: hal_py.Endpoint or None
399  )");
400 
401  py_gate.def_property_readonly("fan_out_nets", py::overload_cast<>(&Gate::get_fan_out_nets, py::const_), R"(
402  A list of all fan-out nets of the gate, i.e., all nets that are connected to one of the output pins.
403 
404  :type: list[hal_py.Net]
405  )");
406 
407  py_gate.def("get_fan_out_nets", py::overload_cast<>(&Gate::get_fan_out_nets, py::const_), R"(
408  Get a list of all fan-out nets of the gate, i.e., all nets that are connected to one of the output pins.
409 
410  :returns: A list of all fan-out nets.
411  :rtype: list[hal_py.Net]
412  )");
413 
414  py_gate.def("get_fan_out_nets", py::overload_cast<const std::function<bool(Net*)>&>(&Gate::get_fan_out_nets, py::const_), py::arg("filter"), R"(
415  Get a list of all fan-out nets of the gate, i.e., all nets that are connected to one of the output pins.
416  The filter is evaluated on every candidate such that the result only contains those matching the specified condition.
417 
418  :param lambda filter: Filter function to be evaluated on each net.
419  :returns: A list of all fan-out nets.
420  :rtype: list[hal_py.Net]
421  )");
422 
423  py_gate.def("get_fan_out_net", py::overload_cast<const std::string&>(&Gate::get_fan_out_net, py::const_), py::arg("pin_name"), R"(
424  Get the fan-out net corresponding to the output pin specified by name.
425 
426  :param str pin_name: The output pin name.
427  :returns: The fan-out net on success, None otherwise.
428  :rtype: hal_py.Net or None
429  )");
430 
431  py_gate.def("get_fan_out_net", py::overload_cast<const GatePin*>(&Gate::get_fan_out_net, py::const_), py::arg("pin"), R"(
432  Get the fan-out net corresponding to the specified output pin.
433 
434  :param hal_py.GatePin pin: The output pin.
435  :returns: The fan-out net on success, None otherwise.
436  :rtype: hal_py.Net or None
437  )");
438 
439  py_gate.def("is_fan_out_net", &Gate::is_fan_out_net, py::arg("net"), R"(
440  Check whether the given net is a fan-out of the gate.
441 
442  :param hal_py.Net net: The net.
443  :returns: True if the net is a fan-out of the gate, False otherwise.
444  :rtype: bool
445  )");
446 
447  py_gate.def_property_readonly("fan_out_endpoints", py::overload_cast<>(&Gate::get_fan_out_endpoints, py::const_), R"(
448  A list of all fan-out endpoints of the gate, i.e., all endpoints associated with an output pin of the gate.
449 
450  :type: list[hal_py.Endpoint]
451  )");
452 
453  py_gate.def("get_fan_out_endpoints", py::overload_cast<>(&Gate::get_fan_out_endpoints, py::const_), R"(
454  Get a list of all fan-out endpoints of the gate, i.e., all endpoints associated with an output pin of the gate.
455 
456  :returns: A list of all fan-out endpoints.
457  :rtype: list[hal_py.Endpoint]
458  )");
459 
460  py_gate.def("get_fan_out_endpoints", py::overload_cast<const std::function<bool(Endpoint*)>&>(&Gate::get_fan_out_endpoints, py::const_), py::arg("filter"), R"(
461  Get a list of all fan-out endpoints of the gate, i.e., all endpoints associated with an output pin of the gate.
462  The filter is evaluated on every candidate such that the result only contains those matching the specified condition.
463 
464  :param lambda filter: Filter function to be evaluated on each endpoint.
465  :returns: A list of all fan-out endpoints.
466  :rtype: list[hal_py.Endpoint]
467  )");
468 
469  py_gate.def("get_fan_out_endpoint", py::overload_cast<const std::string&>(&Gate::get_fan_out_endpoint, py::const_), py::arg("pin_name"), R"(
470  Get the fan-out endpoint corresponding to the output pin specified by name.
471 
472  :param str pin_name: The output pin name.
473  :returns: The endpoint on success, None otherwise.
474  :rtype: hal_py.Endpoint or None
475  )");
476 
477  py_gate.def("get_fan_out_endpoint", py::overload_cast<const GatePin*>(&Gate::get_fan_out_endpoint, py::const_), py::arg("pin"), R"(
478  Get the fan-out endpoint corresponding to the specified output pin.
479 
480  :param hal_py.GatePin pin: The output pin.
481  :returns: The endpoint on success, None otherwise.
482  :rtype: hal_py.Endpoint or None
483  )");
484 
485  py_gate.def("get_fan_out_endpoint", py::overload_cast<const Net*>(&Gate::get_fan_out_endpoint, py::const_), py::arg("net"), R"(
486  Get the fan-out endpoint connected to the specified output net.
487 
488  :param hal_py.Net net: The output net.
489  :returns: The endpoint on success, None otherwise.
490  :rtype: hal_py.Endpoint or None
491  )");
492 
493  py_gate.def_property_readonly("unique_predecessors", [](Gate* g) { return g->get_unique_predecessors(); }, R"(
494  A list of all unique predecessor gates of the gate.
495 
496  :type: list[hal_py.Gate]
497  )");
498 
499  py_gate.def("get_unique_predecessors", &Gate::get_unique_predecessors, py::arg("filter") = nullptr, R"(
500  Get a list of all unique predecessor gates of the gate.
501  The optional filter is evaluated on every candidate such that the result only contains those matching the specified condition.
502 
503  :param lambda filter: An optional filter being evaluated on the gate's input pin as well as the predecessor endpoint.
504  :returns: A list of unique predecessors endpoints.
505  :rtype: list[hal_py.Gate]
506  )");
507 
508  py_gate.def_property_readonly("predecessors", [](Gate* g) { return g->get_predecessors(); }, R"(
509  A list of all direct predecessor endpoints of the gate, i.e., all predecessor endpoints that are connected to an input pin of the gate.
510 
511  :type: list[hal_py.Endpoint]
512  )");
513 
514  py_gate.def("get_predecessors", &Gate::get_predecessors, py::arg("filter") = nullptr, R"(
515  Get a list of all direct predecessor endpoints of the gate, i.e., all predecessor endpoints that are connected to an input pin of the gate.
516  The optional filter is evaluated on every candidate such that the result only contains those matching the specified condition.
517 
518  :param lambda filter: An optional filter being evaluated on the gate's input pin as well as the predecessor endpoint.
519  :returns: A list of predecessors endpoints.
520  :rtype: list[hal_py.Endpoint]
521  )");
522 
523  py_gate.def("get_predecessor", py::overload_cast<const std::string&>(&Gate::get_predecessor, py::const_), py::arg("pin_name"), R"(
524  Get a single direct predecessor endpoint that is connected to the input pin specified by name.
525  Fails if there are no or more than one predecessors.
526 
527  :param str pin_name: The input pin name.
528  :returns: The predecessor endpoint on success, None otherwise.
529  :rtype: hal_py.Endpoint or None
530  )");
531 
532  py_gate.def("get_predecessor", py::overload_cast<const GatePin*>(&Gate::get_predecessor, py::const_), py::arg("pin"), R"(
533  Get a single direct predecessor endpoint that is connected to the specified input pin.
534  Fails if there are no or more than one predecessors.
535 
536  :param hal_py.GatePin pin: The input pin.
537  :returns: The predecessor endpoint on success, None otherwise.
538  :rtype: hal_py.Endpoint or None
539  )");
540 
541  py_gate.def_property_readonly("unique_successors", [](Gate* g) { return g->get_unique_successors(); }, R"(
542  A list of all unique successor gates of the gate.
543 
544  :type: list[hal_py.Gate]
545  )");
546 
547  py_gate.def("get_unique_successors", &Gate::get_unique_successors, py::arg("filter") = nullptr, R"(
548  Get a list of all unique successor gates of the gate.
549  The optional filter is evaluated on every candidate such that the result only contains those matching the specified condition.
550 
551  :param lambda filter: An optional filter being evaluated on the gate's output pin as well as the successor endpoint.
552  :returns: A list of unique successor endpoints.
553  :rtype: list[hal_py.Gate]
554  )");
555 
556  py_gate.def_property_readonly("successors", [](Gate* g) { return g->get_successors(); }, R"(
557  A list of all direct successor endpoints of the gate, i.e., all successor endpoints that are connected to an output pin of the gate.
558 
559  :type: list[hal_py.Endpoint]
560  )");
561 
562  py_gate.def("get_successors", &Gate::get_successors, py::arg("filter") = nullptr, R"(
563  Get a list of all direct successor endpoints of the gate, i.e., all successor endpoints that are connected to an output pin of the gate.
564  The optional filter is evaluated on every candidate such that the result only contains those matching the specified condition.
565 
566  :param lambda filter: An optional filter being evaluated on the gate's output pin as well as the successor endpoint.
567  :returns: A list of successor endpoints.
568  :rtype: list[hal_py.Endpoint]
569  )");
570 
571  py_gate.def("get_successor", py::overload_cast<const std::string&>(&Gate::get_successor, py::const_), py::arg("pin_name"), R"(
572  Get a single direct successor endpoint that is connected to the output pin specified by name.
573  Fails if there are no or more than one successors.
574 
575  :param str pin_name: The output pin name.
576  :returns: The successor endpoint on success, None otherwise.
577  :rtype: hal_py.Endpoint or None
578  )");
579 
580  py_gate.def("get_successor", py::overload_cast<const GatePin*>(&Gate::get_successor, py::const_), py::arg("pin"), R"(
581  Get a single direct successor endpoint that is connected to the output pin specified by name.
582  Fails if there are no or more than one successors.
583 
584  :param hal_py.GatePin pin: The output pin.
585  :returns: The successor endpoint on success, None otherwise.
586  :rtype: hal_py.Endpoint or None
587  )");
588 
589  py_gate.def(
590  "get_init_data",
591  [](Gate& self) -> std::vector<std::string> {
592  auto res = self.get_init_data();
593  if (res.is_ok())
594  {
595  return res.get();
596  }
597  else
598  {
599  log_error("python_context", "error encountered while getting INIT data:\n{}", res.get_error().get());
600  return {};
601  }
602  },
603  R"(
604  Get the INIT data of the gate, if available.
605  An error is returned in case the gate does not hold any INIT data.
606 
607  :returns: The INIT data as a list on success, an empty list otherwise.
608  :rtype: list[str]
609  )");
610 
611  py_gate.def(
612  "set_init_data",
613  [](Gate& self, const std::vector<std::string>& init_data) -> bool {
614  auto res = self.set_init_data(init_data);
615  if (res.is_ok())
616  {
617  return true;
618  }
619  else
620  {
621  log_error("python_context", "error encountered while setting INIT data:\n{}", res.get_error().get());
622  return false;
623  }
624  },
625  py::arg("init_data"),
626  R"(
627  Set the INIT data of the gate, if available.
628  An error is returned in case the gate does not hold any INIT data.
629 
630  :param list[str] init_data: The INIT data as a list.
631  :returns: True on success, False otherwise.
632  :rtype: bool
633  )");
634  }
635 } // namespace hal
Definition: gate.h:58
Net * get_fan_in_net(const std::string &pin_name) const
Definition: gate.cpp:617
void set_location_y(i32 y)
Definition: gate.cpp:159
i32 get_location_x() const
Definition: gate.cpp:130
bool add_boolean_function(const std::string &name, const BooleanFunction &func)
Definition: gate.cpp:497
BooleanFunction get_boolean_function(const std::string &name) const
Definition: gate.cpp:209
bool is_fan_out_net(const Net *net) const
Definition: gate.cpp:781
const std::vector< Net * > & get_fan_in_nets() const
Definition: gate.cpp:591
bool is_fan_in_net(const Net *net) const
Definition: gate.cpp:637
std::vector< Gate * > get_unique_successors(const std::function< bool(const GatePin *pin, Endpoint *ep)> &filter=nullptr) const
Definition: gate.cpp:954
const std::vector< Endpoint * > & get_fan_out_endpoints() const
Definition: gate.cpp:797
i32 get_location_y() const
Definition: gate.cpp:135
GateType * get_type() const
Definition: gate.cpp:125
std::pair< i32, i32 > get_location() const
Definition: gate.cpp:140
bool unmark_vcc_gate()
Definition: gate.cpp:571
std::vector< Endpoint * > get_predecessors(const std::function< bool(const GatePin *pin, Endpoint *ep)> &filter=nullptr) const
Definition: gate.cpp:886
Net * get_fan_out_net(const std::string &pin_name) const
Definition: gate.cpp:761
std::vector< Gate * > get_unique_predecessors(const std::function< bool(const GatePin *pin, Endpoint *ep)> &filter=nullptr) const
Definition: gate.cpp:874
std::vector< Endpoint * > get_successors(const std::function< bool(const GatePin *pin, Endpoint *ep)> &filter=nullptr) const
Definition: gate.cpp:966
const std::string & get_name() const
Definition: gate.cpp:105
Grouping * get_grouping() const
Definition: gate.cpp:204
Endpoint * get_predecessor(const std::string &pin_name) const
Definition: gate.cpp:938
bool has_location() const
Definition: gate.cpp:145
Endpoint * get_fan_in_endpoint(const std::string &pin_name) const
Definition: gate.cpp:679
bool is_vcc_gate() const
Definition: gate.cpp:581
void set_location(const std::pair< i32, i32 > &location)
Definition: gate.cpp:168
bool mark_gnd_gate()
Definition: gate.cpp:566
Module * get_module() const
Definition: gate.cpp:174
ssize_t get_hash() const
Definition: gate.cpp:90
Endpoint * get_successor(const std::string &pin_name) const
Definition: gate.cpp:1018
void set_name(const std::string &name)
Definition: gate.cpp:110
bool unmark_gnd_gate()
Definition: gate.cpp:576
std::vector< Module * > get_modules(const std::function< bool(Module *)> &filter=nullptr, bool recursive=true) const
Definition: gate.cpp:179
bool is_gnd_gate() const
Definition: gate.cpp:586
const std::vector< Net * > & get_fan_out_nets() const
Definition: gate.cpp:735
const std::vector< Endpoint * > & get_fan_in_endpoints() const
Definition: gate.cpp:653
bool mark_vcc_gate()
Definition: gate.cpp:561
void set_location_x(i32 x)
Definition: gate.cpp:150
Endpoint * get_fan_out_endpoint(const std::string &pin_name) const
Definition: gate.cpp:823
std::unordered_map< std::string, BooleanFunction > get_boolean_functions(bool only_custom_functions=false) const
Definition: gate.cpp:262
u32 get_id() const
Definition: gate.cpp:95
Definition: net.h:58
std::unique_ptr< T, py::nodelete > RawPtrWrapper
void gate_init(py::module &m)
Definition: gate.cpp:5
#define log_error(channel,...)
Definition: log.h:78
const Module * module(const Gate *g, const NodeBoxes &boxes)