torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Virtex6.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 Virtex6 class.
18 
19 #ifndef TORC_BITSTREAM_VIRTEX6_HPP
20 #define TORC_BITSTREAM_VIRTEX6_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 Virtex6UnitTest; }
34 namespace bitstream { class Virtex6FarUnitTest; }
35 namespace bitstream { void testVirtex6Device(const std::string& inDeviceName,
36  const boost::filesystem::path& inWorkingPath); }
37 namespace bitstream { void testVirtex6FullMapping(const boost::filesystem::path& inWorkingPath); }
38 namespace bitstream { void testVirtex6PartialMapping(const boost::filesystem::path& inWorkingPath); }
39 
40  /// \brief Virtex6 bitstream.
41  class Virtex6 : public VirtexBitstream {
44  friend void torc::bitstream::bitstream::testVirtex6Device(const std::string& inDeviceName,
45  const boost::filesystem::path& inWorkingPath);
48  protected:
49  // typedefs
50  /// \brief Imported type name.
51  typedef boost::uint32_t uint32_t;
52  public:
53  // enumerations
54  /// \brief Configuration register enumeration.
55  /// \see Type 1 Packet Registers: UG360, v3.2, November 1, 2010, Table 6-26.
61  //
62  /// \brief Configuration command enumeration for eRegisterCMD.
63  /// \see Command Register Codes: UG360, v3.2, November 1, 2010, Table 6-27.
69  //
70  /// \brief Frame Address Register subfields.
71  /// \see Frame Address Register Description: UG360, v3.2, November 1, 2010, Table 6-31.
72  enum EFar {
75  eFarMaskRow = 0x000f8000, eFarShiftRow = 15,
76  eFarMaskMajor = 0x00007f80, eFarShiftMajor = 7,
77  eFarMaskMinor = 0x0000007f, eFarShiftMinor = 0
78  };
79  //
80  /// \brief Frame Address Register top and bottom constants.
81  /// \see Frame Address Register Description: UG360, v3.2, November 1, 2010, Table 6-31.
82  enum EFarTopBottom { eFarTop = 0, eFarBottom = 1 };
83  //
84  /// \brief Frame Address Register block type constants.
87  //
88  /// \brief Assorted constants.
89  /// \see WBSTAR Register Description: UG360, v3.2, November 1, 2010, Table 6-39.
90  enum {
91  eStartAddr = 0x03ffffff,
92  eTimerValue = 0x00ffffff
93  };
94  /// \brief Major column types.
95  /// \details These are defined and used for internal purposes only, and are not derived
96  /// from any Xilinx documentation.
99  /// \brief Frame length.
100  /// \details Constant frame length of 81 32-bit words for the entire Virtex6 family.
101  /// \see Virtex-6 FPGA Frame Count, Frame Length, and Bitstream Size: UG360, v.3.2,
102  /// November 1, 2010, Table 6-22.
103  enum { eFrameLength = 81 };
104  /// \brief Number of pad frames after each frame row.
105  /// \details The configuration controller expects two frames of NOPs after each frame row.
106  enum { eRowPadFrames = 2 };
107  protected:
108  // members
109 // /// \brief Configuration controller registers.
110 // uint32_t mRegister[eRegisterCount];
111  /// \brief Packet type names.
112  static const char* sPacketTypeName[ePacketTypeCount];
113  /// \brief Packet opcode names.
114  static const char* sOpcodeName[eOpcodeCount];
115  /// \brief Configuration register names.
116  static const char* sRegisterName[eRegisterCount];
117  /// \brief Configuration command names.
118  static const char* sCommandName[eCommandCount];
119  /// \brief Configuration Options Register 0 (COR) subfields.
120  static const Subfield sCOR0[];
121  /// \brief Configuration Options Register 1 (COR) subfields.
122  static const Subfield sCOR1[];
123  /// \brief Status Register (STAT) subfields.
124  static const Subfield sSTAT[];
125  /// \brief Control Register 0 (CTL) subfields.
126  static const Subfield sCTL0[];
127  /// \brief Control Register 1 (CTL) subfields.
128  static const Subfield sCTL1[];
129  /// \brief Control Mask Register (MASK) subfields.
130  static const Subfield sMASK0[];
131  /// \brief Warm Boot Start Address Register (WBSTAR) subfields.
132  static const Subfield sWBSTAR[];
133  /// \brief Watchdog Timer Register (TIMER) subfields.
134  static const Subfield sTIMER[];
135  /// \brief Boot History Status Register (BOOTSTS) subfields.
136  static const Subfield sBOOTSTS[];
137  /// \brief The number of top bitstream rows.
139  /// \brief The number of bottom bitstream rows.
141  // functions
142  /// \brief Set the number of top and bottom bitstream rows.
143  void setRowCounts(void);
144  public:
145  // constructors
146  /// \brief Basic constructor.
148 // for(int i = 0; i < eRegisterCount; i++) mRegister[i] = 0;
149  // initialize miscellaneous variables
150  mFrameRowCount = 0;
151  // initialize the column type widths for this family
153  mColumnDefs[eColumnTypeEmpty] = ColumnDef("Empty", 0, 0, 0, 0, 0, 0, 0, 0);
154  mColumnDefs[eColumnTypeBram] = ColumnDef("Bram", 28,128, 0, 0, 0, 0, 0, 0);
155  mColumnDefs[eColumnTypeClb] = ColumnDef("Clb", 36, 0, 0, 0, 0, 0, 0, 0);
156  mColumnDefs[eColumnTypeClock] = ColumnDef("Clock", 38, 0, 0, 0, 0, 0, 0, 0);
157  mColumnDefs[eColumnTypeDsp] = ColumnDef("Dsp", 28, 0, 0, 0, 0, 0, 0, 0);
158  mColumnDefs[eColumnTypeGtx] = ColumnDef("Gtx", 30, 0, 0, 0, 0, 0, 0, 0);
159  mColumnDefs[eColumnTypeIob] = ColumnDef("Iob", 44, 0, 0, 0, 0, 0, 0, 0);
160  // map type type names to column types
174  }
175  // functions
176  /// \brief Return the masked value for a subfield of the specified register.
177  static uint32_t makeSubfield(ERegister inRegister, const std::string& inSubfield,
178  const std::string& inSetting);
179  /// \brief Initialize the device information.
180  virtual void initializeDeviceInfo(const std::string& inDeviceName);
181  /// \brief Initialize the maps between frame indexes and frame addresses.
182  /// \detail This is generally only useful for internal purposes.
183  virtual void initializeFrameMaps(void);
184  /// \brief Read frame data into the frame blocks structure.
185  virtual void readFramePackets(void) {
186  readFramePackets4567<Virtex6>(mBlockFrameIndexBounds, mFrameAddressToIndex,
188  }
189  /// \brief Discard the existing frame packets and return an iterator to the start position.
190  virtual VirtexPacketVector::iterator deleteFramePackets(void) {
191  return deleteFramePackets4567<Virtex6>();
192  }
193  /// \brief Return a packet vector with full frame data.
195  return generateFullBitstreamPackets4567<Virtex6>(mBlockFrameIndexBounds);
196  }
197  /// \brief Return a packet vector with the full bitstream prefix.
199  /// \brief Return a packet vector with the full bitstream suffix.
201  /// \brief Return a packet vector with partial frame data.
202  /// \param inFrameInclusion The type of frames to include: only dirty frames or all frames.
204  return generatePartialBitstreamPackets4567<Virtex6>(inFrameInclusion,
206  }
207  /// \brief Return a packet vector with the partial bitstream prefix.
208  /// \param inBitstreamType The type of partial bitstream to generate: active or shutdown.
210  /// \brief Return a packet vector with the partial bitstream suffix.
211  /// \param inBitstreamType The type of partial bitstream to generate: active or shutdown.
213  /// \brief Returns frames for queried bitstream coordinates
214  VirtexFrameBlocks getBitstreamFrames(uint32_t inBlockCount, uint32_t inBitCol,
215  uint32_t inFrameRow = 0);
216  /// \brief Returns frames for queried xdl coordinates
217  VirtexFrameBlocks getXdlFrames(uint32_t inBlockCount, uint32_t inXdlCol,
218  uint32_t inFrameRow = 0);
219  // deprecation macro
220  /// \cond OMIT_FROM_DOXYGEN
221  // Doxygen gets confused by the explicit "__attribute__ ((deprecated))" so we used this
222  #define DEPRECATED __attribute__ ((deprecated))
223  /// \endcond
224  // deprecated functions
225  /// \brief Loads full bitstream frames into block data structure.
226  DEPRECATED void initializeFullFrameBlocks(void);
227  // accessors
228  /// \brief Return the number of frame rows for the current device.
229  virtual uint32_t getFrameRowCount(void) const { return mFrameRowCount; }
230  /// \brief Return the frame length for the current device.
231  virtual uint32_t getFrameLength(void) const { return eFrameLength; }
232  /// \brief Return the number of pad frames after each row.
233  virtual uint32_t getRowPadFrames(void) const { return eRowPadFrames; }
234  // inserters
235  /// \brief Insert the bitstream header into an output stream.
236  friend std::ostream& operator<< (std::ostream& os, const Virtex6& rhs);
237  // inner classes
239  protected:
240  virtual void assign(uint32_t inAddress) {
243  mRow = (inAddress & eFarMaskRow) >> eFarShiftRow;
244  mMajor = (inAddress & eFarMaskMajor) >> eFarShiftMajor;
245  mMinor = (inAddress & eFarMaskMinor) >> eFarShiftMinor;
246  }
247  public:
249  mMajor(0), mMinor(0) {}
250  FrameAddress(EFarTopBottom inTopBottom, EFarBlockType inBlockType, uint32_t inRow,
251  uint32_t inMajor, uint32_t inMinor) : mTopBottom(inTopBottom),
252  mBlockType(inBlockType), mRow(inRow), mMajor(inMajor), mMinor(inMinor) {}
253  FrameAddress(uint32_t inAddress) { assign(inAddress); }
259  virtual bool operator== (const VirtexFrameAddress& vrhs) const {
260  const FrameAddress& rhs = reinterpret_cast<const FrameAddress&>(vrhs);
261  return mTopBottom == rhs.mTopBottom && mBlockType == rhs.mBlockType
262  && mRow == rhs.mRow && mMajor == rhs.mMajor && mMinor == rhs.mMinor;
263  }
264  virtual bool operator< (const VirtexFrameAddress& vrhs) const {
265  const FrameAddress& rhs = reinterpret_cast<const FrameAddress&>(vrhs);
266  int diffBlockType = mBlockType - rhs.mBlockType;
267  if(diffBlockType) return diffBlockType < 0;
268  int diffTopBottom = mTopBottom - rhs.mTopBottom;
269  if(diffTopBottom) return diffTopBottom < 0;
270  int diffRow = mRow - rhs.mRow;
271  if(diffRow) return diffRow < 0;
272  int diffMajor = mMajor - rhs.mMajor;
273  if(diffMajor) return diffMajor < 0;
274  return mMinor < rhs.mMinor;
275  }
276  operator uint32_t (void) const {
277  return
280  ((mRow << eFarShiftRow) & eFarMaskRow) |
283  }
284  friend std::ostream& operator<< (std::ostream& os, const Virtex6::FrameAddress& rhs) {
285  return os << (rhs.mTopBottom == Virtex6::eFarTop ? 'T' : 'B')
286  << "" << rhs.mBlockType << "(" << rhs.mRow << "," << rhs.mMajor << "."
287  << rhs.mMinor << ")";
288  }
289  private:
290  //operator uint32_t (void) const {
291  // return
292  // ((mTopBottom << eFarShiftTopBottom) & eFarMaskTopBottom) |
293  // ((mBlockType << eFarShiftBlockType) & eFarMaskBlockType) |
294  // ((mRow << eFarShiftRow) & eFarMaskRow) |
295  // ((mMajor << eFarShiftMajor) & eFarMaskMajor) |
296  // ((mMinor << eFarShiftMinor) & eFarMaskMinor);
297  //}
298  };
299  protected:
300  // typedefs
301  /// \brief Map from frame index to frame address.
302  typedef std::map<uint32_t, Virtex6::FrameAddress> FrameIndexToAddress;
303  /// \brief Map from frame address to frame index.
304  typedef std::map<Virtex6::FrameAddress, uint32_t> FrameAddressToIndex;
305  /// \brief Array of vectors to store frame indexes of each block type
306  typedef std::vector<uint32_t> IndexVector;
307 
308  // members
309  /// \brief Map of frame indexes to frame addresses.
311  /// \brief Map of frame addressee to frame indexes.
313  /// \brief Vector to store frame indexes of XDL columns.
315  /// \brief Vector to store frame indexes of Bitstream columns.
317  /// \brief Array to hold frame index boundaries for blocks.
319  /// \brief Map of XDL column indexes to bitstream column indexes.
320  std::map<uint32_t, uint32_t> mXdlColumnToBitColumn;
321  /// \brief Number of frame rows.
323  };
324 
325 } // namespace bitstream
326 } // namespace torc
327 
328 #endif // TORC_BITSTREAM_VIRTEX6_HPP
ColumnDefVector mColumnDefs
Column type widths.
Virtex-class bitstream.
static const char * sOpcodeName[eOpcodeCount]
Packet opcode names.
Definition: Virtex6.hpp:114
virtual uint32_t getRowPadFrames(void) const
Return the number of pad frames after each row.
Definition: Virtex6.hpp:233
static const char * sPacketTypeName[ePacketTypeCount]
Packet type names.
Definition: Virtex6.hpp:112
friend std::ostream & operator<<(std::ostream &os, const Virtex6::FrameAddress &rhs)
Definition: Virtex6.hpp:284
TileTypeNameToColumnType mTileTypeNameToColumnType
FrameAddress(EFarTopBottom inTopBottom, EFarBlockType inBlockType, uint32_t inRow, uint32_t inMajor, uint32_t inMinor)
Definition: Virtex6.hpp:250
Header for the VirtexBitstream class.
IndexVector mBitColumnIndexes[Virtex6::eFarBlockTypeCount]
Vector to store frame indexes of XDL columns.
Definition: Virtex6.hpp:314
static const char * sRegisterName[eRegisterCount]
Configuration register names.
Definition: Virtex6.hpp:116
void testVirtex6FullMapping(const boost::filesystem::path &inWorkingPath)
virtual VirtexPacketVector generateFullBitstreamPrefix(void)
Return a packet vector with the full bitstream prefix.
Definition: Virtex6.cpp:655
uint32_t mFrameRowCount
Number of frame rows.
Definition: Virtex6.hpp:322
static const Subfield sBOOTSTS[]
Boot History Status Register (BOOTSTS) subfields.
Definition: Virtex6.hpp:136
virtual VirtexPacketVector generatePartialBitstreamSuffix(EBitstreamType inBitstreamType)
Return a packet vector with the partial bitstream suffix.
Definition: Virtex6.cpp:947
IndexVector mXdlColumnIndexes[Virtex6::eFarBlockTypeCount]
Vector to store frame indexes of Bitstream columns.
Definition: Virtex6.hpp:316
Virtex6 bitstream.
Definition: Virtex6.hpp:41
std::map< Virtex6::FrameAddress, uint32_t > FrameAddressToIndex
Map from frame address to frame index.
Definition: Virtex6.hpp:304
EFrameInclude
The frames to include in a partial bitstream. Use eFrameIncludeOnlyDirtyFrames to include only dirty...
boost::uint32_t uint32_t
Imported type name.
FrameAddressToIndex mFrameAddressToIndex
Map of frame addressee to frame indexes.
Definition: Virtex6.hpp:312
VirtexFrameBlocks getBitstreamFrames(uint32_t inBlockCount, uint32_t inBitCol, uint32_t inFrameRow=0)
Returns frames for queried bitstream coordinates.
Definition: Virtex6.cpp:1053
Bitstream column definition for Xilinx bitstreams. For every block type 0 through 8...
Definition: DeviceInfo.hpp:35
static const Subfield sCOR0[]
Configuration Options Register 0 (COR) subfields.
Definition: Virtex6.hpp:120
virtual uint32_t getFrameRowCount(void) const
Return the number of frame rows for the current device.
Definition: Virtex6.hpp:229
FrameIndexToAddress mFrameIndexToAddress
Map of frame indexes to frame addresses.
Definition: Virtex6.hpp:310
static const Subfield sMASK0[]
Control Mask Register (MASK) subfields.
Definition: Virtex6.hpp:130
uint32_t mBlockFrameIndexBounds[Virtex6::eFarBlockTypeCount]
Array to hold frame index boundaries for blocks.
Definition: Virtex6.hpp:318
std::string string
std::map< uint32_t, Virtex6::FrameAddress > FrameIndexToAddress
Map from frame index to frame address.
Definition: Virtex6.hpp:302
static const Subfield sCOR1[]
Configuration Options Register 1 (COR) subfields.
Definition: Virtex6.hpp:122
static const char * sCommandName[eCommandCount]
Configuration command names.
Definition: Virtex6.hpp:118
EColumnType
Major column types.
Definition: Virtex6.hpp:97
Virtex Frame Address base-class.
EFar
Frame Address Register subfields.
Definition: Virtex6.hpp:72
friend class torc::bitstream::bitstream::Virtex6FarUnitTest
Definition: Virtex6.hpp:43
static const Subfield sCTL1[]
Control Register 1 (CTL) subfields.
Definition: Virtex6.hpp:128
ECommand
Configuration command enumeration for eRegisterCMD.
Definition: Virtex6.hpp:64
uint32_t mTopRowCount
The number of top bitstream rows.
Definition: Virtex6.hpp:138
ERegister
Configuration register enumeration.
Definition: Virtex6.hpp:56
uint32_t mBottomRowCount
The number of bottom bitstream rows.
Definition: Virtex6.hpp:140
std::vector< uint32_t > IndexVector
Array of vectors to store frame indexes of each block type.
Definition: Virtex6.hpp:306
EBitstreamType
The bitstream type to generate. Use eBitstreamFull to fully reconfigure a device, eBitstreamTypePartialActive to partially reconfigure it while it continues to run, or eBitstreamTypePartialShutdown to partially recongifure it after shutting it down.
boost::filesystem::path path
friend class torc::bitstream::bitstream::Virtex6UnitTest
Definition: Virtex6.hpp:42
void setRowCounts(void)
Set the number of top and bottom bitstream rows.
Definition: Virtex6.cpp:530
virtual VirtexPacketVector generatePartialBitstreamPrefix(EBitstreamType inBitstreamType)
Return a packet vector with the partial bitstream prefix.
Definition: Virtex6.cpp:864
static const Subfield sSTAT[]
Status Register (STAT) subfields.
Definition: Virtex6.hpp:124
std::vector< VirtexPacket > VirtexPacketVector
Vector of Virtex packets.
void testVirtex6PartialMapping(const boost::filesystem::path &inWorkingPath)
virtual uint32_t getFrameLength(void) const
Return the frame length for the current device.
Definition: Virtex6.hpp:231
Virtex6(void)
Basic constructor.
Definition: Virtex6.hpp:147
EFarBlockType
Frame Address Register block type constants.
Definition: Virtex6.hpp:85
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: Virtex6.cpp:364
virtual bool operator==(const VirtexFrameAddress &vrhs) const
Definition: Virtex6.hpp:259
void testVirtex6Device(const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)
EFarTopBottom
Frame Address Register top and bottom constants.
Definition: Virtex6.hpp:82
virtual void readFramePackets(void)
Read frame data into the frame blocks structure.
Definition: Virtex6.hpp:185
DEPRECATED void initializeFullFrameBlocks(void)
Loads full bitstream frames into block data structure.
Definition: Virtex6.cpp:1006
virtual void initializeFrameMaps(void)
Initialize the maps between frame indexes and frame addresses. This is generally only useful for int...
Definition: Virtex6.cpp:559
boost::uint32_t uint32_t
Imported type name.
Definition: Virtex6.hpp:51
virtual void initializeDeviceInfo(const std::string &inDeviceName)
Initialize the device information.
Definition: Virtex6.cpp:412
static const Subfield sCTL0[]
Control Register 0 (CTL) subfields.
Definition: Virtex6.hpp:126
virtual void assign(uint32_t inAddress)
Definition: Virtex6.hpp:240
virtual bool operator<(const VirtexFrameAddress &vrhs) const
Definition: Virtex6.hpp:264
static const Subfield sWBSTAR[]
Warm Boot Start Address Register (WBSTAR) subfields.
Definition: Virtex6.hpp:132
std::map< uint32_t, uint32_t > mXdlColumnToBitColumn
Map of XDL column indexes to bitstream column indexes.
Definition: Virtex6.hpp:320
Header for the VirtexBitstream class.
VirtexFrameBlocks getXdlFrames(uint32_t inBlockCount, uint32_t inXdlCol, uint32_t inFrameRow=0)
Returns frames for queried xdl coordinates.
Definition: Virtex6.cpp:1079
virtual VirtexPacketVector generatePartialBitstreamPackets(EFrameInclude inFrameInclusion)
Return a packet vector with partial frame data.
Definition: Virtex6.hpp:203
static const Subfield sTIMER[]
Watchdog Timer Register (TIMER) subfields.
Definition: Virtex6.hpp:134
virtual VirtexPacketVector generateFullBitstreamSuffix(void)
Return a packet vector with the full bitstream suffix.
Definition: Virtex6.cpp:787
friend std::ostream & operator<<(std::ostream &os, const Virtex6 &rhs)
Insert the bitstream header into an output stream.
virtual VirtexPacketVector generateFullBitstreamPackets(void)
Return a packet vector with full frame data.
Definition: Virtex6.hpp:194
virtual VirtexPacketVector::iterator deleteFramePackets(void)
Discard the existing frame packets and return an iterator to the start position.
Definition: Virtex6.hpp:190