aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2018-07-30 15:35:40 +0200
committerClifford Wolf <clifford@clifford.at>2018-07-30 15:35:40 +0200
commit0daffec2a0efdbea36201eeb5666d208a10d0226 (patch)
treeeffbd8bfd41387213ee0ae3c899e1b25b47e4476
parentb5f90d381481dc3658c408b162aa433e183f79f4 (diff)
downloadnextpnr-0daffec2a0efdbea36201eeb5666d208a10d0226.tar.gz
nextpnr-0daffec2a0efdbea36201eeb5666d208a10d0226.tar.bz2
nextpnr-0daffec2a0efdbea36201eeb5666d208a10d0226.zip
Add predictDelay Arch API
Signed-off-by: Clifford Wolf <clifford@clifford.at>
-rw-r--r--common/nextpnr.cc10
-rw-r--r--ecp5/arch.cc5
-rw-r--r--ecp5/arch.h1
-rw-r--r--generic/arch.cc9
-rw-r--r--generic/arch.h1
-rw-r--r--ice40/arch.cc16
-rw-r--r--ice40/arch.h1
7 files changed, 38 insertions, 5 deletions
diff --git a/common/nextpnr.cc b/common/nextpnr.cc
index cf1b5982..5b0a45ed 100644
--- a/common/nextpnr.cc
+++ b/common/nextpnr.cc
@@ -93,7 +93,9 @@ delay_t Context::getNetinfoRouteDelay(NetInfo *net_info, int user_idx) const
WireId src_wire = getNetinfoSourceWire(net_info);
if (src_wire == WireId())
return 0;
- WireId cursor = getNetinfoSinkWire(net_info, user_idx);
+
+ WireId dst_wire = getNetinfoSinkWire(net_info, user_idx);
+ WireId cursor = dst_wire;
delay_t delay = 0;
while (cursor != WireId() && cursor != src_wire) {
@@ -107,11 +109,9 @@ delay_t Context::getNetinfoRouteDelay(NetInfo *net_info, int user_idx) const
}
if (cursor == src_wire)
- delay += getWireDelay(src_wire).maxDelay();
- else
- delay += estimateDelay(src_wire, cursor);
+ return delay + getWireDelay(src_wire).maxDelay();
- return delay;
+ return predictDelay(src_wire, dst_wire);
}
static uint32_t xorshift32(uint32_t x)
diff --git a/ecp5/arch.cc b/ecp5/arch.cc
index 55fe5704..88b5e4d4 100644
--- a/ecp5/arch.cc
+++ b/ecp5/arch.cc
@@ -413,6 +413,11 @@ delay_t Arch::estimateDelay(WireId src, WireId dst) const
return 200 * (abs(src.location.x - dst.location.x) + abs(src.location.y - dst.location.y));
}
+delay_t Arch::predictDelay(WireId src, WireId dst) const
+{
+ return 200 * (abs(src.location.x - dst.location.x) + abs(src.location.y - dst.location.y));
+}
+
// -----------------------------------------------------------------------
bool Arch::place() { return placer1(getCtx()); }
diff --git a/ecp5/arch.h b/ecp5/arch.h
index b6aac9cf..13f2db1f 100644
--- a/ecp5/arch.h
+++ b/ecp5/arch.h
@@ -776,6 +776,7 @@ struct Arch : BaseCtx
// -------------------------------------------------
delay_t estimateDelay(WireId src, WireId dst) const;
+ delay_t predictDelay(WireId src, WireId dst) const;
delay_t getDelayEpsilon() const { return 20; }
delay_t getRipupDelayPenalty() const { return 200; }
float getDelayNS(delay_t v) const { return v * 0.001; }
diff --git a/generic/arch.cc b/generic/arch.cc
index 5c9864ab..8ef37716 100644
--- a/generic/arch.cc
+++ b/generic/arch.cc
@@ -403,6 +403,15 @@ delay_t Arch::estimateDelay(WireId src, WireId dst) const
return (dx + dy) * grid_distance_to_delay;
}
+delay_t Arch::predictDelay(WireId src, WireId dst) const
+{
+ const WireInfo &s = wires.at(src);
+ const WireInfo &d = wires.at(dst);
+ int dx = abs(s.x - d.x);
+ int dy = abs(s.y - d.y);
+ return (dx + dy) * grid_distance_to_delay;
+}
+
// ---------------------------------------------------------------
bool Arch::place() { return placer1(getCtx()); }
diff --git a/generic/arch.h b/generic/arch.h
index 01a90ee1..60220fbe 100644
--- a/generic/arch.h
+++ b/generic/arch.h
@@ -194,6 +194,7 @@ struct Arch : BaseCtx
const std::vector<GroupId> &getGroupGroups(GroupId group) const;
delay_t estimateDelay(WireId src, WireId dst) const;
+ delay_t predictDelay(WireId src, WireId dst) const;
delay_t getDelayEpsilon() const { return 0.01; }
delay_t getRipupDelayPenalty() const { return 1.0; }
float getDelayNS(delay_t v) const { return v; }
diff --git a/ice40/arch.cc b/ice40/arch.cc
index 3803f842..91c20b42 100644
--- a/ice40/arch.cc
+++ b/ice40/arch.cc
@@ -579,6 +579,22 @@ delay_t Arch::estimateDelay(WireId src, WireId dst) const
int xd = x2 - x1, yd = y2 - y1;
int xscale = 120, yscale = 120, offset = 0;
+ return xscale * abs(xd) + yscale * abs(yd) + offset;
+}
+
+delay_t Arch::predictDelay(WireId src, WireId dst) const
+{
+ NPNR_ASSERT(src != WireId());
+ int x1 = chip_info->wire_data[src.index].x;
+ int y1 = chip_info->wire_data[src.index].y;
+
+ NPNR_ASSERT(dst != WireId());
+ int x2 = chip_info->wire_data[dst.index].x;
+ int y2 = chip_info->wire_data[dst.index].y;
+
+ int xd = x2 - x1, yd = y2 - y1;
+ int xscale = 120, yscale = 120, offset = 0;
+
// if (chip_info->wire_data[src.index].type == WIRE_TYPE_SP4_VERT) {
// yd = yd < -4 ? yd + 4 : (yd < 0 ? 0 : yd);
// offset = 500;
diff --git a/ice40/arch.h b/ice40/arch.h
index 51cbe725..1725d181 100644
--- a/ice40/arch.h
+++ b/ice40/arch.h
@@ -684,6 +684,7 @@ struct Arch : BaseCtx
// -------------------------------------------------
delay_t estimateDelay(WireId src, WireId dst) const;
+ delay_t predictDelay(WireId src, WireId dst) const;
delay_t getDelayEpsilon() const { return 20; }
delay_t getRipupDelayPenalty() const { return 200; }
float getDelayNS(delay_t v) const { return v * 0.001; }