From 5af5bd23d0fd7f16e08ca0d396e7985205c56ffb Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Tue, 19 Jun 2018 16:23:23 +0200 Subject: Add Context::sorted_shuffle API Signed-off-by: Clifford Wolf --- common/nextpnr.h | 7 +++++++ common/route.cc | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/nextpnr.h b/common/nextpnr.h index 2d614058..6e4b87bd 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -23,6 +23,7 @@ #include #include #include +#include #ifndef NEXTPNR_H #define NEXTPNR_H @@ -328,6 +329,12 @@ struct Context : Arch std::swap(a[i], a[j]); } } + + template void sorted_shuffle(std::vector &a) + { + std::sort(a.begin(), a.end()); + shuffle(a); + } }; NEXTPNR_NAMESPACE_END diff --git a/common/route.cc b/common/route.cc index d623b2cf..b031237c 100644 --- a/common/route.cc +++ b/common/route.cc @@ -395,7 +395,7 @@ bool route_design(Context *ctx) bool printNets = netsQueue.size() < 10; std::vector netsArray(netsQueue.begin(), netsQueue.end()); - ctx->shuffle(netsArray); + ctx->sorted_shuffle(netsArray); netsQueue.clear(); for (auto net_name : netsArray) { @@ -441,7 +441,7 @@ bool route_design(Context *ctx) std::vector ripupArray(ripupQueue.begin(), ripupQueue.end()); - ctx->shuffle(ripupArray); + ctx->sorted_shuffle(ripupArray); for (auto net_name : ripupArray) { if (printNets) -- cgit v1.2.3