aboutsummaryrefslogtreecommitdiffstats
path: root/nexus/arch.cc
diff options
context:
space:
mode:
authorDavid Shah <dave@ds0.me>2020-10-12 10:18:23 +0100
committerDavid Shah <dave@ds0.me>2020-11-30 08:45:27 +0000
commit12013b4c1f7a7fc653a06d1af8216680de468147 (patch)
treec23e5d347c0b8c5e785dba93744a40cb53eeb899 /nexus/arch.cc
parente2de234ef17320773f089b9d807aaacbbcae45d2 (diff)
downloadnextpnr-12013b4c1f7a7fc653a06d1af8216680de468147.tar.gz
nextpnr-12013b4c1f7a7fc653a06d1af8216680de468147.tar.bz2
nextpnr-12013b4c1f7a7fc653a06d1af8216680de468147.zip
nexus: Lookup of package and IO pins
Signed-off-by: David Shah <dave@ds0.me>
Diffstat (limited to 'nexus/arch.cc')
-rw-r--r--nexus/arch.cc89
1 files changed, 89 insertions, 0 deletions
diff --git a/nexus/arch.cc b/nexus/arch.cc
index dfcf9510..f309c872 100644
--- a/nexus/arch.cc
+++ b/nexus/arch.cc
@@ -117,6 +117,22 @@ Arch::Arch(ArchArgs args) : args(args)
for (size_t i = 0; i < chip_info->num_tiles; i++) {
tileStatus[i].boundcells.resize(db->loctypes[chip_info->grid[i].loc_type].num_bels);
}
+ // Validate and set up package
+ package_idx = -1;
+ for (size_t i = 0; i < chip_info->num_packages; i++) {
+ if (package == chip_info->packages[i].short_name.get()) {
+ package_idx = i;
+ break;
+ }
+ }
+ if (package_idx == -1) {
+ std::string all_packages = "";
+ for (size_t i = 0; i < chip_info->num_packages; i++) {
+ all_packages += " ";
+ all_packages += chip_info->packages[i].short_name.get();
+ }
+ log_error("Unknown package '%s'. Available package options:%s\n", package.c_str(), all_packages.c_str());
+ }
}
// -----------------------------------------------------------------------
@@ -487,6 +503,79 @@ void Arch::set_cell_pinmux(CellInfo *cell, IdString pin, CellPinMux state)
// -----------------------------------------------------------------------
+const PadInfoPOD *Arch::get_pin_data(const std::string &pin) const
+{
+ for (size_t i = 0; i < chip_info->num_pads; i++) {
+ const PadInfoPOD *pad = &(chip_info->pads[i]);
+ if (pin == pad->pins[package_idx].get())
+ return pad;
+ }
+ return nullptr;
+}
+
+Loc Arch::get_pad_loc(const PadInfoPOD *pad) const
+{
+ Loc loc;
+ switch (pad->side) {
+ case PIO_LEFT:
+ loc.x = 0;
+ loc.y = pad->offset;
+ break;
+ case PIO_RIGHT:
+ loc.x = chip_info->width - 1;
+ loc.y = pad->offset;
+ break;
+ case PIO_TOP:
+ loc.x = pad->offset;
+ loc.y = 0;
+ break;
+ case PIO_BOTTOM:
+ loc.x = pad->offset;
+ loc.y = chip_info->height - 1;
+ }
+ loc.z = pad->pio_index;
+ return loc;
+}
+
+BelId Arch::get_pin_bel(const std::string &pin) const
+{
+ const PadInfoPOD *pad = get_pin_data(pin);
+ if (pad == nullptr)
+ return BelId();
+ return getBelByLocation(get_pad_loc(pad));
+}
+
+const PadInfoPOD *Arch::get_bel_pad(BelId bel) const
+{
+ Loc loc = getBelLocation(bel);
+ int side = -1, offset = -1;
+ // Convert (x, y) to (side, offset)
+ if (loc.x == 0) {
+ side = PIO_LEFT;
+ offset = loc.y;
+ } else if (loc.x == (chip_info->width - 1)) {
+ side = PIO_RIGHT;
+ offset = loc.y;
+ } else if (loc.y == 0) {
+ side = PIO_TOP;
+ offset = loc.x;
+ } else if (loc.y == (chip_info->height - 1)) {
+ side = PIO_BOTTOM;
+ offset = loc.x;
+ } else {
+ return nullptr;
+ }
+ // Lookup in the list of pads
+ for (size_t i = 0; i < chip_info->num_pads; i++) {
+ const PadInfoPOD *pad = &(chip_info->pads[i]);
+ if (pad->side == side && pad->offset == offset && pad->pio_index == loc.z)
+ return pad;
+ }
+ return nullptr;
+}
+
+// -----------------------------------------------------------------------
+
#ifdef WITH_HEAP
const std::string Arch::defaultPlacer = "heap";
#else