aboutsummaryrefslogtreecommitdiffstats
path: root/common/nextpnr.cc
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2018-07-22 02:16:03 +0200
committerClifford Wolf <clifford@clifford.at>2018-07-22 02:16:03 +0200
commitc6e4ad322745b478f0f289f4cc5f3668e05700ac (patch)
tree6fb6435880ba1ebaad9e016948961c5539475122 /common/nextpnr.cc
parent1e96999863da24021c215a3706b5a442789ba3a7 (diff)
downloadnextpnr-c6e4ad322745b478f0f289f4cc5f3668e05700ac.tar.gz
nextpnr-c6e4ad322745b478f0f289f4cc5f3668e05700ac.tar.bz2
nextpnr-c6e4ad322745b478f0f289f4cc5f3668e05700ac.zip
Move common patterns from router1 to Context API
Signed-off-by: Clifford Wolf <clifford@clifford.at>
Diffstat (limited to 'common/nextpnr.cc')
-rw-r--r--common/nextpnr.cc56
1 files changed, 56 insertions, 0 deletions
diff --git a/common/nextpnr.cc b/common/nextpnr.cc
index 3861e5fe..ac292e77 100644
--- a/common/nextpnr.cc
+++ b/common/nextpnr.cc
@@ -51,6 +51,62 @@ void IdString::initialize_add(const BaseCtx *ctx, const char *s, int idx)
ctx->idstring_idx_to_str->push_back(&insert_rc.first->first);
}
+WireId Context::getNetinfoSourceWire(NetInfo *net_info) const
+{
+ if (net_info->driver.cell == nullptr)
+ return WireId();
+
+ auto src_bel = net_info->driver.cell->bel;
+
+ if (src_bel == BelId())
+ return WireId();
+
+ IdString driver_port = net_info->driver.port;
+
+ auto driver_port_it = net_info->driver.cell->pins.find(driver_port);
+ if (driver_port_it != net_info->driver.cell->pins.end())
+ driver_port = driver_port_it->second;
+
+ return getWireBelPin(src_bel, portPinFromId(driver_port));
+}
+
+WireId Context::getNetinfoSinkWire(NetInfo *net_info, int user_idx) const
+{
+ auto &user_info = net_info->users[user_idx];
+ auto dst_bel = user_info.cell->bel;
+
+ if (dst_bel == BelId())
+ return WireId();
+
+ IdString user_port = user_info.port;
+
+ auto user_port_it = user_info.cell->pins.find(user_port);
+
+ if (user_port_it != user_info.cell->pins.end())
+ user_port = user_port_it->second;
+
+ return getWireBelPin(dst_bel, portPinFromId(user_port));
+}
+
+delay_t Context::getNetinfoRouteDelay(NetInfo *net_info, int user_idx) const
+{
+ WireId src_wire = getNetinfoSourceWire(net_info);
+ WireId cursor = getNetinfoSinkWire(net_info, user_idx);
+ delay_t delay = getWireDelay(src_wire).maxDelay();
+
+ while (cursor != WireId() && cursor != src_wire) {
+ auto it = net_info->wires.find(cursor);
+ if (it == net_info->wires.end())
+ break;
+ PipId pip = it->second.pip;
+ delay += getPipDelay(pip).maxDelay();
+ delay += getWireDelay(cursor).maxDelay();
+ cursor = getPipSrcWire(pip);
+ }
+
+ return delay;
+}
+
static uint32_t xorshift32(uint32_t x)
{
x ^= x << 13;