From f646ec790a79f29d6964f3b7e30088f044b4a4e9 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Tue, 31 Jul 2018 19:31:54 -0700 Subject: Modify the getNetinfo*() functions and getBudgetOverride() to not use user_idx and to take a PortRef& instead --- common/nextpnr.cc | 11 +++++------ common/nextpnr.h | 6 +++--- common/router1.cc | 12 ++++++------ common/timing.cc | 15 ++++----------- ecp5/arch.cc | 2 +- ecp5/arch.h | 2 +- generic/arch.cc | 2 +- generic/arch.h | 2 +- ice40/arch.cc | 3 +-- ice40/arch.h | 2 +- 10 files changed, 24 insertions(+), 33 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_mapgetNetinfoSinkWire(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_mapgetNetinfoSinkWire(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); diff --git a/ecp5/arch.cc b/ecp5/arch.cc index 14b5b8f2..ffaa9133 100644 --- a/ecp5/arch.cc +++ b/ecp5/arch.cc @@ -422,7 +422,7 @@ delay_t Arch::predictDelay(const NetInfo *net_info, const PortRef &sink) const; return 200 * (abs(driver_loc.x - sink_loc.x) + abs(driver_loc.y - sink_loc.y)); } -delay_t Arch::getBudgetOverride(NetInfo *net_info, int user_idx, delay_t budget) const { return budget; } +delay_t getBudgetOverride(const NetInfo *net_info, const PortRef &sink, delay_t budget) const { return budget; } // ----------------------------------------------------------------------- diff --git a/ecp5/arch.h b/ecp5/arch.h index 255bafc7..e4d67e0f 100644 --- a/ecp5/arch.h +++ b/ecp5/arch.h @@ -781,7 +781,7 @@ struct Arch : BaseCtx delay_t getRipupDelayPenalty() const { return 200; } float getDelayNS(delay_t v) const { return v * 0.001; } uint32_t getDelayChecksum(delay_t v) const { return v; } - delay_t getBudgetOverride(NetInfo *net_info, int user_idx, delay_t budget) const; + delay_t getBudgetOverride(const NetInfo *net_info, const PortRef &sink, delay_t budget) const; // ------------------------------------------------- diff --git a/generic/arch.cc b/generic/arch.cc index 43015685..756537e8 100644 --- a/generic/arch.cc +++ b/generic/arch.cc @@ -414,7 +414,7 @@ delay_t Arch::predictDelay(const NetInfo *net_info, const PortRef &sink) const; return (dx + dy) * grid_distance_to_delay; } -delay_t Arch::getBudgetOverride(NetInfo *net_info, int user_idx, delay_t budget) const { return budget; } +delay_t getBudgetOverride(const NetInfo *net_info, const PortRef &sink, delay_t budget) const { return budget; } // --------------------------------------------------------------- diff --git a/generic/arch.h b/generic/arch.h index 154a2352..17d62ec3 100644 --- a/generic/arch.h +++ b/generic/arch.h @@ -199,7 +199,7 @@ struct Arch : BaseCtx delay_t getRipupDelayPenalty() const { return 1.0; } float getDelayNS(delay_t v) const { return v; } uint32_t getDelayChecksum(delay_t v) const { return 0; } - delay_t getBudgetOverride(NetInfo *net_info, int user_idx, delay_t budget) const; + delay_t getBudgetOverride(const NetInfo *net_info, const PortRef &sink, delay_t budget) const; bool pack() { return true; } bool place(); diff --git a/ice40/arch.cc b/ice40/arch.cc index bdfb13fe..18887a3c 100644 --- a/ice40/arch.cc +++ b/ice40/arch.cc @@ -642,11 +642,10 @@ delay_t Arch::predictDelay(const NetInfo *net_info, const PortRef &sink) const return xscale * abs(xd) + yscale * abs(yd) + offset; } -delay_t Arch::getBudgetOverride(NetInfo *net_info, int user_idx, delay_t budget) const +delay_t Arch::getBudgetOverride(const NetInfo *net_info, const PortRef& sink, delay_t budget) const { const auto &driver = net_info->driver; if (driver.port == id_cout) { - const auto &sink = net_info->users[user_idx]; auto driver_loc = getBelLocation(driver.cell->bel); auto sink_loc = getBelLocation(sink.cell->bel); if (driver_loc.y == sink_loc.y) diff --git a/ice40/arch.h b/ice40/arch.h index 92698b4d..d813c038 100644 --- a/ice40/arch.h +++ b/ice40/arch.h @@ -702,7 +702,7 @@ struct Arch : BaseCtx delay_t getRipupDelayPenalty() const { return 200; } float getDelayNS(delay_t v) const { return v * 0.001; } uint32_t getDelayChecksum(delay_t v) const { return v; } - delay_t getBudgetOverride(NetInfo *net_info, int user_idx, delay_t budget) const; + delay_t getBudgetOverride(const NetInfo *net_info, const PortRef &sink, delay_t budget) const; // ------------------------------------------------- -- cgit v1.2.3