HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
python_bindings.cpp
Go to the documentation of this file.
2 
3 #include "verilator/verilator.h"
5 #include "pybind11/operators.h"
6 #include "pybind11/pybind11.h"
7 #include "pybind11/stl.h"
8 #include "pybind11/stl_bind.h"
9 
10 namespace py = pybind11;
11 
12 namespace hal
13 {
14  // the name in PYBIND11_MODULE/PYBIND11_PLUGIN *MUST* match the filename of the output library (without extension),
15  // otherwise you will get "ImportError: dynamic module does not define module export function" when importing the module
16 
17 #ifdef PYBIND11_MODULE
18  PYBIND11_MODULE(verilator, m)
19  {
20  m.doc() = "hal VerilatorSimulatorPlugin python bindings";
21 #else
22  PYBIND11_PLUGIN(verilator)
23  {
24  py::module m("verilator", "hal VerilatorSimulatorPlugin python bindings");
25 #endif // ifdef PYBIND11_MODULE
26 
27  py::class_<VerilatorSimulatorPlugin, RawPtrWrapper<VerilatorSimulatorPlugin>, BasePluginInterface>(m, "VerilatorSimulatorPlugin")
28  .def_property_readonly("name", &VerilatorSimulatorPlugin::get_name)
29  .def("get_name", &VerilatorSimulatorPlugin::get_name)
30  .def_property_readonly("version", &VerilatorSimulatorPlugin::get_version)
31  .def("get_version", &VerilatorSimulatorPlugin::get_version);
32 
33  auto py_verilator = m.def_submodule("VerilatorSimulator");
34  py_verilator.def("convert_gate_library_to_verilog", &verilator::converter::convert_gate_library_to_verilog);
35  // py_verilator.def("verify_counter", &verilator::verify_counter);
36 
37 #ifndef PYBIND11_MODULE
38  return m.ptr();
39 #endif // PYBIND11_MODULE
40  }
41 } // namespace hal
std::string get_name() const override
std::string get_version() const override
const Module * module(const Gate *g, const NodeBoxes &boxes)
bool convert_gate_library_to_verilog(const Netlist *nl, const std::filesystem::path verilator_sim_path, const std::filesystem::path model_path="")
Definition: converter.cpp:29
Definition: defines.h:45
PYBIND11_PLUGIN(hal_py)