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.
11 py_netlist.def(py::self == py::self, R"(
12 Check whether two netlists are equal.
13 Does not check netlist IDs.
15 :returns: ``True`` if both netlists are equal, ``False`` otherwise.
19 py_netlist.def(py::self != py::self, R"(
20 Check whether two netlists are unequal.
21 Does not check netlist IDs.
23 :returns: ``True`` if both netlists are unequal, ``False`` otherwise.
27 py_netlist.def(py::init<GateLibrary*>(), py::arg("gate_library"), R
"(
28 Construct a new netlist for the specified gate library.
30 Warning: Use the netlist_factory to create instances!
32 :param hal_py.GateLibrary gate_library: The gate library.
36 The ID of the netlist.
37 If not explicitly set, the ID defaults to 0.
43 Get the ID of the netlist.
44 If not explicitly set, the ID defaults to 0.
46 :returns: The ID of the netlist.
51 Set the ID of the netlist to the specified value.
53 :param int id: The new ID of the netlist.
57 The path to the input file.
63 Get the path to the input file.
65 :returns: The path to the input file.
70 Set the path to the input file.
72 :param pathlib.Path path: The path to the input file.
76 The name of the design.
82 Get the name of the design.
84 :returns: The name of the design.
89 Set the name of the design.
91 :param str design_name: The new name of the design.
95 The name of the target device.
101 Get the name of the target device.
103 :returns: The name of the target device.
108 Set the name of the target device.
110 :param str device_name: The name of the target device.
114 The gate library associated with the netlist.
116 :type: hal_py.GateLibrary
120 Get the gate library associated with the netlist.
122 :returns: The gate library.
123 :rtype: hal_py.GateLibrary
128 [](
Netlist* nl) -> std::shared_ptr<Netlist> {
129 auto res = nl->
copy();
132 return std::shared_ptr<Netlist>(res.get());
136 log_error(
"python_context",
"{}", res.get_error().get());
141 Create a deep copy of the netlist.
143 :returns: The copy of the netlist.
144 :rtype: hal_py.Netlist
148 Clear all internal caches of the netlist.
149 In a typical application, calling this function is not required.
154 The value of 0 is reserved and represents an invalid ID.
156 :returns: The gate ID.
160 py_netlist.def("create_gate",
163 py::arg(
"gate_type"),
168 Create a new gate and add it to the netlist.
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
179 py_netlist.def("create_gate",
181 py::arg(
"gate_type"),
186 Create a new gate and add it to the netlist.
187 The ID of the gate is set automatically.
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
198 Remove a gate from the netlist.
200 :param hal_py.Gate gate: The gate.
201 :returns: ``True`` on success, ``False`` otherwise.
206 Check whether the gate is registered in the netlist.
208 :param hal_py.Gate gate: The gate to check.
209 :returns: ``True`` if the gate is in the netlist, ``False`` otherwise.
214 Get the gate specified by the given ID.
216 :param int gate_id: The unique ID of the gate.
217 :returns: The gate on success, ``None`` otherwise.
218 :rtype: hal_py.Gate or None
221 py_netlist.def_property_readonly("gates", py::overload_cast<>(&
Netlist::get_gates, py::const_), R
"(
222 All gates contained within the netlist.
224 :type: list[hal_py.Gate]
228 Get all gates contained within the netlist.
230 :returns: A list of gates.
231 :rtype: list[hal_py.Gate]
234 py_netlist.def("get_gates", py::overload_cast<
const std::function<
bool(
const Gate*)>&>(&
Netlist::get_gates, py::const_), py::arg(
"filter"), R
"(
235 Get all gates contained within the netlist.
236 The filter is evaluated on every gate such that the result only contains gates matching the specified condition.
238 :param lambda filter: Filter function to be evaluated on each gate.
239 :returns: A list of gates.
240 :rtype: list[hal_py.Gate]
244 Mark a gate as a global VCC gate.
246 :param hal_py.Gate gate: The gate.
247 :returns: ``True`` on success, ``False`` otherwise.
252 Mark a gate as a global GND gate.
254 :param hal_py.Gate gate: The gate.
255 :returns: ``True`` on success, ``False`` otherwise.
260 Unmark a global VCC gate.
262 :param hal_py.Gate gate: The gate.
263 :returns: ``True`` on success, ``False`` otherwise.
268 Unmark a global GND gate.
270 :param hal_py.Gate gate: The gate.
271 :returns: ``True`` on success, ``False`` otherwise.
276 Check whether a gate is a global VCC gate.
278 :param hal_py.Gate gate: The gate to check.
279 :returns: ``True`` if the gate is a global VCC gate, ``False`` otherwise.
284 Check whether a gate is a global GND gate.
286 :param hal_py.Gate gate: The gate to check.
287 :returns: ``True`` if the gate is a global GND gate, ``False`` otherwise.
292 All global VCC gates.
294 :type: list[hal_py.Gate]
298 Get all global VCC gates.
300 :returns: A list of gates.
301 :rtype: list[hal_py.Gate]
305 All global GND gates.
307 :type: list[hal_py.Gate]
311 Get all global GND gates.
313 :returns: A list of gates.
314 :rtype: list[hal_py.Gate]
320 :type: list[hal_py.Net]
324 Get all global VCC nets.
326 :returns: A list of nets.
327 :rtype: list[hal_py.Net]
333 :type: list[hal_py.Net]
337 Get all GND nets in the netlist.
339 :returns: A list of nets.
340 :rtype: list[hal_py.Net]
345 The value of 0 is reserved and represents an invalid ID.
347 :returns: The net ID.
351 py_netlist.def("create_net", py::overload_cast<const u32, const std::string&>(&
Netlist::create_net), py::arg(
"net_id"), py::arg(
"name"), R
"(
352 Create a new net and add it to the netlist.
354 :param int net_id: The unique ID of the net.
355 :param str name: The name of the net.
356 :returns: The new net on success, ``None`` otherwise.
357 :rtype: hal_py.Net or None
360 py_netlist.def("create_net", py::overload_cast<const std::string&>(&
Netlist::create_net), py::arg(
"name"), R
"(
361 Create a new net and add it to the netlist.
362 The ID of the net is set automatically.
364 :param str name: The name of the net.
365 :returns: The new net on success, ``None`` otherwise.
366 :rtype: hal_py.Net or None
370 Remove a net from the netlist.
372 :param hal_py.Net net: The net.
373 :returns: ``True`` on success, ``False`` otherwise.
378 Check whether a net is registered in the netlist.
380 :param hal_py.Net net: The net to check.
381 :returns: ``True`` if the net is in the netlist, ``False`` otherwise.
386 Get the net specified by the given ID.
388 :param int net_id: The unique ID of the net.
389 :returns: The net on success, ``None`` otherwise.
390 :rtype: hal_py.Net or None
393 py_netlist.def_property_readonly("nets", py::overload_cast<>(&
Netlist::get_nets, py::const_), R
"(
394 All nets contained within the netlist.
396 :type: list[hal_py.Net]
399 py_netlist.def("get_nets", py::overload_cast<>(&
Netlist::get_nets, py::const_), R
"(
400 Get all nets contained within the netlist.
402 :returns: A list of nets.
403 :rtype: list[hal_py.Net]
406 py_netlist.def("get_nets", py::overload_cast<
const std::function<
bool(
const Net*)>&>(&
Netlist::get_nets, py::const_), py::arg(
"filter"), R
"(
407 Get all nets contained within the netlist.<br>
408 The filter is evaluated on every net such that the result only contains nets matching the specified condition.
410 :param lambda filter: Filter function to be evaluated on each net.
411 :returns: A list of nets.
412 :rtype: list[hal_py.Net]
416 Mark a net as a global input net.
418 :param hal_py.Net net: The net.
419 :returns: ``True`` on success, ``False`` otherwise.
424 Mark a net as a global output net.
426 :param hal_py.Net net: The net.
427 :returns: ``True`` on success, ``False`` otherwise.
432 Unmark a global input net.
434 :param hal_py.Net net: The net.
435 :returns: ``True`` on success, ``False`` otherwise.
440 Unmark a global output net.
442 :param hal_py.Net net: The net.
443 :returns: ``True`` on success, ``False`` otherwise.
448 Check whether a net is a global input net.
450 :param hal_py.Net net: The net to check.
451 :returns: ``True`` if the net is a global input net, ``False`` otherwise.
456 Check whether a net is a global output net.
458 :param hal_py.Net net: The net to check.
459 :returns: ``True`` if the net is a global output net, ``False`` otherwise.
464 All global input nets.
466 :type: list[hal_py.Net]
470 Get all global input nets.
472 :returns: A list of nets.
473 :rtype: list[hal_py.Net]
477 All global output nets.
479 :type: list[hal_py.Net]
483 Get all global output nets.
485 :returns: A list of nets.
486 :rtype: list[hal_py.Net]
490 Enables or disables automatic checks on nets that determine whether a net is an input or output of a module.
492 WARNING: if disabled, the user is responsible to assign correct input and output nets and create respective module pins. Wrong usage may result in unknown behavior or crashes.
494 :param bool enable_checks: Set ``True`` to enable automatic checks, ``False`` otherwise.
498 Get a spare module ID.
499 The value of 0 is reserved and represents an invalid ID.
501 :returns: The module ID.
505 py_netlist.def("create_module",
507 py::arg(
"module_id"),
510 py::arg(
"gates") = std::vector<Gate*>(),
512 Create a new module and add it to the netlist.
514 :param int module_id: The unique ID of the module.
515 :param str name: The name of the module.
516 :param hal_py.Module parent: The parent module.
517 :param list gates: Gates to assign to the new module.
518 :returns: The new module on success, ``None`` otherwise.
519 :rtype: hal_py.Module or None
522 py_netlist.def("create_module",
526 py::arg(
"gates") = std::vector<Gate*>(),
528 Create a new module and add it to the netlist.
529 The ID of the module is set automatically.
531 :param str name: The name of the module.
532 :param hal_py.Module parent: The parent module.
533 :param list gates: Gates to assign to the new module.
534 :returns: The new module on success, ``None`` otherwise.
535 :rtype: hal_py.Module or None
539 Remove a module from the netlist.
540 Submodules, gates and nets under this module will be moved to the parent of this module.
542 :param hal_py.Module module: The module.
543 :returns: ``True`` on success, ``False`` otherwise.
548 Check whether a module is registered in the netlist.
550 :param hal_py.Module module: The module to check.
551 :returns: ``True`` if the module is in the netlist, ``False`` otherwise.
556 Get the module specified by the given ID.
558 :param int module_id: The unique ID of the module.
559 :returns: The module on success, ``None`` otherwise.
560 :rtype: hal_py.Module
563 py_netlist.def_property_readonly("modules", py::overload_cast<>(&
Netlist::get_modules, py::const_), R
"(
564 All modules contained within the netlist, including the top module.
566 :type: list[hal_py.Module]
570 Get all modules contained within the netlist, including the top module.
572 :returns: A list of modules.
573 :rtype: list[hal_py.Module]
576 py_netlist.def("get_modules", py::overload_cast<
const std::function<
bool(
const Module*)>&>(&
Netlist::get_modules, py::const_), py::arg(
"filter"), R
"(
577 Get all modules contained within the netlist, including the top module.
578 The filter is evaluated on every module such that the result only contains modules matching the specified condition.
580 :param lambda filter: Filter function to be evaluated on each module.
581 :returns: A list of modules.
582 :rtype: list[hal_py.Module]
586 The top module of the netlist.
592 Get the top module of the netlist.
594 :returns: The top module.
595 :rtype: hal_py.Module
599 Get a spare and unique grouping ID.
600 The value of 0 is reserved and represents an invalid ID.
602 :returns: The grouping ID.
606 py_netlist.def("create_grouping",
608 py::arg(
"grouping_id"),
611 Create a new grouping and add it to the netlist.
613 :param int grouping_id: The unique ID of the grouping.
614 :param str name: The name of the grouping.
615 :returns: The new grouping on success, ``None`` otherwise.
616 :rtype: hal_py.Grouping or None
619 py_netlist.def("create_grouping",
623 Create a new grouping and add it to the netlist.
624 The ID of the grouping is set automatically.
626 :param str name: The name of the grouping.
627 :returns: The new grouping on success, ``None`` otherwise.
628 :rtype: hal_py.Grouping or None
632 Remove a grouping from the netlist.
634 :param hal_py.Grouping grouping: The grouping.
635 :returns: ``True`` on success, ``False`` otherwise.
640 Check whether the grouping is registered in the netlist.
642 :param hal_py.Module grouping: The grouping to check.
643 :returns: ``True`` on success, ``False`` otherwise.
648 Get the grouping specified by the given ID.
650 :param int grouping_id: The unique ID of the grouping.
651 :returns: The grouping on success, nullptr otherwise.
652 :rtype: hal_py.Grouping
655 py_netlist.def_property_readonly("groupings", py::overload_cast<>(&
Netlist::get_groupings, py::const_), R
"(
656 All groupings contained within the netlist.
658 :type: list[hal_py.Grouping]
662 Get all groupings contained within the netlist.
664 :returns: A list of groupings.
665 :rtype: list[hal_py.Grouping]
668 py_netlist.def("get_groupings", py::overload_cast<
const std::function<
bool(
const Grouping*)>&>(&
Netlist::get_groupings, py::const_), py::arg(
"filter"), R
"(
669 Get all groupings contained within the netlist.
670 The filter is evaluated on every grouping such that the result only contains groupings matching the specified condition.
672 :param lambda filter: Filter function to be evaluated on each grouping.
673 :returns: A list of groupings.
674 :rtype: list[hal_py.Grouping]
678 Get the gate ID following the highest currently used ID.
680 :returns: The next gate ID.
685 Set the gate ID following the highest currently used ID.
687 :param int id: The next gate ID.
691 Get a set of all currently used gate IDs.
693 :returns: All used gate IDs.
698 Set a set of all currently used gate IDs.
700 :param set[int] ids: All used gate IDs.
704 Get a set of all gate IDs that have previously been used but been freed ever since.
706 :returns: All freed gate IDs.
711 Set a set of all gate IDs that have previously been used but been freed ever since.
713 :param set[int] ids: All freed gate IDs.
717 Get the net ID following the highest currently used ID.
719 :returns: The next net ID.
724 Set the net ID following the highest currently used ID.
726 :param int id: The next net ID.
730 Get a set of all currently used net IDs.
732 :returns: All used net IDs.
737 Set a set of all currently used net IDs.
739 :param set[int] ids: All used net IDs.
743 Get a set of all net IDs that have previously been used but been freed ever since.
745 :returns: All freed net IDs.
750 Set a set of all net IDs that have previously been used but been freed ever since.
752 :param set[int] ids: All freed net IDs.
756 Get the module ID following the highest currently used ID.
758 :returns: The next module ID.
763 Set the module ID following the highest currently used ID.
765 :param int id: The next module ID.
769 Get a set of all currently used module IDs.
771 :returns: All used module IDs.
776 Set a set of all currently used module IDs.
778 :param set[int] ids: All used module IDs.
782 Get a set of all module IDs that have previously been used but been freed ever since.
784 :returns: All freed module IDs.
789 Set a set of all module IDs that have previously been used but been freed ever since.
791 :param set[int] ids: All freed module IDs.
795 Get the grouping ID following the highest currently used ID.
797 :returns: The next grouping ID.
802 Set the grouping ID following the highest currently used ID.
804 :param int id: The next grouping ID.
808 Get a set of all currently used grouping IDs.
810 :returns: All used grouping IDs.
815 Set a set of all currently used grouping IDs.
817 :param set[int] ids: All used grouping IDs.
821 Get a set of all grouping IDs that have previously been used but been freed ever since.
823 :returns: All freed grouping IDs.
828 Set a set of all grouping IDs that have previously been used but been freed ever since.
830 :param set[int] ids: All freed grouping IDs.
834 "load_gate_locations_from_data", &
Netlist::load_gate_locations_from_data, py::arg(
"data_category") = std::string(), py::arg(
"data_identifiers") = std::pair<std::string, std::string>(), R
"(
835 Load the locations of the gates in the netlist from their associated data using the specified category and identifier.
836 If no parameter is given, the data is querried using the default category and identifier stored with the gate library.
838 :param str data_category: The data category.
839 :param tuple(str,str) data_identifiers: The data identifiers for the x- and y-coordinates.
840 :returns: ``True`` on success, ``False`` otherwise.
void set_input_filename(const std::filesystem::path &path)
Module * get_top_module() const
const std::vector< Gate * > & get_gates() const
std::vector< Net * > get_vcc_nets() const
bool mark_vcc_gate(Gate *gate)
const std::vector< Net * > & get_global_input_nets() const
bool mark_gnd_gate(Gate *gate)
void set_used_gate_ids(const std::set< u32 > ids)
u32 get_unique_grouping_id()
void set_used_net_ids(const std::set< u32 > ids)
Grouping * create_grouping(const u32 grouping_id, const std::string &name="")
bool is_gate_in_netlist(const Gate *gate) const
Gate * get_gate_by_id(const u32 gate_id) const
bool is_module_in_netlist(const Module *module) const
bool delete_grouping(Grouping *grouping)
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 >())
void set_free_grouping_ids(const std::set< u32 > ids)
std::set< u32 > get_free_module_ids() const
u32 get_unique_module_id()
bool delete_net(Net *net)
bool is_gnd_gate(const Gate *gate) const
Net * create_net(const u32 net_id, const std::string &name)
std::vector< Net * > get_gnd_nets() const
const std::vector< Gate * > & get_gnd_gates() const
std::set< u32 > get_used_net_ids() const
void set_next_gate_id(const u32 id)
void set_free_module_ids(const std::set< u32 > ids)
void set_design_name(const std::string &name)
std::set< u32 > get_free_gate_ids() const
void enable_automatic_net_checks(bool enable_checks=true)
std::set< u32 > get_used_grouping_ids() const
bool delete_module(Module *module)
const std::vector< Gate * > & get_vcc_gates() const
bool unmark_gnd_gate(Gate *gate)
bool delete_gate(Gate *gate)
bool is_grouping_in_netlist(const Grouping *grouping) const
u32 get_next_net_id() const
u32 get_next_module_id() const
Result< std::unique_ptr< Netlist > > copy() const
const std::vector< Module * > & get_modules() const
void set_id(const u32 id)
std::set< u32 > get_used_gate_ids() const
bool unmark_vcc_gate(Gate *gate)
void set_free_net_ids(const std::set< u32 > ids)
const std::string & get_device_name() const
void set_next_module_id(const u32 id)
bool mark_global_input_net(Net *net)
bool is_net_in_netlist(const Net *net) const
std::set< u32 > get_used_module_ids() const
Module * get_module_by_id(u32 module_id) const
bool is_vcc_gate(const Gate *gate) const
Gate * create_gate(const u32 gate_id, GateType *gate_type, const std::string &name="", i32 x=-1, i32 y=-1)
void set_free_gate_ids(const std::set< u32 > ids)
bool mark_global_output_net(Net *net)
void set_next_grouping_id(const u32 id)
Net * get_net_by_id(u32 net_id) const
std::set< u32 > get_free_grouping_ids() const
void set_used_grouping_ids(const std::set< u32 > ids)
const std::string & get_design_name() const
const std::vector< Net * > & get_global_output_nets() const
const std::vector< Net * > & get_nets() const
bool unmark_global_output_net(Net *net)
void set_device_name(const std::string &name)
const std::vector< Grouping * > & get_groupings() const
bool is_global_input_net(const Net *net) const
void set_next_net_id(const u32 id)
void set_used_module_ids(const std::set< u32 > ids)
u32 get_next_grouping_id() const
u32 get_next_gate_id() const
std::filesystem::path get_input_filename() const
const GateLibrary * get_gate_library() const
Grouping * get_grouping_by_id(u32 grouping_id) const
std::set< u32 > get_free_net_ids() const
bool unmark_global_input_net(Net *net)
bool is_global_output_net(const Net *net) const
Module * create_module(const u32 module_id, const std::string &name, Module *parent, const std::vector< Gate * > &gates={})
std::unique_ptr< T, py::nodelete > RawPtrWrapper
void netlist_init(py::module &m)
#define log_error(channel,...)
const Module * module(const Gate *g, const NodeBoxes &boxes)