Global design object working

Signed-off-by: David Shah <davey1576@gmail.com>
This commit is contained in:
David Shah 2018-06-07 12:57:52 +02:00
parent a5249da02d
commit b0e66d441c
4 changed files with 14 additions and 4 deletions

View File

@ -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)

View File

@ -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

View File

@ -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>>();

View File

@ -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))