HAL
netlist_serializer.cpp
Go to the documentation of this file.
2 
3 namespace hal
4 {
6  {
7  auto py_netlist_serializer = m.def_submodule("NetlistSerializer", R"(
8  HAL Netlist Serializer functions.
9  )");
10 
11  py_netlist_serializer.def("serialize_to_file", netlist_serializer::serialize_to_file, py::arg("netlist"), py::arg("hal_file"), R"(
12  Serializes a netlist into a ``.hal`` file.
13 
14  :param hal_py.Netlist netlist: The netlist to serialize.
15  :param pathlib.Path hal_file: The path to the ``.hal`` file.
16  :returns: ``True`` on success, ``False`` otherwise.
17  :rtype: bool
18  )");
19 
20  py_netlist_serializer.def(
21  "deserialize_from_file",
22  [](const std::filesystem::path& hal_file, GateLibrary* gate_lib = nullptr) { return std::shared_ptr<Netlist>(netlist_serializer::deserialize_from_file(hal_file, gate_lib)); },
23  py::arg("hal_file"),
24  py::arg("gate_lib") = nullptr,
25  R"(
26  Deserializes a netlist from a ``.hal`` file using the provided gate library.
27  If no gate library is provided, a gate library path must be specified within the ``.hal`` file.
28 
29  :param pathlib.Path hal_file: The path to the ``.hal`` file.
30  :param hal_py.GateLibrary gate_lib: The gate library. Defaults to ``None``.
31  :returns: The deserialized netlist on success, ``None`` otherwise.
32  :rtype: hal_py.Netlist or None
33  )");
34 
35  py_netlist_serializer.def(
36  "deserialize_from_string",
37  [](const std::string& hal_string, GateLibrary* gate_lib = nullptr) { return std::shared_ptr<Netlist>(netlist_serializer::deserialize_from_string(hal_string, gate_lib)); },
38  py::arg("hal_string"),
39  py::arg("gate_lib") = nullptr,
40  R"(
41  Deserializes a string which contains a netlist in HAL-(JSON)-format using the provided gate library.
42  If no gate library is provided, a gate library path must be specified within the ``.hal`` file.
43 
44  :param pathlib.Path hal_file: The string containing the netlist in HAL-(JSON)-format.
45  :param hal_py.GateLibrary gate_lib: The gate library. Defaults to ``None``.
46  :returns: The deserialized netlist on success, ``None`` otherwise.
47  :rtype: hal_py.Netlist or None
48  )");
49  }
50 } // namespace hal
void netlist_serializer_init(py::module &m)
const Module * module(const Gate *g, const NodeBoxes &boxes)
bool serialize_to_file(const Netlist *nl, const std::filesystem::path &hal_file)
std::unique_ptr< Netlist > deserialize_from_string(const std::string &hal_string, GateLibrary *gatelib)
std::unique_ptr< Netlist > deserialize_from_file(const std::filesystem::path &hal_file, GateLibrary *gatelib)