torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tilewire.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 Tilewire class.
18 
19 #ifndef TORC_ARCHITECTURE_TILEWIRE_HPP
20 #define TORC_ARCHITECTURE_TILEWIRE_HPP
21 
23 #include <vector>
24 
25 namespace torc {
26 namespace architecture {
27 
28  // Pack Tilewire objects tightly.
29  /// \todo Have to justify the packing decision, and its impact on memory footprint versus
30  /// performance.
31  #ifdef __GNUC__
32  #pragma pack(push, 2)
33  #endif
34 
35  /// \brief Encapsulation of a device tile and wire pair.
36  /// \details A tilewire uniquely identifies a physical wire in the device, as defined by its
37  /// tile index and wire index. Tilewires are used extensively by the device database, and
38  /// by the router and tracer classes.
39  class Tilewire {
40  protected:
41  // types
42  /// \brief Imported type name.
44  /// \brief Imported type name.
46  // members
47  /// \brief The tile index.
49  /// \brief The wire index.
51  public:
52  // constructors
53  /// \brief Null constructor.
54  /// \details The tilewire will be set to Tilewire::sInvalid.
55  Tilewire(void) : mTileIndex(TileIndex::undefined()), mWireIndex(WireIndex::undefined()) {}
56  /// \brief Public constructor.
57  Tilewire(const TileIndex& inTileIndex, const WireIndex& inWireIndex)
58  : mTileIndex(inTileIndex), mWireIndex(inWireIndex) {}
59  /// \brief Copy constructor.
60  Tilewire(const Tilewire& inTilewire)
61  : mTileIndex(inTilewire.mTileIndex), mWireIndex(inTilewire.mWireIndex) {}
62  // accessors
63  /// \brief Returns the tile index.
64  const TileIndex& getTileIndex(void) const { return mTileIndex; }
65  /// \brief Returns the wire index.
66  const WireIndex& getWireIndex(void) const { return mWireIndex; }
67  /// \brief Sets the tile index.
68  void setTileIndex(const TileIndex& inTileIndex) { mTileIndex = inTileIndex; }
69  /// \brief Sets the wire index.
70  void setWireIndex(const WireIndex& inWireIndex) { mWireIndex = inWireIndex; }
71  // operators
72  /// \brief Equality operator.
73  bool operator ==(const Tilewire& rhs) const
74  { return mTileIndex == rhs.mTileIndex && mWireIndex == rhs.mWireIndex; }
75  /// \brief Assignment operator.
76  const Tilewire& operator =(const Tilewire& rhs)
77  { mTileIndex = rhs.mTileIndex; mWireIndex = rhs.mWireIndex; return *this; }
78  /// \brief Comparison operator.
79  /// \details This operator facilitates ordering in containers.
80  bool operator <(const Tilewire& rhs) const {
81  if(mTileIndex < rhs.mTileIndex) return true;
82  if(mTileIndex == rhs.mTileIndex && mWireIndex < rhs.mWireIndex) return true;
83  return false;
84  }
85  // functions
86  bool isUndefined(void) const {
88  }
89  // friends
90  /// \brief Return a hash value for the specified tilewire.
91  friend std::size_t hash_value(const Tilewire& inTilewire);
92  // static
93  static const Tilewire sInvalid;
94  };
95 
96  #ifdef __GNUC__
97  #pragma pack(pop)
98  #endif
99 
100  /// \brief Vector of Tilewire objects.
101  typedef std::vector<Tilewire> TilewireVector;
102 
103 } // namespace architecture
104 } // namespace torc
105 
106 #endif // TORC_ARCHITECTURE_TILEWIRE_HPP
const WireIndex & getWireIndex(void) const
Returns the wire index.
Definition: Tilewire.hpp:66
Encapsulation of a tile index in an unsigned 32-bit integer.
std::vector< Tilewire > TilewireVector
Vector of Tilewire objects.
Definition: Tilewire.hpp:101
xilinx::TileIndex TileIndex
Imported type name.
Definition: Tilewire.hpp:43
Encapsulation of a wire index in an unsigned 16-bit integer.
Tilewire(void)
Null constructor.
Definition: Tilewire.hpp:55
bool operator==(const Tilewire &rhs) const
Equality operator.
Definition: Tilewire.hpp:73
friend std::size_t hash_value(const Tilewire &inTilewire)
Return a hash value for the specified tilewire.
Definition: Tilewire.cpp:27
Encapsulation of a device tile and wire pair.
Definition: Tilewire.hpp:39
const Tilewire & operator=(const Tilewire &rhs)
Assignment operator.
Definition: Tilewire.hpp:76
TileIndex mTileIndex
The tile index.
Definition: Tilewire.hpp:48
xilinx::WireIndex WireIndex
Imported type name.
Definition: Tilewire.hpp:45
void setTileIndex(const TileIndex &inTileIndex)
Sets the tile index.
Definition: Tilewire.hpp:68
Tilewire(const TileIndex &inTileIndex, const WireIndex &inWireIndex)
Public constructor.
Definition: Tilewire.hpp:57
const TileIndex & getTileIndex(void) const
Returns the tile index.
Definition: Tilewire.hpp:64
static const Tilewire sInvalid
Definition: Tilewire.hpp:93
bool isUndefined(void) const
Definition: Tilewire.hpp:86
void setWireIndex(const WireIndex &inWireIndex)
Sets the wire index.
Definition: Tilewire.hpp:70
bool operator<(const Tilewire &rhs) const
Comparison operator.
Definition: Tilewire.hpp:80
WireIndex mWireIndex
The wire index.
Definition: Tilewire.hpp:50
Tilewire(const Tilewire &inTilewire)
Copy constructor.
Definition: Tilewire.hpp:60
Device database types for Xilinx architectures.