aboutsummaryrefslogtreecommitdiffstats
path: root/ecp5
diff options
context:
space:
mode:
Diffstat (limited to 'ecp5')
-rw-r--r--ecp5/cells.cc4
-rw-r--r--ecp5/globals.cc29
2 files changed, 33 insertions, 0 deletions
diff --git a/ecp5/cells.cc b/ecp5/cells.cc
index e3532f36..c7afdbc2 100644
--- a/ecp5/cells.cc
+++ b/ecp5/cells.cc
@@ -124,6 +124,10 @@ std::unique_ptr<CellInfo> create_ecp5_cell(Context *ctx, IdString type, std::str
add_port(ctx, new_cell.get(), "C", PORT_IN);
add_port(ctx, new_cell.get(), "D", PORT_IN);
add_port(ctx, new_cell.get(), "Z", PORT_OUT);
+ } else if (type == ctx->id("DCCA")) {
+ add_port(ctx, new_cell.get(), "CLKI", PORT_IN);
+ add_port(ctx, new_cell.get(), "CLKO", PORT_OUT);
+ add_port(ctx, new_cell.get(), "CE", PORT_IN);
} else {
log_error("unable to create ECP5 cell of type %s", type.c_str(ctx));
}
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;
};