00001 // Torc - Copyright 2011 University of Southern California. All Rights Reserved. 00002 // $HeadURL: https://svn.east.isi.edu/torc/trunk/src/torc/architecture/Tilewire.hpp $ 00003 // $Id: Tilewire.hpp 481 2011-06-07 20:34:36Z 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 Tilewire class. 00018 00019 #ifndef TORC_ARCHITECTURE_TILEWIRE_HPP 00020 #define TORC_ARCHITECTURE_TILEWIRE_HPP 00021 00022 #include "torc/architecture/XilinxDatabaseTypes.hpp" 00023 #include <vector> 00024 00025 namespace torc { 00026 namespace architecture { 00027 00028 // Pack Tilewire objects tightly. 00029 /// \todo Have to justify the packing decision, and its impact on memory footprint versus 00030 /// performance. 00031 #ifdef __GNUC__ 00032 #pragma pack(push, 2) 00033 #endif 00034 00035 /// \brief Encapsulation of a device tile and wire pair. 00036 /// \details A tilewire uniquely identifies a physical wire in the device, as defined by its 00037 /// tile index and wire index. Tilewires are used extensively by the device database, and 00038 /// by the router and tracer classes. 00039 class Tilewire { 00040 protected: 00041 // types 00042 /// \brief Imported type name. 00043 typedef xilinx::TileIndex TileIndex; 00044 /// \brief Imported type name. 00045 typedef xilinx::WireIndex WireIndex; 00046 // members 00047 /// \brief The tile index. 00048 TileIndex mTileIndex; 00049 /// \brief The wire index. 00050 WireIndex mWireIndex; 00051 public: 00052 // constructors 00053 /// \brief Null constructor. 00054 /// \details The tilewire will be set to Tilewire::sInvalid. 00055 Tilewire(void) : mTileIndex(TileIndex::undefined()), mWireIndex(WireIndex::undefined()) {} 00056 /// \brief Public constructor. 00057 Tilewire(const TileIndex& inTileIndex, const WireIndex& inWireIndex) 00058 : mTileIndex(inTileIndex), mWireIndex(inWireIndex) {} 00059 /// \brief Copy constructor. 00060 Tilewire(const Tilewire& inTilewire) 00061 : mTileIndex(inTilewire.mTileIndex), mWireIndex(inTilewire.mWireIndex) {} 00062 // accessors 00063 /// \brief Returns the tile index. 00064 const TileIndex& getTileIndex(void) const { return mTileIndex; } 00065 /// \brief Returns the wire index. 00066 const WireIndex& getWireIndex(void) const { return mWireIndex; } 00067 /// \brief Sets the tile index. 00068 void setTileIndex(const TileIndex& inTileIndex) { mTileIndex = inTileIndex; } 00069 /// \brief Sets the wire index. 00070 void setWireIndex(const WireIndex& inWireIndex) { mWireIndex = inWireIndex; } 00071 // operators 00072 /// \brief Equality operator. 00073 bool operator ==(const Tilewire& rhs) const 00074 { return mTileIndex == rhs.mTileIndex && mWireIndex == rhs.mWireIndex; } 00075 /// \brief Assignment operator. 00076 const Tilewire& operator =(const Tilewire& rhs) 00077 { mTileIndex = rhs.mTileIndex; mWireIndex = rhs.mWireIndex; return *this; } 00078 /// \brief Comparison operator. 00079 /// \details This operator facilitates ordering in containers. 00080 bool operator <(const Tilewire& rhs) const { 00081 if(mTileIndex < rhs.mTileIndex) return true; 00082 if(mTileIndex == rhs.mTileIndex && mWireIndex < rhs.mWireIndex) return true; 00083 return false; 00084 } 00085 // functions 00086 bool isUndefined(void) const { 00087 return mTileIndex.isUndefined() || mWireIndex.isUndefined(); 00088 } 00089 // friends 00090 /// \brief Return a hash value for the specified tilewire. 00091 friend std::size_t hash_value(const Tilewire& inTilewire); 00092 // static 00093 static const Tilewire sInvalid; 00094 }; 00095 00096 #ifdef __GNUC__ 00097 #pragma pack(pop) 00098 #endif 00099 00100 /// \brief Vector of Tilewire objects. 00101 typedef std::vector<Tilewire> TilewireVector; 00102 00103 } // namespace architecture 00104 } // namespace torc 00105 00106 #endif // TORC_ARCHITECTURE_TILEWIRE_HPP