torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TileInfo.hpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 /// \file
17 /// \brief Header for the TileInfo class.
18 
19 #ifndef TORC_ARCHITECTURE_TILEINFO_HPP
20 #define TORC_ARCHITECTURE_TILEINFO_HPP
21 
23 #include <cstring>
24 #include <cstdlib>
25 
26 namespace torc {
27 namespace architecture {
28 
29 // forward declaration of our unit test class within its namespace
30 namespace architecture { class TileInfoUnitTest; }
31 
32  /// \brief Encapsulation of a tile within a device tile map.
33  class TileInfo {
34  // friends
35  /// \brief The Tiles class has access to our protected members.
36  friend class Tiles;
37  /// \brief Our unit test has direct access to our internals.
39  protected:
40  // types
41  typedef boost::uint32_t uint32_t; ///< \brief Imported type name.
42  typedef boost::int32_t int32_t; ///< \brief Imported type name.
43  typedef xilinx::TileTypeIndex TileTypeIndex; ///< \brief Imported type name.
44  typedef xilinx::TileRow TileRow; ///< \brief Imported type name.
45  typedef xilinx::TileCol TileCol; ///< \brief Imported type name.
46  // members
47  /// \brief The tile type index for this tile.
49  /// \brief The row for this tile.
51  /// \brief The column for this tile.
53  /// \brief The name for this tile.
54  const char* mName;
55  // initializer
56  /// \brief Protected initializer intended for use by the Tiles class.
57  /// \param inTypeIndex The tile type index.
58  /// \param inRow The tile row.
59  /// \param inCol The tile column.
60  /// \param inName The tile name.
61  void set(const TileTypeIndex& inTypeIndex, const TileRow& inRow, const TileCol& inCol,
62  const char* inName) {
63  // release the current name if applicable
64  if(mName != 0) { free(const_cast<char*>(mName)); mName = 0; }
65  // make a private copy of the tile name
66  mName = strdup(inName);
67  // copy the remaining fields
68  mTypeIndex = inTypeIndex;
69  mRow = inRow;
70  mCol = inCol;
71  }
72  // constructors
73  /// \brief Disabled copy constructor.
74  TileInfo(const TileInfo& /*rhs*/) : mTypeIndex(), mRow(), mCol(), mName(0) {}
75  public:
76  // constructors
77  /// \brief Null constructor.
78  TileInfo(void) : mTypeIndex(), mRow(), mCol(), mName(0) {}
79  /// \brief Non-virtual destructor.
80  ~TileInfo(void) {
81  // release the tile name if allocated
82  if(mName != 0) { free(const_cast<char*>(mName)); mName = 0; }
83  }
84  // function
85  /// \brief Returns the Manhattan distance between two tiles.
86  friend uint32_t manhattanDistance(const TileInfo& inA, const TileInfo& inB) {
87  return uint32_t(abs(int32_t(inA.mRow) - int32_t(inB.mRow)))
88  + uint32_t(abs(int32_t(inA.mCol) - int32_t(inB.mCol)));
89  }
90  // accessors
91  /// \brief Returns the tile type index for this tile.
92  const TileTypeIndex& getTypeIndex(void) const { return mTypeIndex; }
93  /// \brief Returns the row for this tile.
94  const TileRow& getRow(void) const { return mRow; }
95  /// \brief Returns the column for this tile.
96  const TileCol& getCol(void) const { return mCol; }
97  /// \brief Returns the name for this tile.
98  const char* getName(void) const { return mName; }
99  };
100 
101 } // namespace architecture
102 } // namespace torc
103 
104 #endif // TORC_ARCHITECTURE_TILEINFO_HPP
TileCol mCol
The column for this tile.
Definition: TileInfo.hpp:52
xilinx::TileTypeIndex TileTypeIndex
Imported type name.
Definition: TileInfo.hpp:43
const TileCol & getCol(void) const
Returns the column for this tile.
Definition: TileInfo.hpp:96
Encapsulation of a tile row in an unsigned 16-bit integer.
const TileRow & getRow(void) const
Returns the row for this tile.
Definition: TileInfo.hpp:94
Encapsulation of a tile column in an unsigned 16-bit integer.
friend class torc::architecture::architecture::TileInfoUnitTest
Our unit test has direct access to our internals.
Definition: TileInfo.hpp:38
xilinx::TileCol TileCol
Imported type name.
Definition: TileInfo.hpp:45
TileInfo(void)
Null constructor.
Definition: TileInfo.hpp:78
friend uint32_t manhattanDistance(const TileInfo &inA, const TileInfo &inB)
Returns the Manhattan distance between two tiles.
Definition: TileInfo.hpp:86
~TileInfo(void)
Non-virtual destructor.
Definition: TileInfo.hpp:80
TileTypeIndex mTypeIndex
The tile type index for this tile.
Definition: TileInfo.hpp:48
Tile map, tile type, and wire information for the family and device.
Definition: Tiles.hpp:36
Encapsulation of a tile within a device tile map.
Definition: TileInfo.hpp:33
const TileTypeIndex & getTypeIndex(void) const
Returns the tile type index for this tile.
Definition: TileInfo.hpp:92
TileInfo(const TileInfo &)
Disabled copy constructor.
Definition: TileInfo.hpp:74
boost::int32_t int32_t
Imported type name.
Definition: TileInfo.hpp:42
void set(const TileTypeIndex &inTypeIndex, const TileRow &inRow, const TileCol &inCol, const char *inName)
Protected initializer intended for use by the Tiles class.
Definition: TileInfo.hpp:61
const char * mName
The name for this tile.
Definition: TileInfo.hpp:54
boost::uint32_t uint32_t
Imported type name.
Definition: TileInfo.hpp:41
Encapsulation of a tile type index in an unsigned 16-bit integer.
const char * getName(void) const
Returns the name for this tile.
Definition: TileInfo.hpp:98
TileRow mRow
The row for this tile.
Definition: TileInfo.hpp:50
xilinx::TileRow TileRow
Imported type name.
Definition: TileInfo.hpp:44
Device database types for Xilinx architectures.