aboutsummaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorEddie Hung <e.hung@imperial.ac.uk>2018-07-24 22:20:10 -0700
committerEddie Hung <e.hung@imperial.ac.uk>2018-07-24 22:20:10 -0700
commit9382938661613b84e3ad3155e414aaae2fa87da2 (patch)
tree107c14811cf2e91c82ee4f9ea983260ee7acea8c /generic
parent4920cf18fa1128758dac2ffd12bf88d194863f17 (diff)
parent32c7247785f48b2307e559a0af50d9387bda8b49 (diff)
downloadnextpnr-9382938661613b84e3ad3155e414aaae2fa87da2.tar.gz
nextpnr-9382938661613b84e3ad3155e414aaae2fa87da2.tar.bz2
nextpnr-9382938661613b84e3ad3155e414aaae2fa87da2.zip
Merge branch 'master' into redist_slack
Diffstat (limited to 'generic')
-rw-r--r--generic/arch.cc40
-rw-r--r--generic/arch.h3
-rw-r--r--generic/arch_pybindings.cc12
3 files changed, 41 insertions, 14 deletions
diff --git a/generic/arch.cc b/generic/arch.cc
index f5e94778..577193b4 100644
--- a/generic/arch.cc
+++ b/generic/arch.cc
@@ -77,18 +77,18 @@ void Arch::addBel(IdString name, IdString type, Loc loc, bool gb)
bel_ids.push_back(name);
bel_by_loc[loc] = name;
- if (bels_by_tile.size() <= loc.x)
+ if (int(bels_by_tile.size()) <= loc.x)
bels_by_tile.resize(loc.x + 1);
- if (bels_by_tile[loc.x].size() <= loc.y)
+ if (int(bels_by_tile[loc.x].size()) <= loc.y)
bels_by_tile[loc.x].resize(loc.y + 1);
bels_by_tile[loc.x][loc.y].push_back(name);
- if (tileDimZ.size() <= loc.x)
+ if (int(tileDimZ.size()) <= loc.x)
tileDimZ.resize(loc.x + 1);
- if (tileDimZ[loc.x].size() <= loc.y)
+ if (int(tileDimZ[loc.x].size()) <= loc.y)
tileDimZ[loc.x].resize(loc.y + 1);
gridDimX = std::max(gridDimX, loc.x + 1);
@@ -193,6 +193,30 @@ BelId Arch::getBelByName(IdString name) const
IdString Arch::getBelName(BelId bel) const { return bel; }
+Loc Arch::getBelLocation(BelId bel) const
+{
+ auto &info = bels.at(bel);
+ return Loc(info.x, info.y, info.z);
+}
+
+BelId Arch::getBelByLocation(Loc loc) const
+{
+ auto it = bel_by_loc.find(loc);
+ if (it != bel_by_loc.end())
+ return it->second;
+ return BelId();
+}
+
+const std::vector<BelId> &Arch::getBelsByTile(int x, int y) const
+{
+ return bels_by_tile.at(x).at(y);
+}
+
+bool Arch::getBelGlobalBuf(BelId bel) const
+{
+ return bels.at(bel).gb;
+}
+
uint32_t Arch::getBelChecksum(BelId bel) const
{
// FIXME
@@ -234,6 +258,7 @@ std::vector<PortPin> Arch::getBelPins(BelId bel) const
std::vector<PortPin> ret;
for (auto &it : bels.at(bel).pins)
ret.push_back(it.first);
+ return ret;
}
// ---------------------------------------------------------------
@@ -368,13 +393,6 @@ const std::vector<GroupId> &Arch::getGroupGroups(GroupId group) const { return g
// ---------------------------------------------------------------
-void Arch::estimatePosition(BelId bel, int &x, int &y, bool &gb) const
-{
- x = bels.at(bel).x;
- y = bels.at(bel).y;
- gb = bels.at(bel).gb;
-}
-
delay_t Arch::estimateDelay(WireId src, WireId dst) const
{
const WireInfo &s = wires.at(src);
diff --git a/generic/arch.h b/generic/arch.h
index 2b952da6..43f43842 100644
--- a/generic/arch.h
+++ b/generic/arch.h
@@ -141,7 +141,7 @@ struct Arch : BaseCtx
IdString getBelName(BelId bel) const;
Loc getBelLocation(BelId bel) const;
BelId getBelByLocation(Loc loc) const;
- std::vector<BelId> getBelsByTile(int x, int y) const;
+ const std::vector<BelId> &getBelsByTile(int x, int y) const;
bool getBelGlobalBuf(BelId bel) const;
uint32_t getBelChecksum(BelId bel) const;
void bindBel(BelId bel, IdString cell, PlaceStrength strength);
@@ -191,7 +191,6 @@ struct Arch : BaseCtx
const std::vector<PipId> &getGroupPips(GroupId group) const;
const std::vector<GroupId> &getGroupGroups(GroupId group) const;
- void estimatePosition(BelId bel, int &x, int &y, bool &gb) const;
delay_t estimateDelay(WireId src, WireId dst) const;
delay_t getDelayEpsilon() const { return 0.01; }
delay_t getRipupDelayPenalty() const { return 1.0; }
diff --git a/generic/arch_pybindings.cc b/generic/arch_pybindings.cc
index a99723f2..186b2c13 100644
--- a/generic/arch_pybindings.cc
+++ b/generic/arch_pybindings.cc
@@ -20,12 +20,22 @@
#ifndef NO_PYTHON
+#include "arch_pybindings.h"
#include "nextpnr.h"
#include "pybindings.h"
NEXTPNR_NAMESPACE_BEGIN
-void arch_wrap_python() { class_<ArchArgs>("ArchArgs"); }
+void arch_wrap_python()
+{
+ using namespace PythonConversion;
+ auto arch_cls = class_<Arch, Arch *, bases<BaseCtx>, boost::noncopyable>("Arch", init<ArchArgs>());
+ auto ctx_cls = class_<Context, Context *, bases<Arch>, boost::noncopyable>("Context", no_init)
+ .def("checksum", &Context::checksum)
+ .def("pack", &Context::pack)
+ .def("place", &Context::place)
+ .def("route", &Context::route);
+}
NEXTPNR_NAMESPACE_END