From abdaa9c8a1953bc1a48fd5d141fc6ce7bf86fdfd Mon Sep 17 00:00:00 2001 From: David Shah Date: Sat, 16 Nov 2019 11:04:39 +0000 Subject: ecp5: Router2 test integration Signed-off-by: David Shah --- ecp5/arch.cc | 39 ++++++++++++++++++++++++++++++++++++++- ecp5/arch.h | 1 + 2 files changed, 39 insertions(+), 1 deletion(-) (limited to 'ecp5') diff --git a/ecp5/arch.cc b/ecp5/arch.cc index 994e8660..93e42db7 100644 --- a/ecp5/arch.cc +++ b/ecp5/arch.cc @@ -30,6 +30,7 @@ #include "placer1.h" #include "placer_heap.h" #include "router1.h" +#include "router2.h" #include "timing.h" #include "util.h" @@ -492,6 +493,42 @@ delay_t Arch::estimateDelay(WireId src, WireId dst) const (6 + std::max(dx - 5, 0) + std::max(dy - 5, 0) + 2 * (std::min(dx, 5) + std::min(dy, 5))); } +ArcBounds Arch::getRouteBoundingBox(WireId src, WireId dst) const +{ + ArcBounds bb; + auto est_location = [&](WireId w) -> std::pair { + const auto &wire = locInfo(w)->wire_data[w.index]; + if (w == gsrclk_wire) { + auto phys_wire = getPipSrcWire(*(getPipsUphill(w).begin())); + return std::make_pair(int(phys_wire.location.x), int(phys_wire.location.y)); + } else if (wire.num_bel_pins > 0) { + return std::make_pair(w.location.x + wire.bel_pins[0].rel_bel_loc.x, + w.location.y + wire.bel_pins[0].rel_bel_loc.y); + } else if (wire.num_downhill > 0) { + return std::make_pair(w.location.x + wire.pips_downhill[0].rel_loc.x, + w.location.y + wire.pips_downhill[0].rel_loc.y); + } else if (wire.num_uphill > 0) { + return std::make_pair(w.location.x + wire.pips_uphill[0].rel_loc.x, + w.location.y + wire.pips_uphill[0].rel_loc.y); + } else { + return std::make_pair(int(w.location.x), int(w.location.y)); + } + }; + + auto src_loc = est_location(src); + std::pair dst_loc; + if (wire_loc_overrides.count(dst)) { + dst_loc = wire_loc_overrides.at(dst); + } else { + dst_loc = est_location(dst); + } + bb.x0 = std::min(src_loc.first, dst_loc.first); + bb.y0 = std::min(src_loc.second, dst_loc.second); + bb.x1 = std::max(src_loc.first, dst_loc.first); + bb.y1 = std::max(src_loc.second, dst_loc.second); + return bb; +} + delay_t Arch::predictDelay(const NetInfo *net_info, const PortRef &sink) const { const auto &driver = net_info->driver; @@ -573,7 +610,7 @@ bool Arch::route() route_ecp5_globals(getCtx()); assignArchInfo(); assign_budget(getCtx(), true); - + router2_test(getCtx()); bool result = router1(getCtx(), Router1Cfg(getCtx())); #if 0 std::vector> fanout_vector; diff --git a/ecp5/arch.h b/ecp5/arch.h index b3e36e52..24997768 100644 --- a/ecp5/arch.h +++ b/ecp5/arch.h @@ -948,6 +948,7 @@ struct Arch : BaseCtx // ------------------------------------------------- delay_t estimateDelay(WireId src, WireId dst) const; + ArcBounds getRouteBoundingBox(WireId src, WireId dst) const; delay_t predictDelay(const NetInfo *net_info, const PortRef &sink) const; delay_t getDelayEpsilon() const { return 20; } delay_t getRipupDelayPenalty() const; -- cgit v1.2.3 From d2c77fd9ae3ca4af2f8235a5502f73d8ebd297d0 Mon Sep 17 00:00:00 2001 From: David Shah Date: Thu, 16 Jan 2020 11:32:00 +0000 Subject: ecp5: router2 main rename Signed-off-by: David Shah --- ecp5/arch.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ecp5') diff --git a/ecp5/arch.cc b/ecp5/arch.cc index 93e42db7..e620b3a3 100644 --- a/ecp5/arch.cc +++ b/ecp5/arch.cc @@ -610,7 +610,7 @@ bool Arch::route() route_ecp5_globals(getCtx()); assignArchInfo(); assign_budget(getCtx(), true); - router2_test(getCtx()); + router2(getCtx()); bool result = router1(getCtx(), Router1Cfg(getCtx())); #if 0 std::vector> fanout_vector; -- cgit v1.2.3 From 5e1aac67db4bec579ca9e8075aa32e4183d1004f Mon Sep 17 00:00:00 2001 From: David Shah Date: Thu, 16 Jan 2020 12:00:52 +0000 Subject: ecp5: Improve bounding box accuracy Signed-off-by: David Shah --- ecp5/arch.cc | 23 +++++++++++++++++++---- ecp5/arch_place.cc | 21 +++++++++++++++------ 2 files changed, 34 insertions(+), 10 deletions(-) (limited to 'ecp5') diff --git a/ecp5/arch.cc b/ecp5/arch.cc index e620b3a3..a10be174 100644 --- a/ecp5/arch.cc +++ b/ecp5/arch.cc @@ -496,6 +496,19 @@ delay_t Arch::estimateDelay(WireId src, WireId dst) const ArcBounds Arch::getRouteBoundingBox(WireId src, WireId dst) const { ArcBounds bb; + + bb.x0 = src.location.x; + bb.y0 = src.location.y; + bb.x1 = src.location.x; + bb.y1 = src.location.y; + + auto extend = [&](int x, int y) { + bb.x0 = std::min(bb.x0, x); + bb.x1 = std::max(bb.x1, x); + bb.y0 = std::min(bb.y0, y); + bb.y1 = std::max(bb.y1, y); + }; + auto est_location = [&](WireId w) -> std::pair { const auto &wire = locInfo(w)->wire_data[w.index]; if (w == gsrclk_wire) { @@ -516,16 +529,18 @@ ArcBounds Arch::getRouteBoundingBox(WireId src, WireId dst) const }; auto src_loc = est_location(src); + extend(src_loc.first, src_loc.second); + if (wire_loc_overrides.count(src)) { + extend(wire_loc_overrides.at(src).first, wire_loc_overrides.at(src).second); + } std::pair dst_loc; + extend(dst.location.x, dst.location.y); if (wire_loc_overrides.count(dst)) { dst_loc = wire_loc_overrides.at(dst); } else { dst_loc = est_location(dst); } - bb.x0 = std::min(src_loc.first, dst_loc.first); - bb.y0 = std::min(src_loc.second, dst_loc.second); - bb.x1 = std::max(src_loc.first, dst_loc.first); - bb.y1 = std::max(src_loc.second, dst_loc.second); + extend(dst_loc.first, dst_loc.second); return bb; } diff --git a/ecp5/arch_place.cc b/ecp5/arch_place.cc index 6057605b..c5330694 100644 --- a/ecp5/arch_place.cc +++ b/ecp5/arch_place.cc @@ -203,17 +203,26 @@ void Arch::setupWireLocations() CellInfo *ci = cell.second; if (ci->bel == BelId()) continue; - if (ci->type == id_MULT18X18D || ci->type == id_DCUA) { + if (ci->type == id_MULT18X18D || ci->type == id_DCUA || ci->type == id_DDRDLL || ci->type == id_DQSBUFM || + ci->type == id_EHXPLLL) { for (auto &port : ci->ports) { - if (port.second.type != PORT_IN || port.second.net == nullptr) + if (port.second.net == nullptr) continue; WireId pw = getBelPinWire(ci->bel, port.first); if (pw == WireId()) continue; - for (auto uh : getPipsUphill(pw)) { - WireId pip_src = getPipSrcWire(uh); - wire_loc_overrides[pw] = std::make_pair(pip_src.location.x, pip_src.location.y); - break; + if (port.second.type == PORT_OUT) { + for (auto dh : getPipsDownhill(pw)) { + WireId pip_dst = getPipDstWire(dh); + wire_loc_overrides[pw] = std::make_pair(pip_dst.location.x, pip_dst.location.y); + break; + } + } else { + for (auto uh : getPipsUphill(pw)) { + WireId pip_src = getPipSrcWire(uh); + wire_loc_overrides[pw] = std::make_pair(pip_src.location.x, pip_src.location.y); + break; + } } } } -- cgit v1.2.3 From ad1cc12df1aa13c1618d85c07805a4987e0e041f Mon Sep 17 00:00:00 2001 From: David Shah Date: Mon, 3 Feb 2020 11:38:15 +0000 Subject: router2: Make magic numbers configurable Signed-off-by: David Shah --- ecp5/arch.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ecp5') diff --git a/ecp5/arch.cc b/ecp5/arch.cc index a10be174..52cfc187 100644 --- a/ecp5/arch.cc +++ b/ecp5/arch.cc @@ -625,7 +625,7 @@ bool Arch::route() route_ecp5_globals(getCtx()); assignArchInfo(); assign_budget(getCtx(), true); - router2(getCtx()); + router2(getCtx(), Router2Cfg(getCtx())); bool result = router1(getCtx(), Router1Cfg(getCtx())); #if 0 std::vector> fanout_vector; -- cgit v1.2.3 From 7123209324c93297efab6c2b2fc92286196be3fb Mon Sep 17 00:00:00 2001 From: David Shah Date: Mon, 3 Feb 2020 11:54:38 +0000 Subject: Allow selection of router algorithm Signed-off-by: David Shah --- ecp5/arch.cc | 18 ++++++++++++++++-- ecp5/arch.h | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'ecp5') diff --git a/ecp5/arch.cc b/ecp5/arch.cc index 52cfc187..b8abec64 100644 --- a/ecp5/arch.cc +++ b/ecp5/arch.cc @@ -621,12 +621,23 @@ bool Arch::place() bool Arch::route() { + std::string router = str_or_default(settings, id("router"), defaultRouter); + setupWireLocations(); route_ecp5_globals(getCtx()); assignArchInfo(); assign_budget(getCtx(), true); - router2(getCtx(), Router2Cfg(getCtx())); - bool result = router1(getCtx(), Router1Cfg(getCtx())); + + bool result; + if (router == "router1") { + result = router1(getCtx(), Router1Cfg(getCtx())); + } else if (router == "router2") { + router2(getCtx(), Router2Cfg(getCtx())); + result = router1(getCtx(), Router1Cfg(getCtx())); + } else { + log_error("ECP5 architecture does not support router '%s'\n", router.c_str()); + } + #if 0 std::vector> fanout_vector; std::copy(wire_fanout.begin(), wire_fanout.end(), std::back_inserter(fanout_vector)); @@ -1173,6 +1184,9 @@ const std::vector Arch::availablePlacers = {"sa", #endif }; +const std::string Arch::defaultRouter = "router1"; +const std::vector Arch::availableRouters = {"router1", "router2"}; + // ----------------------------------------------------------------------- GroupId Arch::getGroupByName(IdString name) const diff --git a/ecp5/arch.h b/ecp5/arch.h index 24997768..55494b1f 100644 --- a/ecp5/arch.h +++ b/ecp5/arch.h @@ -1066,6 +1066,8 @@ struct Arch : BaseCtx static const std::string defaultPlacer; static const std::vector availablePlacers; + static const std::string defaultRouter; + static const std::vector availableRouters; }; NEXTPNR_NAMESPACE_END -- cgit v1.2.3 From 2248e07b662bb99bbe053e485c5c4d8d10cf234b Mon Sep 17 00:00:00 2001 From: David Shah Date: Mon, 3 Feb 2020 13:46:05 +0000 Subject: router2: Improve flow and log output Signed-off-by: David Shah --- ecp5/arch.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ecp5') diff --git a/ecp5/arch.cc b/ecp5/arch.cc index b8abec64..0a44e020 100644 --- a/ecp5/arch.cc +++ b/ecp5/arch.cc @@ -633,7 +633,7 @@ bool Arch::route() result = router1(getCtx(), Router1Cfg(getCtx())); } else if (router == "router2") { router2(getCtx(), Router2Cfg(getCtx())); - result = router1(getCtx(), Router1Cfg(getCtx())); + result = true; } else { log_error("ECP5 architecture does not support router '%s'\n", router.c_str()); } -- cgit v1.2.3