torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tiles.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 Tiles class.
18 
19 #ifndef TORC_ARCHITECTURE_TILES_HPP
20 #define TORC_ARCHITECTURE_TILES_HPP
21 
28 
29 namespace torc {
30 namespace architecture {
31 
32  /// \brief Tile map, tile type, and wire information for the family and device.
33  /// \details The tile map defines the tile layout for the current device. Every tile is
34  /// associated with a tile type that has been defined for the family. The wire type
35  /// information is likewise device independent, and is therefore included in this class.
37  // friends
38  /// \brief The database has access to our protected functions.
39  friend class DDB;
40  protected:
41  // types
42  typedef std::string string; ///< \brief Imported type name.
43  typedef boost::uint16_t uint16_t; ///< \brief Imported type name.
44  typedef boost::uint32_t uint32_t; ///< \brief Imported type name.
45  typedef xilinx::TileRow TileRow; ///< \brief Imported type name.
46  typedef xilinx::TileCol TileCol; ///< \brief Imported type name.
47  typedef xilinx::TileCount TileCount; ///< \brief Imported type name.
48  typedef xilinx::TileIndex TileIndex; ///< \brief Imported type name.
49  typedef xilinx::TileTypeCount TileTypeCount; ///< \brief Imported type name.
50  typedef xilinx::TileTypeIndex TileTypeIndex; ///< \brief Imported type name.
51  typedef xilinx::WireCount WireCount; ///< \brief Imported type name.
52  typedef xilinx::WireIndex WireIndex; ///< \brief Imported type name.
53  /// \brief Wrapper for a tile name with corresponding tile index.
54  typedef std::pair<std::string, xilinx::TileIndex> TileNameIndexPair;
55  /// \brief Wrapper for a wire name with corresponding wire index.
56  typedef std::pair<std::string, xilinx::WireIndex> WireNameIndexPair;
57  // nested classes
58  /// \brief Wrapper around char* for use with the Array template.
60  // members
61  /// \brief The char* string.
62  char* mString;
63  public:
64  // constructors
65  /// \brief Null constructor.
66  CharStringWrapper(void) : mString(0) {}
67  /// \brief Public constructor.
68  CharStringWrapper(const char* inString) : mString(strdup(inString)) {}
69  /// \brief Non-virtual destructor.
70  ~CharStringWrapper(void) { if(mString != 0) { free(mString); mString = 0; } }
71  // accessors
72  /// \brief Cast operator.
73  operator const char*(void) const { return mString; }
74  // operators
75  /// \brief Assignment operator.
76  CharStringWrapper& operator= (const char* inString) {
77  if(mString != 0) free(mString);
78  mString = strdup(inString);
79  return *this;
80  }
81  };
82  // members
83  /// \brief The tile count for this device.
85  /// \brief The tile row count for this device.
87  /// \brief The tile column count for this device.
89  /// \brief The two-dimensional tile map for this device.
91  /// \brief The tile information for this device.
93  /// \brief The tile name to tile index mapping for this device.
95  /// \brief The number of tile types for this family.
97  /// \brief The tile type names for this family.
99  /// \brief The wire information for this family.
101  /// \brief The wire name to wire index mapping for each tile type for this family.
103  // functions
104  /// \brief Read the family tile types.
105  size_t readTileTypes(DigestStream& inStream);
106  /// \brief Read the family wire info.
107  size_t readTileWireInfo(DigestStream& inStream);
108  /// \brief Read the device tile map.
109  size_t readTileMap(DigestStream& inStream);
110  // static
111  /// \brief Compare tile pairs by name, for ordering purposes.
112  static bool CompareTilePairByName(const TileNameIndexPair& inA,
113  const TileNameIndexPair& inB) {
114  return inA.first < inB.first;
115  }
116  /// \brief Compare wire pairs by name, for ordering purposes.
117  static bool CompareWirePairByName(const WireNameIndexPair& inA,
118  const WireNameIndexPair& inB) {
119  return inA.first < inB.first;
120  }
121  // constructors
122  /// \brief Protected constructor.
125  public:
126  // constructors
127  /// \brief Non-virtual destructor.
128  ~Tiles(void) {
129  // release the tile map memory; the other objects will go away by themselves
130  if(mTileMap != 0) {
131  if(mTileMap[0] != 0) { delete[] mTileMap[0]; mTileMap[0] = 0; }
132  delete[] mTileMap; mTileMap = 0;
133  }
134  }
135  // accessors
136  /// \brief Returns the TileInfo object for the specified tile.
137  const TileInfo& getTileInfo(TileIndex inTileIndex) const {
138  return mTiles[inTileIndex]; }
139  /// \brief Returns the WireInfo array for the specified tile type.
140  const Array<const WireInfo>& getWireInfo(TileTypeIndex inTileTypeIndex) const
141  { return mWires[inTileTypeIndex]; }
142  /// \brief Returns the WireInfo object for the specified tile type and wire index.
143  const WireInfo& getWireInfo(TileTypeIndex inTileTypeIndex, WireIndex inWireIndex) const
144  { return mWires[inTileTypeIndex][inWireIndex]; }
145  /// \brief Returns the WireInfo object for the specified tile index and wire index.
146  const WireInfo& getWireInfo(TileIndex inTileIndex, WireIndex inWireIndex) const
147  { return mWires[mTiles[inTileIndex].mTypeIndex][inWireIndex]; }
148  /// \brief Returns the tile count for this device.
149  TileCount getTileCount(void) const { return mTileCount; }
150  /// \brief Returns the tile type count for this device.
152  /// \brief Returns the row count for this device.
153  TileRow getRowCount(void) const { return mRowCount; }
154  /// \brief Returns the column count for this device.
155  TileCol getColCount(void) const { return mColCount; }
156  /// \brief Returns the wire count for the specified tile type.
157  WireCount getWireCount(TileTypeIndex inTileTypeIndex) const
158  { return WireCount(mWires[inTileTypeIndex].getSize()); }
159  // functions
160  /// \brief Returns the tile index for the given [row,column] pair.
161  TileIndex getTileIndex(TileRow inRow, TileCol inCol) const
162  { return mTileMap[inRow][inCol]; }
163  /// \brief Returns the tile type name for the given tile type index.
164  const char* getTileTypeName(TileTypeIndex inTileTypeIndex) const
165  { return mTileTypeNames[inTileTypeIndex]; }
166  /// \brief Returns the tile index for the given tile name.
167  /// \details The search has logarithmic complexity.
168  /// \returns TileIndex(-1) if the name does not exist, or the corresponding tile index
169  /// otherwise.
170  TileIndex findTileIndex(const string& inName) const {
174  Array<const TileNameIndexPair>::const_iterator p = lower_bound(b, e, value,
176  return TileIndex((p == e || p->first != inName) ? -1 : p->second);
177  }
178  /// \brief Returns the wire index for the given wire name in the given tile type.
179  /// \details The search has logarithmic complexity.
180  /// \returns WireIndex(-1) if the name does not exist, or the corresponding wire index
181  /// otherwise.
182  WireIndex findWireIndex(TileTypeIndex inTileTypeIndex, const string& inName) const {
183  const Array<const WireNameIndexPair>& wireNameIndexPairArray
184  = mOrderedWireNames[inTileTypeIndex];
185  Array<const WireNameIndexPair>::const_iterator b = wireNameIndexPairArray.begin();
186  Array<const WireNameIndexPair>::const_iterator e = wireNameIndexPairArray.end();
188  Array<const WireNameIndexPair>::const_iterator p = lower_bound(b, e, value,
190  return WireIndex((p == e || p->first != inName) ? -1 : p->second);
191  }
192  };
193 
194 } // namespace architecture
195 } // namespace torc
196 
197 #endif // TORC_ARCHITECTURE_TILES_HPP
xilinx::TileIndex TileIndex
Imported type name.
Definition: Tiles.hpp:48
Encapsulation of a wire belonging to a compact segment.
Definition: Segments.hpp:64
xilinx::TileCount TileCount
Imported type name.
Definition: Tiles.hpp:47
CharStringWrapper & operator=(const char *inString)
Assignment operator.
Definition: Tiles.hpp:76
TileRow mRowCount
The tile row count for this device.
Definition: Tiles.hpp:86
Encapsulation of a tile index in an unsigned 32-bit integer.
Encapsulation of a tile row in an unsigned 16-bit integer.
~CharStringWrapper(void)
Non-virtual destructor.
Definition: Tiles.hpp:70
Encapsulation of a tile column in an unsigned 16-bit integer.
std::pair< std::string, xilinx::WireIndex > WireNameIndexPair
Wrapper for a wire name with corresponding wire index.
Definition: Tiles.hpp:56
Device database, including complete wiring and logic support.
Definition: DDB.hpp:42
TileTypeCount getTileTypeCount(void) const
Returns the tile type count for this device.
Definition: Tiles.hpp:151
TileRow getRowCount(void) const
Returns the row count for this device.
Definition: Tiles.hpp:153
static bool CompareWirePairByName(const WireNameIndexPair &inA, const WireNameIndexPair &inB)
Compare wire pairs by name, for ordering purposes.
Definition: Tiles.hpp:117
const TileInfo & getTileInfo(TileIndex inTileIndex) const
Returns the TileInfo object for the specified tile.
Definition: Tiles.hpp:137
T * end(void)
Returns the non-constant end iterator.
Definition: Array.hpp:97
Header for the WireInfo class.
CharStringWrapper(const char *inString)
Public constructor.
Definition: Tiles.hpp:68
const WireInfo & getWireInfo(TileTypeIndex inTileTypeIndex, WireIndex inWireIndex) const
Returns the WireInfo object for the specified tile type and wire index.
Definition: Tiles.hpp:143
Array< const CharStringWrapper > mTileTypeNames
The tile type names for this family.
Definition: Tiles.hpp:98
TileCol mColCount
The tile column count for this device.
Definition: Tiles.hpp:88
size_t readTileWireInfo(DigestStream &inStream)
Read the family wire info.
Definition: Tiles.cpp:58
Device database console streams class.
const Array< const WireInfo > & getWireInfo(TileTypeIndex inTileTypeIndex) const
Returns the WireInfo array for the specified tile type.
Definition: Tiles.hpp:140
size_t readTileTypes(DigestStream &inStream)
Read the family tile types.
Definition: Tiles.cpp:25
xilinx::TileTypeIndex TileTypeIndex
Imported type name.
Definition: Tiles.hpp:50
TileTypeCount mTileTypeCount
The number of tile types for this family.
Definition: Tiles.hpp:96
Encapsulation of a wire index in an unsigned 16-bit integer.
boost::uint32_t uint32_t
Imported type name.
Definition: Tiles.hpp:44
TileCount getTileCount(void) const
Returns the tile count for this device.
Definition: Tiles.hpp:149
std::string string
xilinx::TileTypeCount TileTypeCount
Imported type name.
Definition: Tiles.hpp:49
std::string string
Imported type name.
Definition: Tiles.hpp:42
Header for the DDBConsoleStreams class.
Wrapper around char* for use with the Array template.
Definition: Tiles.hpp:59
Tile map, tile type, and wire information for the family and device.
Definition: Tiles.hpp:36
Array< const TileInfo > mTiles
The tile information for this device.
Definition: Tiles.hpp:92
Encapsulation of a wire count in an unsigned 16-bit integer.
Encapsulation of a tile count in an unsigned 32-bit integer.
Encapsulation of a tile within a device tile map.
Definition: TileInfo.hpp:33
const WireInfo & getWireInfo(TileIndex inTileIndex, WireIndex inWireIndex) const
Returns the WireInfo object for the specified tile index and wire index.
Definition: Tiles.hpp:146
Array2D< const WireNameIndexPair > mOrderedWireNames
The wire name to wire index mapping for each tile type for this family.
Definition: Tiles.hpp:102
Encapsulation of a 2D static array.
Definition: Array.hpp:125
const char * getTileTypeName(TileTypeIndex inTileTypeIndex) const
Returns the tile type name for the given tile type index.
Definition: Tiles.hpp:164
TileCount mTileCount
The tile count for this device.
Definition: Tiles.hpp:84
TileIndex findTileIndex(const string &inName) const
Returns the tile index for the given tile name.
Definition: Tiles.hpp:170
TileIndex ** mTileMap
The two-dimensional tile map for this device.
Definition: Tiles.hpp:90
static bool CompareTilePairByName(const TileNameIndexPair &inA, const TileNameIndexPair &inB)
Compare tile pairs by name, for ordering purposes.
Definition: Tiles.hpp:112
Encapsulation of a tile type count in an unsigned 16-bit integer.
Header for the Array class.
Header for the DigestStream class.
TileCol getColCount(void) const
Returns the column count for this device.
Definition: Tiles.hpp:155
xilinx::WireCount WireCount
Imported type name.
Definition: Tiles.hpp:51
WireIndex findWireIndex(TileTypeIndex inTileTypeIndex, const string &inName) const
Returns the wire index for the given wire name in the given tile type.
Definition: Tiles.hpp:182
Encapsulation of a tile type index in an unsigned 16-bit integer.
T * begin(void)
Returns the non-constant begin iterator.
Definition: Array.hpp:95
Header for the TileInfo class.
Encapsulation of a wire within a tile type.
Definition: WireInfo.hpp:36
char * mString
The char* string.
Definition: Tiles.hpp:62
~Tiles(void)
Non-virtual destructor.
Definition: Tiles.hpp:128
Array2D< const WireInfo > mWires
The wire information for this family.
Definition: Tiles.hpp:100
std::pair< std::string, xilinx::TileIndex > TileNameIndexPair
Wrapper for a tile name with corresponding tile index.
Definition: Tiles.hpp:54
Encapsulation of a device or family digest stream.
size_t readTileMap(DigestStream &inStream)
Read the device tile map.
Definition: Tiles.cpp:226
Tiles(void)
Protected constructor.
Definition: Tiles.hpp:123
boost::uint16_t uint16_t
Imported type name.
Definition: Tiles.hpp:43
WireCount getWireCount(TileTypeIndex inTileTypeIndex) const
Returns the wire count for the specified tile type.
Definition: Tiles.hpp:157
xilinx::WireIndex WireIndex
Imported type name.
Definition: Tiles.hpp:52
CharStringWrapper(void)
Null constructor.
Definition: Tiles.hpp:66
TileIndex getTileIndex(TileRow inRow, TileCol inCol) const
Returns the tile index for the given [row,column] pair.
Definition: Tiles.hpp:161
Array< const TileNameIndexPair > mOrderedTileNames
The tile name to tile index mapping for this device.
Definition: Tiles.hpp:94
Encapsulation of a static array.
Definition: Array.hpp:39
xilinx::TileRow TileRow
Imported type name.
Definition: Tiles.hpp:45
Device database types for Xilinx architectures.
xilinx::TileCol TileCol
Imported type name.
Definition: Tiles.hpp:46