diff options
Diffstat (limited to 'common/pybindings.cc')
-rw-r--r-- | common/pybindings.cc | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/common/pybindings.cc b/common/pybindings.cc index 10c8fd44..c3818cad 100644 --- a/common/pybindings.cc +++ b/common/pybindings.cc @@ -38,7 +38,67 @@ // architectures void arch_wrap_python(); +bool operator==(const PortRef &a, const PortRef &b) { + return (a.cell == b.cell) && (a.port == b.port); +} + BOOST_PYTHON_MODULE (MODULE_NAME) { + class_<GraphicElement>("GraphicElement") + .def_readwrite("style", &GraphicElement::style) + .def_readwrite("type", &GraphicElement::type) + .def_readwrite("x1", &GraphicElement::x1) + .def_readwrite("y1", &GraphicElement::y1) + .def_readwrite("x2", &GraphicElement::x2) + .def_readwrite("y2", &GraphicElement::y2) + .def_readwrite("text", &GraphicElement::text); + + class_<PortRef>("PortRef") + .def_readwrite("cell", &PortRef::cell) + .def_readwrite("port", &PortRef::port); + + class_<NetInfo, NetInfo*>("NetInfo") + .def_readwrite("name", &NetInfo::name) + .def_readwrite("driver", &NetInfo::driver) + .def_readwrite("users", &NetInfo::users) + .def_readwrite("attrs", &NetInfo::attrs) + .def_readwrite("wires", &NetInfo::wires); + + WRAP_MAP(decltype(NetInfo::attrs), "IdStrMap"); + + class_<vector<PortRef>>("PortRefVector") + .def(vector_indexing_suite<vector<PortRef>>()); + + enum_<PortType>("PortType") + .value("PORT_IN", PORT_IN) + .value("PORT_OUT", PORT_OUT) + .value("PORT_INOUT", PORT_INOUT) + .export_values(); + + class_<PortInfo>("PortInfo") + .def_readwrite("name", &PortInfo::name) + .def_readwrite("net", &PortInfo::net) + .def_readwrite("type", &PortInfo::type); + + class_<CellInfo, CellInfo*>("CellInfo") + .def_readwrite("name", &CellInfo::name) + .def_readwrite("type", &CellInfo::type) + .def_readwrite("ports", &CellInfo::ports) + .def_readwrite("attrs", &CellInfo::attrs) + .def_readwrite("params", &CellInfo::params) + .def_readwrite("bel", &CellInfo::bel) + .def_readwrite("pins", &CellInfo::pins); + + WRAP_MAP(decltype(CellInfo::ports), "IdPortMap"); + //WRAP_MAP(decltype(CellInfo::pins), "IdIdMap"); + + class_<Design, Design*>("Design", no_init) + .def_readwrite("chip", &Design::chip) + .def_readwrite("nets", &Design::nets) + .def_readwrite("cells", &Design::cells); + + WRAP_MAP(decltype(Design::nets), "IdNetMap"); + WRAP_MAP(decltype(Design::cells), "IdCellMap"); + arch_wrap_python(); } @@ -59,6 +119,7 @@ void init_python(const char *executable) { emb::append_inittab(); Py_SetProgramName(program); Py_Initialize(); + PyImport_ImportModule(TOSTRING(MODULE_NAME)); } catch (boost::python::error_already_set const &) { // Parse and output the exception std::string perror_str = parse_python_exception(); |