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 --- ice40/arch.cc | 17 +++++++++++++++-- ice40/arch.h | 2 ++ 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'ice40') diff --git a/ice40/arch.cc b/ice40/arch.cc index 0f8e5969..edc104f0 100644 --- a/ice40/arch.cc +++ b/ice40/arch.cc @@ -28,6 +28,7 @@ #include "placer1.h" #include "placer_heap.h" #include "router1.h" +#include "router2.h" #include "timing_opt.h" #include "util.h" NEXTPNR_NAMESPACE_BEGIN @@ -696,10 +697,19 @@ bool Arch::place() bool Arch::route() { - bool retVal = router1(getCtx(), Router1Cfg(getCtx())); + std::string router = str_or_default(settings, id("router"), defaultRouter); + 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("iCE40 architecture does not support router '%s'\n", router.c_str()); + } getCtx()->settings[getCtx()->id("route")] = 1; archInfoToAttributes(); - return retVal; + return result; } // ----------------------------------------------------------------------- @@ -1257,4 +1267,7 @@ const std::vector Arch::availablePlacers = {"sa", #endif }; +const std::string Arch::defaultRouter = "router1"; +const std::vector Arch::availableRouters = {"router1", "router2"}; + NEXTPNR_NAMESPACE_END diff --git a/ice40/arch.h b/ice40/arch.h index ea29f4f1..a6a3cd70 100644 --- a/ice40/arch.h +++ b/ice40/arch.h @@ -900,6 +900,8 @@ struct Arch : BaseCtx static const std::string defaultPlacer; static const std::vector availablePlacers; + static const std::string defaultRouter; + static const std::vector availableRouters; }; void ice40DelayFuzzerMain(Context *ctx); -- cgit v1.2.3 From ce144addb3644dcb4790b5861bd028d40fc6f15d Mon Sep 17 00:00:00 2001 From: David Shah Date: Mon, 3 Feb 2020 12:00:05 +0000 Subject: ice40: Implement getRouteBoundingBox for router2 Signed-off-by: David Shah --- ice40/arch.cc | 24 ++++++++++++++++++++++++ ice40/arch.h | 2 ++ 2 files changed, 26 insertions(+) (limited to 'ice40') diff --git a/ice40/arch.cc b/ice40/arch.cc index edc104f0..b429a1cd 100644 --- a/ice40/arch.cc +++ b/ice40/arch.cc @@ -1255,6 +1255,30 @@ void Arch::assignCellInfo(CellInfo *cell) } } +ArcBounds Arch::getRouteBoundingBox(WireId src, WireId dst) const +{ + ArcBounds bb; + + int src_x = chip_info->wire_data[src.index].x; + int src_y = chip_info->wire_data[src.index].y; + int dst_x = chip_info->wire_data[dst.index].x; + int dst_y = chip_info->wire_data[dst.index].y; + + bb.x0 = src_x; + bb.y0 = src_y; + bb.x1 = src_x; + bb.y1 = src_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); + }; + extend(dst_x, dst_y); + return bb; +} + #ifdef WITH_HEAP const std::string Arch::defaultPlacer = "heap"; #else diff --git a/ice40/arch.h b/ice40/arch.h index a6a3cd70..f2f9069a 100644 --- a/ice40/arch.h +++ b/ice40/arch.h @@ -826,6 +826,8 @@ struct Arch : BaseCtx uint32_t getDelayChecksum(delay_t v) const { return v; } bool getBudgetOverride(const NetInfo *net_info, const PortRef &sink, delay_t &budget) const; + ArcBounds getRouteBoundingBox(WireId src, WireId dst) const; + // ------------------------------------------------- bool pack(); -- 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 --- ice40/arch.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ice40') diff --git a/ice40/arch.cc b/ice40/arch.cc index b429a1cd..a43c4c21 100644 --- a/ice40/arch.cc +++ b/ice40/arch.cc @@ -703,7 +703,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("iCE40 architecture does not support router '%s'\n", router.c_str()); } -- cgit v1.2.3