aboutsummaryrefslogtreecommitdiffstats
path: root/ecp5/globals.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ecp5/globals.cc')
-rw-r--r--ecp5/globals.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/ecp5/globals.cc b/ecp5/globals.cc
index df7f4461..3d7d7518 100644
--- a/ecp5/globals.cc
+++ b/ecp5/globals.cc
@@ -21,6 +21,7 @@
#include <iomanip>
#include <queue>
#include "nextpnr.h"
+#include "cells.h"
#include "log.h"
@@ -230,6 +231,34 @@ class Ecp5GlobalRouter
}
}
+
+ // Insert a DCC into a net to promote it to a global
+ NetInfo *insert_dcc(NetInfo *net)
+ {
+ auto dcc = create_ecp5_cell(ctx, ctx->id("DCCA"), "$gbuf$" + net->name.str(ctx));
+
+ std::unique_ptr<NetInfo> glbnet = std::unique_ptr<NetInfo>(new NetInfo);
+ glbnet->name = ctx->id("$glbnet$" + net->name.str(ctx));
+ glbnet->driver.cell = dcc.get();
+ glbnet->driver.port = ctx->id("CLKO");
+
+ for (auto user : net->users) {
+ user.cell->ports.at(user.port).net = glbnet.get();
+ }
+ net->users.clear();
+
+ dcc->ports[ctx->id("CLKI")].net = net;
+ PortRef clki_pr;
+ clki_pr.port = ctx->id("CLKI");
+ clki_pr.cell = dcc.get();
+ net->users.push_back(clki_pr);
+
+ ctx->cells[dcc->name] = std::move(dcc);
+ NetInfo *glbptr = glbnet.get();
+ ctx->nets[glbnet->name] = std::move(glbnet);
+ return glbptr;
+ }
+
Context *ctx;
};