torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Virtex2.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 Virtex2 class.
18 
19 #ifndef TORC_BITSTREAM_VIRTEX2_HPP
20 #define TORC_BITSTREAM_VIRTEX2_HPP
21 
22 #include <boost/cstdint.hpp>
23 #include <boost/filesystem.hpp>
26 #include <map>
27 
28 namespace torc { namespace architecture { class DDB; } }
29 
30 namespace torc {
31 namespace bitstream {
32 
33 namespace bitstream { class Virtex2UnitTest; }
34 namespace bitstream { class Virtex2FarUnitTest; }
35 namespace bitstream { void testVirtex2Device(const std::string& inDeviceName,
36  const boost::filesystem::path& inWorkingPath); }
37 namespace bitstream { void testVirtex2FullMapping(const boost::filesystem::path& inWorkingPath); }
38 
39  /// \brief Virtex2 bitstream.
40  class Virtex2 : public VirtexBitstream {
43  friend void torc::bitstream::bitstream::testVirtex2Device(const std::string& inDeviceName,
44  const boost::filesystem::path& inWorkingPath);
46  protected:
47  // typedefs
48  /// \brief Imported type name.
49  typedef boost::uint32_t uint32_t;
50  public:
51  // enumerations
52  //
53  /// \brief Configuration register enumeration.
54  /// \see configuration registers: UG002, v2.2, November, 2007, Table 4-19.
59  //
60  /// \brief Configuration command enumeration for eRegisterCMD.
61  /// \see CMD register commands: UG002, v2.2, November, 2007, Table 4-23.
65  //
66  /// \brief Frame Address Register subfields.
67  /// \see Frame Address Register Description: UG002, v2.2, November, 2007, Figure 4-32.
68  enum EFar {
70  eFarMaskMajor = 0x01fe0000, eFarShiftMajor = 17,
71  eFarMaskMinor = 0x0001fe00, eFarShiftMinor = 9,
72  };
73  /// \brief Frame Address Register block type constants.
76  /// \brief Major column types.
77  /// \details These are defined and used for internal purposes only, and are not derived
78  /// from any Xilinx documentation.
81  protected:
82  // members
83 // /// \brief Configuration controller registers.
84 // uint32_t mRegister[eRegisterCount];
85  /// \brief Packet type names.
86  static const char* sPacketTypeName[ePacketTypeCount];
87  /// \brief Packet opcode names.
88  static const char* sOpcodeName[eOpcodeCount];
89  /// \brief Configuration register names.
90  static const char* sRegisterName[eRegisterCount];
91  /// \brief Configuration command names.
92  static const char* sCommandName[eCommandCount];
93  /// \brief Configuration Options Register (COR) subfields.
94  static const Subfield sCOR[];
95  /// \brief Status Register (STAT) subfields.
96  static const Subfield sSTAT[];
97  /// \brief Control Register (CTL) subfields.
98  static const Subfield sCTL[];
99  /// \brief Control Mask Register (MASK) subfields.
100  static const Subfield sMASK[];
101  // functions
103  public:
104  // constructors
105  /// \brief Basic constructor.
107 // for(int i = 0; i < eRegisterCount; i++) mRegister[i] = 0;
108  // initialize the column type widths for this family
110  mColumnDefs[eColumnTypeEmpty] = ColumnDef("Empty", 0, 0, 0, 0, 0, 0, 0, 0);
111  mColumnDefs[eColumnTypeBram] = ColumnDef("Bram", 0, 64, 22, 0, 0, 0, 0, 0);
112  mColumnDefs[eColumnTypeClb] = ColumnDef("Clb", 22, 0, 0, 0, 0, 0, 0, 0);
113  mColumnDefs[eColumnTypeClock] = ColumnDef("Clock", 4, 0, 0, 0, 0, 0, 0, 0);
114  mColumnDefs[eColumnTypeGtx] = ColumnDef("Gtx", 22, 0, 0, 0, 0, 0, 0, 0);
115  mColumnDefs[eColumnTypeIob] = ColumnDef("Iob", 4, 0, 0, 0, 0, 0, 0, 0);
116  // map type type names to column types
123  }
124  // functions
125  /// \brief Return the masked value for a subfield of the specified register.
126  static uint32_t makeSubfield(ERegister inRegister, const std::string& inSubfield,
127  const std::string& inSetting);
128  /// \note This function should be called after the bitstream header has been read.
129  virtual void readPackets(std::istream& inStream);
130  // functions
131  /// \brief Initialize the device information.
132  virtual void initializeDeviceInfo(const std::string& inDeviceName);
133  /// \brief Initialize the maps between frame indexes and frame addresses.
134  /// \detail This is generally only useful for internal purposes.
135  virtual void initializeFrameMaps(void);
136  /// \brief Loads full bitstream frames into block data structure.
137  void initializeFullFrameBlocks(void);
138  /// \brief Returns frames for queried bitstream coordinates
139  VirtexFrameBlocks getBitstreamFrames(uint32_t inBlockCount, uint32_t inBitCol);
140  /// \brief Returns frames for queried xdl coordinates
141  VirtexFrameBlocks getXdlFrames(uint32_t inBlockCount, uint32_t inXdlCol);
142  // inserters
143  /// \brief Insert the bitstream header into an output stream.
144  friend std::ostream& operator<< (std::ostream& os, const Virtex2& rhs);
145  // inner classes
147  protected:
148  virtual void assign(uint32_t inAddress) {
150  mMajor = (inAddress & eFarMaskMajor) >> eFarShiftMajor;
151  mMinor = (inAddress & eFarMaskMinor) >> eFarShiftMinor;
152  }
153  public:
155  FrameAddress(EFarBlockType inBlockType, uint32_t inMajor, uint32_t inMinor) :
156  mBlockType(inBlockType), mMajor(inMajor), mMinor(inMinor) {}
157  FrameAddress(uint32_t inAddress) { assign(inAddress); }
161  virtual bool operator== (const VirtexFrameAddress& vrhs) const {
162  const FrameAddress& rhs = reinterpret_cast<const FrameAddress&>(vrhs);
163  return mBlockType == rhs.mBlockType && mMajor == rhs.mMajor && mMinor == rhs.mMinor;
164  }
165  virtual bool operator< (const VirtexFrameAddress& vrhs) const {
166  const FrameAddress& rhs = reinterpret_cast<const FrameAddress&>(vrhs);
167  int diffBlockType = mBlockType - rhs.mBlockType;
168  if(diffBlockType) return diffBlockType < 0;
169  int diffMajor = mMajor - rhs.mMajor;
170  if(diffMajor) return diffMajor < 0;
171  return mMinor < rhs.mMinor;
172  }
173  friend std::ostream& operator<< (std::ostream& os, const Virtex2::FrameAddress& rhs) {
174  return os << rhs.mBlockType << "(" << rhs.mMajor << "." << rhs.mMinor << ")";
175  }
176  private:
177  //operator uint32_t (void) const {
178  // return
179  // ((mTopBottom << eFarShiftTopBottom) & eFarMaskTopBottom) |
180  // ((mBlockType << eFarShiftBlockType) & eFarMaskBlockType) |
181  // ((mRow << eFarShiftRow) & eFarMaskRow) |
182  // ((mMajor << eFarShiftMajor) & eFarMaskMajor) |
183  // ((mMinor << eFarShiftMinor) & eFarMaskMinor);
184  //}
185  };
186  // accessors
187  virtual uint32_t getFrameLength(void) const {
188  using namespace torc::common;
189  // Frame Length Register Value: UG002, v2.2, November 5, 2007, Table 4-15.
190  switch(mDevice) {
191  case eXC2V40: return 26;
192  case eXC2V80: return 46;
193  case eXC2V250: return 66;
194  case eXC2V500: return 86;
195  case eXC2V1000: return 106;
196  case eXC2V1500: return 126;
197  case eXC2V2000: return 146;
198  case eXC2V3000: return 166;
199  case eXC2V4000: return 206;
200  case eXC2V6000: return 246;
201  case eXC2V8000: return 286;
202  default: return 0;
203  }
204  }
205  /// \brief Return the number of frame rows for the current device.
206  virtual uint32_t getFrameRowCount(void) const { return 0; }
207  protected:
208  // typedefs
209  /// \brief Map from frame index to frame address.
210  typedef std::map<uint32_t, Virtex2::FrameAddress> FrameIndexToAddress;
211  /// \brief Map from frame address to frame index.
212  typedef std::map<Virtex2::FrameAddress, uint32_t> FrameAddressToIndex;
213  /// \brief Array of vectors to store frame indexes of each block type
214  typedef std::vector<uint32_t> IndexVector;
215 
216  // members
217  /// \brief Map of frame indexes to frame addresses.
218  FrameIndexToAddress mFrameIndexToAddress;
219  /// \brief Map of frame addressee to frame indexes.
220  FrameAddressToIndex mFrameAddressToIndex;
221  /// \brief Vector to store frame indexes of XDL columns.
223  /// \brief Vector to store frame indexes of Bitstream columns.
225  /// \brief Array to hold frame index boundaries for blocks.
227  /// \brief Map of XDL column indexes to bitstream column indexes.
228  std::map<uint32_t, uint32_t> mXdlColumnToBitColumn;
229  };
230 
231 } // namespace bitstream
232 } // namespace torc
233 
234 #endif // TORC_BITSTREAM_VIRTEX2_HPP
ColumnDefVector mColumnDefs
Column type widths.
Virtex-class bitstream.
VirtexFrameBlocks getBitstreamFrames(uint32_t inBlockCount, uint32_t inBitCol)
Returns frames for queried bitstream coordinates.
Definition: Virtex2.cpp:475
static const char * sOpcodeName[eOpcodeCount]
Packet opcode names.
Definition: Virtex2.hpp:88
TileTypeNameToColumnType mTileTypeNameToColumnType
Header for the VirtexBitstream class.
friend std::ostream & operator<<(std::ostream &os, const Virtex2::FrameAddress &rhs)
Definition: Virtex2.hpp:173
virtual void initializeFrameMaps(void)
Initialize the maps between frame indexes and frame addresses. This is generally only useful for int...
Definition: Virtex2.cpp:366
VirtexFrameBlocks getXdlFrames(uint32_t inBlockCount, uint32_t inXdlCol)
Returns frames for queried xdl coordinates.
Definition: Virtex2.cpp:497
boost::uint32_t uint32_t
Imported type name.
void testVirtex2Device(const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)
Bitstream column definition for Xilinx bitstreams. For every block type 0 through 8...
Definition: DeviceInfo.hpp:35
Virtex2 bitstream.
Definition: Virtex2.hpp:40
EDevice mDevice
Bitstream device enumeration.
std::string string
ERegister
Configuration register enumeration.
Definition: Virtex2.hpp:55
Virtex2(void)
Basic constructor.
Definition: Virtex2.hpp:106
boost::uint32_t uint32_t
Imported type name.
static const Subfield sSTAT[]
Status Register (STAT) subfields.
Definition: Virtex2.hpp:96
std::map< uint32_t, Virtex2::FrameAddress > FrameIndexToAddress
Map from frame index to frame address.
Definition: Virtex2.hpp:210
virtual void readPackets(std::istream &inStream)
Definition: Virtex2.cpp:231
Virtex Frame Address base-class.
virtual uint32_t getFrameLength(void) const
Definition: Virtex2.hpp:187
friend class torc::bitstream::bitstream::Virtex2FarUnitTest
Definition: Virtex2.hpp:42
std::vector< uint32_t > IndexVector
Array of vectors to store frame indexes of each block type.
Definition: Virtex2.hpp:214
virtual bool operator<(const VirtexFrameAddress &vrhs) const
Definition: Virtex2.hpp:165
IndexVector mBitColumnIndexes[Virtex2::eFarBlockTypeCount]
Vector to store frame indexes of XDL columns.
Definition: Virtex2.hpp:222
friend std::ostream & operator<<(std::ostream &os, const Virtex2 &rhs)
Insert the bitstream header into an output stream.
void initializeFullFrameBlocks(void)
Loads full bitstream frames into block data structure.
Definition: Virtex2.cpp:453
boost::filesystem::path path
friend class torc::bitstream::bitstream::Virtex2UnitTest
Definition: Virtex2.hpp:41
uint32_t mBlockFrameIndexBounds[Virtex2::eFarBlockTypeCount]
Array to hold frame index boundaries for blocks.
Definition: Virtex2.hpp:226
virtual bool operator==(const VirtexFrameAddress &vrhs) const
Definition: Virtex2.hpp:161
FrameAddress(EFarBlockType inBlockType, uint32_t inMajor, uint32_t inMinor)
Definition: Virtex2.hpp:155
static const char * sCommandName[eCommandCount]
Configuration command names.
Definition: Virtex2.hpp:92
EFarBlockType
Frame Address Register block type constants.
Definition: Virtex2.hpp:74
boost::uint32_t uint32_t
Imported type name.
Definition: Virtex2.hpp:49
EFar
Frame Address Register subfields.
Definition: Virtex2.hpp:68
EColumnType
Major column types.
Definition: Virtex2.hpp:79
std::map< uint32_t, uint32_t > mXdlColumnToBitColumn
Map of XDL column indexes to bitstream column indexes.
Definition: Virtex2.hpp:228
static const char * sPacketTypeName[ePacketTypeCount]
Packet type names.
Definition: Virtex2.hpp:86
static uint32_t makeSubfield(ERegister inRegister, const std::string &inSubfield, const std::string &inSetting)
Return the masked value for a subfield of the specified register.
Definition: Virtex2.cpp:209
std::map< Virtex2::FrameAddress, uint32_t > FrameAddressToIndex
Map from frame address to frame index.
Definition: Virtex2.hpp:212
static const char * sRegisterName[eRegisterCount]
Configuration register names.
Definition: Virtex2.hpp:90
ECommand
Configuration command enumeration for eRegisterCMD.
Definition: Virtex2.hpp:62
Header for the VirtexBitstream class.
virtual void assign(uint32_t inAddress)
Definition: Virtex2.hpp:148
IndexVector mXdlColumnIndexes[Virtex2::eFarBlockTypeCount]
Vector to store frame indexes of Bitstream columns.
Definition: Virtex2.hpp:224
FrameIndexToAddress mFrameIndexToAddress
Map of frame indexes to frame addresses.
Definition: Virtex2.hpp:218
static const Subfield sCTL[]
Control Register (CTL) subfields.
Definition: Virtex2.hpp:98
static const Subfield sCOR[]
Configuration Options Register (COR) subfields.
Definition: Virtex2.hpp:94
static const Subfield sMASK[]
Control Mask Register (MASK) subfields.
Definition: Virtex2.hpp:100
virtual void initializeDeviceInfo(const std::string &inDeviceName)
Initialize the device information.
Definition: Virtex2.cpp:263
void testVirtex2FullMapping(const boost::filesystem::path &inWorkingPath)
FrameAddressToIndex mFrameAddressToIndex
Map of frame addressee to frame indexes.
Definition: Virtex2.hpp:220
virtual uint32_t getFrameRowCount(void) const
Return the number of frame rows for the current device.
Definition: Virtex2.hpp:206