diff options
author | Keith Rothman <537074+litghost@users.noreply.github.com> | 2021-01-29 12:57:23 -0800 |
---|---|---|
committer | Keith Rothman <537074+litghost@users.noreply.github.com> | 2021-01-29 13:42:14 -0800 |
commit | b8c823ef99c0bd2ccab62b5f01f21eab0ae0fd37 (patch) | |
tree | b8de41a5ae4f5e9dfaa77f933888150249e213fe | |
parent | 15b2852b916c1299dfc1d91a217de3060701bfbe (diff) | |
download | nextpnr-b8c823ef99c0bd2ccab62b5f01f21eab0ae0fd37.tar.gz nextpnr-b8c823ef99c0bd2ccab62b5f01f21eab0ae0fd37.tar.bz2 nextpnr-b8c823ef99c0bd2ccab62b5f01f21eab0ae0fd37.zip |
Avoid linear scan in PIP check loop.
The previous additions to archcheck increased the runtime of the nexus
archcheck quiet a bit.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
-rw-r--r-- | common/archcheck.cc | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/common/archcheck.cc b/common/archcheck.cc index 9c943e86..3c4c3133 100644 --- a/common/archcheck.cc +++ b/common/archcheck.cc @@ -127,6 +127,8 @@ void archcheck_conn(const Context *ctx) log_info("Checking all wires...\n"); + std::unordered_map<PipId, WireId> pips_downhill; + std::unordered_map<PipId, WireId> pips_uphill; for (WireId wire : ctx->getWires()) { for (BelPin belpin : ctx->getWireBelPins(wire)) { WireId wire2 = ctx->getBelPinWire(belpin.bel, belpin.pin); @@ -136,11 +138,17 @@ void archcheck_conn(const Context *ctx) for (PipId pip : ctx->getPipsDownhill(wire)) { WireId wire2 = ctx->getPipSrcWire(pip); log_assert(wire == wire2); + + auto result = pips_downhill.emplace(pip, wire); + log_assert(result.second); } for (PipId pip : ctx->getPipsUphill(wire)) { WireId wire2 = ctx->getPipDstWire(pip); log_assert(wire == wire2); + + auto result = pips_uphill.emplace(pip, wire); + log_assert(result.second); } } @@ -169,28 +177,12 @@ void archcheck_conn(const Context *ctx) for (PipId pip : ctx->getPips()) { WireId src_wire = ctx->getPipSrcWire(pip); if (src_wire != WireId()) { - bool found_pip = false; - for (PipId downhill_pip : ctx->getPipsDownhill(src_wire)) { - if (pip == downhill_pip) { - found_pip = true; - break; - } - } - - log_assert(found_pip); + log_assert(pips_downhill.at(pip) == src_wire); } WireId dst_wire = ctx->getPipDstWire(pip); if (dst_wire != WireId()) { - bool found_pip = false; - for (PipId uphill_pip : ctx->getPipsUphill(dst_wire)) { - if (pip == uphill_pip) { - found_pip = true; - break; - } - } - - log_assert(found_pip); + log_assert(pips_uphill.at(pip) == dst_wire); } } } |