diff --git a/xc7/arch.cc b/xc7/arch.cc index 7600e3a1..13fad6e0 100644 --- a/xc7/arch.cc +++ b/xc7/arch.cc @@ -41,7 +41,7 @@ TorcInfo::TorcInfo(Arch *ctx, const std::string &inDeviceName, const std::string 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)), + num_wires(wire_to_tilewire.size()), wire_to_delay(construct_wire_to_delay(tiles, wire_to_tilewire, *ddb)), pip_to_arc(construct_pip_to_arc(wire_to_tilewire, *ddb, wire_to_pips_uphill, wire_to_pips_downhill)), num_pips(pip_to_arc.size()) { @@ -163,7 +163,7 @@ TorcInfo::construct_wire_to_tilewire(const Segments &segments, const Tiles &tile wire_to_tilewire.shrink_to_fit(); return wire_to_tilewire; } -std::vector TorcInfo::construct_wire_to_delay(const std::vector &wire_to_tilewire, const DDB &ddb) +std::vector TorcInfo::construct_wire_to_delay(const Tiles &tiles, const std::vector &wire_to_tilewire, const DDB &ddb) { std::vector wire_to_delay; wire_to_delay.reserve(wire_to_tilewire.size()); @@ -174,45 +174,62 @@ std::vector TorcInfo::construct_wire_to_delay(const std::vector> delay_lookup; boost::cmatch what; - ExtendedWireInfo ewi(ddb); for (const auto &tw : wire_to_tilewire) { - ewi.set(tw); - DelayInfo d; - if (boost::regex_match(ewi.mWireName, what, re_124)) { - switch (what.str(2)[0]) { - case '1': - d.delay = 150; - break; - case '2': - d.delay = 170; - break; - case '4': - d.delay = 210; - break; - case '6': - d.delay = 210; - break; - default: - throw; + const TileInfo& tileInfo = tiles.getTileInfo(tw.getTileIndex()); + auto tile_type_index = tileInfo.getTypeIndex(); + + auto it = delay_lookup.find(tile_type_index); + if (it == delay_lookup.end()) { + auto wireCount = tiles.getWireCount(tile_type_index); + std::vector tile_delays(wireCount); + for (WireIndex wireIndex(0); wireIndex < wireCount; wireIndex++) { + const WireInfo& wireInfo = tiles.getWireInfo(tile_type_index, wireIndex); + auto wire_name = wireInfo.getName(); + if (boost::regex_match(wire_name, what, re_124)) { + switch (what.str(2)[0]) { + case '1': tile_delays[wireIndex] = 150; break; + case '2': tile_delays[wireIndex] = 170; break; + case '4': tile_delays[wireIndex] = 210; break; + case '6': tile_delays[wireIndex] = 210; break; + default: throw; + } + } else if (boost::regex_match(wire_name, what, re_L)) { + std::string l(what[2]); + if (l == "H") + tile_delays[wireIndex] = 360; + else if (l == "VB") + tile_delays[wireIndex] = 300; + else if (l == "V") + tile_delays[wireIndex] = 350; + else + throw; + } else if (boost::regex_match(wire_name, what, re_BYP)) { + tile_delays[wireIndex] = 190; + } else if (boost::regex_match(wire_name, what, re_BYP_B)) { + } else if (boost::regex_match(wire_name, what, re_FAN)) { + tile_delays[wireIndex] = 190; + } else if (boost::regex_match(wire_name, what, re_CLB_I1_6)) { + switch (what.str(2)[0]) { + case '1': tile_delays[wireIndex] = 280; break; + case '2': tile_delays[wireIndex] = 280; break; + case '3': tile_delays[wireIndex] = 180; break; + case '4': tile_delays[wireIndex] = 180; break; + case '5': tile_delays[wireIndex] = 80; break; + case '6': tile_delays[wireIndex] = 40; break; + default: throw; + } + } } - } else if (boost::regex_match(ewi.mWireName, what, re_L)) { - std::string l(what[2]); - if (l == "H") - d.delay = 360; - else if (l == "VB") - d.delay = 300; - else if (l == "V") - d.delay = 350; - else - throw; - } else if (boost::regex_match(ewi.mWireName, what, re_BYP)) { - d.delay = 190; - } else if (boost::regex_match(ewi.mWireName, what, re_BYP_B)) { - } else if (boost::regex_match(ewi.mWireName, what, re_FAN)) { - d.delay = 190; + it = delay_lookup.emplace(tile_type_index, std::move(tile_delays)).first; } + assert(it != delay_lookup.end()); + DelayInfo d; + d.delay = it->second[tw.getWireIndex()]; wire_to_delay.emplace_back(std::move(d)); } diff --git a/xc7/arch.h b/xc7/arch.h index 092cd5f6..24501d61 100644 --- a/xc7/arch.h +++ b/xc7/arch.h @@ -331,7 +331,7 @@ struct TorcInfo construct_wire_to_tilewire(const Segments &segments, const Tiles &tiles, std::unordered_map &segment_to_wire, std::unordered_map &trivial_to_wire); - static std::vector construct_wire_to_delay(const std::vector &wire_to_tilewire, + static std::vector construct_wire_to_delay(const Tiles &tiles, const std::vector &wire_to_tilewire, const DDB &ddb); static std::vector construct_pip_to_arc(const std::vector &wire_to_tilewire, const DDB &ddb, std::vector> &wire_to_pips_uphill,