00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "torc/common/DeviceDesignator.hpp"
00020 #include <boost/algorithm/string.hpp>
00021 #include <boost/regex.hpp>
00022
00023 namespace torc {
00024 namespace common {
00025
00026 boost::regex DeviceDesignator::sSpartan2RegEx(
00027 "(x?c?2s[0-9]+)"
00028 "((?:cs|fg|pq|tq|vq)[0-9]+)?"
00029 "(-[0-9]+Q?)?",
00030 boost::regex_constants::icase
00031 );
00032
00033 boost::regex DeviceDesignator::sSpartan2ERegEx(
00034 "(x?c?2s[0-9]+e)"
00035 "((?:fg|ft|pq)[0-9]+)?"
00036 "(-[0-9]+Q?)?",
00037 boost::regex_constants::icase
00038 );
00039
00040 boost::regex DeviceDesignator::sSpartan3RegEx(
00041 "(x?c?3s[0-9]+l?)"
00042 "((?:cp|fg|ft|pq|tq|vq)[0-9]+)?"
00043 "(-[0-9]+)?",
00044 boost::regex_constants::icase
00045 );
00046
00047 boost::regex DeviceDesignator::sSpartan3ARegEx(
00048 "(x?c?3s[0-9]+an?)"
00049 "((?:fg|fgg|ft|tq|tqg)[0-9]+)?"
00050 "(-[0-9]+)?",
00051 boost::regex_constants::icase
00052 );
00053
00054 boost::regex DeviceDesignator::sSpartan3ERegEx(
00055 "(x?c?3s[0-9]+e)"
00056 "((?:cp|fg|ft|pq|vq)[0-9]+)?"
00057 "(-[0-9]+)?",
00058 boost::regex_constants::icase
00059 );
00060
00061 boost::regex DeviceDesignator::sSpartan6RegEx(
00062 "(x?c?6s[l]x[0-9]+t?)"
00063 "((?:cpg|csg|fgg|ftg|tqg)[0-9]+)?"
00064 "(-[0-9]+)?",
00065 boost::regex_constants::icase
00066 );
00067
00068 boost::regex DeviceDesignator::sSpartan6LRegEx(
00069 "(x?c?6s[l]x[0-9]+t?l)"
00070 "((?:cpg|csg|fgg|ftg|tqg)[0-9]+)?"
00071 "(-[0-9]+)?",
00072 boost::regex_constants::icase
00073 );
00074
00075 boost::regex DeviceDesignator::sVirtexRegEx(
00076 "(x?c?v[0-9]+)"
00077 "((?:bg|cs|fg|hq|pq|tq)[0-9]+)?"
00078 "(-[0-9]+)?",
00079 boost::regex_constants::icase
00080 );
00081
00082 boost::regex DeviceDesignator::sVirtexERegEx(
00083 "(x?c?v[0-9]+e)"
00084 "((?:bg|cs|fg|hq|pq)[0-9]+)?"
00085 "(-[0-9]+)?",
00086 boost::regex_constants::icase
00087 );
00088
00089 boost::regex DeviceDesignator::sVirtex2RegEx(
00090 "(x?c?2v[0-9]+)"
00091 "((?:bf|bg|cs|ff|fg)[0-9]+)?"
00092 "(-[0-9]+)?",
00093 boost::regex_constants::icase
00094 );
00095
00096 boost::regex DeviceDesignator::sVirtex2PRegEx(
00097 "(x?c?2vpx?[0-9]+)"
00098 "((?:ff|fg)[0-9]+)?"
00099 "(-[0-9]+)?",
00100 boost::regex_constants::icase
00101 );
00102
00103 boost::regex DeviceDesignator::sVirtex4RegEx(
00104 "(x?c?4v[fls]x[0-9]+)"
00105 "((?:ff|sf)[0-9]+)?"
00106 "(-[0-9]+)?",
00107 boost::regex_constants::icase
00108 );
00109
00110 boost::regex DeviceDesignator::sVirtex5RegEx(
00111 "(x?c?5v[flst]x[0-9]+t?)"
00112 "((?:ff)[0-9]+)?"
00113 "(-[0-9]+)?",
00114 boost::regex_constants::icase
00115 );
00116
00117 boost::regex DeviceDesignator::sVirtex6RegEx(
00118 "(x?c?6v[chls]x[0-9]+t?)"
00119 "((?:ff)[0-9]+)?"
00120 "(-[0-9]+)?",
00121 boost::regex_constants::icase
00122 );
00123
00124 boost::regex DeviceDesignator::sVirtex6LRegEx(
00125 "(x?c?6v[ls]x[0-9]+t?l)"
00126 "((?:ff)[0-9]+)?"
00127 "(-1L)?",
00128 boost::regex_constants::icase
00129 );
00130
00131 boost::regex DeviceDesignator::sVirtex7RegEx(
00132 "(x?c?7vx?[0-9]+t)"
00133 "((?:ffg|fhg)[0-9]+)?"
00134 "(-[0-9]+)?",
00135 boost::regex_constants::icase
00136 );
00137
00138 boost::regex DeviceDesignator::sVirtex7LRegEx(
00139 "(x?c?7v[0-9]+tl)"
00140 "((?:ffg|fhg)[0-9]+)?"
00141 "(-1L)?",
00142 boost::regex_constants::icase
00143 );
00144
00145 boost::regex DeviceDesignator::sKintex7RegEx(
00146 "(x?c?7k[0-9]+t)"
00147 "((?:fbg|ffg|sbg)[0-9]+)?"
00148 "(-[0-9]+)?",
00149 boost::regex_constants::icase
00150 );
00151
00152 boost::regex DeviceDesignator::sKintex7LRegEx(
00153 "(x?c?7k[0-9]+tl)"
00154 "((?:fbg|ffg|sbg)[0-9]+)?"
00155 "(-1L)?",
00156 boost::regex_constants::icase
00157 );
00158
00159 DeviceDesignator::DeviceDesignator(const string& inDeviceDesignator) {
00160 mDeviceDesignator = inDeviceDesignator;
00161 if(parse(inDeviceDesignator, sSpartan2RegEx)) { mFamily = eFamilySpartan2; } else
00162 if(parse(inDeviceDesignator, sSpartan2ERegEx)) { mFamily = eFamilySpartan2E; } else
00163 if(parse(inDeviceDesignator, sSpartan3RegEx)) { mFamily = eFamilySpartan3; } else
00164 if(parse(inDeviceDesignator, sSpartan3ARegEx)) { mFamily = eFamilySpartan3A; } else
00165 if(parse(inDeviceDesignator, sSpartan3ERegEx)) { mFamily = eFamilySpartan3E; } else
00166 if(parse(inDeviceDesignator, sSpartan6RegEx)) { mFamily = eFamilySpartan6; } else
00167 if(parse(inDeviceDesignator, sSpartan6LRegEx)) { mFamily = eFamilySpartan6L; } else
00168 if(parse(inDeviceDesignator, sVirtexRegEx)) { mFamily = eFamilyVirtex; } else
00169 if(parse(inDeviceDesignator, sVirtexERegEx)) { mFamily = eFamilyVirtexE; } else
00170 if(parse(inDeviceDesignator, sVirtex2RegEx)) { mFamily = eFamilyVirtex2; } else
00171 if(parse(inDeviceDesignator, sVirtex2PRegEx)) { mFamily = eFamilyVirtex2P; } else
00172 if(parse(inDeviceDesignator, sVirtex4RegEx)) { mFamily = eFamilyVirtex4; } else
00173 if(parse(inDeviceDesignator, sVirtex5RegEx)) { mFamily = eFamilyVirtex5; } else
00174 if(parse(inDeviceDesignator, sVirtex6RegEx)) { mFamily = eFamilyVirtex6; } else
00175 if(parse(inDeviceDesignator, sVirtex6LRegEx)) { mFamily = eFamilyVirtex6L; } else
00176 if(parse(inDeviceDesignator, sVirtex7RegEx)) { mFamily = eFamilyVirtex7; } else
00177 if(parse(inDeviceDesignator, sVirtex7LRegEx)) { mFamily = eFamilyVirtex7L; } else
00178 if(parse(inDeviceDesignator, sKintex7RegEx)) { mFamily = eFamilyKintex7; } else
00179 if(parse(inDeviceDesignator, sKintex7LRegEx)) { mFamily = eFamilyKintex7L; } else
00180 { mFamily = eFamilyUnknown; }
00181 }
00182
00183 bool DeviceDesignator::parse(const string& inDeviceDesignator, const boost::regex& inRegEx) {
00184 boost::smatch what;
00185 string designator = inDeviceDesignator;
00186 boost::to_lower(designator);
00187 if(boost::regex_match(designator, what, inRegEx, boost::match_default)) {
00188 if(what[1].matched) mDeviceName = std::string(what[1].first, what[1].second);
00189 if(what[2].matched) mDevicePackage = std::string(what[2].first, what[2].second);
00190 if(what[3].matched) mDeviceSpeedGrade = std::string(what[3].first, what[3].second);
00191 if(what[1].matched) {
00192
00193 mDeviceName = boost::regex_replace(mDeviceName, boost::regex("^x?c?"), "xc");
00194 }
00195 return true;
00196 } else {
00197 return false;
00198 }
00199 }
00200
00201 std::ostream& operator<< (std::ostream& os, const DeviceDesignator& rhs) {
00202 os << rhs.getDeviceName();
00203 if(rhs.getDevicePackage().length()) os << rhs.getDevicePackage();
00204 if(rhs.getDeviceSpeedGrade().length()) os << rhs.getDeviceSpeedGrade();
00205 return os;
00206 }
00207
00208 }
00209 }