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/PrimitiveElementPin.hpp $ 00003 // $Id: PrimitiveElementPin.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 PrimitiveElementPin class. 00018 00019 #ifndef TORC_ARCHITECTURE_PRIMITIVEELEMENTPIN_HPP 00020 #define TORC_ARCHITECTURE_PRIMITIVEELEMENTPIN_HPP 00021 00022 #include "torc/architecture/XilinxDatabaseTypes.hpp" 00023 #include "torc/architecture/PrimitivePin.hpp" 00024 #include "torc/architecture/Array.hpp" 00025 #include <boost/shared_ptr.hpp> 00026 #include <string> 00027 #include <vector> 00028 00029 namespace torc { 00030 namespace architecture { 00031 00032 namespace architecture { class PrimitiveElementPinUnitTest; } 00033 00034 // forward declarations 00035 class PrimitiveElement; 00036 class PrimitiveConn; 00037 typedef boost::shared_ptr<const PrimitiveConn> PrimitiveConnSharedPtr; 00038 00039 /// \brief Encapsulation of a primitive element pin's name, flags, and element pointer. 00040 /// \detail Primitive element pins are sub-site inputs or outputs. 00041 class PrimitiveElementPin : public PinDirection { 00042 protected: 00043 // friends 00044 /// \brief The Sites class has access to our internals. 00045 friend class Sites; 00046 /// \brief Our unit test class has access to our internals. 00047 friend class torc::architecture::architecture::PrimitiveElementPinUnitTest; 00048 // types 00049 typedef xilinx::PinFlags PinFlags; ///< \brief Imported type name. 00050 typedef std::string string; ///< \brief Imported type name. 00051 // members 00052 /// \brief The primitive element that owns this pin. 00053 const PrimitiveElement* mElementPtr; 00054 /// \brief The pin name. 00055 string mName; 00056 /// \brief The pin direction flags. 00057 /// \see PinDirection. 00058 PinFlags mFlags; 00059 /// \brief The primitive connection that includes this pin. 00060 const PrimitiveConnSharedPtr mPrimitiveConn; 00061 // constructors 00062 /// \brief Protected constructor. 00063 /// \parameter inElementPtr The primitive element that owns this pin. 00064 /// \parameter inName The pin name. 00065 /// \parameter inFlags The pin direction flags. 00066 PrimitiveElementPin(const PrimitiveElement* inElementPtr, const std::string& inName, 00067 PinFlags inFlags) : mElementPtr(inElementPtr), mName(inName), mFlags(inFlags) {} 00068 public: 00069 // accessors 00070 /// \brief Returns a pointer to the primitive element that owns this pin. 00071 const PrimitiveElement* getElementPtr(void) const { return mElementPtr; } 00072 /// \brief Returns the pin name. 00073 const string& getName(void) const { return mName; } 00074 /// \brief Returns the pin direction flags. 00075 PinFlags getFlags(void) const { return mFlags; } 00076 /// \brief Returns the primitive connection that includes this pin. 00077 const PrimitiveConnSharedPtr getPrimitiveConn(void) const { return mPrimitiveConn; } 00078 /// \brief Null constructor. 00079 /// \detail This constructor should only be used by containers. 00080 PrimitiveElementPin(void) : mElementPtr(0), mName(), mFlags() {}; 00081 /// \brief Returns true if this pin is a primitive input. 00082 bool isInput(void) const { return (mFlags & ePinDirectionInput) != 0; } 00083 /// \brief Returns true if this pin is a primitive output. 00084 bool isOutput(void) const { return (mFlags & ePinDirectionOutput) != 0; } 00085 }; 00086 00087 /// \brief Array of constant PrimitiveElementPin objects. 00088 typedef Array<const PrimitiveElementPin> PrimitiveElementPinArray; 00089 00090 /// \brief Vector of constant PrimitiveElementPin pointers. 00091 typedef std::vector<const PrimitiveElementPin*> PrimitiveElementPinPtrVector; 00092 00093 } // namespace architecture 00094 } // namespace torc 00095 00096 #endif // TORC_ARCHITECTURE_PRIMITIVEELEMENTPIN_HPP