From c6fa1a179aa8c79d335ba03814ea71d871c87577 Mon Sep 17 00:00:00 2001 From: gatecat Date: Thu, 6 May 2021 12:25:32 +0100 Subject: [PATCH] nexus: Use new cluster API Signed-off-by: gatecat --- nexus/archdefs.h | 5 ++++- nexus/pack.cc | 20 ++++++++++++-------- nexus/post_place.cc | 5 +---- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/nexus/archdefs.h b/nexus/archdefs.h index b9ac3c77..660f166c 100644 --- a/nexus/archdefs.h +++ b/nexus/archdefs.h @@ -23,6 +23,7 @@ #include #include +#include "base_clusterinfo.h" #include "idstring.h" #include "nextpnr_namespaces.h" @@ -157,7 +158,9 @@ inline bool operator!=(const FFControlSet &a, const FFControlSet &b) (a.ce != b.ce); } -struct ArchCellInfo +typedef IdString ClusterId; + +struct ArchCellInfo : BaseClusterInfo { union { diff --git a/nexus/pack.cc b/nexus/pack.cc index ffec29bd..66ab4b09 100644 --- a/nexus/pack.cc +++ b/nexus/pack.cc @@ -1000,12 +1000,13 @@ struct NexusPacker // Setup relative constraints combs[0]->constr_z = 0; combs[0]->constr_abs_z = true; + combs[0]->cluster = combs[0]->name; for (int i = 1; i < 4; i++) { combs[i]->constr_x = 0; combs[i]->constr_y = 0; combs[i]->constr_z = ((i / 2) << 3) | (i % 2); combs[i]->constr_abs_z = true; - combs[i]->constr_parent = combs[0]; + combs[i]->cluster = combs[0]->name; combs[0]->constr_children.push_back(combs[i]); } @@ -1013,7 +1014,7 @@ struct NexusPacker ramw->constr_y = 0; ramw->constr_z = (2 << 3) | Arch::BEL_RAMW; ramw->constr_abs_z = true; - ramw->constr_parent = combs[0]; + ramw->cluster = combs[0]->name; combs[0]->constr_children.push_back(ramw); // Remove now-packed cell ctx->cells.erase(ci->name); @@ -1182,11 +1183,12 @@ struct NexusPacker combs[0]->params[id_INIT] = ctx->parse_lattice_param(ci, id_INIT0, 16, 0); combs[1]->params[id_INIT] = ctx->parse_lattice_param(ci, id_INIT1, 16, 0); - combs[1]->constr_parent = combs[0]; + combs[1]->cluster = combs[0]->name; combs[1]->constr_x = 0; combs[1]->constr_y = 0; combs[1]->constr_z = 1; combs[1]->constr_abs_z = false; + combs[0]->cluster = combs[0]->name; combs[0]->constr_children.push_back(combs[1]); ctx->cells.erase(ci->name); @@ -1253,10 +1255,11 @@ struct NexusPacker if (constr_base == nullptr) { // This is the very first cell in the chain constr_base = combs[i]; + constr_base->cluster = constr_base->name; } else { combs[i]->constr_x = (idx / 8); combs[i]->constr_y = 0; - combs[i]->constr_parent = constr_base; + combs[i]->cluster = constr_base->name; constr_base->constr_children.push_back(combs[i]); } @@ -1455,19 +1458,20 @@ struct NexusPacker CellInfo *cell = ctx->createCell(name, type); if (constr_base != nullptr) { // We might be constraining against an already-constrained cell - if (constr_base->constr_parent != nullptr) { + if (constr_base->cluster != ClusterId() && constr_base->cluster != constr_base->name) { cell->constr_x = dx + constr_base->constr_x; cell->constr_y = constr_base->constr_y; cell->constr_z = dz + constr_base->constr_z; cell->constr_abs_z = false; - cell->constr_parent = constr_base->constr_parent; - constr_base->constr_parent->constr_children.push_back(cell); + cell->cluster = constr_base->cluster; + ctx->cells.at(constr_base->cluster)->constr_children.push_back(cell); } else { cell->constr_x = dx; cell->constr_y = 0; cell->constr_z = dz; cell->constr_abs_z = false; - cell->constr_parent = constr_base; + cell->cluster = constr_base->name; + constr_base->cluster = constr_base->name; constr_base->constr_children.push_back(cell); } } diff --git a/nexus/post_place.cc b/nexus/post_place.cc index b712aea3..b6817b57 100644 --- a/nexus/post_place.cc +++ b/nexus/post_place.cc @@ -32,10 +32,7 @@ struct NexusPostPlaceOpt NexusPostPlaceOpt(Context *ctx) : ctx(ctx), tmg(ctx){}; - inline bool is_constrained(CellInfo *cell) - { - return cell->constr_parent != nullptr || !cell->constr_children.empty(); - } + inline bool is_constrained(CellInfo *cell) { return cell->cluster != ClusterId(); } bool swap_cell_placement(CellInfo *cell, BelId new_bel) {