diff options
author | YRabbit <rabbit@yrabbit.cyou> | 2022-12-29 11:17:45 +1000 |
---|---|---|
committer | YRabbit <rabbit@yrabbit.cyou> | 2022-12-29 11:17:45 +1000 |
commit | 8424dc79d2555ce6b070371c9a5fb11aa76e950d (patch) | |
tree | 0f336bcad535531e7f6cb24ae0ef39afa83c08e7 /gowin | |
parent | 0004cd54dbe9278ee5cdc72b044f0d7a7a5cbbf3 (diff) | |
download | nextpnr-8424dc79d2555ce6b070371c9a5fb11aa76e950d.tar.gz nextpnr-8424dc79d2555ce6b070371c9a5fb11aa76e950d.tar.bz2 nextpnr-8424dc79d2555ce6b070371c9a5fb11aa76e950d.zip |
gowin: correct the delay calculation
And do a full enumeration when searching for a delay because it is not
yet clear whether the orderliness of the vector is guaranteed.
Signed-off-by: YRabbit <rabbit@yrabbit.cyou>
Diffstat (limited to 'gowin')
-rw-r--r-- | gowin/arch.cc | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/gowin/arch.cc b/gowin/arch.cc index 8c908b04..40570af7 100644 --- a/gowin/arch.cc +++ b/gowin/arch.cc @@ -698,17 +698,28 @@ template <class T, class C> const T *genericLookup(const T *first, int len, cons } } +template <class T, class C> const T *timingLookup(const T *first, int len, const T val, C compare) +{ + for (int i = 0; i < len; ++i) { + auto res = &first[i]; + if (!(compare(*res, val) || compare(val, *res))) { + return res; + } + } + return nullptr; +} + DelayQuad delayLookup(const TimingPOD *first, int len, IdString name) { TimingPOD needle; needle.name_id = name.index; - const TimingPOD *timing = genericLookup(first, len, needle, timingCompare); + const TimingPOD *timing = timingLookup(first, len, needle, timingCompare); DelayQuad delay; if (timing != nullptr) { - delay.fall.max_delay = std::max(timing->ff, timing->rf) / 1000; - delay.fall.min_delay = std::min(timing->ff, timing->rf) / 1000; - delay.rise.max_delay = std::max(timing->rr, timing->fr) / 1000; - delay.rise.min_delay = std::min(timing->rr, timing->fr) / 1000; + delay.fall.max_delay = std::max(timing->ff, timing->rf) / 1000.; + delay.fall.min_delay = std::min(timing->ff, timing->rf) / 1000.; + delay.rise.max_delay = std::max(timing->rr, timing->fr) / 1000.; + delay.rise.min_delay = std::min(timing->rr, timing->fr) / 1000.; } else { delay = DelayQuad(0); } |