diff options
author | Eddie Hung <eddieh@ece.ubc.ca> | 2018-07-31 19:31:54 -0700 |
---|---|---|
committer | Eddie Hung <eddieh@ece.ubc.ca> | 2018-07-31 19:31:54 -0700 |
commit | f646ec790a79f29d6964f3b7e30088f044b4a4e9 (patch) | |
tree | 5bcbcf52c0a4ee1b0c3aa52cfb829a455be3f368 /common | |
parent | 720e81586502f527cba7b9052b6bfed719c0b165 (diff) | |
download | nextpnr-f646ec790a79f29d6964f3b7e30088f044b4a4e9.tar.gz nextpnr-f646ec790a79f29d6964f3b7e30088f044b4a4e9.tar.bz2 nextpnr-f646ec790a79f29d6964f3b7e30088f044b4a4e9.zip |
Modify the getNetinfo*() functions and getBudgetOverride() to not use
user_idx and to take a PortRef& instead
Diffstat (limited to 'common')
-rw-r--r-- | common/nextpnr.cc | 11 | ||||
-rw-r--r-- | common/nextpnr.h | 6 | ||||
-rw-r--r-- | common/router1.cc | 12 | ||||
-rw-r--r-- | common/timing.cc | 15 |
4 files changed, 18 insertions, 26 deletions
diff --git a/common/nextpnr.cc b/common/nextpnr.cc index 4a97bd93..4e15a594 100644 --- a/common/nextpnr.cc +++ b/common/nextpnr.cc @@ -51,7 +51,7 @@ 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 +WireId Context::getNetinfoSourceWire(const NetInfo *net_info) const { if (net_info->driver.cell == nullptr) return WireId(); @@ -70,9 +70,8 @@ WireId Context::getNetinfoSourceWire(NetInfo *net_info) const return getBelPinWire(src_bel, portPinFromId(driver_port)); } -WireId Context::getNetinfoSinkWire(NetInfo *net_info, int user_idx) const +WireId Context::getNetinfoSinkWire(const NetInfo *net_info, const PortRef& user_info) const { - auto &user_info = net_info->users[user_idx]; auto dst_bel = user_info.cell->bel; if (dst_bel == BelId()) @@ -88,13 +87,13 @@ WireId Context::getNetinfoSinkWire(NetInfo *net_info, int user_idx) const return getBelPinWire(dst_bel, portPinFromId(user_port)); } -delay_t Context::getNetinfoRouteDelay(NetInfo *net_info, int user_idx) const +delay_t Context::getNetinfoRouteDelay(const NetInfo *net_info, const PortRef& user_info) const { WireId src_wire = getNetinfoSourceWire(net_info); if (src_wire == WireId()) return 0; - WireId dst_wire = getNetinfoSinkWire(net_info, user_idx); + WireId dst_wire = getNetinfoSinkWire(net_info, user_info); WireId cursor = dst_wire; delay_t delay = 0; @@ -111,7 +110,7 @@ delay_t Context::getNetinfoRouteDelay(NetInfo *net_info, int user_idx) const if (cursor == src_wire) return delay + getWireDelay(src_wire).maxDelay(); - return predictDelay(net_info, net_info->users[user_idx]); + return predictDelay(net_info, user_info); } static uint32_t xorshift32(uint32_t x) diff --git a/common/nextpnr.h b/common/nextpnr.h index b163300a..9044e545 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -482,9 +482,9 @@ struct Context : Arch, DeterministicRNG // -------------------------------------------------------------- - WireId getNetinfoSourceWire(NetInfo *net_info) const; - WireId getNetinfoSinkWire(NetInfo *net_info, int user_idx) const; - delay_t getNetinfoRouteDelay(NetInfo *net_info, int user_idx) const; + WireId getNetinfoSourceWire(const NetInfo *net_info) const; + WireId getNetinfoSinkWire(const NetInfo *net_info, const PortRef& sink) const; + delay_t getNetinfoRouteDelay(const NetInfo *net_info, const PortRef& sink) const; // provided by router1.cc bool getActualRouteDelay(WireId src_wire, WireId dst_wire, delay_t &delay); diff --git a/common/router1.cc b/common/router1.cc index 5fffbc6d..3a55afcd 100644 --- a/common/router1.cc +++ b/common/router1.cc @@ -298,7 +298,7 @@ struct Router src_wires[src_wire] = ctx->getWireDelay(src_wire).maxDelay(); for (int user_idx = 0; user_idx < int(net_info->users.size()); user_idx++) { - auto dst_wire = ctx->getNetinfoSinkWire(net_info, user_idx); + auto dst_wire = ctx->getNetinfoSinkWire(net_info, net_info->users[user_idx]); if (dst_wire == WireId()) log_error("No wire found for port %s on destination cell %s.\n", @@ -352,7 +352,7 @@ struct Router log(" Route to: %s.%s.\n", net_info->users[user_idx].cell->name.c_str(ctx), net_info->users[user_idx].port.c_str(ctx)); - auto dst_wire = ctx->getNetinfoSinkWire(net_info, user_idx); + auto dst_wire = ctx->getNetinfoSinkWire(net_info, net_info->users[user_idx]); if (dst_wire == WireId()) log_error("No wire found for port %s on destination cell %s.\n", @@ -483,7 +483,7 @@ void addFullNetRouteJob(Context *ctx, IdString net_name, std::unordered_map<IdSt if (net_cache[user_idx]) continue; - auto dst_wire = ctx->getNetinfoSinkWire(net_info, user_idx); + auto dst_wire = ctx->getNetinfoSinkWire(net_info, net_info->users[user_idx]); if (dst_wire == WireId()) log_error("No wire found for port %s on destination cell %s.\n", net_info->users[user_idx].port.c_str(ctx), @@ -540,7 +540,7 @@ void addNetRouteJobs(Context *ctx, IdString net_name, std::unordered_map<IdStrin if (net_cache[user_idx]) continue; - auto dst_wire = ctx->getNetinfoSinkWire(net_info, user_idx); + auto dst_wire = ctx->getNetinfoSinkWire(net_info, net_info->users[user_idx]); if (dst_wire == WireId()) log_error("No wire found for port %s on destination cell %s.\n", net_info->users[user_idx].port.c_str(ctx), @@ -767,7 +767,7 @@ bool router1(Context *ctx) bool got_negative_slack = false; NetInfo *net_info = ctx->nets.at(net_it.first).get(); for (int user_idx = 0; user_idx < int(net_info->users.size()); user_idx++) { - delay_t arc_delay = ctx->getNetinfoRouteDelay(net_info, user_idx); + delay_t arc_delay = ctx->getNetinfoRouteDelay(net_info, net_info->users[user_idx]); delay_t arc_budget = net_info->users[user_idx].budget; delay_t arc_slack = arc_budget - arc_delay; if (arc_slack < 0) { @@ -779,7 +779,7 @@ bool router1(Context *ctx) if (ctx->verbose) log_info(" arc %s -> %s has %f ns slack (delay %f, budget %f)\n", ctx->getWireName(ctx->getNetinfoSourceWire(net_info)).c_str(ctx), - ctx->getWireName(ctx->getNetinfoSinkWire(net_info, user_idx)).c_str(ctx), + ctx->getWireName(ctx->getNetinfoSinkWire(net_info, net_info->users[user_idx])).c_str(ctx), ctx->getDelayNS(arc_slack), ctx->getDelayNS(arc_delay), ctx->getDelayNS(arc_budget)); tns += ctx->getDelayNS(arc_slack); diff --git a/common/timing.cc b/common/timing.cc index 1b3fd040..be57f445 100644 --- a/common/timing.cc +++ b/common/timing.cc @@ -72,18 +72,17 @@ static delay_t follow_net(Context *ctx, NetInfo *net, int path_length, delay_t s PortRefList *current_path, PortRefList *crit_path) { delay_t net_budget = slack / (path_length + 1); - for (unsigned i = 0; i < net->users.size(); ++i) { - auto &usr = net->users[i]; + for (auto &usr : net->users) { if (crit_path) current_path->push_back(&usr); // If budget override is less than existing budget, then do not increment path length int pl = path_length + 1; - auto budget = ctx->getBudgetOverride(net, i, net_budget); + auto budget = ctx->getBudgetOverride(net, usr, net_budget); if (budget < net_budget) { net_budget = budget; pl = std::max(1, path_length); } - auto delay = ctx->getNetinfoRouteDelay(net, i); + auto delay = ctx->getNetinfoRouteDelay(net, usr); net_budget = std::min( net_budget, follow_user_port(ctx, usr, pl, slack - delay, update, min_slack, current_path, crit_path)); if (update) @@ -189,12 +188,6 @@ delay_t timing_analysis(Context *ctx, bool print_fmax, bool print_path) auto sink_cell = sink->cell; auto &port = sink_cell->ports.at(sink->port); auto net = port.net; - unsigned i = 0; - for (auto &usr : net->users) - if (&usr == sink) - break; - else - ++i; auto &driver = net->driver; auto driver_cell = driver.cell; DelayInfo comb_delay; @@ -202,7 +195,7 @@ delay_t timing_analysis(Context *ctx, bool print_fmax, bool print_path) total += comb_delay.maxDelay(); log_info("%4d %4d Source %s.%s\n", comb_delay.maxDelay(), total, driver_cell->name.c_str(ctx), driver.port.c_str(ctx)); - auto net_delay = ctx->getNetinfoRouteDelay(net, i); + auto net_delay = ctx->getNetinfoRouteDelay(net, *sink); total += net_delay; auto driver_loc = ctx->getBelLocation(driver_cell->bel); auto sink_loc = ctx->getBelLocation(sink_cell->bel); |