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/PrimitiveDef.hpp $ 00003 // $Id: PrimitiveDef.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 PrimitiveDef class. 00018 00019 #ifndef TORC_ARCHITECTURE_PRIMITIVEDEF_HPP 00020 #define TORC_ARCHITECTURE_PRIMITIVEDEF_HPP 00021 00022 #include "torc/architecture/PrimitiveConn.hpp" 00023 #include "torc/architecture/PrimitiveElement.hpp" 00024 00025 namespace torc { 00026 namespace architecture { 00027 00028 /// \brief Encapsulation of primitive site definition, with associated connections, elements, 00029 /// and pins. 00030 class PrimitiveDef { 00031 protected: 00032 // friends 00033 friend class Sites; 00034 // types 00035 typedef xilinx::PinIndex PinIndex; ///< \brief Imported type name. 00036 typedef std::string string; ///< \brief Imported type name. 00037 /// \brief Map of pin names to pin indexes for a primitive element. 00038 typedef std::map<std::string, PinIndex> PinNameToPinIndexMap; 00039 // elements 00040 /// \brief The primitive name. 00041 std::string mName; 00042 /// \brief The primitive pins. 00043 PrimitivePinArray mPins; 00044 /// \brief The primitive elements. 00045 PrimitiveElementArray mElements; 00046 /// \brief The primitive internal connections. 00047 PrimitiveConnSharedPtrArray mConnections; 00048 /// \brief The map of pin names to pin indexes. 00049 PinNameToPinIndexMap mPinNameToPinIndex; 00050 // functions 00051 /// \brief Returns a non-constant array of element pins. 00052 /// \detail This function should only be used by the Sites class during database 00053 /// iniialization. 00054 PrimitivePinArray& getPins(void) { return mPins; } 00055 public: 00056 // constructors 00057 /// \brief Null constructor. 00058 /// \detail This constructor should only be used by containers. 00059 PrimitiveDef(void) : mName(), mPins(), mPinNameToPinIndex() {} 00060 // functions 00061 /// \brief Returns the pin index corresponding to the given pin name, or 00062 /// PinIndex::undefined() if the pin name does not exist. 00063 /// \parameter inName The pin name to find. 00064 PinIndex findPinIndexByName(const std::string& inName) const { 00065 PinNameToPinIndexMap::const_iterator p = mPinNameToPinIndex.find(inName); 00066 return (p == mPinNameToPinIndex.end()) 00067 ? PinIndex(PinIndex::undefined()) : p->second; 00068 } 00069 // accessors 00070 /// \brief Returns the name of the primitive. 00071 const string& getName(void) const { return mName; } 00072 /// \brief Returns a constant array of primitive pins. 00073 const PrimitivePinArray& getPins(void) const { return mPins; } 00074 /// \brief Returns a constant array of primitive elements. 00075 const PrimitiveElementArray& getElements(void) const { return mElements; } 00076 /// \brief Returns a constant array of primitive connection shared pointers. 00077 const PrimitiveConnSharedPtrArray& getConnections(void) const { return mConnections; } 00078 }; 00079 00080 } // namespace architecture 00081 } // namespace torc 00082 00083 #endif // TORC_ARCHITECTURE_PRIMITIVEDEF_HPP