aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Shah <davey1576@gmail.com>2018-06-07 12:57:52 +0200
committerDavid Shah <davey1576@gmail.com>2018-06-07 12:57:52 +0200
commitb0e66d441cf584e7e48049d4f07afcc8e743309a (patch)
treeb74e2ff57532f59fac5bd5246b6312d3f8ec739d
parenta5249da02d2a55d4b838dd8c29e159513dd71418 (diff)
downloadnextpnr-b0e66d441cf584e7e48049d4f07afcc8e743309a.tar.gz
nextpnr-b0e66d441cf584e7e48049d4f07afcc8e743309a.tar.bz2
nextpnr-b0e66d441cf584e7e48049d4f07afcc8e743309a.zip
Global design object working
Signed-off-by: David Shah <davey1576@gmail.com>
-rw-r--r--common/pybindings.cc6
-rw-r--r--common/pybindings.h2
-rw-r--r--ice40/main.cc2
-rw-r--r--python/dump_design.py8
4 files changed, 14 insertions, 4 deletions
diff --git a/common/pybindings.cc b/common/pybindings.cc
index 4ae83cb0..a051eea6 100644
--- a/common/pybindings.cc
+++ b/common/pybindings.cc
@@ -66,6 +66,12 @@ BOOST_PYTHON_MODULE (MODULE_NAME) {
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)
diff --git a/common/pybindings.h b/common/pybindings.h
index 44898198..a99ad51b 100644
--- a/common/pybindings.h
+++ b/common/pybindings.h
@@ -94,7 +94,7 @@ void python_export_global(const char *name, Tn &x) {
return;
d = PyModule_GetDict(m);
try {
- PyObject * p = object(boost::ref(x)).ptr();
+ PyObject * p = incref(object(boost::ref(x)).ptr());
PyDict_SetItemString(d, name, p);
} catch (boost::python::error_already_set const &) {
// Parse and output the exception
diff --git a/ice40/main.cc b/ice40/main.cc
index 12c6b86c..88ef4155 100644
--- a/ice40/main.cc
+++ b/ice40/main.cc
@@ -205,7 +205,7 @@ int main(int argc, char *argv[])
parse_json_file(f, filename, &design);
}
-
+
if (vm.count("file"))
{
std::vector<std::string> files = vm["file"].as<std::vector<std::string>>();
diff --git a/python/dump_design.py b/python/dump_design.py
index 9d8ade3e..b8436288 100644
--- a/python/dump_design.py
+++ b/python/dump_design.py
@@ -1,2 +1,6 @@
-for cell in design.cells:
- print(cell.first)
+# Run ./nextpnr-ice40 --json ice40/blinky.json --file python/dump_design.py
+for cell in sorted(design.cells, key=lambda x: x.first):
+ print("Cell {} : {}".format(cell.first, cell.second.type))
+ for port in sorted(cell.second.ports, key=lambda x: x.first):
+ dir = (" <-- ", " --> ", " <-> ")[int(port.second.type)]
+ print(" {} {} {}".format(port.first, dir, port.second.net.name))