diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/nextpnr.h | 24 | ||||
-rw-r--r-- | common/router1.cc | 19 | ||||
-rw-r--r-- | common/timing.cc | 5 |
3 files changed, 46 insertions, 2 deletions
diff --git a/common/nextpnr.h b/common/nextpnr.h index bc64adb5..40fd3d13 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -27,6 +27,8 @@ #include <unordered_set> #include <vector> +#include <boost/functional/hash.hpp> + #ifndef NEXTPNR_H #define NEXTPNR_H @@ -158,8 +160,30 @@ struct GraphicElement std::string text; }; +struct Loc +{ + int x = -1, y = -1, z = -1; + + bool operator==(const Loc &other) const { return (x == other.x) && (y == other.y) && (z == other.z); } + bool operator!=(const Loc &other) const { return (x != other.x) || (y != other.y) || (z == other.z); } +}; + NEXTPNR_NAMESPACE_END +namespace std { +template <> struct hash<NEXTPNR_NAMESPACE_PREFIX Loc> +{ + std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX Loc &obj) const noexcept + { + std::size_t seed = 0; + boost::hash_combine(seed, hash<int>()(obj.x)); + boost::hash_combine(seed, hash<int>()(obj.y)); + boost::hash_combine(seed, hash<int>()(obj.z)); + return seed; + } +}; +} // namespace std + #include "archdefs.h" NEXTPNR_NAMESPACE_BEGIN diff --git a/common/router1.cc b/common/router1.cc index 94c7070e..50022169 100644 --- a/common/router1.cc +++ b/common/router1.cc @@ -402,6 +402,21 @@ struct Router NEXTPNR_NAMESPACE_BEGIN +static void prioritise_nets(Context *ctx, std::vector<IdString> &netsArray) +{ + std::unordered_map<IdString, delay_t> netScores; + for (auto net_name : netsArray) { + delay_t score = std::numeric_limits<delay_t>::max(); + for (const auto &sink : ctx->nets.at(net_name)->users) { + if (sink.budget < score) + score = sink.budget; + } + netScores[net_name] = score; + } + std::sort(netsArray.begin(), netsArray.end(), + [&netScores](IdString a, IdString b) { return netScores[a] < netScores[b]; }); +} + bool router1(Context *ctx) { try { @@ -508,7 +523,7 @@ bool router1(Context *ctx) bool printNets = ctx->verbose && (netsQueue.size() < 10); std::vector<IdString> netsArray(netsQueue.begin(), netsQueue.end()); - ctx->sorted_shuffle(netsArray); + prioritise_nets(ctx, netsArray); netsQueue.clear(); for (auto net_name : netsArray) { @@ -560,7 +575,7 @@ bool router1(Context *ctx) int ripCnt = 0; std::vector<IdString> ripupArray(ripupQueue.begin(), ripupQueue.end()); - ctx->sorted_shuffle(ripupArray); + prioritise_nets(ctx, ripupArray); for (auto net_name : ripupArray) { if (printNets) diff --git a/common/timing.cc b/common/timing.cc index 479dba26..5f744621 100644 --- a/common/timing.cc +++ b/common/timing.cc @@ -217,6 +217,11 @@ void update_budget(Context *ctx) if (it == updates.end()) continue; user.budget = delays.at(pi) + it->second; + // HACK HACK HACK + if (net.second->driver.port == ctx->id("COUT")) + user.budget = 0; + // HACK HACK HACK + // Post-update check // if (user.budget < 0) // log_warning("port %s.%s, connected to net '%s', has negative " |