From 8cbc92b7f3cd106363ee115c4ec6a9f2bbaba8c8 Mon Sep 17 00:00:00 2001 From: David Shah Date: Mon, 1 Oct 2018 18:45:14 +0100 Subject: ecp5: Small DRAM routing fixes Signed-off-by: David Shah --- ecp5/globals.cc | 16 +++++++++++++++- ecp5/pack.cc | 16 ++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/ecp5/globals.cc b/ecp5/globals.cc index e5627b66..364e4bca 100644 --- a/ecp5/globals.cc +++ b/ecp5/globals.cc @@ -302,6 +302,14 @@ class Ecp5GlobalRouter ctx->nets[glbnet->name] = std::move(glbnet); return glbptr; } + + int global_route_priority(const PortRef &load) + { + if (load.port == id_WCK || load.port == id_WRE) + return 90; + return 99; + } + Context *ctx; public: @@ -333,7 +341,13 @@ class Ecp5GlobalRouter NetInfo *global = insert_dcc(clock); bool routed = route_onto_global(global, glbid); NPNR_ASSERT(routed); - for (const auto &user : global->users) { + + // WCK must have routing priority + auto sorted_users = global->users; + std::sort(sorted_users.begin(), sorted_users.end(), [this](const PortRef &a, const PortRef &b) { + return global_route_priority(a) < global_route_priority(b); + }); + for (const auto &user : sorted_users) { route_logic_tile_global(global, glbid, user); } } diff --git a/ecp5/pack.cc b/ecp5/pack.cc index 8e33356e..60ac55f6 100644 --- a/ecp5/pack.cc +++ b/ecp5/pack.cc @@ -598,9 +598,11 @@ class Ecp5Packer if (f0net != nullptr) { ff0 = net_only_drives(ctx, f0net, is_ff, ctx->id("DI"), false); if (ff0 != nullptr && can_add_ff_to_tile(tile_ffs, ff0)) { - ff_packing.push_back(std::make_tuple(ff0, slice, 0)); - tile_ffs.push_back(ff0); - packed_cells.insert(ff0->name); + if (net_or_nullptr(ff0, ctx->id("CLK")) == net_or_nullptr(slice, ctx->id("WCK"))) { + ff_packing.push_back(std::make_tuple(ff0, slice, 0)); + tile_ffs.push_back(ff0); + packed_cells.insert(ff0->name); + } } } @@ -610,9 +612,11 @@ class Ecp5Packer ff1 = net_only_drives(ctx, f1net, is_ff, ctx->id("DI"), false); if (ff1 != nullptr && (ff0 == nullptr || can_pack_ffs(ff0, ff1)) && can_add_ff_to_tile(tile_ffs, ff1)) { - ff_packing.push_back(std::make_tuple(ff1, slice, 1)); - tile_ffs.push_back(ff1); - packed_cells.insert(ff1->name); + if (net_or_nullptr(ff1, ctx->id("CLK")) == net_or_nullptr(slice, ctx->id("WCK"))) { + ff_packing.push_back(std::make_tuple(ff1, slice, 1)); + tile_ffs.push_back(ff1); + packed_cells.insert(ff1->name); + } } } } -- cgit v1.2.3