aboutsummaryrefslogtreecommitdiffstats
path: root/ecp5
diff options
context:
space:
mode:
authorDavid Shah <davey1576@gmail.com>2018-07-29 10:07:58 +0200
committerDavid Shah <davey1576@gmail.com>2018-09-29 16:06:30 +0100
commit7d48acff52cfa31cf7873d7462a3a4e6395ee520 (patch)
tree00e3fc236f637fb4d5b0141a5cce7058cb10ebbe /ecp5
parent30f122854a6dd00f81fc15e7c9384644dd90385b (diff)
downloadnextpnr-7d48acff52cfa31cf7873d7462a3a4e6395ee520.tar.gz
nextpnr-7d48acff52cfa31cf7873d7462a3a4e6395ee520.tar.bz2
nextpnr-7d48acff52cfa31cf7873d7462a3a4e6395ee520.zip
ecp5: Clock usage counter function
Signed-off-by: David Shah <davey1576@gmail.com>
Diffstat (limited to 'ecp5')
-rw-r--r--ecp5/globals.cc35
1 files changed, 34 insertions, 1 deletions
diff --git a/ecp5/globals.cc b/ecp5/globals.cc
index d435ca93..770eb7e2 100644
--- a/ecp5/globals.cc
+++ b/ecp5/globals.cc
@@ -18,6 +18,7 @@
*/
#include "nextpnr.h"
+#include <algorithm>
NEXTPNR_NAMESPACE_BEGIN
@@ -25,6 +26,39 @@ class Ecp5GlobalRouter
{
public:
Ecp5GlobalRouter(Context *ctx) : ctx(ctx){};
+ private:
+
+ bool is_clock_port(const PortRef &user) {
+ if (user.cell->type == ctx->id("TRELLIS_LC") && user.port == ctx->id("CLK"))
+ return true;
+ return false;
+ }
+
+ std::vector<NetInfo*> get_clocks()
+ {
+ std::unordered_map<IdString, int> clockCount;
+ for (auto &net : ctx->nets) {
+ NetInfo *ni = net.second.get();
+ clockCount[ni->name] = 0;
+ for (const auto &user : ni->users) {
+ if (is_clock_port(user))
+ clockCount[ni->name]++;
+ }
+ }
+ std::vector<NetInfo*> clocks;
+ while (clocks.size() < 16) {
+ auto max = std::max_element(clockCount.begin(), clockCount.end(), [](
+ const decltype(clockCount)::value_type &a, const decltype(clockCount)::value_type &b
+ ) {
+ return a.second < b.second;
+ });
+ if (max == clockCount.end() || max->second < 3)
+ break;
+ clocks.push_back(ctx->nets.at(max->first).get());
+ clockCount.erase(max->first);
+ }
+ return clocks;
+ }
PipId find_tap_pip(WireId tile_glb)
{
@@ -43,7 +77,6 @@ class Ecp5GlobalRouter
return *(ctx->getPipsUphill(tap_wire).begin());
}
- private:
Context *ctx;
};