torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DeviceInfo.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 DeviceInfo class.
18 
19 #ifndef TORC_BITSTREAM_DEVICEINFO_HPP
20 #define TORC_BITSTREAM_DEVICEINFO_HPP
21 
22 #include <boost/cstdint.hpp>
23 #include <string>
24 #include <vector>
25 
26 namespace torc {
27 namespace bitstream {
28 
29 namespace bitstream { class bitstream_static_device_info; }
30 
31  /// \brief Bitstream column definition for Xilinx bitstreams.
32  /// \detail For every block type 0 through 8, this class provides the width of the specified
33  /// column in minor frames. Note that in most families, block types beyond 3 or 4 are
34  /// unused, and hence of zero width.
35  class ColumnDef {
36  protected:
37  // typedefs
38  typedef boost::uint32_t uint32_t; ///< Imported type name.
39  typedef std::string string; ///< Imported type name.
40  /// \brief The column type name.
41  /// \detail Note that this name is not used by Xilinx, and may not directly correspond to
42  /// that found in the device tile map.
43  string mName;
44  /// \brief The column width in minor frames for each of the eight block types.
46  public:
47  // constructors
48  /// \brief Basic constructor.
49  ColumnDef(const string& inName = string(), uint32_t in0 = 0, uint32_t in1 = 0,
50  uint32_t in2 = 0, uint32_t in3 = 0, uint32_t in4 = 0, uint32_t in5 = 0,
51  uint32_t in6 = 0, uint32_t in7 = 0) : mName(inName) {
52  int i = 0;
53  mWidth[i++] = in0; mWidth[i++] = in1; mWidth[i++] = in2; mWidth[i++] = in3;
54  mWidth[i++] = in4; mWidth[i++] = in5; mWidth[i++] = in6; mWidth[i++] = in7;
55  }
56  // functions
57  /// \brief Clears all column widths.
58  void clear(void) { for(int i = 0; i < 8; i++) mWidth[i] = 0; }
59  // accessors
60  /// \brief Returns the specified column width.
61  uint32_t operator[] (int inIndex) const { return mWidth[inIndex]; }
62  /// \brief Returns the column type name.
63  const string& getName(void) const { return mName; }
64  };
65 
66  /// \brief Column definition vector.
67  class ColumnDefVector : public std::vector<ColumnDef> {};
68 
69  /// \brief Column type vector.
70  class ColumnTypeVector : public std::vector<boost::uint32_t> {};
71 
72  /// \brief Static device information class for Xilinx bitstreams.
73  /// \detail This class facilitates the creation of frame address maps without dependence upon
74  /// torc::architecture.
75  class DeviceInfo {
76  protected:
77  // typedefs
78  typedef boost::uint32_t uint32_t; ///< Imported type name.
79  typedef boost::uint16_t uint16_t; ///< Imported type name.
80  // members
81  /// \brief The tile count for this device.
83  /// \brief The row count for this device.
84  /// \brief These are regular tile rows, not bitstream clock region rows.
86  /// \brief The column count for this device.
88  /// \brief The column types as applicable for the bitstream.
90  public:
91  // constructors
92  /// \brief Basic constructor.
93  DeviceInfo(uint32_t inTileCount, uint16_t inRowCount, uint16_t inColCount,
94  uint32_t* inColumns) : mTileCount(inTileCount), mRowCount(inRowCount),
95  mColCount(inColCount) {
96  while(true) {
97  uint32_t type = *inColumns++;
98  if(type == static_cast<uint32_t>(-1)) break;
99  mColumnTypes.push_back(type);
100  }
101  }
102  /// \brief Constructor.
103  DeviceInfo(uint32_t inTileCount, uint16_t inRowCount, uint16_t inColCount,
104  const ColumnTypeVector& inColumnTypes) : mTileCount(inTileCount), mRowCount(inRowCount),
105  mColCount(inColCount), mColumnTypes(inColumnTypes) {}
106  /// \brief Null constructor.
107  DeviceInfo(void) {}
108  // accessors
109  /// \brief Returns the tile count.
110  uint32_t getTileCount(void) const { return mTileCount; }
111  /// \brief Returns the row count.
112  uint16_t getRowCount(void) const { return mRowCount; }
113  /// \brief Returns the column count.
114  uint16_t getColCount(void) const { return mColCount; }
115  /// \brief Returns the column type vector.
116  const ColumnTypeVector& getColumnTypes(void) const { return mColumnTypes; }
117  };
118 
119 } // namespace bitstream
120 } // namespace torc
121 
122 #endif // TORC_BITSTREAM_DEVICEINFO_HPP
uint32_t mWidth[8]
The column width in minor frames for each of the eight block types.
Definition: DeviceInfo.hpp:45
boost::uint32_t uint32_t
Imported type name.
Definition: DeviceInfo.hpp:38
uint16_t getRowCount(void) const
Returns the row count.
Definition: DeviceInfo.hpp:112
Static device information class for Xilinx bitstreams. This class facilitates the creation of frame ...
Definition: DeviceInfo.hpp:75
ColumnDef(const string &inName=string(), uint32_t in0=0, uint32_t in1=0, uint32_t in2=0, uint32_t in3=0, uint32_t in4=0, uint32_t in5=0, uint32_t in6=0, uint32_t in7=0)
Basic constructor.
Definition: DeviceInfo.hpp:49
uint16_t getColCount(void) const
Returns the column count.
Definition: DeviceInfo.hpp:114
Bitstream column definition for Xilinx bitstreams. For every block type 0 through 8...
Definition: DeviceInfo.hpp:35
ColumnTypeVector mColumnTypes
The column types as applicable for the bitstream.
Definition: DeviceInfo.hpp:89
std::string string
DeviceInfo(uint32_t inTileCount, uint16_t inRowCount, uint16_t inColCount, uint32_t *inColumns)
Basic constructor.
Definition: DeviceInfo.hpp:93
uint16_t mRowCount
The row count for this device.
Definition: DeviceInfo.hpp:85
Column definition vector.
Definition: DeviceInfo.hpp:67
uint32_t operator[](int inIndex) const
Returns the specified column width.
Definition: DeviceInfo.hpp:61
const ColumnTypeVector & getColumnTypes(void) const
Returns the column type vector.
Definition: DeviceInfo.hpp:116
boost::uint16_t uint16_t
Imported type name.
Definition: DeviceInfo.hpp:79
string mName
The column type name. Note that this name is not used by Xilinx, and may not directly correspond to ...
Definition: DeviceInfo.hpp:43
DeviceInfo(void)
Null constructor.
Definition: DeviceInfo.hpp:107
const string & getName(void) const
Returns the column type name.
Definition: DeviceInfo.hpp:63
uint32_t mTileCount
The tile count for this device.
Definition: DeviceInfo.hpp:82
void clear(void)
Clears all column widths.
Definition: DeviceInfo.hpp:58
uint16_t mColCount
The column count for this device.
Definition: DeviceInfo.hpp:87
uint32_t getTileCount(void) const
Returns the tile count.
Definition: DeviceInfo.hpp:110
DeviceInfo(uint32_t inTileCount, uint16_t inRowCount, uint16_t inColCount, const ColumnTypeVector &inColumnTypes)
Constructor.
Definition: DeviceInfo.hpp:103
boost::uint32_t uint32_t
Imported type name.
Definition: DeviceInfo.hpp:78