Add Context::sorted_shuffle API

Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
Clifford Wolf 2018-06-19 16:23:23 +02:00
parent 8e26e4381b
commit 5af5bd23d0
2 changed files with 9 additions and 2 deletions

View File

@ -23,6 +23,7 @@
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <algorithm>
#ifndef NEXTPNR_H
#define NEXTPNR_H
@ -328,6 +329,12 @@ struct Context : Arch
std::swap(a[i], a[j]);
}
}
template <typename T> void sorted_shuffle(std::vector<T> &a)
{
std::sort(a.begin(), a.end());
shuffle(a);
}
};
NEXTPNR_NAMESPACE_END

View File

@ -395,7 +395,7 @@ bool route_design(Context *ctx)
bool printNets = netsQueue.size() < 10;
std::vector<IdString> 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<IdString> ripupArray(ripupQueue.begin(),
ripupQueue.end());
ctx->shuffle(ripupArray);
ctx->sorted_shuffle(ripupArray);
for (auto net_name : ripupArray) {
if (printNets)