From 5c56fab0abe05f78f2f2b7fd4c2c2b2dfe9f4f1a Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Sat, 3 Nov 2018 15:56:06 -0700 Subject: [PATCH] [xc7] Add torc_info->site_index_to_bel lookup; also fix Arch::getBelByName() --- xc7/arch.cc | 32 ++++++++++++++++++-------------- xc7/arch.h | 2 ++ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/xc7/arch.cc b/xc7/arch.cc index 18f5b64e..65c8bee1 100644 --- a/xc7/arch.cc +++ b/xc7/arch.cc @@ -36,7 +36,9 @@ std::unique_ptr torc_info; TorcInfo::TorcInfo(Arch *ctx, const std::string &inDeviceName, const std::string &inPackageName) : ddb(new DDB(inDeviceName, inPackageName)), sites(ddb->getSites()), tiles(ddb->getTiles()), segments(ddb->getSegments()), bel_to_site_index(construct_bel_to_site_index(ctx, sites)), - num_bels(bel_to_site_index.size()), site_index_to_type(construct_site_index_to_type(ctx, sites)), + num_bels(bel_to_site_index.size()), + site_index_to_bel(construct_site_index_to_bel(ctx, sites, bel_to_site_index)), + site_index_to_type(construct_site_index_to_type(ctx, sites)), bel_to_loc(construct_bel_to_loc(sites, tiles, num_bels, site_index_to_type)), wire_to_tilewire(construct_wire_to_tilewire(segments, tiles, segment_to_wire, trivial_to_wire)), num_wires(wire_to_tilewire.size()), wire_to_delay(construct_wire_to_delay(wire_to_tilewire, *ddb)), @@ -68,6 +70,18 @@ std::vector TorcInfo::construct_bel_to_site_index(Arch *ctx, const Si } return bel_to_site_index; } +std::vector TorcInfo::construct_site_index_to_bel(Arch *ctx, const Sites &sites, const std::vector &bel_to_site_index) +{ + std::vector site_index_to_bel; + site_index_to_bel.resize(sites.getSiteCount()); + BelId b; + b.index = 0; + for (auto i : bel_to_site_index) { + site_index_to_bel[i] = b; + ++b.index; + } + return site_index_to_bel; +} std::vector TorcInfo::construct_site_index_to_type(Arch *ctx, const Sites &sites) { std::vector site_index_to_type; @@ -344,13 +358,10 @@ IdString Arch::archArgsToId(ArchArgs args) const BelId Arch::getBelByName(IdString name) const { - BelId ret; - auto it = torc_info->sites.findSiteIndex(name.str(this)); if (it != SiteIndex(-1)) - ret.index = it; - - return ret; + return torc_info->site_index_to_bel.at(it); + return BelId(); } BelId Arch::getBelByLocation(Loc loc) const @@ -602,14 +613,7 @@ IdString Arch::getPipName(PipId pip) const BelId Arch::getPackagePinBel(const std::string &pin) const { - // for (int i = 0; i < package_info->num_pins; i++) { - // if (package_info->pins[i].name.get() == pin) { - // BelId id; - // id.index = package_info->pins[i].bel_index; - // return id; - // } - // } - return BelId(); + return getBelByName(id(pin)); } std::string Arch::getBelPackagePin(BelId bel) const diff --git a/xc7/arch.h b/xc7/arch.h index b5721552..9d8c4251 100644 --- a/xc7/arch.h +++ b/xc7/arch.h @@ -307,6 +307,7 @@ struct TorcInfo const std::vector bel_to_site_index; const int num_bels; + const std::vector site_index_to_bel; const std::vector site_index_to_type; const std::vector bel_to_loc; std::unordered_map segment_to_wire; @@ -322,6 +323,7 @@ struct TorcInfo private: static std::vector construct_bel_to_site_index(Arch *ctx, const Sites &sites); + static std::vector construct_site_index_to_bel(Arch *ctx, const Sites &sites, const std::vector &bel_to_site_index); static std::vector construct_site_index_to_type(Arch *ctx, const Sites &sites); static std::vector construct_bel_to_loc(const Sites &sites, const Tiles &tiles, const int num_bels, const std::vector &site_index_to_type);