diff options
author | Eddie Hung <eddie.hung+gitlab@gmail.com> | 2018-07-23 14:14:18 +0000 |
---|---|---|
committer | Eddie Hung <eddie.hung+gitlab@gmail.com> | 2018-07-23 14:14:18 +0000 |
commit | 14c33cd197b420da1ef9a5a2ed5c19e4490ba7c9 (patch) | |
tree | 79af7f375362eeae2a0d9ee96c1bc6f09ab8fcce /common/nextpnr.cc | |
parent | dfdeb21690181044a95c2b2d64c197c999507b0c (diff) | |
parent | e647604e2a584917ad2fc9acfe838a1395c613c2 (diff) | |
download | nextpnr-14c33cd197b420da1ef9a5a2ed5c19e4490ba7c9.tar.gz nextpnr-14c33cd197b420da1ef9a5a2ed5c19e4490ba7c9.tar.bz2 nextpnr-14c33cd197b420da1ef9a5a2ed5c19e4490ba7c9.zip |
Merge branch 'master' into 'master'
Master
See merge request eddiehung/nextpnr!7
Diffstat (limited to 'common/nextpnr.cc')
-rw-r--r-- | common/nextpnr.cc | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/common/nextpnr.cc b/common/nextpnr.cc index 3861e5fe..2c50c9a1 100644 --- a/common/nextpnr.cc +++ b/common/nextpnr.cc @@ -51,6 +51,67 @@ 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 getBelPinWire(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 getBelPinWire(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 = 0; + + 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); + } + + if (cursor == src_wire) + delay += getWireDelay(src_wire).maxDelay(); + else + delay += estimateDelay(src_wire, cursor); + + return delay; +} + static uint32_t xorshift32(uint32_t x) { x ^= x << 13; |