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/architecture/Package.hpp $ 00003 // $Id: Package.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 Package class. 00018 00019 #ifndef TORC_ARCHITECTURE_PACKAGE_HPP 00020 #define TORC_ARCHITECTURE_PACKAGE_HPP 00021 00022 #include "torc/architecture/XilinxDatabaseTypes.hpp" 00023 #include "torc/architecture/Array.hpp" 00024 #include "torc/architecture/Pad.hpp" 00025 #include <map> 00026 00027 namespace torc { 00028 namespace architecture { 00029 00030 namespace architecture { class PackageUnitTest; } 00031 00032 /// \brief Encapsulation of a physical device package and its pins. 00033 class Package { 00034 protected: 00035 // friends 00036 /// \brief The Sites class has access to our internals. 00037 friend class Sites; 00038 /// \brief Our unit test class has access to our internals. 00039 friend class torc::architecture::architecture::PackageUnitTest; 00040 // types 00041 typedef std::string string; ///< \brief Imported type name. 00042 typedef xilinx::PadIndex PadIndex; ///< \brief Imported type name. 00043 /// \brief A map from pad names to pad indexes. 00044 typedef std::map<std::string, PadIndex> PadNameToPadIndexMap; 00045 // members 00046 /// \brief The package name. 00047 string mName; 00048 /// \brief The array of pads for this package. 00049 PadArray mPads; 00050 /// \brief The map from pad names to corresponding map indexes. 00051 PadNameToPadIndexMap mPadNameToPadIndex; 00052 // constructors 00053 /// \brief Protected constructor 00054 Package(const string& inName) : mName(inName), mPads() {} 00055 // accessors 00056 /// \brief Returns a non-constant array of package pads 00057 PadArray& getPads(void) { return mPads; } 00058 public: 00059 // constructors 00060 /// \brief Null constructor. 00061 Package(void) : mName(), mPads() {} 00062 // accessors 00063 /// \brief Returns the package name. 00064 const string& getName(void) const { return mName; } 00065 /// \brief Returns a constant array of package pads 00066 const PadArray& getPads(void) const { return mPads; } 00067 // functions 00068 /// \brief Returns the pad index corresponding to the given pad name. 00069 PadIndex findPadIndexByName(const string& inName) const { 00070 PadNameToPadIndexMap::const_iterator p = mPadNameToPadIndex.find(inName); 00071 return (p == mPadNameToPadIndex.end()) ? PadIndex(-1) : p->second; 00072 } 00073 }; 00074 00075 } // namespace architecture 00076 } // namespace torc 00077 00078 #endif // TORC_ARCHITECTURE_PACKAGE_HPP