aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorgatecat <gatecat@ds0.me>2023-01-18 16:28:33 +0100
committergatecat <gatecat@ds0.me>2023-01-18 16:28:33 +0100
commit60793266334639144a9a5f8b7b0855c811ccd087 (patch)
treed3224d8cb266cc68eb46a15e4cc9426f3c704338 /common
parenta46afc6ff8aca9a4b9275b3385bfec70f008e10b (diff)
downloadnextpnr-60793266334639144a9a5f8b7b0855c811ccd087.tar.gz
nextpnr-60793266334639144a9a5f8b7b0855c811ccd087.tar.bz2
nextpnr-60793266334639144a9a5f8b7b0855c811ccd087.zip
context: Add getNetinfoRouteDelayQuad
Signed-off-by: gatecat <gatecat@ds0.me>
Diffstat (limited to 'common')
-rw-r--r--common/kernel/context.cc47
-rw-r--r--common/kernel/context.h1
-rw-r--r--common/kernel/sdf.cc2
3 files changed, 49 insertions, 1 deletions
diff --git a/common/kernel/context.cc b/common/kernel/context.cc
index 014394a6..821ad822 100644
--- a/common/kernel/context.cc
+++ b/common/kernel/context.cc
@@ -157,6 +157,53 @@ delay_t Context::getNetinfoRouteDelay(const NetInfo *net_info, const PortRef &us
return max_delay;
}
+DelayQuad Context::getNetinfoRouteDelayQuad(const NetInfo *net_info, const PortRef &user_info) const
+{
+#ifdef ARCH_ECP5
+ if (net_info->is_global)
+ return DelayQuad(0);
+#endif
+
+ if (net_info->wires.empty())
+ return DelayQuad(predictArcDelay(net_info, user_info));
+
+ WireId src_wire = getNetinfoSourceWire(net_info);
+ if (src_wire == WireId())
+ return DelayQuad(0);
+
+ DelayQuad result(std::numeric_limits<delay_t>::max(), std::numeric_limits<delay_t>::lowest());
+
+ for (auto dst_wire : getNetinfoSinkWires(net_info, user_info)) {
+ WireId cursor = dst_wire;
+ DelayQuad 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;
+ if (pip == PipId())
+ break;
+
+ delay = delay + getPipDelay(pip);
+ delay = delay + getWireDelay(cursor);
+ cursor = getPipSrcWire(pip);
+ }
+
+ if (cursor == src_wire)
+ delay = delay + getWireDelay(src_wire);
+ else
+ delay = DelayQuad(predictArcDelay(net_info, user_info)); // unrouted
+ result.rise.min_delay = std::min(result.rise.min_delay, delay.rise.min_delay);
+ result.rise.max_delay = std::max(result.rise.max_delay, delay.rise.max_delay);
+ result.fall.min_delay = std::min(result.fall.min_delay, delay.fall.min_delay);
+ result.fall.max_delay = std::max(result.fall.max_delay, delay.fall.max_delay);
+ }
+ return result;
+}
+
static uint32_t xorshift32(uint32_t x)
{
x ^= x << 13;
diff --git a/common/kernel/context.h b/common/kernel/context.h
index 4a5667d0..b4e7920d 100644
--- a/common/kernel/context.h
+++ b/common/kernel/context.h
@@ -58,6 +58,7 @@ struct Context : Arch, DeterministicRNG
size_t getNetinfoSinkWireCount(const NetInfo *net_info, const PortRef &sink) const;
WireId getNetinfoSinkWire(const NetInfo *net_info, const PortRef &sink, size_t phys_idx) const;
delay_t getNetinfoRouteDelay(const NetInfo *net_info, const PortRef &sink) const;
+ DelayQuad getNetinfoRouteDelayQuad(const NetInfo *net_info, const PortRef &sink) const;
// provided by router1.cc
bool checkRoutedDesign() const;
diff --git a/common/kernel/sdf.cc b/common/kernel/sdf.cc
index acff56ed..eb547ff2 100644
--- a/common/kernel/sdf.cc
+++ b/common/kernel/sdf.cc
@@ -324,7 +324,7 @@ void Context::writeSDF(std::ostream &out, bool cvc_mode) const
ic.to.cell = usr.cell->name.str(this);
ic.to.port = usr.port.str(this);
// FIXME: min/max routing delay
- ic.delay = convert_delay(DelayQuad(getNetinfoRouteDelay(ni, usr)));
+ ic.delay = convert_delay(getNetinfoRouteDelayQuad(ni, usr));
wr.conn.push_back(ic);
}
}