From 07e265868b49447b600c6c3da9f042c593f467f3 Mon Sep 17 00:00:00 2001 From: David Shah Date: Sun, 4 Nov 2018 14:03:33 +0000 Subject: archapi: Add getDelayFromNS to improve timing algorithm portability Signed-off-by: David Shah --- common/timing.cc | 6 +++--- docs/archapi.md | 4 ++++ ice40/arch.h | 6 ++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/common/timing.cc b/common/timing.cc index 10b321f7..60b97655 100644 --- a/common/timing.cc +++ b/common/timing.cc @@ -117,7 +117,7 @@ struct Timing delay_t walk_paths() { - const auto clk_period = delay_t(1.0e12 / ctx->target_freq); + const auto clk_period = ctx->getDelayFromNS(1.0e9 / ctx->target_freq).maxDelay(); // First, compute the topographical order of nets to walk through the circuit, assuming it is a _acyclic_ graph // TODO(eddieh): Handle the case where it is cyclic, e.g. combinatorial loops @@ -344,7 +344,7 @@ struct Timing if (!crit_nets.count(clockPair) || crit_nets.at(clockPair).first < endpoint_arrival) { crit_nets[clockPair] = std::make_pair(endpoint_arrival, net); (*crit_path)[clockPair].path_delay = endpoint_arrival; - (*crit_path)[clockPair].path_period = clk_period; + (*crit_path)[clockPair].path_period = period; (*crit_path)[clockPair].ports.clear(); (*crit_path)[clockPair].ports.push_back(&usr); } @@ -591,7 +591,7 @@ void timing_analysis(Context *ctx, bool print_histogram, bool print_fmax, bool p DelayInfo comb_delay; if (last_port == driver.port) { // Case where we start with a STARTPOINT etc - comb_delay.delay = 0; + comb_delay = ctx->getDelayFromNS(0); } else { ctx->getCellDelay(sink_cell, last_port, driver.port, comb_delay); } diff --git a/docs/archapi.md b/docs/archapi.md index 6b22c6df..fd3bfb3a 100644 --- a/docs/archapi.md +++ b/docs/archapi.md @@ -398,6 +398,10 @@ actual penalty used is a multiple of this value (i.e. a weighted version of this Convert an `delay_t` to an actual real-world delay in nanoseconds. +### DelayInfo getDelayFromNS(float v) const + +Convert a real-world delay in nanoseconds to a DelayInfo with equal min/max rising/falling values. + ### uint32\_t getDelayChecksum(delay\_t v) const Convert a `delay_t` to an integer for checksum calculations. diff --git a/ice40/arch.h b/ice40/arch.h index ff2f7e4c..80fcf761 100644 --- a/ice40/arch.h +++ b/ice40/arch.h @@ -775,6 +775,12 @@ struct Arch : BaseCtx delay_t getDelayEpsilon() const { return 20; } delay_t getRipupDelayPenalty() const { return 200; } float getDelayNS(delay_t v) const { return v * 0.001; } + DelayInfo getDelayFromNS(float ns) const + { + DelayInfo del; + del.delay = delay_t(ns * 1000); + return del; + } uint32_t getDelayChecksum(delay_t v) const { return v; } bool getBudgetOverride(const NetInfo *net_info, const PortRef &sink, delay_t &budget) const; -- cgit v1.2.3