diff options
author | Eddie Hung <e.hung@imperial.ac.uk> | 2018-07-23 07:16:39 -0700 |
---|---|---|
committer | Eddie Hung <e.hung@imperial.ac.uk> | 2018-07-23 07:16:39 -0700 |
commit | 771edd1fda8692930e186a8913b7588d18fda710 (patch) | |
tree | e77d130f96c8061374318f036856aa73d431017d /common/nextpnr.cc | |
parent | e92698f32e3d6ff1ac8cfccc46c966114acb8433 (diff) | |
parent | 14c33cd197b420da1ef9a5a2ed5c19e4490ba7c9 (diff) | |
download | nextpnr-771edd1fda8692930e186a8913b7588d18fda710.tar.gz nextpnr-771edd1fda8692930e186a8913b7588d18fda710.tar.bz2 nextpnr-771edd1fda8692930e186a8913b7588d18fda710.zip |
Merge branch 'master' into redist_slack
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; |