nexus: Use new cluster API

Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
gatecat 2021-05-06 12:25:32 +01:00
parent 1bf202adcd
commit c6fa1a179a
3 changed files with 17 additions and 13 deletions

View File

@ -23,6 +23,7 @@
#include <boost/functional/hash.hpp> #include <boost/functional/hash.hpp>
#include <unordered_map> #include <unordered_map>
#include "base_clusterinfo.h"
#include "idstring.h" #include "idstring.h"
#include "nextpnr_namespaces.h" #include "nextpnr_namespaces.h"
@ -157,7 +158,9 @@ inline bool operator!=(const FFControlSet &a, const FFControlSet &b)
(a.ce != b.ce); (a.ce != b.ce);
} }
struct ArchCellInfo typedef IdString ClusterId;
struct ArchCellInfo : BaseClusterInfo
{ {
union union
{ {

View File

@ -1000,12 +1000,13 @@ struct NexusPacker
// Setup relative constraints // Setup relative constraints
combs[0]->constr_z = 0; combs[0]->constr_z = 0;
combs[0]->constr_abs_z = true; combs[0]->constr_abs_z = true;
combs[0]->cluster = combs[0]->name;
for (int i = 1; i < 4; i++) { for (int i = 1; i < 4; i++) {
combs[i]->constr_x = 0; combs[i]->constr_x = 0;
combs[i]->constr_y = 0; combs[i]->constr_y = 0;
combs[i]->constr_z = ((i / 2) << 3) | (i % 2); combs[i]->constr_z = ((i / 2) << 3) | (i % 2);
combs[i]->constr_abs_z = true; 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]); combs[0]->constr_children.push_back(combs[i]);
} }
@ -1013,7 +1014,7 @@ struct NexusPacker
ramw->constr_y = 0; ramw->constr_y = 0;
ramw->constr_z = (2 << 3) | Arch::BEL_RAMW; ramw->constr_z = (2 << 3) | Arch::BEL_RAMW;
ramw->constr_abs_z = true; ramw->constr_abs_z = true;
ramw->constr_parent = combs[0]; ramw->cluster = combs[0]->name;
combs[0]->constr_children.push_back(ramw); combs[0]->constr_children.push_back(ramw);
// Remove now-packed cell // Remove now-packed cell
ctx->cells.erase(ci->name); 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[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]->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_x = 0;
combs[1]->constr_y = 0; combs[1]->constr_y = 0;
combs[1]->constr_z = 1; combs[1]->constr_z = 1;
combs[1]->constr_abs_z = false; combs[1]->constr_abs_z = false;
combs[0]->cluster = combs[0]->name;
combs[0]->constr_children.push_back(combs[1]); combs[0]->constr_children.push_back(combs[1]);
ctx->cells.erase(ci->name); ctx->cells.erase(ci->name);
@ -1253,10 +1255,11 @@ struct NexusPacker
if (constr_base == nullptr) { if (constr_base == nullptr) {
// This is the very first cell in the chain // This is the very first cell in the chain
constr_base = combs[i]; constr_base = combs[i];
constr_base->cluster = constr_base->name;
} else { } else {
combs[i]->constr_x = (idx / 8); combs[i]->constr_x = (idx / 8);
combs[i]->constr_y = 0; 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]); constr_base->constr_children.push_back(combs[i]);
} }
@ -1455,19 +1458,20 @@ struct NexusPacker
CellInfo *cell = ctx->createCell(name, type); CellInfo *cell = ctx->createCell(name, type);
if (constr_base != nullptr) { if (constr_base != nullptr) {
// We might be constraining against an already-constrained cell // 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_x = dx + constr_base->constr_x;
cell->constr_y = constr_base->constr_y; cell->constr_y = constr_base->constr_y;
cell->constr_z = dz + constr_base->constr_z; cell->constr_z = dz + constr_base->constr_z;
cell->constr_abs_z = false; cell->constr_abs_z = false;
cell->constr_parent = constr_base->constr_parent; cell->cluster = constr_base->cluster;
constr_base->constr_parent->constr_children.push_back(cell); ctx->cells.at(constr_base->cluster)->constr_children.push_back(cell);
} else { } else {
cell->constr_x = dx; cell->constr_x = dx;
cell->constr_y = 0; cell->constr_y = 0;
cell->constr_z = dz; cell->constr_z = dz;
cell->constr_abs_z = false; 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); constr_base->constr_children.push_back(cell);
} }
} }

View File

@ -32,10 +32,7 @@ struct NexusPostPlaceOpt
NexusPostPlaceOpt(Context *ctx) : ctx(ctx), tmg(ctx){}; NexusPostPlaceOpt(Context *ctx) : ctx(ctx), tmg(ctx){};
inline bool is_constrained(CellInfo *cell) inline bool is_constrained(CellInfo *cell) { return cell->cluster != ClusterId(); }
{
return cell->constr_parent != nullptr || !cell->constr_children.empty();
}
bool swap_cell_placement(CellInfo *cell, BelId new_bel) bool swap_cell_placement(CellInfo *cell, BelId new_bel)
{ {