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/PrimitivePin.hpp $ 00003 // $Id: PrimitivePin.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 PrimitivePin class. 00018 00019 #ifndef TORC_ARCHITECTURE_PRIMITIVEPIN_HPP 00020 #define TORC_ARCHITECTURE_PRIMITIVEPIN_HPP 00021 00022 #include "torc/architecture/XilinxDatabaseTypes.hpp" 00023 #include "torc/architecture/Array.hpp" 00024 #include <string> 00025 00026 namespace torc { 00027 namespace architecture { 00028 00029 namespace architecture { class PrimitivePinUnitTest; } 00030 00031 /// \bried Encapsulation of pin directionality. 00032 /// \detail These direction enumerations are obtained from the database build code, and are 00033 /// used by the PrimitivePin and PrimitivElementPin classes. 00034 class PinDirection { 00035 public: 00036 // enumerations 00037 enum EPinDirection { ePinDirectionNone = 0, ePinDirectionInput = 2, 00038 ePinDirectionOutput = 4 }; 00039 }; 00040 00041 /// \brief Encapsulation of a primitive pin's name and flags. 00042 /// \detail Primitive pins are logic site inputs or outputs. 00043 class PrimitivePin : public PinDirection { 00044 protected: 00045 // friends 00046 /// \brief The Sites class has access to our internals. 00047 friend class Sites; 00048 /// \brief Our unit test class has access to our internals. 00049 friend class torc::architecture::architecture::PrimitivePinUnitTest; 00050 // types 00051 typedef xilinx::PinFlags PinFlags; ///< \brief Imported type name. 00052 typedef std::string string; ///< \brief Imported type name. 00053 // members 00054 /// \brief The pin name. 00055 string mName; 00056 /// \brief The pin direction flags. 00057 /// \see PinDirection. 00058 PinFlags mFlags; 00059 // constructors 00060 /// \brief Protected constructor. 00061 /// \parameter inName The pin name. 00062 /// \parameter inFlags The pin direction flags. 00063 PrimitivePin(const string& inName, PinFlags inFlags) : mName(inName), mFlags(inFlags) 00064 {} 00065 public: 00066 // accessors 00067 /// \brief Returns the pin name. 00068 const string& getName(void) const { return mName; } 00069 /// \brief Returns the pin direction flags. 00070 PinFlags getFlags(void) const { return mFlags; } 00071 /// \brief Null constructor. 00072 /// \detail This constructor should only be used by containers. 00073 PrimitivePin(void) : mName(), mFlags() {}; 00074 /// \brief Returns true if this pin is a primitive input. 00075 bool isInput(void) const { return (mFlags & ePinDirectionInput) != 0; } 00076 /// \brief Returns true if this pin is a primitive output. 00077 bool isOutput(void) const { return (mFlags & ePinDirectionOutput) != 0; } 00078 }; 00079 00080 /// \brief Array of constant PrimitivePin objects. 00081 typedef Array<const PrimitivePin> PrimitivePinArray; 00082 00083 } // namespace architecture 00084 } // namespace torc 00085 00086 #endif // TORC_ARCHITECTURE_PRIMITIVEPIN_HPP