aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dummy/chip.cc37
-rw-r--r--dummy/chip.h12
-rw-r--r--ice40/chip.cc32
-rw-r--r--ice40/chip.h14
4 files changed, 80 insertions, 15 deletions
diff --git a/dummy/chip.cc b/dummy/chip.cc
index ae962508..bab65ae4 100644
--- a/dummy/chip.cc
+++ b/dummy/chip.cc
@@ -17,6 +17,7 @@
*
*/
+#include <math.h>
#include "nextpnr.h"
NEXTPNR_NAMESPACE_BEGIN
@@ -138,6 +139,42 @@ const std::vector<PipId> &Chip::getWireAliases(WireId wire) const
return ret;
}
+// ---------------------------------------------------------------
+
+PosInfo Chip::getBelPosition(BelId bel) const
+{
+ PosInfo pos;
+ assert(bel != BelId());
+ // pos.x = ...;
+ // pos.y = ...;
+ return pos;
+}
+
+PosInfo Chip::getWirePosition(WireId wire) const
+{
+ PosInfo pos;
+ assert(wire != WireId());
+ // pos.x = ...;
+ // pos.y = ...;
+ return pos;
+}
+
+PosInfo Chip::getPipPosition(PipId pip) const
+{
+ PosInfo pos;
+ assert(pip != PipId());
+ // pos.x = ...;
+ // pos.y = ...;
+ return pos;
+}
+
+float Chip::estimateDelay(PosInfo src, PosInfo dst) const
+{
+ return fabsf(src.x - dst.x) + fabsf(src.x - dst.x);
+}
+
+// ---------------------------------------------------------------
+
std::vector<GraphicElement> Chip::getBelGraphics(BelId bel) const
{
static std::vector<GraphicElement> ret;
diff --git a/dummy/chip.h b/dummy/chip.h
index e5a6dd56..bc70fa5d 100644
--- a/dummy/chip.h
+++ b/dummy/chip.h
@@ -42,6 +42,11 @@ struct DelayInfo
}
};
+struct PosInfo
+{
+ float x = 0, y = 0;
+};
+
typedef IdString BelType;
typedef IdString PortPin;
@@ -108,9 +113,10 @@ struct Chip
const std::vector<PipId> &getPipsUphill(WireId wire) const;
const std::vector<PipId> &getWireAliases(WireId wire) const;
- void getBelPosition(BelId bel, float &x, float &y) const;
- void getWirePosition(WireId wire, float &x, float &y) const;
- void getPipPosition(PipId pip, float &x, float &y) const;
+ PosInfo getBelPosition(BelId bel) const;
+ PosInfo getWirePosition(WireId wire) const;
+ PosInfo getPipPosition(PipId pip) const;
+ float estimateDelay(PosInfo src, PosInfo dst) const;
std::vector<GraphicElement> getBelGraphics(BelId bel) const;
std::vector<GraphicElement> getWireGraphics(WireId wire) const;
diff --git a/ice40/chip.cc b/ice40/chip.cc
index 918a7fb4..de33b020 100644
--- a/ice40/chip.cc
+++ b/ice40/chip.cc
@@ -17,6 +17,7 @@
*
*/
+#include <math.h>
#include "log.h"
#include "nextpnr.h"
@@ -230,27 +231,40 @@ PipId Chip::getPipByName(IdString name) const
// -----------------------------------------------------------------------
-void Chip::getBelPosition(BelId bel, float &x, float &y) const
+PosInfo Chip::getBelPosition(BelId bel) const
{
+ PosInfo pos;
assert(bel != BelId());
- x = chip_info.bel_data[bel.index].x;
- y = chip_info.bel_data[bel.index].y;
+ pos.x = chip_info.bel_data[bel.index].x;
+ pos.y = chip_info.bel_data[bel.index].y;
+ return pos;
}
-void Chip::getWirePosition(WireId wire, float &x, float &y) const
+PosInfo Chip::getWirePosition(WireId wire) const
{
+ PosInfo pos;
assert(wire != WireId());
- x = chip_info.wire_data[wire.index].x;
- y = chip_info.wire_data[wire.index].y;
+ pos.x = chip_info.wire_data[wire.index].x;
+ pos.y = chip_info.wire_data[wire.index].y;
+ return pos;
}
-void Chip::getPipPosition(PipId pip, float &x, float &y) const
+PosInfo Chip::getPipPosition(PipId pip) const
{
+ PosInfo pos;
assert(pip != PipId());
- x = chip_info.pip_data[pip.index].x;
- y = chip_info.pip_data[pip.index].y;
+ pos.x = chip_info.pip_data[pip.index].x;
+ pos.y = chip_info.pip_data[pip.index].y;
+ return pos;
}
+float Chip::estimateDelay(PosInfo src, PosInfo dst) const
+{
+ return fabsf(src.x - dst.x) + fabsf(src.x - dst.x);
+}
+
+// -----------------------------------------------------------------------
+
std::vector<GraphicElement> Chip::getBelGraphics(BelId bel) const
{
std::vector<GraphicElement> ret;
diff --git a/ice40/chip.h b/ice40/chip.h
index f8946610..2c95bf4e 100644
--- a/ice40/chip.h
+++ b/ice40/chip.h
@@ -42,6 +42,11 @@ struct DelayInfo
}
};
+struct PosInfo
+{
+ float x = 0, y = 0;
+};
+
// -----------------------------------------------------------------------
enum BelType
@@ -679,9 +684,12 @@ struct Chip
// -------------------------------------------------
- void getBelPosition(BelId bel, float &x, float &y) const;
- void getWirePosition(WireId wire, float &x, float &y) const;
- void getPipPosition(PipId pip, float &x, float &y) const;
+ PosInfo getBelPosition(BelId bel) const;
+ PosInfo getWirePosition(WireId wire) const;
+ PosInfo getPipPosition(PipId pip) const;
+ float estimateDelay(PosInfo src, PosInfo dst) const;
+
+ // -------------------------------------------------
std::vector<GraphicElement> getBelGraphics(BelId bel) const;
std::vector<GraphicElement> getWireGraphics(WireId wire) const;