HAL
gate_library.cpp
Go to the documentation of this file.
2 
3 namespace hal
4 {
6  {
7  py::class_<GateLibrary, RawPtrWrapper<GateLibrary>> py_gate_library(m, "GateLibrary", R"(
8  A gate library is a collection of gate types including their pins and Boolean functions.
9  )");
10 
11  py_gate_library.def(py::init<const std::filesystem::path&, const std::string&>(), py::arg("path"), py::arg("name"), R"(
12  Construct a gate library by specifying its name and the path to the file that describes the library.
13 
14  :param pathlib.Path path: The path to the gate library file.
15  :param str name: The name of the gate library.
16  )");
17 
18  py_gate_library.def_property_readonly("name", &GateLibrary::get_name, R"(
19  The name of the gate library.
20 
21  :type: str
22  )");
23 
24  py_gate_library.def("get_name", &GateLibrary::get_name, R"(
25  Get the name of the gate library.
26 
27  :returns: The name of the gate library.
28  :rtype: str
29  )");
30 
31  py_gate_library.def_property_readonly("path", &GateLibrary::get_name, R"(
32  The path to the file describing the gate library.
33 
34  :type: pathlib.Path
35  )");
36 
37  py_gate_library.def("get_path", &GateLibrary::get_name, R"(
38  Get the path to the file describing the gate library.
39 
40  :returns: The path to the gate library file.
41  :rtype: pathlib.Path
42  )");
43 
44  py_gate_library.def("set_gate_location_data_category", &GateLibrary::set_gate_location_data_category, py::arg("category"), R"(
45  Set the data category of the gate location information.
46 
47  :param str category: The data category.
48  )");
49 
50  py_gate_library.def("get_gate_location_data_category", &GateLibrary::get_gate_location_data_category, R"(
51  Get the data category of the gate location information.
52 
53  :returns: The data category.
54  :rtype: str
55  )");
56 
57  py_gate_library.def("set_gate_location_data_identifiers", &GateLibrary::set_gate_location_data_identifiers, py::arg("x_coordinate"), py::arg("y_coordinate"), R"(
58  Set the data identifiers of the gate location information for both the x- and y-coordinates.
59 
60  :param str x_coordinate: The data identifier for the x-coordinate.
61  :param str y_coordinate: The data identifier for the y-coordinate.
62  )");
63 
64  py_gate_library.def("get_gate_location_data_category", &GateLibrary::get_gate_location_data_category, R"(
65  Get the data identifiers of the gate location information for both the x- and y-coordinates.
66 
67  :returns: A pair of data identifiers.
68  :rtype: tuple(str,str)
69  )");
70 
71  // py_gate_library.def("create_gate_type", &GateLibrary::create_gate_type, py::arg("name"), py::arg("properties") = std::set<GateTypeProperty>(), R"(
72  // Create a new gate type, add it to the gate library, and return it.
73 
74  // :param str name: The name of the gate type.
75  // :param set[hal_py.GateTypeProperty] properties: The properties of the gate type.
76  // :returns: The new gate type instance on success, None otherwise.
77  // :rtype: hal_py.GateType
78  // )");
79 
80  py_gate_library.def("contains_gate_type", &GateLibrary::contains_gate_type, py::arg("gate_type"), R"(
81  Check whether the given gate type is contained in this library.
82 
83  :param hal_py.GateType gate_type: The gate type.
84  :returns: True if the gate type is part of this library, false otherwise.
85  :rtype: bool
86  )");
87 
88  py_gate_library.def("contains_gate_type_by_name", &GateLibrary::contains_gate_type_by_name, py::arg("name"), R"(
89  Check by name whether the given gate type is contained in this library.
90 
91  :param str name: The name of the gate type.
92  :returns: True if the gate type is part of this library, false otherwise.
93  :rtype: bool
94  )");
95 
96  py_gate_library.def("get_gate_type_by_name", &GateLibrary::get_gate_type_by_name, py::arg("name"), R"(
97  Get the gate type corresponding to the given name if contained within the library. In case there is no gate type with that name, None is returned.
98 
99  :param str name: The name of the gate type.
100  :returns: The gate type on success, None otherwise.
101  :rtype: hal_py.GateType or None
102  )");
103 
104  py_gate_library.def_property_readonly("gate_types", [](const GateLibrary& self) { return self.get_gate_types(); }, R"(
105  All gate types of the gate library as as dict from gate type names to gate types.
106 
107  :type: dict[str,hal_py.GateType]
108  )");
109 
110  py_gate_library.def("get_gate_types", &GateLibrary::get_gate_types, py::arg("filter") = nullptr, R"(
111  Get all gate types of the library.
112  In case a filter is applied, only the gate types matching the filter condition are returned.
113 
114  :param lambda filter: The user-defined filter function.
115  :returns: A dict from gate type names to gate types.
116  :rtype: dict[str,hal_py.GateType]
117  )");
118 
119  py_gate_library.def("mark_vcc_gate_type", &GateLibrary::mark_vcc_gate_type, py::arg("gate_type"), R"(
120  Mark a gate type as a VCC gate type.
121 
122  :param hal_py.GateType gate_type: The gate type.
123  :returns: True on success, false otherwise.
124  :rtype: bool
125  )");
126 
127  py_gate_library.def_property_readonly("vcc_gate_types", &GateLibrary::get_vcc_gate_types, R"(
128  All VCC gate types of the gate library as as dict from gate type names to gate types.
129 
130  :type: dict[str,hal_py.GateType]
131  )");
132 
133  py_gate_library.def("get_vcc_gate_types", &GateLibrary::get_vcc_gate_types, R"(
134  Get all VCC gate types of the library.
135 
136  :returns: A dict from VCC gate type names to gate type objects.
137  :rtype: dict[str,hal_py.GateType]
138  )");
139 
140  py_gate_library.def("mark_gnd_gate_type", &GateLibrary::mark_gnd_gate_type, py::arg("gate_type"), R"(
141  Mark a gate type as a GND gate type.
142 
143  :param hal_py.GateType gate_type: The gate type.
144  :returns: True on success, false otherwise.
145  :rtype: bool
146  )");
147 
148  py_gate_library.def_property_readonly("gnd_gate_types", &GateLibrary::get_vcc_gate_types, R"(
149  All GND gate types of the gate library as as dict from gate type names to gate types.
150 
151  :type: dict[str,hal_py.GateType]
152  )");
153 
154  py_gate_library.def("get_gnd_gate_types", &GateLibrary::get_gnd_gate_types, R"(
155  Get all GND gate types of the library.
156 
157  :returns: A dict from GND gate type names to gate type objects.
158  :rtype: dict[str,hal_py.GateType]
159  )");
160 
161  py_gate_library.def("add_include", &GateLibrary::add_include, py::arg("include"), R"(
162  Add an include required for parsing a corresponding netlist, e.g., VHDL libraries.
163 
164  :param str inc: The include to add.
165  )");
166 
167  py_gate_library.def_property_readonly("includes", &GateLibrary::get_includes, R"(
168  A list of includes required for parsing a corresponding netlist, e.g., VHDL libraries.
169 
170  :type: list[str]
171  )");
172 
173  py_gate_library.def("get_includes", &GateLibrary::get_includes, R"(
174  Get a list of includes required for parsing a corresponding netlist, e.g., VHDL libraries.
175 
176  :returns: A list of includes.
177  :rtype: list[str]
178  )");
179  }
180 } // namespace hal
bool contains_gate_type_by_name(const std::string &name) const
bool mark_vcc_gate_type(GateType *gate_type)
std::unordered_map< std::string, GateType * > get_gate_types(const std::function< bool(const GateType *)> &filter=nullptr) const
std::unordered_map< std::string, GateType * > get_vcc_gate_types() const
GateType * get_gate_type_by_name(const std::string &name) const
void set_gate_location_data_category(const std::string &category)
bool mark_gnd_gate_type(GateType *gate_type)
bool contains_gate_type(GateType *gate_type) const
void add_include(const std::string &inc)
std::vector< std::string > get_includes() const
void set_gate_location_data_identifiers(const std::string &x_coordinate, const std::string &y_coordinate)
std::unordered_map< std::string, GateType * > get_gnd_gate_types() const
std::string get_name() const
const std::string & get_gate_location_data_category() const
void gate_library_init(py::module &m)
Definition: gate_library.cpp:5
const Module * module(const Gate *g, const NodeBoxes &boxes)