diff options
author | David Shah <davey1576@gmail.com> | 2018-06-07 11:41:54 +0200 |
---|---|---|
committer | David Shah <davey1576@gmail.com> | 2018-06-07 11:41:54 +0200 |
commit | e576f71838290ff12b98145fb02af84563fc03c1 (patch) | |
tree | 023a1ac5e0ccacb2257f79f1109ea485818f13eb /common/pybindings.cc | |
parent | 3769b2058019ce7c6be824085e1047e1beec07dc (diff) | |
download | nextpnr-e576f71838290ff12b98145fb02af84563fc03c1.tar.gz nextpnr-e576f71838290ff12b98145fb02af84563fc03c1.tar.bz2 nextpnr-e576f71838290ff12b98145fb02af84563fc03c1.zip |
Developing Python bindings for Design and related types
Diffstat (limited to 'common/pybindings.cc')
-rw-r--r-- | common/pybindings.cc | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/common/pybindings.cc b/common/pybindings.cc index 7a542dc1..04b2fa27 100644 --- a/common/pybindings.cc +++ b/common/pybindings.cc @@ -36,7 +36,54 @@ // 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>>()); + + 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); + + class_<Design>("Design", no_init) + .def_readwrite("chip", &Design::chip) + .def_readwrite("nets", &Design::nets) + .def_readwrite("cells", &Design::cells); arch_wrap_python(); } |