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/TileInfo.hpp $ 00003 // $Id: TileInfo.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 TileInfo class. 00018 00019 #ifndef TORC_ARCHITECTURE_TILEINFO_HPP 00020 #define TORC_ARCHITECTURE_TILEINFO_HPP 00021 00022 #include "torc/architecture/XilinxDatabaseTypes.hpp" 00023 #include <cstring> 00024 #include <cstdlib> 00025 00026 namespace torc { 00027 namespace architecture { 00028 00029 /// \brief Encapsulation of a tile within a device tile map. 00030 class TileInfo { 00031 // friends 00032 /// \brief The Tiles class has access to our protected members. 00033 friend class Tiles; 00034 protected: 00035 // types 00036 typedef boost::uint16_t uint16_t; ///< \brief Imported type name. 00037 typedef xilinx::TileTypeIndex TileTypeIndex; ///< \brief Imported type name. 00038 typedef xilinx::TileRow TileRow; ///< \brief Imported type name. 00039 typedef xilinx::TileCol TileCol; ///< \brief Imported type name. 00040 // members 00041 /// \brief The tile type index for this tile. 00042 TileTypeIndex mTypeIndex; 00043 /// \brief The row for this tile. 00044 TileRow mRow; 00045 /// \brief The column for this tile. 00046 TileCol mCol; 00047 /// \brief The name for this tile. 00048 const char* mName; 00049 // initializer 00050 /// \brief Protected initializer intended for use by the Tiles class. 00051 /// \param inTypeIndex The tile type index. 00052 /// \param inRow The tile row. 00053 /// \param inCol The tile column. 00054 /// \param inName The tile name. 00055 void set(const TileTypeIndex& inTypeIndex, const TileRow& inRow, const TileCol& inCol, 00056 const char* inName) { 00057 // release the current name if applicable 00058 if(mName != 0) { free(const_cast<char*>(mName)); mName = 0; } 00059 // make a private copy of the tile name 00060 mName = strdup(inName); 00061 // copy the remaining fields 00062 mTypeIndex = inTypeIndex; 00063 mRow = inRow; 00064 mCol = inCol; 00065 } 00066 // constructors 00067 /// \brief Disabled copy constructor. 00068 TileInfo(const TileInfo& /*rhs*/) : mTypeIndex(), mRow(), mCol(), mName(0) {} 00069 public: 00070 // constructors 00071 /// \brief Null constructor. 00072 TileInfo(void) : mTypeIndex(), mRow(), mCol(), mName(0) {} 00073 /// \brief Non-virtual destructor. 00074 ~TileInfo(void) { 00075 // release the tile name if allocated 00076 if(mName != 0) { free(const_cast<char*>(mName)); mName = 0; } 00077 } 00078 // accessors 00079 /// \brief Returns the tile type index for this tile. 00080 const TileTypeIndex& getTypeIndex(void) const { return mTypeIndex; } 00081 /// \brief Returns the row for this tile. 00082 const TileRow& getRow(void) const { return mRow; } 00083 /// \brief Returns the column for this tile. 00084 const TileCol& getCol(void) const { return mCol; } 00085 /// \brief Returns the name for this tile. 00086 const char* getName(void) const { return mName; } 00087 }; 00088 00089 } // namespace architecture 00090 } // namespace torc 00091 00092 #endif // TORC_ARCHITECTURE_TILEINFO_HPP