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.)");
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.
13 :returns: True if both gates are equal, false otherwise.
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.
21 :returns: True if both gates are unequal, false otherwise.
26 Python requires hash for set and dict container.
33 The unique ID of the gate.
39 Get the unique ID of the gate.
41 :returns: The unique id.
46 The netlist this gate is associated with.
52 Get the netlist this gate is associated with.
54 :returns: The netlist.
55 :rtype: hal_py.Netlist
65 Get the name of the gate.
72 Set the name of the gate.
74 :param str name: The new name.
80 :type: hal_py.Gate_type
84 Get the type of the gate.
86 :returns: The gate's type.
87 :rtype: hal_py.Gate_type
91 Checks whether the gate's location in the layout is available.
93 :returns: True if valid location data is available, false otherwise.
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.
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.
107 :returns: The gate's x-coordinate.
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.
115 :param int x: The gate's x-coordinate.
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.
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.
129 :returns: The gate's y-coordinate.
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.
137 :param int y: The gate's y-coordinate.
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.
144 :type: tuple(int,int)
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.
151 :returns: A tuple <x-coordinate, y-coordinate>.
152 :rtype: tuple(int,int)
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.
159 :param tuple(int,int) location: A tuple <x-coordinate, y-coordinate>.
163 The module in which contains this gate.
169 Get the module which contains this gate.
171 :returns: The module.
172 :rtype: hal_py.Module
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.
178 :type: list[hal_py.Module]
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.
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]
193 Gets the grouping in which this gate is contained.
194 If no grouping contains this gate, *None* is returned.
196 :returns: The grouping.
197 :rtype: hal_py.Grouping
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.
204 :param str name: The name.
205 :returns: The Boolean function on success, an empty Boolean function otherwise.
206 :rtype: hal_py.BooleanFunction
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.
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
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);
228 log_error(
"python_context",
"{}", res.get_error().get());
233 py::arg(
"use_net_variables") =
false,
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``.
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
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.
247 :rtype: dict[str,hal_py.BooleanFunction]
251 Get a dictionary from function name to Boolean function for all boolean functions associated with this gate.
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]
259 Add a Boolean function with the given name to the gate.
261 :param str name: The name.
262 :param hal_py.BooleanFunction func: The function.
263 :returns: True on success, False otherwise.
268 Mark this gate as a global vcc gate.
270 :returns: True on success, False otherwise.
275 Mark this gate as a global gnd gate.
277 :returns: True on success, False otherwise.
282 Unmark this gate as a global vcc gate.
284 :returns: True on success, False otherwise.
289 Unmark this gate as a global gnd gate.
291 :returns: True on success, False otherwise.
296 Checks whether this gate is a global vcc gate.
298 :returns: True if the gate is a global vcc gate, False otherwise.
303 Checks whether this gate is a global gnd gate.
305 :returns: True if the gate is a global gnd gate, False otherwise.
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.
312 :type: list[hal_py.Net]
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.
318 :returns: A list of all fan-in nets.
319 :rtype: list[hal_py.Net]
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.
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]
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.
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
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.
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
348 Check whether the given net is a fan-in of the gate.
350 :param hal_py.Net net: The net.
351 :returns: True if the net is a fan-in of the gate, False otherwise.
356 A list of all fan-in endpoints of the gate, i.e., all endpoints associated with an input pin of the gate.
358 :type: list[hal_py.Endpoint]
362 Get a list of all fan-in endpoints of the gate, i.e., all endpoints associated with an input pin of the gate.
364 :returns: A list of all fan-in endpoints.
365 :rtype: list[hal_py.Endpoint]
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.
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]
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.
380 :param str pin_name: The input pin name.
381 :returns: The endpoint on success, None otherwise.
382 :rtype: hal_py.Endpoint or None
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.
388 :param hal_py.GatePin pin: The input pin.
389 :returns: The endpoint on success, None otherwise.
390 :rtype: hal_py.Endpoint or None
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.
396 :param hal_py.Net net: The input net.
397 :returns: The endpoint on success, None otherwise.
398 :rtype: hal_py.Endpoint or None
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.
404 :type: list[hal_py.Net]
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.
410 :returns: A list of all fan-out nets.
411 :rtype: list[hal_py.Net]
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.
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]
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.
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
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.
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
440 Check whether the given net is a fan-out of the gate.
442 :param hal_py.Net net: The net.
443 :returns: True if the net is a fan-out of the gate, False otherwise.
448 A list of all fan-out endpoints of the gate, i.e., all endpoints associated with an output pin of the gate.
450 :type: list[hal_py.Endpoint]
454 Get a list of all fan-out endpoints of the gate, i.e., all endpoints associated with an output pin of the gate.
456 :returns: A list of all fan-out endpoints.
457 :rtype: list[hal_py.Endpoint]
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.
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]
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.
472 :param str pin_name: The output pin name.
473 :returns: The endpoint on success, None otherwise.
474 :rtype: hal_py.Endpoint or None
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.
480 :param hal_py.GatePin pin: The output pin.
481 :returns: The endpoint on success, None otherwise.
482 :rtype: hal_py.Endpoint or None
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.
488 :param hal_py.Net net: The output net.
489 :returns: The endpoint on success, None otherwise.
490 :rtype: hal_py.Endpoint or None
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.
496 :type: list[hal_py.Gate]
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.
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]
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.
511 :type: list[hal_py.Endpoint]
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.
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]
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.
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
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.
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
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.
544 :type: list[hal_py.Gate]
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.
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]
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.
559 :type: list[hal_py.Endpoint]
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.
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]
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.
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
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.
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
591 [](
Gate&
self) -> std::vector<std::string> {
592 auto res =
self.get_init_data();
599 log_error(
"python_context",
"error encountered while getting INIT data:\n{}", res.get_error().get());
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.
607 :returns: The INIT data as a list on success, an empty list otherwise.
613 [](
Gate&
self,
const std::vector<std::string>& init_data) ->
bool {
614 auto res =
self.set_init_data(init_data);
621 log_error(
"python_context",
"error encountered while setting INIT data:\n{}", res.get_error().get());
625 py::arg(
"init_data"),
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.
630 :param list[str] init_data: The INIT data as a list.
631 :returns: True on success, False otherwise.
Net * get_fan_in_net(const std::string &pin_name) const
void set_location_y(i32 y)
i32 get_location_x() const
bool add_boolean_function(const std::string &name, const BooleanFunction &func)
BooleanFunction get_boolean_function(const std::string &name) const
bool is_fan_out_net(const Net *net) const
const std::vector< Net * > & get_fan_in_nets() const
bool is_fan_in_net(const Net *net) const
std::vector< Gate * > get_unique_successors(const std::function< bool(const GatePin *pin, Endpoint *ep)> &filter=nullptr) const
const std::vector< Endpoint * > & get_fan_out_endpoints() const
i32 get_location_y() const
GateType * get_type() const
std::pair< i32, i32 > get_location() const
std::vector< Endpoint * > get_predecessors(const std::function< bool(const GatePin *pin, Endpoint *ep)> &filter=nullptr) const
Net * get_fan_out_net(const std::string &pin_name) const
std::vector< Gate * > get_unique_predecessors(const std::function< bool(const GatePin *pin, Endpoint *ep)> &filter=nullptr) const
std::vector< Endpoint * > get_successors(const std::function< bool(const GatePin *pin, Endpoint *ep)> &filter=nullptr) const
const std::string & get_name() const
Grouping * get_grouping() const
Endpoint * get_predecessor(const std::string &pin_name) const
bool has_location() const
Endpoint * get_fan_in_endpoint(const std::string &pin_name) const
void set_location(const std::pair< i32, i32 > &location)
Module * get_module() const
Endpoint * get_successor(const std::string &pin_name) const
void set_name(const std::string &name)
std::vector< Module * > get_modules(const std::function< bool(Module *)> &filter=nullptr, bool recursive=true) const
const std::vector< Net * > & get_fan_out_nets() const
const std::vector< Endpoint * > & get_fan_in_endpoints() const
void set_location_x(i32 x)
Endpoint * get_fan_out_endpoint(const std::string &pin_name) const
std::unordered_map< std::string, BooleanFunction > get_boolean_functions(bool only_custom_functions=false) const
std::unique_ptr< T, py::nodelete > RawPtrWrapper
void gate_init(py::module &m)
#define log_error(channel,...)
const Module * module(const Gate *g, const NodeBoxes &boxes)