aboutsummaryrefslogtreecommitdiffstats
path: root/ecp5/globals.cc
diff options
context:
space:
mode:
authorDavid Shah <davey1576@gmail.com>2018-10-17 11:14:27 +0100
committerGitHub <noreply@github.com>2018-10-17 11:14:27 +0100
commitb53a4862db99e41f16c06425f314a1a398a21985 (patch)
treedbe277f6d9487eab64715e4c14ce9be230820c38 /ecp5/globals.cc
parent529a595157a2eef24f8529b0de0c504a40ed503b (diff)
parent1cde2080902c25d2a59e8ebb5b0b23a90f693e8e (diff)
downloadnextpnr-b53a4862db99e41f16c06425f314a1a398a21985.tar.gz
nextpnr-b53a4862db99e41f16c06425f314a1a398a21985.tar.bz2
nextpnr-b53a4862db99e41f16c06425f314a1a398a21985.zip
Merge pull request #89 from YosysHQ/ecp5_bram
ECP5 BRAM support
Diffstat (limited to 'ecp5/globals.cc')
-rw-r--r--ecp5/globals.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/ecp5/globals.cc b/ecp5/globals.cc
index 364e4bca..5e5a2a01 100644
--- a/ecp5/globals.cc
+++ b/ecp5/globals.cc
@@ -24,7 +24,7 @@
#include "cells.h"
#include "log.h"
#include "nextpnr.h"
-
+#include "place_common.h"
#define fmt_str(x) (static_cast<const std::ostringstream &>(std::ostringstream() << x).str())
NEXTPNR_NAMESPACE_BEGIN
@@ -260,15 +260,24 @@ class Ecp5GlobalRouter
// Attempt to place a DCC
void place_dcc(CellInfo *dcc)
{
+ BelId best_bel;
+ wirelen_t best_wirelen = 9999999;
for (auto bel : ctx->getBels()) {
if (ctx->getBelType(bel) == id_DCCA && ctx->checkBelAvail(bel)) {
if (ctx->isValidBelForCell(dcc, bel)) {
ctx->bindBel(bel, dcc, STRENGTH_LOCKED);
- return;
+ float tns;
+ wirelen_t wirelen = get_net_metric(ctx, dcc->ports.at(id_CLKI).net, MetricType::WIRELENGTH, tns);
+ if (wirelen < best_wirelen) {
+ best_bel = bel;
+ best_wirelen = wirelen;
+ }
+ ctx->unbindBel(bel);
}
}
}
- NPNR_ASSERT_FALSE("failed to place dcca");
+ NPNR_ASSERT(best_bel != BelId());
+ ctx->bindBel(best_bel, dcc, STRENGTH_LOCKED);
}
// Insert a DCC into a net to promote it to a global