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/PrimitiveElement.hpp $ 00003 // $Id: PrimitiveElement.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 PrimitiveElement class. 00018 00019 #ifndef TORC_ARCHITECTURE_PRIMITIVEELEMENT_HPP 00020 #define TORC_ARCHITECTURE_PRIMITIVEELEMENT_HPP 00021 00022 #include "torc/architecture/XilinxDatabaseTypes.hpp" 00023 #include "torc/architecture/PrimitiveElementPin.hpp" 00024 #include "torc/architecture/Array.hpp" 00025 #include <boost/cstdint.hpp> 00026 #include <map> 00027 #include <set> 00028 00029 namespace torc { 00030 namespace architecture { 00031 00032 namespace architecture { class PrimitiveElementUnitTest; } 00033 00034 /// \brief Encapsulation of a primitive site element. 00035 /// \detail Primitive elements are subcomponents of logic primitive sites. 00036 class PrimitiveElement { 00037 public: 00038 // types 00039 /// \brief A set of configuration values. 00040 typedef std::set<std::string> StringSet; 00041 protected: 00042 // friends 00043 /// \brief The Sites class has access to our internals. 00044 friend class Sites; 00045 /// \brief Our unit test class has access to our internals. 00046 friend class torc::architecture::architecture::PrimitiveElementUnitTest; 00047 // types 00048 typedef xilinx::PinIndex PinIndex; ///< \brief Imported type name. 00049 typedef std::string string; ///< \brief Imported type name. 00050 /// \brief Map of pin names to pin indexes for a primitive element. 00051 typedef std::map<std::string, PinIndex> PinNameToPinIndexMap; 00052 // members 00053 /// \brief The element name. 00054 string mName; 00055 /// \brief The array of pins. 00056 PrimitiveElementPinArray mPins; 00057 /// \brief The set of allowable configuration values. 00058 StringSet mCfgs; 00059 /// \brief A flag indicating whether or not this element is a BEL (Basic ELement). 00060 bool mIsBel; 00061 /// \brief The map of pin names to pin indexes. 00062 PinNameToPinIndexMap mPinNameToPinIndex; 00063 // accessors 00064 /// \brief Returns a non-constant array of element pins. 00065 /// \detail This function should only be used by the Sites class during database 00066 /// iniialization. 00067 PrimitiveElementPinArray& getPins(void) { return mPins; } 00068 public: 00069 // constructors 00070 /// \brief Null constructor. 00071 /// \detail This constructor should only be used by containers. 00072 PrimitiveElement(void) : mName(), mPins(), mCfgs(), mPinNameToPinIndex() {}; 00073 // functions 00074 /// \brief Returns the pin index corresponding to the given pin name, or 00075 /// PinIndex::undefined() if the pin name does not exist. 00076 /// \parameter inName The pin name to find. 00077 PinIndex findPinIndexByName(const string& inName) const { 00078 PinNameToPinIndexMap::const_iterator p = mPinNameToPinIndex.find(inName); 00079 return (p == mPinNameToPinIndex.end()) 00080 ? PinIndex(PinIndex::undefined()) : p->second; 00081 } 00082 // accessors 00083 /// \brief Returns the name of the element. 00084 const string& getName(void) const { return mName; } 00085 /// \brief Returns a constant array of element pins. 00086 const PrimitiveElementPinArray& getPins(void) const { return mPins; } 00087 /// \brief Returns the set of allowable configuration values. 00088 const StringSet& getCfgs(void) const { return mCfgs; } 00089 /// \brief Returns true if this element is a BEL (Basic ELement). 00090 bool isBel(void) const { return mIsBel; } 00091 }; 00092 00093 /// \brief Array of constant PrimitiveElement objects. 00094 typedef Array<const PrimitiveElement> PrimitiveElementArray; 00095 00096 } // namespace architecture 00097 } // namespace torc 00098 00099 #endif // TORC_ARCHITECTURE_PRIMITIVEELEMENT_HPP