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 filename: 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 divice_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 gate: The gate.
201 :type gate: hal_py.Gate
202 :returns: True on success, false otherwise.
207 Check whether the gate is registered in the netlist.
209 :param gate: The gate to check.
210 :type gate: hal_py.Gate
211 :returns: True if the gate is in the netlist, false otherwise.
216 Get the gate specified by the given ID.
218 :param int gate_id: The unique ID of the gate.
219 :returns: The gate on success, None otherwise.
220 :rtype: hal_py.Gate or None
223 py_netlist.def_property_readonly("gates", py::overload_cast<>(&
Netlist::get_gates, py::const_), R
"(
224 All gates contained within the netlist.
226 :type: list[hal_py.Gate]
230 Get all gates contained within the netlist.
232 :returns: A list of gates.
233 :rtype: list[hal_py.Gate]
236 py_netlist.def("get_gates", py::overload_cast<
const std::function<
bool(
const Gate*)>&>(&
Netlist::get_gates, py::const_), py::arg(
"filter"), R
"(
237 Get all gates contained within the netlist.
238 The filter is evaluated on every gate such that the result only contains gates matching the specified condition.
240 :param lambda filter: Filter function to be evaluated on each gate.
241 :returns: A list of gates.
242 :rtype: list[hal_py.Gate]
246 Mark a gate as global VCC gate.
248 :param hal_py.Gate gate: The gate.
249 :returns: True on success, false otherwise.
254 Mark a gate as global GND gate.
256 :param hal_py.Gate gate: The gate.
257 :returns: True on success, false otherwise.
262 Unmark a global VCC gate.
264 :param hal_py.Gate gate: The gate.
265 :returns: True on success, false otherwise.
270 Unmark a global GND gate.
272 :param hal_py.Gate gate: The gate.
273 :returns: True on success, false otherwise.
278 Check whether a gate is a global VCC gate.
280 :param gate: The gate to check.
281 :type gate: hal_py.Gate
282 :returns: True if the gate is a global VCC gate, false otherwise.
287 Check whether a gate is a global GND gate.
289 :param gate: The gate to check.
290 :type gate: hal_py.Gate
291 :returns: True if the gate is a global GND gate, false otherwise.
296 All global VCC gates.
298 :type: list[hal_py.Gate]
302 Get all global VCC gates.
304 :returns: A list of gates.
305 :rtype: list[hal_py.Gate]
309 All global GND gates.
311 :type: list[hal_py.Gate]
315 Get all global GND gates.
317 :returns: A list of gates.
318 :rtype: list[hal_py.Gate]
324 :type: list[hal_py.Net]
328 Get all global VCC nets.
330 :returns: A list of nets.
331 :rtype: list[hal_py.Net]
337 :type: list[hal_py.Net]
341 Get all global GND nets.
343 :returns: A list of nets.
344 :rtype: list[hal_py.Net]
349 The value of 0 is reserved and represents an invalid ID.
351 :returns: The net ID.
355 py_netlist.def("create_net", py::overload_cast<const u32, const std::string&>(&
Netlist::create_net), py::arg(
"net_id"), py::arg(
"name"), R
"(
356 Create a new net and add it to the netlist.
358 :param int net_id: The unique ID of the net.
359 :param str name: The name of the net.
360 :returns: The new net on success, None otherwise.
361 :rtype: hal_py.Net or None
364 py_netlist.def("create_net", py::overload_cast<const std::string&>(&
Netlist::create_net), py::arg(
"name"), R
"(
365 Create a new net and add it to the netlist.
366 The ID of the net is set automatically.
368 :param str name: The name of the net.
369 :returns: The new net on success, None otherwise.
370 :rtype: hal_py.Net or None
374 Removes a net from the netlist.
376 :param hal_py.Net net: The net.
377 :returns: True on success, false otherwise.
382 Check whether a net is registered in the netlist.
384 :param hal_py.Net net: The net to check.
385 :returns: True if the net is in the netlist, false otherwise.
390 Get the net specified by the given ID.
392 :param int net_id: The unique ID of the net.
393 :returns: The net on success, None otherwise.
394 :rtype: hal_py.Net or None
397 py_netlist.def_property_readonly("nets", py::overload_cast<>(&
Netlist::get_nets, py::const_), R
"(
398 All nets contained within the netlist.
400 :type: list[hal_py.Net]
403 py_netlist.def("get_nets", py::overload_cast<>(&
Netlist::get_nets, py::const_), R
"(
404 Get all nets contained within the netlist.
406 :returns: A list of nets.
407 :rtype: list[hal_py.Net]
410 py_netlist.def("get_nets", py::overload_cast<
const std::function<
bool(
const Net*)>&>(&
Netlist::get_nets, py::const_), py::arg(
"filter"), R
"(
411 Get all nets contained within the netlist.<br>
412 The filter is evaluated on every net such that the result only contains nets matching the specified condition.
414 :param lambda filter: Filter function to be evaluated on each net.
415 :returns: A list of nets.
416 :rtype: list[hal_py.Net]
420 Mark a net as a global input net.
422 :param hal_py.Net net: The net.
423 :returns: True on success, false otherwise.
428 Mark a net as a global output net.
430 :param hal_py.Net net: The net.
431 :returns: True on success, false otherwise.
436 Unmark a global input net.
438 :param hal_py.Net net: The net.
439 :returns: True on success, false otherwise.
444 Unmark a global output net.
446 :param hal_py.Net net: The net.
447 :returns: True on success, false otherwise.
452 Check whether a net is a global input net.
454 :param hal_py.Net net: The net to check.
455 :returns: True if the net is a global input net, false otherwise.
460 Check whether a net is a global output net.
462 :param hal_py.Net net: The net to check.
463 :returns: True if the net is a global output net, false otherwise.
468 All global input nets.
470 :type: list[hal_py.Net]
474 Get all global input nets.
476 :returns: A list of nets.
477 :rtype: list[hal_py.Net]
481 All global output nets.
483 :type: list[hal_py.Net]
487 Get all global output nets.
489 :returns: A list of nets.
490 :rtype: list[hal_py.Net]
494 Enables or disables automatic checks on nets that determine whether a net is an input or output of a module.
496 WARNING: if disabled, the user is responsible to assign correct input and output nets and create respective module pins. Wrong usage may result in unknown behavior or crashes.
498 :param bool enable_checks: Set True to enable automatic checks, False otherwise.
502 Get a spare module ID.
503 The value of 0 is reserved and represents an invalid ID.
505 :returns: The module ID.
509 py_netlist.def("create_module",
511 py::arg(
"module_id"),
514 py::arg(
"gates") = std::vector<Gate*>(),
516 Create a new module and add it to the netlist.
518 :param int module_id: The unique ID of the module.
519 :param str name: The name of the module.
520 :param hal_py.Module parent: The parent module.
521 :param list gates: Gates to assign to the new module.
522 :returns: The new module on succes, None on error.
523 :rtype: hal_py.Module or None
526 py_netlist.def("create_module",
530 py::arg(
"gates") = std::vector<Gate*>(),
532 Create a new module and add it to the netlist.
533 The ID of the module is set automatically.
535 :param str name: The name of the module.
536 :param hal_py.Module parent: The parent module.
537 :param list gates: Gates to assign to the new module.
538 :returns: The new module on succes, None on error.
539 :rtype: hal_py.Module or None
543 Remove a module from the netlist.
544 Submodules, gates and nets under this module will be moved to the parent of this module.
546 :param module: The module.
547 :type module: hal_py.Module
548 :returns: True on success, false otherwise.
553 Check whether a module is registered in the netlist.
555 :param hal_py.Module module: The module to check.
556 :returns: True if the module is in the netlist, false otherwise.
561 Get the module specified by the given ID.
563 :param int module_id: The unique ID of the module.
564 :returns: The module on success, None otherwise.
565 :rtype: hal_py.Module
568 py_netlist.def_property_readonly("modules", py::overload_cast<>(&
Netlist::get_modules, py::const_), R
"(
569 All modules contained within the netlist, including the top module.
571 :type: list[hal_py.Module]
575 Get all modules contained within the netlist, including the top module.
577 :returns: A list of modules.
578 :rtype: list[hal_py.Module]
581 py_netlist.def("get_modules", py::overload_cast<
const std::function<
bool(
const Module*)>&>(&
Netlist::get_modules, py::const_), py::arg(
"filter"), R
"(
582 Get all modules contained within the netlist, including the top module.
583 The filter is evaluated on every module such that the result only contains modules matching the specified condition.
585 :param lambda filter: Filter function to be evaluated on each module.
586 :returns: A list of modules.
587 :rtype: list[hal_py.Module]
591 The top module of the netlist.
597 Get the top module of the netlist.
599 :returns: The top module.
600 :rtype: hal_py.Module
604 Get a spare and unique grouping ID.
605 The value of 0 is reserved and represents an invalid ID.
607 :returns: The grouping ID.
611 py_netlist.def("create_grouping",
613 py::arg(
"grouping_id"),
616 Create a new grouping and add it to the netlist.
618 :param int grouping_id: The unique ID of the grouping.
619 :param str name: The name of the grouping.
620 :returns: The new grouping on success, None otherwise.
621 :rtype: hal_py.Grouping or None
624 py_netlist.def("create_grouping",
628 Create a new grouping and add it to the netlist.
629 The ID of the grouping is set automatically.
631 :param str name: The name of the grouping.
632 :returns: The new grouping on success, None otherwise.
633 :rtype: hal_py.Grouping or None
637 Remove a grouping from the netlist.
639 :param hal_py.Grouping grouping: The grouping.
640 :returns: True on success, false otherwise.
645 Check whether the grouping is registered in the netlist.
647 :param hal_py.Module grouping: The grouping to check.
648 :returns: True on success, false otherwise.
653 Get the grouping specified by the given ID.
655 :param int grouping_id: The unique ID of the grouping.
656 :returns: The grouping on success, nullptr otherwise.
657 :rtype: hal_py.Grouping
660 py_netlist.def_property_readonly("groupings", py::overload_cast<>(&
Netlist::get_groupings, py::const_), R
"(
661 All groupings contained within the netlist.
663 :type: list[hal_py.Grouping]
667 Get all groupings contained within the netlist.
669 :returns: A list of groupings.
670 :rtype: list[hal_py.Grouping]
673 py_netlist.def("get_groupings", py::overload_cast<
const std::function<
bool(
const Grouping*)>&>(&
Netlist::get_groupings, py::const_), py::arg(
"filter"), R
"(
674 Get all groupings contained within the netlist.
675 The filter is evaluated on every grouping such that the result only contains groupings matching the specified condition.
677 :param lambda filter: Filter function to be evaluated on each grouping.
678 :returns: A list of groupings.
679 :rtype: list[hal_py.Grouping]
683 Get the gate ID following the highest currently used ID.
685 :returns: The next gate ID.
690 Set the gate ID following the highest currently used ID.
692 :param int id: The next gate ID.
696 Get a set of all currently used gate IDs.
698 :returns: All used gate IDs.
703 Set a set of all currently used gate IDs.
705 :param set[int] ids: All used gate IDs.
709 Get a set of all gate IDs that have previously been used but been freed ever since.
711 :returns: All freed gate IDs.
716 Set a set of all gate IDs that have previously been used but been freed ever since.
718 :param set[int] ids: All freed gate IDs.
722 Get the net ID following the highest currently used ID.
724 :returns: The next net ID.
729 Set the net ID following the highest currently used ID.
731 :param int id: The next net ID.
735 Get a set of all currently used net IDs.
737 :returns: All used net IDs.
742 Set a set of all currently used net IDs.
744 :param set[int] ids: All used net IDs.
748 Get a set of all net IDs that have previously been used but been freed ever since.
750 :returns: All freed net IDs.
755 Set a set of all net IDs that have previously been used but been freed ever since.
757 :param set[int] ids: All freed net IDs.
761 Get the module ID following the highest currently used ID.
763 :returns: The next module ID.
768 Set the module ID following the highest currently used ID.
770 :param int id: The next module ID.
774 Get a set of all currently used module IDs.
776 :returns: All used module IDs.
781 Set a set of all currently used module IDs.
783 :param set[int] ids: All used module IDs.
787 Get a set of all module IDs that have previously been used but been freed ever since.
789 :returns: All freed module IDs.
794 Set a set of all module IDs that have previously been used but been freed ever since.
796 :param set[int] ids: All freed module IDs.
800 Get the grouping ID following the highest currently used ID.
802 :returns: The next grouping ID.
807 Set the grouping ID following the highest currently used ID.
809 :param int id: The next grouping ID.
813 Get a set of all currently used grouping IDs.
815 :returns: All used grouping IDs.
820 Set a set of all currently used grouping IDs.
822 :param set[int] ids: All used grouping IDs.
826 Get a set of all grouping IDs that have previously been used but been freed ever since.
828 :returns: All freed grouping IDs.
833 Set a set of all grouping IDs that have previously been used but been freed ever since.
835 :param set[int] ids: All freed grouping IDs.
839 "load_gate_locations_from_data", &
Netlist::load_gate_locations_from_data, py::arg(
"data_category") = std::string(), py::arg(
"data_identifiers") = std::pair<std::string, std::string>(), R
"(
840 Load the locations of the gates in the netlist from their associated data using the specified category and identifier.
841 If no parameter is given, the data is querried using the default category and identifier stored with the gate library.
843 :param str data_category: The data category.
844 :param tuple(str,str) data_identifiers: The data identifiers for the x- and y-coordinates.
845 :returns: True on success, False otherwise.
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)