From dfdaaa6f57a0a9f87878491a24b659e94aaec5fd Mon Sep 17 00:00:00 2001 From: David Shah Date: Tue, 7 Aug 2018 12:16:51 +0200 Subject: ecp5: Adding DCCA insertion function Signed-off-by: David Shah --- ecp5/cells.cc | 4 ++++ ecp5/globals.cc | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) (limited to 'ecp5') 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 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 #include #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 glbnet = std::unique_ptr(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; }; -- cgit v1.2.3