aboutsummaryrefslogtreecommitdiffstats
path: root/json
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2019-06-02 16:46:07 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2019-06-02 16:46:07 +0200
commit1894cb549c368ccd5c932535852d6d9367136865 (patch)
tree69989401bf9acee9f97e737b0e6895f0badbd237 /json
parentd0273f7faa9f7d75350f421966a7d5cbb4ccc9ba (diff)
downloadnextpnr-1894cb549c368ccd5c932535852d6d9367136865.tar.gz
nextpnr-1894cb549c368ccd5c932535852d6d9367136865.tar.bz2
nextpnr-1894cb549c368ccd5c932535852d6d9367136865.zip
preserve constraints
Diffstat (limited to 'json')
-rw-r--r--json/jsonwrite.cc28
1 files changed, 26 insertions, 2 deletions
diff --git a/json/jsonwrite.cc b/json/jsonwrite.cc
index 8c1f914f..7143bf93 100644
--- a/json/jsonwrite.cc
+++ b/json/jsonwrite.cc
@@ -81,6 +81,30 @@ void write_routing(std::ostream &f, Context *ctx, NetInfo *net, bool first)
f << get_string(routing);
}
+void write_constraints(std::ostream &f, Context *ctx, CellInfo *cell, bool first)
+{
+ std::string constr;
+ constr += std::to_string(cell->constr_x) + ";";
+ constr += std::to_string(cell->constr_y) + ";";
+ constr += std::to_string(cell->constr_z) + ";";
+ constr += std::to_string(cell->constr_abs_z ? 1:0) + ";";
+ constr += cell->constr_parent!=nullptr ? cell->constr_parent->name.c_str(ctx) : "";
+ f << stringf("%s\n", first ? "" : ",");
+ f << stringf(" \"NEXTPNR_CONSTRAINT\": ");
+ f << get_string(constr);
+
+ constr = "";
+ for(auto &item : cell->constr_children)
+ {
+ if (!constr.empty()) constr += std::string(";");
+ constr += item->name.c_str(ctx);
+ }
+ f << stringf(",\n");
+ f << stringf(" \"NEXTPNR_CONSTR_CHILDREN\": ");
+ f << get_string(constr);
+
+}
+
void write_module(std::ostream &f, Context *ctx)
{
f << stringf(" %s: {\n", get_string("top").c_str());
@@ -109,7 +133,8 @@ void write_module(std::ostream &f, Context *ctx)
write_parameters(f, ctx, c->params);
f << stringf("\n },\n");
f << stringf(" \"attributes\": {");
- write_parameters(f, ctx, c->attrs);
+ bool first3 = write_parameters(f, ctx, c->attrs);
+ write_constraints(f, ctx, c.get(), first3);
f << stringf("\n },\n");
f << stringf(" \"port_directions\": {");
bool first2 = true;
@@ -123,7 +148,6 @@ void write_module(std::ostream &f, Context *ctx)
f << stringf("\n },\n");
f << stringf(" \"connections\": {");
first2 = true;
-
for (auto &conn : c->ports) {
auto &p = conn.second;
f << stringf("%s\n", first2 ? "" : ",");