From 0ea7f153a1f14ac6af079b5660afe1981e5f8b51 Mon Sep 17 00:00:00 2001 From: David Shah Date: Sun, 1 Dec 2019 14:18:33 +0000 Subject: Allow constraining non-leaf cells to regions Signed-off-by: David Shah --- common/nextpnr.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/common/nextpnr.cc b/common/nextpnr.cc index a6345b42..1156490c 100644 --- a/common/nextpnr.cc +++ b/common/nextpnr.cc @@ -523,7 +523,16 @@ void BaseCtx::createRectangularRegion(IdString name, int x0, int y0, int x1, int void BaseCtx::addBelToRegion(IdString name, BelId bel) { region[name]->bels.insert(bel); } void BaseCtx::constrainCellToRegion(IdString cell, IdString region_name) { - cells[cell]->region = region[region_name].get(); + // Support hierarchical cells as well as leaf ones + if (hierarchy.count(cell)) { + auto &hc = hierarchy.at(cell); + for (auto &lc : hc.leaf_cells) + constrainCellToRegion(lc.second, region_name); + for (auto &hsc : hc.hier_cells) + constrainCellToRegion(hsc.second, region_name); + } + if (cells.count(cell)) + cells.at(cell)->region = region[region_name].get(); } DecalXY BaseCtx::constructDecalXY(DecalId decal, float x, float y) { -- cgit v1.2.3