aboutsummaryrefslogtreecommitdiffstats
path: root/cyclonev/arch.cc
diff options
context:
space:
mode:
authorDan Ravensloft <dan.ravensloft@gmail.com>2021-02-04 02:29:59 +0000
committergatecat <gatecat@ds0.me>2021-05-15 14:54:33 +0100
commit170d6cffddeec70051b8488933c5adec460e6a81 (patch)
treedafe466d2fc07ca95625efe845dced40dfd5857e /cyclonev/arch.cc
parentfcdf1e0bfdb45f1ee8a315d1d1ca0a07ca66f7a4 (diff)
downloadnextpnr-170d6cffddeec70051b8488933c5adec460e6a81.tar.gz
nextpnr-170d6cffddeec70051b8488933c5adec460e6a81.tar.bz2
nextpnr-170d6cffddeec70051b8488933c5adec460e6a81.zip
current progress
Diffstat (limited to 'cyclonev/arch.cc')
-rw-r--r--cyclonev/arch.cc96
1 files changed, 95 insertions, 1 deletions
diff --git a/cyclonev/arch.cc b/cyclonev/arch.cc
index ac19b7d2..c4b21b4a 100644
--- a/cyclonev/arch.cc
+++ b/cyclonev/arch.cc
@@ -106,6 +106,100 @@ void Arch::unbindBel(BelId bel)
refreshUiBel(bel);
}
-bool Arch::checkBelAvail(BelId bel) const { return bels.at(bel).bound_cell == nullptr; }
+std::vector<BelId> Arch::getBels() const
+{
+ // This should probably be redesigned, but it's a hack.
+ std::vector<BelId> bels{};
+
+ for (int x = 0; x < cyclonev->get_tile_sx(); x++) {
+ for (int y = 0; y < cyclonev->get_tile_sy(); y++) {
+ CycloneV::pos_t pos = cyclonev->xy2pos(x, y);
+
+ for (CycloneV::block_type_t bel : cyclonev->pos_get_bels(pos)) {
+ switch (bel) {
+ case CycloneV::block_type_t::LAB:
+ /*
+ * nextpnr and mistral disagree on what a BEL is: mistral thinks an entire LAB
+ * is one BEL, but nextpnr wants something with more precision.
+ *
+ * One LAB contains 10 ALMs.
+ * One ALM contains 2 LUT outputs and 4 flop outputs.
+ */
+ for (int z = 0; z < 60; z++) {
+ bels.push_back(BelId(pos, z));
+ }
+ case CycloneV::block_type_t::GPIO:
+ // GPIO tiles contain 4 pins.
+ for (int z = 0; z < 4; z++) {
+ bels.push_back(BelId(pos, z));
+ }
+ default:
+ continue;
+ }
+ }
+ }
+ }
+
+ return bels;
+}
+
+std::vector<BelId> Arch::getBelsByTile(int x, int y) const
+{
+ // This should probably be redesigned, but it's a hack.
+ std::vector<BelId> bels{};
+
+ CycloneV::pos_t pos = cyclonev->xy2pos(x, y);
+
+ for (CycloneV::block_type_t bel : cyclonev->pos_get_bels(pos)) {
+ switch (bel) {
+ case CycloneV::block_type_t::LAB:
+ /*
+ * nextpnr and mistral disagree on what a BEL is: mistral thinks an entire LAB
+ * is one BEL, but nextpnr wants something with more precision.
+ *
+ * One LAB contains 10 ALMs.
+ * One ALM contains 2 LUT outputs and 4 flop outputs.
+ */
+ for (int z = 0; z < 60; z++) {
+ bels.push_back(BelId(pos, z));
+ }
+ case CycloneV::block_type_t::GPIO:
+ // GPIO tiles contain 4 pins.
+ for (int z = 0; z < 4; z++) {
+ bels.push_back(BelId(pos, z));
+ }
+ default:
+ continue;
+ }
+ }
+
+ return bels;
+}
+
+IdString Arch::getBelType(BelId bel) const
+{
+ CycloneV::pos_t pos = cyclonev->xy2pos(x, y);
+
+ for (CycloneV::block_type_t bel : cyclonev->pos_get_bels(pos)) {
+ switch (bel) {
+ case CycloneV::block_type_t::LAB:
+ /*
+ * nextpnr and mistral disagree on what a BEL is: mistral thinks an entire LAB
+ * is one BEL, but nextpnr wants something with more precision.
+ *
+ * One LAB contains 10 ALMs.
+ * One ALM contains 2 LUT outputs and 4 flop outputs.
+ */
+ return IdString(this, "LAB");
+ case CycloneV::block_type_t::GPIO:
+ // GPIO tiles contain 4 pins.
+ return IdString(this, "GPIO");
+ default:
+ continue;
+ }
+ }
+
+ return IdString();
+}
NEXTPNR_NAMESPACE_END \ No newline at end of file