HAL  v4.5.0-254-g8f9f6a423
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
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  :rtype: 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 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", py::cpp_function(&Gate::get_module, py::is_method(py_gate), borrowed()), 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, borrowed(), 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", py::cpp_function([](Gate* g) { return g->get_modules(); }, py::is_method(py_gate), borrowed()), 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, borrowed(), 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, borrowed(), 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",
201  py::overload_cast<const std::string&>(&Gate::get_boolean_function, py::const_),
202  py::arg("name"),
203  R"(
204  Get the raw Boolean function specified by the given name without inlining or net substitution.
205  This name can for example be an ``output`` pin of the gate or any other user-defined function name.
206  For full control over inlining and net substitution use ``get_boolean_function`` with ``inlined`` and ``substitute_nets``.
207 
208  :param str name: The name. If empty, the first output pin is used.
209  :returns: The Boolean function on success, an empty Boolean function otherwise.
210  :rtype: hal_py.BooleanFunction
211  )");
212 
213  py_gate.def(
214  "get_boolean_function",
215  [](const Gate& self, const std::string& name, bool inlined, bool substitute_nets) -> std::optional<BooleanFunction> {
216  auto res = self.get_boolean_function(name, inlined, substitute_nets);
217  if (res.is_ok())
218  {
219  return res.get();
220  }
221  else
222  {
223  log_error("python_context", "{}", res.get_error().get());
224  return std::nullopt;
225  }
226  },
227  py::arg("name"),
228  py::arg("inlined"),
229  py::arg("substitute_nets"),
230  R"(
231  Get the Boolean function specified by the given name, with full error reporting.
232  When ``inlined`` is ``True``, ``internal`` and ``output`` pin variables are recursively substituted with
233  their definitions, and any gate-instance parameter values are reduced.
234  When ``substitute_nets`` is ``True``, the remaining input pin variables are additionally substituted
235  with variable names derived from the fan-in nets using ``BooleanFunctionNetDecorator``.
236  ``substitute_nets`` requires ``inlined`` to be ``True``; passing ``substitute_nets=True`` with ``inlined=False`` returns ``None``.
237 
238  :param str name: The name. Must not be empty.
239  :param bool inlined: Set ``True`` to inline ``internal`` and ``output`` pins and reduce parameter-conditional expressions.
240  :param bool substitute_nets: Set ``True`` to substitute input pin variables with fan-in net variables. Requires ``inlined=True`` and every input pin to have a connected net.
241  :returns: The Boolean function on success, ``None`` otherwise.
242  :rtype: hal_py.BooleanFunction or None
243  )");
244 
245  py_gate.def("get_boolean_function",
246  py::overload_cast<const GatePin*>(&Gate::get_boolean_function, py::const_),
247  py::arg("pin") = nullptr,
248  R"(
249  Get the raw Boolean function corresponding to the given ``output`` pin without inlining or net substitution.
250  If ``pin`` is ``None``, the Boolean function of the first ``output`` pin is returned.
251  For full control over inlining and net substitution use ``get_boolean_function`` with ``inlined`` and ``substitute_nets``.
252 
253  :param hal_py.GatePin pin: The pin.
254  :returns: The Boolean function on success, an empty Boolean function otherwise.
255  :rtype: hal_py.BooleanFunction
256  )");
257 
258  py_gate.def(
259  "get_boolean_function",
260  [](const Gate& self, const GatePin* pin, bool inlined, bool substitute_nets) -> std::optional<BooleanFunction> {
261  auto res = self.get_boolean_function(pin, inlined, substitute_nets);
262  if (res.is_ok())
263  {
264  return res.get();
265  }
266  else
267  {
268  log_error("python_context", "{}", res.get_error().get());
269  return std::nullopt;
270  }
271  },
272  py::arg("pin"),
273  py::arg("inlined"),
274  py::arg("substitute_nets"),
275  R"(
276  Get the Boolean function corresponding to the given ``output`` pin, with full error reporting.
277  When ``inlined`` is ``True``, ``internal`` and ``output`` pin variables are recursively substituted with
278  their definitions, and any gate-instance parameter values are reduced.
279  When ``substitute_nets`` is ``True``, the remaining input pin variables are additionally substituted
280  with variable names derived from the fan-in nets using ``BooleanFunctionNetDecorator``.
281  ``substitute_nets`` requires ``inlined`` to be ``True``; passing ``substitute_nets=True`` with ``inlined=False`` returns ``None``.
282  Returns ``None`` if ``pin`` is ``None``.
283 
284  :param hal_py.GatePin pin: The output pin.
285  :param bool inlined: Set ``True`` to inline ``internal`` and ``output`` pins and reduce parameter-conditional expressions.
286  :param bool substitute_nets: Set ``True`` to substitute input pin variables with fan-in net variables. Requires ``inlined=True`` and every input pin to have a connected net.
287  :returns: The Boolean function on success, ``None`` otherwise.
288  :rtype: hal_py.BooleanFunction or None
289  )");
290 
291  py_gate.def("has_boolean_function", py::overload_cast<const std::string&>(&Gate::has_boolean_function, py::const_), py::arg("name"), R"(
292  Check whether the gate has a Boolean function with the given name, i.e., whether ``get_boolean_function`` finds one.
293  This name can for example be an output pin of the gate or any other user-defined function name.
294  Every LUT output pin has a Boolean function, even if the LUT is not configured.
295 
296  :param str name: The name.
297  :returns: ``True`` if the gate has a Boolean function with that name, ``False`` otherwise.
298  :rtype: bool
299  )");
300 
301  py_gate.def("has_boolean_function", py::overload_cast<const GatePin*>(&Gate::has_boolean_function, py::const_), py::arg("pin"), R"(
302  Check whether the gate has a Boolean function for the given output pin, i.e., whether ``get_boolean_function`` finds one.
303  If pin is ``None``, the first output pin is checked.
304  Every LUT output pin has a Boolean function, even if the LUT is not configured.
305 
306  :param hal_py.GatePin pin: The pin.
307  :returns: ``True`` if the gate has a Boolean function for the pin, ``False`` otherwise.
308  :rtype: bool
309  )");
310 
311  py_gate.def_property_readonly("boolean_functions", [](Gate* g) { return g->get_boolean_functions(); }, R"(
312  A dictionary from function name to raw Boolean function for all boolean functions associated with this gate.
313 
314  :rtype: dict[str,hal_py.BooleanFunction]
315  )");
316 
317  py_gate.def("get_boolean_functions",
318  py::overload_cast<bool>(&Gate::get_boolean_functions, py::const_),
319  py::arg("only_custom_functions") = false,
320  R"(
321  Get a dictionary from function name to raw Boolean function for all boolean functions associated with this gate.
322  For full control over inlining and net substitution use ``get_boolean_functions`` with ``inlined`` and ``substitute_nets``.
323 
324  :param bool only_custom_functions: Set ``True`` to get only Boolean functions that are local to the gate, ``False`` otherwise.
325  :returns: A dict from function name to function on success, an empty dict otherwise.
326  :rtype: dict[str,hal_py.BooleanFunction]
327  )");
328 
329  py_gate.def(
330  "get_boolean_functions",
331  [](const Gate& self, bool only_custom_functions, bool inlined, bool substitute_nets) -> std::optional<std::unordered_map<std::string, BooleanFunction>> {
332  auto res = self.get_boolean_functions(only_custom_functions, inlined, substitute_nets);
333  if (res.is_ok())
334  {
335  return res.get();
336  }
337  else
338  {
339  log_error("python_context", "{}", res.get_error().get());
340  return std::nullopt;
341  }
342  },
343  py::arg("only_custom_functions"),
344  py::arg("inlined"),
345  py::arg("substitute_nets"),
346  R"(
347  Get a dictionary from function name to Boolean function for all boolean functions associated with this gate.
348  When ``inlined`` is ``True``, ``internal`` and ``output`` pin variables are recursively substituted with
349  their definitions, and gate-instance parameter values are reduced.
350  When ``substitute_nets`` is ``True``, the remaining input pin variables are additionally substituted with
351  variable names derived from the fan-in nets. ``substitute_nets`` requires ``inlined`` to be ``True``.
352  Aborts on the first failure and returns ``None``.
353 
354  :param bool only_custom_functions: If ``True``, returns only functions set via :func:`add_boolean_function`.
355  :param bool inlined: Set ``True`` to inline ``internal`` and ``output`` pins and reduce parameter-conditional expressions.
356  :param bool substitute_nets: Set ``True`` to substitute input pin variables with fan-in net variables. Requires ``inlined=True``.
357  :returns: A map from function name to function on success, ``None`` otherwise.
358  :rtype: dict[str,hal_py.BooleanFunction] or None
359  )");
360 
361  py_gate.def("add_boolean_function", &Gate::add_boolean_function, py::arg("name"), py::arg("func"), R"(
362  Add a Boolean function with the given name to the gate.
363 
364  :param str name: The name.
365  :param hal_py.BooleanFunction func: The function.
366  :returns: ``True`` on success, ``False`` otherwise.
367  :rtype: bool
368  )");
369 
370  py_gate.def("mark_vcc_gate", &Gate::mark_vcc_gate, R"(
371  Mark this gate as a global vcc gate.
372 
373  :returns: ``True`` on success, ``False`` otherwise.
374  :rtype: bool
375  )");
376 
377  py_gate.def("mark_gnd_gate", &Gate::mark_gnd_gate, R"(
378  Mark this gate as a global gnd gate.
379 
380  :returns: ``True`` on success, ``False`` otherwise.
381  :rtype: bool
382  )");
383 
384  py_gate.def("unmark_vcc_gate", &Gate::unmark_vcc_gate, R"(
385  Unmark this gate as a global vcc gate.
386 
387  :returns: ``True`` on success, ``False`` otherwise.
388  :rtype: bool
389  )");
390 
391  py_gate.def("unmark_gnd_gate", &Gate::unmark_gnd_gate, R"(
392  Unmark this gate as a global gnd gate.
393 
394  :returns: ``True`` on success, ``False`` otherwise.
395  :rtype: bool
396  )");
397 
398  py_gate.def("is_vcc_gate", &Gate::is_vcc_gate, R"(
399  Checks whether this gate is a global vcc gate.
400 
401  :returns: ``True`` if the gate is a global vcc gate, ``False`` otherwise.
402  :rtype: bool
403  )");
404 
405  py_gate.def("is_gnd_gate", &Gate::is_gnd_gate, R"(
406  Checks whether this gate is a global gnd gate.
407 
408  :returns: ``True`` if the gate is a global gnd gate, ``False`` otherwise.
409  :rtype: bool
410  )");
411 
412  py_gate.def_property_readonly("fan_in_nets", py::cpp_function(py::overload_cast<>(&Gate::get_fan_in_nets, py::const_), py::is_method(py_gate), borrowed()), R"(
413  A list of all fan-in nets of the gate, i.e., all nets that are connected to one of the input pins.
414 
415  :type: list[hal_py.Net]
416  )");
417 
418  py_gate.def("get_fan_in_nets", py::overload_cast<>(&Gate::get_fan_in_nets, py::const_), borrowed(), R"(
419  Get a list of all fan-in nets of the gate, i.e., all nets that are connected to one of the input pins.
420 
421  :returns: A list of all fan-in nets.
422  :rtype: list[hal_py.Net]
423  )");
424 
425  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"), borrowed(), R"(
426  Get a list of all fan-in nets of the gate, i.e., all nets that are connected to one of the input pins.
427  The filter is evaluated on every candidate such that the result only contains those matching the specified condition.
428 
429  :param lambda filter: Filter function to be evaluated on each net.
430  :returns: A list of all fan-in nets.
431  :rtype: list[hal_py.Net]
432  )");
433 
434  py_gate.def("get_fan_in_net", py::overload_cast<const std::string&>(&Gate::get_fan_in_net, py::const_), py::arg("pin_name"), borrowed(), R"(
435  Get the fan-in net corresponding to the input pin specified by name.
436 
437  :param str pin_name: The input pin name.
438  :returns: The fan-in net on success, ``None`` otherwise.
439  :rtype: hal_py.Net or None
440  )");
441 
442  py_gate.def("get_fan_in_net", py::overload_cast<const GatePin*>(&Gate::get_fan_in_net, py::const_), py::arg("pin"), borrowed(), R"(
443  Get the fan-in net corresponding to the specified input pin.
444 
445  :param hal_py.GatePin pin: The input pin.
446  :returns: The fan-in net on success, ``None`` otherwise.
447  :rtype: hal_py.Net or None
448  )");
449 
450  py_gate.def("is_fan_in_net", &Gate::is_fan_in_net, py::arg("net"), R"(
451  Check whether the given net is a fan-in of the gate.
452 
453  :param hal_py.Net net: The net.
454  :returns: ``True`` if the net is a fan-in of the gate, ``False`` otherwise.
455  :rtype: bool
456  )");
457 
458  py_gate.def_property_readonly("fan_in_endpoints", py::cpp_function(py::overload_cast<>(&Gate::get_fan_in_endpoints, py::const_), py::is_method(py_gate), borrowed()), R"(
459  A list of all fan-in endpoints of the gate, i.e., all endpoints associated with an input pin of the gate.
460 
461  :type: list[hal_py.Endpoint]
462  )");
463 
464  py_gate.def("get_fan_in_endpoints", py::overload_cast<>(&Gate::get_fan_in_endpoints, py::const_), borrowed(), R"(
465  Get a list of all fan-in endpoints of the gate, i.e., all endpoints associated with an input pin of the gate.
466 
467  :returns: A list of all fan-in endpoints.
468  :rtype: list[hal_py.Endpoint]
469  )");
470 
471  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"), borrowed(), R"(
472  Get a list of all fan-in endpoints of the gate, i.e., all endpoints associated with an input pin of the gate.
473  The filter is evaluated on every candidate such that the result only contains those matching the specified condition.
474 
475  :param lambda filter: Filter function to be evaluated on each endpoint.
476  :returns: A list of all fan-in endpoints.
477  :rtype: list[hal_py.Endpoint]
478  )");
479 
480  py_gate.def("get_fan_in_endpoint", py::overload_cast<const std::string&>(&Gate::get_fan_in_endpoint, py::const_), py::arg("pin_name"), borrowed(), R"(
481  Get the fan-in endpoint corresponding to the input pin specified by name.
482 
483  :param str pin_name: The input pin name.
484  :returns: The endpoint on success, ``None`` otherwise.
485  :rtype: hal_py.Endpoint or None
486  )");
487 
488  py_gate.def("get_fan_in_endpoint", py::overload_cast<const GatePin*>(&Gate::get_fan_in_endpoint, py::const_), py::arg("pin"), borrowed(), R"(
489  Get the fan-in endpoint corresponding to the specified input pin.
490 
491  :param hal_py.GatePin pin: The input pin.
492  :returns: The endpoint on success, ``None`` otherwise.
493  :rtype: hal_py.Endpoint or None
494  )");
495 
496  py_gate.def("get_fan_in_endpoint", py::overload_cast<const Net*>(&Gate::get_fan_in_endpoint, py::const_), py::arg("net"), borrowed(), R"(
497  Get the fan-in endpoint connected to the specified input net.
498 
499  :param hal_py.Net net: The input net.
500  :returns: The endpoint on success, ``None`` otherwise.
501  :rtype: hal_py.Endpoint or None
502  )");
503 
504  py_gate.def_property_readonly("fan_out_nets", py::cpp_function(py::overload_cast<>(&Gate::get_fan_out_nets, py::const_), py::is_method(py_gate), borrowed()), R"(
505  A list of all fan-out nets of the gate, i.e., all nets that are connected to one of the output pins.
506 
507  :type: list[hal_py.Net]
508  )");
509 
510  py_gate.def("get_fan_out_nets", py::overload_cast<>(&Gate::get_fan_out_nets, py::const_), borrowed(), R"(
511  Get a list of all fan-out nets of the gate, i.e., all nets that are connected to one of the output pins.
512 
513  :returns: A list of all fan-out nets.
514  :rtype: list[hal_py.Net]
515  )");
516 
517  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"), borrowed(), R"(
518  Get a list of all fan-out nets of the gate, i.e., all nets that are connected to one of the output pins.
519  The filter is evaluated on every candidate such that the result only contains those matching the specified condition.
520 
521  :param lambda filter: Filter function to be evaluated on each net.
522  :returns: A list of all fan-out nets.
523  :rtype: list[hal_py.Net]
524  )");
525 
526  py_gate.def("get_fan_out_net", py::overload_cast<const std::string&>(&Gate::get_fan_out_net, py::const_), py::arg("pin_name"), borrowed(), R"(
527  Get the fan-out net corresponding to the output pin specified by name.
528 
529  :param str pin_name: The output pin name.
530  :returns: The fan-out net on success, ``None`` otherwise.
531  :rtype: hal_py.Net or None
532  )");
533 
534  py_gate.def("get_fan_out_net", py::overload_cast<const GatePin*>(&Gate::get_fan_out_net, py::const_), py::arg("pin"), borrowed(), R"(
535  Get the fan-out net corresponding to the specified output pin.
536 
537  :param hal_py.GatePin pin: The output pin.
538  :returns: The fan-out net on success, ``None`` otherwise.
539  :rtype: hal_py.Net or None
540  )");
541 
542  py_gate.def("is_fan_out_net", &Gate::is_fan_out_net, py::arg("net"), R"(
543  Check whether the given net is a fan-out of the gate.
544 
545  :param hal_py.Net net: The net.
546  :returns: ``True`` if the net is a fan-out of the gate, ``False`` otherwise.
547  :rtype: bool
548  )");
549 
550  py_gate.def_property_readonly("fan_out_endpoints", py::cpp_function(py::overload_cast<>(&Gate::get_fan_out_endpoints, py::const_), py::is_method(py_gate), borrowed()), R"(
551  A list of all fan-out endpoints of the gate, i.e., all endpoints associated with an output pin of the gate.
552 
553  :type: list[hal_py.Endpoint]
554  )");
555 
556  py_gate.def("get_fan_out_endpoints", py::overload_cast<>(&Gate::get_fan_out_endpoints, py::const_), borrowed(), R"(
557  Get a list of all fan-out endpoints of the gate, i.e., all endpoints associated with an output pin of the gate.
558 
559  :returns: A list of all fan-out endpoints.
560  :rtype: list[hal_py.Endpoint]
561  )");
562 
563  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"), borrowed(), R"(
564  Get a list of all fan-out endpoints of the gate, i.e., all endpoints associated with an output pin of the gate.
565  The filter is evaluated on every candidate such that the result only contains those matching the specified condition.
566 
567  :param lambda filter: Filter function to be evaluated on each endpoint.
568  :returns: A list of all fan-out endpoints.
569  :rtype: list[hal_py.Endpoint]
570  )");
571 
572  py_gate.def("get_fan_out_endpoint", py::overload_cast<const std::string&>(&Gate::get_fan_out_endpoint, py::const_), py::arg("pin_name"), borrowed(), R"(
573  Get the fan-out endpoint corresponding to the output pin specified by name.
574 
575  :param str pin_name: The output pin name.
576  :returns: The endpoint on success, ``None`` otherwise.
577  :rtype: hal_py.Endpoint or None
578  )");
579 
580  py_gate.def("get_fan_out_endpoint", py::overload_cast<const GatePin*>(&Gate::get_fan_out_endpoint, py::const_), py::arg("pin"), borrowed(), R"(
581  Get the fan-out endpoint corresponding to the specified output pin.
582 
583  :param hal_py.GatePin pin: The output pin.
584  :returns: The endpoint on success, ``None`` otherwise.
585  :rtype: hal_py.Endpoint or None
586  )");
587 
588  py_gate.def("get_fan_out_endpoint", py::overload_cast<const Net*>(&Gate::get_fan_out_endpoint, py::const_), py::arg("net"), borrowed(), R"(
589  Get the fan-out endpoint connected to the specified output net.
590 
591  :param hal_py.Net net: The output net.
592  :returns: The endpoint on success, ``None`` otherwise.
593  :rtype: hal_py.Endpoint or None
594  )");
595 
596  py_gate.def_property_readonly("unique_predecessors", py::cpp_function([](Gate* g) { return g->get_unique_predecessors(); }, py::is_method(py_gate), borrowed()), R"(
597  A list of all unique predecessor gates of the gate.
598 
599  :type: list[hal_py.Gate]
600  )");
601 
602  py_gate.def("get_unique_predecessors", &Gate::get_unique_predecessors, py::arg("filter") = nullptr, borrowed(), R"(
603  Get a list of all unique predecessor gates of the gate.
604  The optional filter is evaluated on every candidate such that the result only contains those matching the specified condition.
605 
606  :param lambda filter: An optional filter being evaluated on the gate's input pin as well as the predecessor endpoint.
607  :returns: A list of unique predecessor gates.
608  :rtype: list[hal_py.Gate]
609  )");
610 
611  py_gate.def_property_readonly("predecessors", py::cpp_function([](Gate* g) { return g->get_predecessors(); }, py::is_method(py_gate), borrowed()), R"(
612  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.
613 
614  :type: list[hal_py.Endpoint]
615  )");
616 
617  py_gate.def("get_predecessors", &Gate::get_predecessors, py::arg("filter") = nullptr, borrowed(), R"(
618  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.
619  The optional filter is evaluated on every candidate such that the result only contains those matching the specified condition.
620 
621  :param lambda filter: An optional filter being evaluated on the gate's input pin as well as the predecessor endpoint.
622  :returns: A list of predecessor endpoints.
623  :rtype: list[hal_py.Endpoint]
624  )");
625 
626  py_gate.def("get_predecessor", py::overload_cast<const std::string&>(&Gate::get_predecessor, py::const_), py::arg("pin_name"), borrowed(), R"(
627  Get a single direct predecessor endpoint that is connected to the input pin specified by name.
628  Fails if there are no or more than one predecessors.
629 
630  :param str pin_name: The input pin name.
631  :returns: The predecessor endpoint on success, ``None`` otherwise.
632  :rtype: hal_py.Endpoint or None
633  )");
634 
635  py_gate.def("get_predecessor", py::overload_cast<const GatePin*>(&Gate::get_predecessor, py::const_), py::arg("pin"), borrowed(), R"(
636  Get a single direct predecessor endpoint that is connected to the specified input pin.
637  Fails if there are no or more than one predecessors.
638 
639  :param hal_py.GatePin pin: The input pin.
640  :returns: The predecessor endpoint on success, ``None`` otherwise.
641  :rtype: hal_py.Endpoint or None
642  )");
643 
644  py_gate.def_property_readonly("unique_successors", py::cpp_function([](Gate* g) { return g->get_unique_successors(); }, py::is_method(py_gate), borrowed()), R"(
645  A list of all unique successor gates of the gate.
646 
647  :type: list[hal_py.Gate]
648  )");
649 
650  py_gate.def("get_unique_successors", &Gate::get_unique_successors, py::arg("filter") = nullptr, borrowed(), R"(
651  Get a list of all unique successor gates of the gate.
652  The optional filter is evaluated on every candidate such that the result only contains those matching the specified condition.
653 
654  :param lambda filter: An optional filter being evaluated on the gate's output pin as well as the successor endpoint.
655  :returns: A list of unique successor gates.
656  :rtype: list[hal_py.Gate]
657  )");
658 
659  py_gate.def_property_readonly("successors", py::cpp_function([](Gate* g) { return g->get_successors(); }, py::is_method(py_gate), borrowed()), R"(
660  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.
661 
662  :type: list[hal_py.Endpoint]
663  )");
664 
665  py_gate.def("get_successors", &Gate::get_successors, py::arg("filter") = nullptr, borrowed(), R"(
666  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.
667  The optional filter is evaluated on every candidate such that the result only contains those matching the specified condition.
668 
669  :param lambda filter: An optional filter being evaluated on the gate's output pin as well as the successor endpoint.
670  :returns: A list of successor endpoints.
671  :rtype: list[hal_py.Endpoint]
672  )");
673 
674  py_gate.def("get_successor", py::overload_cast<const std::string&>(&Gate::get_successor, py::const_), py::arg("pin_name"), borrowed(), R"(
675  Get a single direct successor endpoint that is connected to the output pin specified by name.
676  Fails if there are no or more than one successors.
677 
678  :param str pin_name: The output pin name.
679  :returns: The successor endpoint on success, ``None`` otherwise.
680  :rtype: hal_py.Endpoint or None
681  )");
682 
683  py_gate.def("get_successor", py::overload_cast<const GatePin*>(&Gate::get_successor, py::const_), py::arg("pin"), borrowed(), R"(
684  Get a single direct successor endpoint that is connected to the output pin specified by name.
685  Fails if there are no or more than one successors.
686 
687  :param hal_py.GatePin pin: The output pin.
688  :returns: The successor endpoint on success, ``None`` otherwise.
689  :rtype: hal_py.Endpoint or None
690  )");
691 
692  }
693 } // namespace hal
Definition: gate.h:59
Net * get_fan_in_net(const std::string &pin_name) const
Definition: gate.cpp:852
void set_location_y(i32 y)
Definition: gate.cpp:196
i32 get_location_x() const
Definition: gate.cpp:167
bool add_boolean_function(const std::string &name, const BooleanFunction &func)
Definition: gate.cpp:704
BooleanFunction get_boolean_function(const std::string &name) const
Definition: gate.cpp:246
bool is_fan_out_net(const Net *net) const
Definition: gate.cpp:1016
const std::vector< Net * > & get_fan_in_nets() const
Definition: gate.cpp:826
bool is_fan_in_net(const Net *net) const
Definition: gate.cpp:872
std::vector< Gate * > get_unique_successors(const std::function< bool(const GatePin *pin, Endpoint *ep)> &filter=nullptr) const
Definition: gate.cpp:1189
const std::vector< Endpoint * > & get_fan_out_endpoints() const
Definition: gate.cpp:1032
i32 get_location_y() const
Definition: gate.cpp:172
GateType * get_type() const
Definition: gate.cpp:162
std::pair< i32, i32 > get_location() const
Definition: gate.cpp:177
bool unmark_vcc_gate()
Definition: gate.cpp:806
std::vector< Endpoint * > get_predecessors(const std::function< bool(const GatePin *pin, Endpoint *ep)> &filter=nullptr) const
Definition: gate.cpp:1121
Net * get_fan_out_net(const std::string &pin_name) const
Definition: gate.cpp:996
std::vector< Gate * > get_unique_predecessors(const std::function< bool(const GatePin *pin, Endpoint *ep)> &filter=nullptr) const
Definition: gate.cpp:1109
std::vector< Endpoint * > get_successors(const std::function< bool(const GatePin *pin, Endpoint *ep)> &filter=nullptr) const
Definition: gate.cpp:1201
const std::string & get_name() const
Definition: gate.cpp:142
Grouping * get_grouping() const
Definition: gate.cpp:241
Endpoint * get_predecessor(const std::string &pin_name) const
Definition: gate.cpp:1173
bool has_location() const
Definition: gate.cpp:182
Endpoint * get_fan_in_endpoint(const std::string &pin_name) const
Definition: gate.cpp:914
bool is_vcc_gate() const
Definition: gate.cpp:816
void set_location(const std::pair< i32, i32 > &location)
Definition: gate.cpp:205
bool mark_gnd_gate()
Definition: gate.cpp:801
Module * get_module() const
Definition: gate.cpp:211
ssize_t get_hash() const
Definition: gate.cpp:127
Endpoint * get_successor(const std::string &pin_name) const
Definition: gate.cpp:1253
bool has_boolean_function(const std::string &name) const
Definition: gate.cpp:409
void set_name(const std::string &name)
Definition: gate.cpp:147
bool unmark_gnd_gate()
Definition: gate.cpp:811
std::vector< Module * > get_modules(const std::function< bool(Module *)> &filter=nullptr, bool recursive=true) const
Definition: gate.cpp:216
bool is_gnd_gate() const
Definition: gate.cpp:821
const std::vector< Net * > & get_fan_out_nets() const
Definition: gate.cpp:970
const std::vector< Endpoint * > & get_fan_in_endpoints() const
Definition: gate.cpp:888
bool mark_vcc_gate()
Definition: gate.cpp:796
void set_location_x(i32 x)
Definition: gate.cpp:187
Netlist * get_netlist() const
Definition: gate.cpp:137
Endpoint * get_fan_out_endpoint(const std::string &pin_name) const
Definition: gate.cpp:1058
std::unordered_map< std::string, BooleanFunction > get_boolean_functions(bool only_custom_functions=false) const
Definition: gate.cpp:451
u32 get_id() const
Definition: gate.cpp:132
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)
Definition: defines.h:45
std::string name