00001 // Torc - Copyright 2011 University of Southern California. All Rights Reserved. 00002 // $HeadURL: https://torc-isi.svn.sourceforge.net/svnroot/torc-isi/branches/staging/0.9/src/torc/common/DeviceDesignator.hpp $ 00003 // $Id: DeviceDesignator.hpp 10 2011-10-12 18:40:16Z nsteiner $ 00004 00005 // This program is free software: you can redistribute it and/or modify it under the terms of the 00006 // GNU General Public License as published by the Free Software Foundation, either version 3 of the 00007 // License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 00010 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 00011 // the GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License along with this program. If 00014 // not, see <http://www.gnu.org/licenses/>. 00015 00016 /// \file 00017 /// \brief Header for the DeviceDesignator class. 00018 00019 #ifndef TORC_COMMON_DEVICEDESIGNATOR_HPP 00020 #define TORC_COMMON_DEVICEDESIGNATOR_HPP 00021 00022 #include <boost/regex.hpp> 00023 #include <ostream> 00024 #include <string> 00025 00026 namespace torc { 00027 namespace common { 00028 00029 /// \brief Encapsulation of a device designator and its constituent elements. 00030 class DeviceDesignator { 00031 public: 00032 // enums 00033 enum EFamily { 00034 // unknown families 00035 eFamilyUnknown = 0, 00036 // Spartan families 00037 eFamilySpartan2, eFamilySpartan2E, eFamilySpartan3, eFamilySpartan3A, eFamilySpartan3E, 00038 eFamilySpartan6, eFamilySpartan6L, 00039 // Virtex families 00040 eFamilyVirtex, eFamilyVirtexE, eFamilyVirtex2, eFamilyVirtex2P, eFamilyVirtex4, 00041 eFamilyVirtex5, eFamilyVirtex6, eFamilyVirtex6L, eFamilyVirtex7, eFamilyVirtex7L, 00042 eFamilyKintex7, eFamilyKintex7L 00043 }; 00044 protected: 00045 // typedefs 00046 typedef std::string string; ///< \brief Imported type name. 00047 // members 00048 /// \brief The full device designator. 00049 string mDeviceDesignator; 00050 /// \brief The family type. 00051 EFamily mFamily; 00052 /// \brief The device name. 00053 string mDeviceName; 00054 /// \brief The device package. 00055 string mDevicePackage; 00056 /// \brief The device speed grade. 00057 string mDeviceSpeedGrade; 00058 // functions 00059 /// \brief Parses the device name into constituent device, package, and speed components. 00060 bool parse(const string& inDeviceDesignator, const boost::regex& inRegEx); 00061 // statics 00062 static boost::regex sSpartan2RegEx; ///< \brief Regular expression for Spartan2 devices. 00063 static boost::regex sSpartan2ERegEx; ///< \brief Regular expression for Spartan2E devices. 00064 static boost::regex sSpartan3RegEx; ///< \brief Regular expression for Spartan3 devices. 00065 static boost::regex sSpartan3ARegEx; ///< \brief Regular expression for Spartan3A devices. 00066 static boost::regex sSpartan3ERegEx; ///< \brief Regular expression for Spartan3E devices. 00067 static boost::regex sSpartan6RegEx; ///< \brief Regular expression for Spartan3E devices. 00068 static boost::regex sSpartan6LRegEx; ///< \brief Regular expression for Spartan3E devices. 00069 static boost::regex sVirtexRegEx; ///< \brief Regular expression for Virtex devices. 00070 static boost::regex sVirtexERegEx; ///< \brief Regular expression for VirtexE devices. 00071 static boost::regex sVirtex2RegEx; ///< \brief Regular expression for Virtex2 devices. 00072 static boost::regex sVirtex2PRegEx; ///< \brief Regular expression for Virtex2P devices. 00073 static boost::regex sVirtex4RegEx; ///< \brief Regular expression for Virtex4 devices. 00074 static boost::regex sVirtex5RegEx; ///< \brief Regular expression for Virtex5 devices. 00075 static boost::regex sVirtex6RegEx; ///< \brief Regular expression for Virtex6 devices. 00076 static boost::regex sVirtex6LRegEx; ///< \brief Regular expression for Virtex6L devices. 00077 static boost::regex sVirtex7RegEx; ///< \brief Regular expression for Virtex7 devices. 00078 static boost::regex sVirtex7LRegEx; ///< \brief Regular expression for Virtex7L devices. 00079 static boost::regex sKintex7RegEx; ///< \brief Regular expression for Kintex7 devices. 00080 static boost::regex sKintex7LRegEx; ///< \brief Regular expression for Kintex7L devices. 00081 public: 00082 // constructors 00083 /// \brief Basic constructor. 00084 DeviceDesignator(const string& inDeviceDesignator); 00085 // operators 00086 /// \brief Stream insertion operator. 00087 friend std::ostream& operator<< (std::ostream& os, const DeviceDesignator& rhs); 00088 // accessors 00089 /// \brief Returns the device designator. 00090 const string& getDeviceDesignator(void) const { return mDeviceDesignator; } 00091 /// \brief Returns the device family. 00092 const EFamily& getFamily(void) const { return mFamily; } 00093 /// \brief Returns the device name. 00094 const string& getDeviceName(void) const { return mDeviceName; } 00095 /// \brief Returns the device package. 00096 const string& getDevicePackage(void) const { return mDevicePackage; } 00097 /// \brief Returns the device speed grade. 00098 const string& getDeviceSpeedGrade(void) const { return mDeviceSpeedGrade; } 00099 }; 00100 00101 } // namespace common 00102 } // namespace torc 00103 00104 #endif // TORC_COMMON_DEVICEDESIGNATOR_HPP