torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Segments.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 Segments class.
18 
19 #ifndef TORC_ARCHITECTURE_SEGMENTS_HPP
20 #define TORC_ARCHITECTURE_SEGMENTS_HPP
21 
27 
28 namespace torc {
29 namespace architecture {
30 
31 // forward declaration of our unit test class within its namespace
32 namespace architecture { class architecture_segments; }
33 namespace architecture { class segments_regression_test_helper; }
34 namespace architecture { class segments_unit_test_helper; }
35 
36  /// \brief Segment and irregular arc data for the device.
37  /// \details Segment data is encoded in a collection of compact segments (segment shapes
38  /// normalized to tile index 0) and a mapping from tilewires to segment references and
39  /// anchor tile indexes.
41  // friends
42  /// \brief The database has access to our protected functions.
43  friend class DDB;
44  /// \brief Our unit test has access to our protected functions.
48  protected:
49  // types
50  typedef std::string string; ///< \brief Imported type name.
51  typedef xilinx::TileCount TileCount; ///< \brief Imported type name.
52  typedef xilinx::TileIndex TileIndex; ///< \brief Imported type name.
53  typedef xilinx::WireIndex WireIndex; ///< \brief Imported type name.
54  typedef xilinx::TileOffset TileOffset; ///< \brief Imported type name.
55  typedef xilinx::CompactSegmentCount CompactSegmentCount; ///< \brief Imported type name.
56  typedef xilinx::CompactSegmentIndex CompactSegmentIndex; ///< \brief Imported type name.
57  // enums
58  enum { eSegmentUndefined = 0xffffffff, eSegmentTrivial = 0 };
59  // nested classes
60  /// \brief Encapsulation of a wire belonging to a compact segment.
61  /// \details A compact segment is defined by wire indexes in tiles normalized relative to
62  /// tile index 0. The set of wire index and tile offset pairs fully defines the shape
63  /// of the compact segment.
67  public:
68  inline WireIndex getWireIndex(void) const { return mWireIndex; }
69  inline TileOffset getTileOffset(void) const { return mTileOffset; }
71  CompactSegmentTilewire(WireIndex inWireIndex, TileOffset inTileOffset)
72  : mWireIndex(inWireIndex), mTileOffset(inTileOffset) {}
73  };
74  public:
75  /// \brief Encapsulation of compact segment index and an anchoring tile index.
76  /// \details Compact segments are normalized relative to tile index 0. The accompanying
77  /// tile index serves as an anchor from which to derive a full segment description.
81  public:
83  { return mCompactSegmentIndex; }
84  inline TileIndex getAnchorTileIndex(void) const { return mAnchorTileIndex; }
86  SegmentReference(CompactSegmentIndex inCompactSegmentIndex, TileIndex inAnchorTileIndex)
87  : mCompactSegmentIndex(inCompactSegmentIndex), mAnchorTileIndex(inAnchorTileIndex)
88  {}
89  void undefine(void) {
92  }
93  bool isDefined(void) const { return mCompactSegmentIndex != eSegmentUndefined; }
94  bool isTrivial(void) const { return mCompactSegmentIndex == eSegmentTrivial; }
95  static const SegmentReference& getTrivialSegment(void)
96  { return sTrivialSegmentReference; }
98  };
99  protected:
100  /// \brief Encapsulation of an irregular arc.
101  /// \details Arcs which are defined for a tile type, but which are not instantiated in
102  /// every single tile of that type are considered irregular, and must be considered on
103  /// a case by case basis. Every irregular arc in a given tile defines its source and
104  /// sink wire indexes.
105  class IrregularArc {
108  public:
109  inline WireIndex getSourceWireIndex(void) const { return mSourceWireIndex; }
110  inline WireIndex getSinkWireIndex(void) const { return mSinkWireIndex; }
112  IrregularArc(WireIndex inSourceWireIndex, WireIndex inSinkWireIndex)
113  : mSourceWireIndex(inSourceWireIndex), mSinkWireIndex(inSinkWireIndex) {}
114  };
115  // members
116  /// \brief The compact segments in the device.
118  /// \brief The segment references for every wire in every tile.
120  /// \brief The irregular arcs for in the device.
122  /// \brief The number of compact segments in the device.
124  /// \brief The number of irregular arcs in the device.
126  /// \brief The total number of wires in the device (pruned and actual).
127  /// \note We cannot use a WireCount for this, because it is only intended for use in a
128  /// single tile, and is consequently only 16 bits wide.
129  uint32_t mTotalWireCount;
130  /// \brief The number of pruned wires in the device.
131  /// \note We cannot use a WireCount for this, because it is only intended for use in a
132  /// single tile, and is consequently only 16 bits wide.
134  /// \brief The number of actual wires on non-trivial segments in the device.
135  /// \note We cannot use a WireCount for this, because it is only intended for use in a
136  /// single tile, and is consequently only 16 bits wide.
138  /// \brief The number of defined trivial segments.
139  /// \note We could use a CompactSegmentCount for this, but that would be semantically
140  /// incorrect because we are really counting full segments, not compact segments.
142  /// \brief The number of defined non-trivial segments.
143  /// \note We could use a CompactSegmentCount for this, but that would be semantically
144  /// incorrect because we are really counting full segments, not compact segments.
146  /// \brief The total number of defined segments.
147  /// \note We could use a CompactSegmentCount for this, but that would be semantically
148  /// incorrect because we are really counting full segments, not compact segments.
150  // constructors
151  /// \brief Protected constructor.
152  Segments(void);
153  // functions
154  /// \brief Read the segment entries for every tile.
155  size_t readTilewireSegments(DigestStream& inStream);
156  /// \brief Read the compact segments for the device.
157  size_t readSegments(DigestStream& inStream, bool inExtendedAnchorTileCount);
158  /// \brief Read the irregular arcs for the device.
159  size_t readIrregularArcs(DigestStream& inStream);
160  /// \brief Return a pointer to the requested IrregularArc, or 0 if the arc does not exist.
162  WireIndex inSourceWireIndex, WireIndex inSinkWireIndex);
163  public:
164  // accessors
165  /// \brief Return the total number of wires in the device (pruned and actual).
166  uint32_t getTotalWireCount(void) const { return mTotalWireCount; }
167  /// \brief Return the number of actual wires in the device (unpruned and non-trivial).
168  uint32_t getActualWireCount(void) const { return mActualWireCount; }
169  /// \brief Return the number of pruned wires in the device.
170  uint32_t getPrunedWireCount(void) const { return mPrunedWireCount; }
171  /// \brief Return the total number of trivial segments in the device.
172  uint32_t getTrivialSegmentCount(void) const { return mNonTrivialSegmentCount; }
173  /// \brief Return the total number of non-trivial segments in the device.
174  uint32_t getNonTrivialSegmentCount(void) const { return mNonTrivialSegmentCount; }
175  /// \brief Return the total number of full segments in the device.
176  uint32_t getTotalSegmentCount(void) const { return mTotalSegmentCount; }
177  /// \brief Return the number of compact segments in the device.
178  uint32_t getCompactSegmentCount(void) const { return mCompactSegmentCount; }
179  /// \brief Return the total number of irregular args in the device.
180  uint32_t getIrregularArcCount(void) const { return mIrregularArcCount; }
181  /// \brief Return the segment reference for the given tile and wire index.
182  const Segments::SegmentReference& getTilewireSegment(const Tilewire& inTilewire) const {
183  return mTilewireSegments[inTilewire.getTileIndex()][inTilewire.getWireIndex()];
184  }
185  };
186 
187 } // namespace architecture
188 } // namespace torc
189 
190 #endif // TORC_ARCHITECTURE_SEGMENTS_HPP
Encapsulation of a wire belonging to a compact segment.
Definition: Segments.hpp:64
xilinx::WireIndex WireIndex
Imported type name.
Definition: Segments.hpp:53
xilinx::TileCount TileCount
Imported type name.
Definition: Segments.hpp:51
friend class torc::architecture::architecture::segments_regression_test_helper
Definition: Segments.hpp:46
uint32_t mTrivialSegmentCount
The number of defined trivial segments.
Definition: Segments.hpp:141
const WireIndex & getWireIndex(void) const
Returns the wire index.
Definition: Tilewire.hpp:66
Encapsulation of a tile index in an unsigned 32-bit integer.
friend class torc::architecture::architecture::segments_unit_test_helper
Definition: Segments.hpp:47
CompactSegmentIndex getCompactSegmentIndex(void) const
Definition: Segments.hpp:82
uint32_t getPrunedWireCount(void) const
Return the number of pruned wires in the device.
Definition: Segments.hpp:170
Encapsulation of a compact segment count in an unsigned 32-bit integer.
CompactSegmentCount mCompactSegmentCount
The number of compact segments in the device.
Definition: Segments.hpp:123
uint32_t getTrivialSegmentCount(void) const
Return the total number of trivial segments in the device.
Definition: Segments.hpp:172
Device database, including complete wiring and logic support.
Definition: DDB.hpp:42
uint32_t getTotalSegmentCount(void) const
Return the total number of full segments in the device.
Definition: Segments.hpp:176
uint32_t mNonTrivialSegmentCount
The number of defined non-trivial segments.
Definition: Segments.hpp:145
Device database console streams class.
size_t readIrregularArcs(DigestStream &inStream)
Read the irregular arcs for the device.
Definition: Segments.cpp:173
Encapsulation of an irregular arc.
Definition: Segments.hpp:105
Array2D< SegmentReference > mTilewireSegments
The segment references for every wire in every tile.
Definition: Segments.hpp:119
CompactSegmentTilewire(WireIndex inWireIndex, TileOffset inTileOffset)
Definition: Segments.hpp:71
Encapsulation of a wire index in an unsigned 16-bit integer.
static const SegmentReference & getTrivialSegment(void)
Definition: Segments.hpp:95
xilinx::TileIndex TileIndex
Imported type name.
Definition: Segments.hpp:52
IrregularArc(WireIndex inSourceWireIndex, WireIndex inSinkWireIndex)
Definition: Segments.hpp:112
friend class torc::architecture::architecture::architecture_segments
Our unit test has access to our protected functions.
Definition: Segments.hpp:45
std::string string
uint32_t getActualWireCount(void) const
Return the number of actual wires in the device (unpruned and non-trivial).
Definition: Segments.hpp:168
Encapsulation of a tile offset in an unsigned 32-bit integer.
SegmentReference(CompactSegmentIndex inCompactSegmentIndex, TileIndex inAnchorTileIndex)
Definition: Segments.hpp:86
Segments(void)
Protected constructor.
Definition: Segments.cpp:27
Header for the DDBConsoleStreams class.
Encapsulation of a device tile and wire pair.
Definition: Tilewire.hpp:39
xilinx::CompactSegmentIndex CompactSegmentIndex
Imported type name.
Definition: Segments.hpp:56
uint32_t getNonTrivialSegmentCount(void) const
Return the total number of non-trivial segments in the device.
Definition: Segments.hpp:174
Array2D< CompactSegmentTilewire > mCompactSegments
The compact segments in the device.
Definition: Segments.hpp:117
WireIndex getSinkWireIndex(void) const
Definition: Segments.hpp:110
uint32_t mIrregularArcCount
The number of irregular arcs in the device.
Definition: Segments.hpp:125
Encapsulation of a tile count in an unsigned 32-bit integer.
WireIndex getSourceWireIndex(void) const
Definition: Segments.hpp:109
Encapsulation of a 2D static array.
Definition: Array.hpp:125
xilinx::CompactSegmentCount CompactSegmentCount
Imported type name.
Definition: Segments.hpp:55
uint32_t mActualWireCount
The number of actual wires on non-trivial segments in the device.
Definition: Segments.hpp:137
uint32_t mTotalWireCount
The total number of wires in the device (pruned and actual).
Definition: Segments.hpp:129
Encapsulation of a compact segment index in an unsigned 32-bit integer.
uint32_t mTotalSegmentCount
The total number of defined segments.
Definition: Segments.hpp:149
Header for the Tilewire class.
uint32_t getIrregularArcCount(void) const
Return the total number of irregular args in the device.
Definition: Segments.hpp:180
std::string string
Imported type name.
Definition: Segments.hpp:50
const Segments::IrregularArc * getIrregularArc(TileIndex inTileIndex, WireIndex inSourceWireIndex, WireIndex inSinkWireIndex)
Return a pointer to the requested IrregularArc, or 0 if the arc does not exist.
Definition: Segments.cpp:213
Encapsulation of compact segment index and an anchoring tile index.
Definition: Segments.hpp:78
Array2D< IrregularArc > mIrregularArcs
The irregular arcs for in the device.
Definition: Segments.hpp:121
Header for the Array class.
Header for the DigestStream class.
uint32_t getCompactSegmentCount(void) const
Return the number of compact segments in the device.
Definition: Segments.hpp:178
const Segments::SegmentReference & getTilewireSegment(const Tilewire &inTilewire) const
Return the segment reference for the given tile and wire index.
Definition: Segments.hpp:182
const TileIndex & getTileIndex(void) const
Returns the tile index.
Definition: Tilewire.hpp:64
xilinx::TileOffset TileOffset
Imported type name.
Definition: Segments.hpp:54
Encapsulation of a device or family digest stream.
Segment and irregular arc data for the device.
Definition: Segments.hpp:40
size_t readTilewireSegments(DigestStream &inStream)
Read the segment entries for every tile.
Definition: Segments.cpp:32
static const SegmentReference sTrivialSegmentReference
Definition: Segments.hpp:97
uint32_t mPrunedWireCount
The number of pruned wires in the device.
Definition: Segments.hpp:133
size_t readSegments(DigestStream &inStream, bool inExtendedAnchorTileCount)
Read the compact segments for the device.
Definition: Segments.cpp:89
uint32_t getTotalWireCount(void) const
Return the total number of wires in the device (pruned and actual).
Definition: Segments.hpp:166
Device database types for Xilinx architectures.