torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Virtex4.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 Virtex4 class.
18 
19 #ifndef TORC_BITSTREAM_VIRTEX4_HPP
20 #define TORC_BITSTREAM_VIRTEX4_HPP
21 
22 #include <boost/cstdint.hpp>
23 #include <boost/filesystem.hpp>
26 
27 namespace torc { namespace architecture { class DDB; } }
28 
29 namespace torc {
30 namespace bitstream {
31 
32 namespace bitstream { class Virtex4UnitTest; }
33 namespace bitstream { class Virtex4FarUnitTest; }
34 namespace bitstream { void testVirtex4Device(const std::string& inDeviceName,
35  const boost::filesystem::path& inWorkingPath); }
36 namespace bitstream { void testVirtex4FullMapping(const boost::filesystem::path& inWorkingPath); }
37 namespace bitstream { void testVirtex4PartialMapping(const boost::filesystem::path& inWorkingPath); }
38 
39  /// \brief Virtex4 bitstream.
40  class Virtex4 : public VirtexBitstream {
43  friend void torc::bitstream::bitstream::testVirtex4Device(const std::string& inDeviceName,
44  const boost::filesystem::path& inWorkingPath);
47  protected:
48  // typedefs
49  /// \brief Imported type name.
50  typedef boost::uint32_t uint32_t;
51  public:
52  // enumerations
53  //
54  /// \brief Configuration register enumeration.
55  /// \see configuration registers: UG071, v1.10, April 8, 2008, Table 7-5.
59  //
60  /// \brief Configuration command enumeration for eRegisterCMD.
61  /// \see CMD register commands: UG071, v1.10, April 8, 2008, Table 7-6.
65  //
66  /// \brief Frame Address Register subfields.
67  /// \see Frame Address Register Description: UG071, v1.10, April 8, 2008, Table 7-8.
68  enum EFar {
71  eFarMaskRow = 0x0007c000, eFarShiftRow = 14,
72  eFarMaskMajor = 0x00003fc0, eFarShiftMajor = 6,
73  eFarMaskMinor = 0x0000003f, eFarShiftMinor = 0,
74  };
75  //
76  /// \brief Frame Address Register top and bottom constants.
77  enum EFarTopBottom { eFarTop = 0, eFarBottom = 1 };
78  /// \brief Frame Address Register block type constants.
81  /// \brief Major column types.
82  /// \details These are defined and used for internal purposes only, and are not derived
83  /// from any Xilinx documentation.
86  /// \brief Frame length.
87  /// \details Constant frame length of 41 32-bit words for the entire Virtex5 family.
88  /// \see Virtex-4 Frame Count, Frame Length, Overhead and Bitstream Size: UG071, v.1.10,
89  /// April 8, 2008, Table 7-1.
90  enum { eFrameLength = 41 };
91  /// \brief Number of pad frames after each frame row.
92  /// \details The configuration controller expects two frames of NOPs after each frame row.
93  enum { eRowPadFrames = 2 };
94  protected:
95  // members
96 // /// \brief Configuration controller registers.
97 // uint32_t mRegister[eRegisterCount];
98  /// \brief Packet type names.
99  static const char* sPacketTypeName[ePacketTypeCount];
100  /// \brief Packet opcode names.
101  static const char* sOpcodeName[eOpcodeCount];
102  /// \brief Configuration register names.
103  static const char* sRegisterName[eRegisterCount];
104  /// \brief Configuration command names.
105  static const char* sCommandName[eCommandCount];
106  /// \brief Configuration Options Register (COR) subfields.
107  static const Subfield sCOR[];
108  /// \brief Status Register (STAT) subfields.
109  static const Subfield sSTAT[];
110  /// \brief Control Register (CTL) subfields.
111  static const Subfield sCTL[];
112  /// \brief Control Mask Register (MASK) subfields.
113  static const Subfield sMASK[];
114  public:
115  // constructors
116  /// \brief Basic constructor.
118 // for(int i = 0; i < eRegisterCount; i++) mRegister[i] = 0;
119  // initialize miscellaneous variables
120  mFrameRowCount = 0;
121  // initialize the column type widths for this family
123  mColumnDefs[eColumnTypeEmpty] = ColumnDef("Empty", 0, 0, 0, 0, 0, 0, 0, 0);
124  mColumnDefs[eColumnTypeBram] = ColumnDef("Bram", 0, 20, 64, 0, 0, 0, 0, 0);
125  mColumnDefs[eColumnTypeClb] = ColumnDef("Clb", 22, 0, 0, 0, 0, 0, 0, 0);
126  mColumnDefs[eColumnTypeClock] = ColumnDef("Clock", 3, 0, 0, 0, 0, 0, 0, 0);
127  mColumnDefs[eColumnTypeDsp] = ColumnDef("Dsp", 21, 0, 0, 0, 0, 0, 0, 0);
128  mColumnDefs[eColumnTypeGtx] = ColumnDef("Gtx", 20, 0, 0, 0, 0, 0, 0, 0);
129  mColumnDefs[eColumnTypeIob] = ColumnDef("Iob", 30, 0, 0, 0, 0, 0, 0, 0);
130  // map type type names to column types
143  }
144  // functions
145  /// \brief Return the masked value for a subfield of the specified register.
146  static uint32_t makeSubfield(ERegister inRegister, const std::string& inSubfield,
147  const std::string& inSetting);
148  /// \brief Initialize the device information.
149  virtual void initializeDeviceInfo(const std::string& inDeviceName);
150  /// \brief Initialize the maps between frame indexes and frame addresses.
151  /// \detail This is generally only useful for internal purposes.
152  virtual void initializeFrameMaps(void);
153  /// \brief Read frame data into the frame blocks structure.
154  virtual void readFramePackets(void) {
155  readFramePackets4567<Virtex4>(mBlockFrameIndexBounds, mFrameAddressToIndex,
157  }
158  /// \brief Discard the existing frame packets and return an iterator to the start position.
159  virtual VirtexPacketVector::iterator deleteFramePackets(void) {
160  return deleteFramePackets4567<Virtex4>();
161  }
162  /// \brief Return a packet vector with full frame data.
164  return generateFullBitstreamPackets4567<Virtex4>(mBlockFrameIndexBounds);
165  }
166  /// \brief Return a packet vector with the full bitstream prefix.
168  /// \brief Return a packet vector with the full bitstream suffix.
170  /// \brief Return a packet vector with partial frame data.
171  /// \param inFrameInclusion The type of frames to include: only dirty frames or all frames.
173  return generatePartialBitstreamPackets4567<Virtex4>(inFrameInclusion,
175  }
176  /// \brief Return a packet vector with the partial bitstream prefix.
177  /// \param inBitstreamType The type of partial bitstream to generate: active or shutdown.
179  /// \brief Return a packet vector with the partial bitstream suffix.
180  /// \param inBitstreamType The type of partial bitstream to generate: active or shutdown.
182  /// \brief Returns frames for queried bitstream coordinates
183  VirtexFrameBlocks getBitstreamFrames(uint32_t inBlockCount, uint32_t inBitCol,
184  uint32_t inFrameRow = 0);
185  /// \brief Returns frames for queried xdl coordinates
186  VirtexFrameBlocks getXdlFrames(uint32_t inBlockCount, uint32_t inXdlCol,
187  uint32_t inFrameRow = 0);
188  // deprecation macro
189  /// \cond OMIT_FROM_DOXYGEN
190  // Doxygen gets confused by the explicit "__attribute__ ((deprecated))" so we used this
191  #define DEPRECATED __attribute__ ((deprecated))
192  /// \endcond
193  // deprecated functions
194  /// \brief Loads full bitstream frames into block data structure.
195  DEPRECATED void initializeFullFrameBlocks(void);
196  // accessors
197  /// \brief Return the number of frame rows for the current device.
198  virtual uint32_t getFrameRowCount(void) const { return mFrameRowCount; }
199  /// \brief Return the frame length for the current device.
200  virtual uint32_t getFrameLength(void) const { return eFrameLength; }
201  /// \brief Return the number of pad frames after each row.
202  virtual uint32_t getRowPadFrames(void) const { return eRowPadFrames; }
203  // inserters
204  /// \brief Insert the bitstream header into an output stream.
205  friend std::ostream& operator<< (std::ostream& os, const Virtex4& rhs);
206  // inner classes
208  protected:
209  virtual void assign(uint32_t inAddress) {
212  mRow = (inAddress & eFarMaskRow) >> eFarShiftRow;
213  mMajor = (inAddress & eFarMaskMajor) >> eFarShiftMajor;
214  mMinor = (inAddress & eFarMaskMinor) >> eFarShiftMinor;
215  }
216  public:
218  mMajor(0), mMinor(0) {}
219  FrameAddress(EFarTopBottom inTopBottom, EFarBlockType inBlockType, uint32_t inRow,
220  uint32_t inMajor, uint32_t inMinor) : mTopBottom(inTopBottom),
221  mBlockType(inBlockType), mRow(inRow), mMajor(inMajor), mMinor(inMinor) {}
222  FrameAddress(uint32_t inAddress) { assign(inAddress); }
228  virtual bool operator== (const VirtexFrameAddress& vrhs) const {
229  const FrameAddress& rhs = reinterpret_cast<const FrameAddress&>(vrhs);
230  return mTopBottom == rhs.mTopBottom && mBlockType == rhs.mBlockType
231  && mRow == rhs.mRow && mMajor == rhs.mMajor && mMinor == rhs.mMinor;
232  }
233  virtual bool operator< (const VirtexFrameAddress& vrhs) const {
234  const FrameAddress& rhs = reinterpret_cast<const FrameAddress&>(vrhs);
235  int diffBlockType = mBlockType - rhs.mBlockType;
236  if(diffBlockType) return diffBlockType < 0;
237  int diffTopBottom = mTopBottom - rhs.mTopBottom;
238  if(diffTopBottom) return diffTopBottom < 0;
239  int diffRow = mRow - rhs.mRow;
240  if(diffRow) return diffRow < 0;
241  int diffMajor = mMajor - rhs.mMajor;
242  if(diffMajor) return diffMajor < 0;
243  return mMinor < rhs.mMinor;
244  }
245  operator uint32_t (void) const {
248  | ((mRow << eFarShiftRow) & eFarMaskRow)
250  | ((mMinor << eFarShiftMinor) & eFarMaskMinor));
251  }
252  friend std::ostream& operator<< (std::ostream& os, const Virtex4::FrameAddress& rhs) {
253  return os << (rhs.mTopBottom == Virtex4::eFarTop ? 'T' : 'B')
254  << "" << rhs.mBlockType << "(" << rhs.mRow << "," << rhs.mMajor << "."
255  << rhs.mMinor << ")";
256  }
257  private:
258  //
259  };
260  protected:
261  // typedefs
262  /// \brief Map from frame index to frame address.
263  typedef std::map<uint32_t, Virtex4::FrameAddress> FrameIndexToAddress;
264  /// \brief Map from frame address to frame index.
265  typedef std::map<Virtex4::FrameAddress, uint32_t> FrameAddressToIndex;
266  /// \brief Array of vectors to store frame indexes of each block type
267  typedef std::vector<uint32_t> IndexVector;
268 
269  // members
270  /// \brief Map of frame indexes to frame addresses.
272  /// \brief Map of frame addressee to frame indexes.
274  /// \brief Vector to store frame indexes of XDL columns.
276  /// \brief Vector to store frame indexes of Bitstream columns.
278  /// \brief Array to hold frame index boundaries for blocks.
280  /// \brief Map of XDL column indexes to bitstream column indexes.
281  std::map<uint32_t, uint32_t> mXdlColumnToBitColumn;
282  /// \brief Number of frame rows.
284  };
285 
286 } // namespace bitstream
287 } // namespace torc
288 
289 #endif // TORC_BITSTREAM_VIRTEX4_HPP
ColumnDefVector mColumnDefs
Column type widths.
Virtex-class bitstream.
static const char * sOpcodeName[eOpcodeCount]
Packet opcode names.
Definition: Virtex4.hpp:101
virtual VirtexPacketVector generatePartialBitstreamPrefix(EBitstreamType inBitstreamType)
Return a packet vector with the partial bitstream prefix.
Definition: Virtex4.cpp:643
void testVirtex4Device(const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)
EFarTopBottom
Frame Address Register top and bottom constants.
Definition: Virtex4.hpp:77
virtual uint32_t getFrameRowCount(void) const
Return the number of frame rows for the current device.
Definition: Virtex4.hpp:198
TileTypeNameToColumnType mTileTypeNameToColumnType
virtual void initializeDeviceInfo(const std::string &inDeviceName)
Initialize the device information.
Definition: Virtex4.cpp:277
std::map< uint32_t, uint32_t > mXdlColumnToBitColumn
Map of XDL column indexes to bitstream column indexes.
Definition: Virtex4.hpp:281
ERegister
Configuration register enumeration.
Definition: Virtex4.hpp:56
virtual VirtexPacketVector generateFullBitstreamPackets(void)
Return a packet vector with full frame data.
Definition: Virtex4.hpp:163
Header for the VirtexBitstream class.
friend class torc::bitstream::bitstream::Virtex4FarUnitTest
Definition: Virtex4.hpp:42
FrameIndexToAddress mFrameIndexToAddress
Map of frame indexes to frame addresses.
Definition: Virtex4.hpp:271
EColumnType
Major column types.
Definition: Virtex4.hpp:84
virtual bool operator<(const VirtexFrameAddress &vrhs) const
Definition: Virtex4.hpp:233
virtual uint32_t getRowPadFrames(void) const
Return the number of pad frames after each row.
Definition: Virtex4.hpp:202
virtual void initializeFrameMaps(void)
Initialize the maps between frame indexes and frame addresses. This is generally only useful for int...
Definition: Virtex4.cpp:385
virtual VirtexPacketVector generatePartialBitstreamSuffix(EBitstreamType inBitstreamType)
Return a packet vector with the partial bitstream suffix.
Definition: Virtex4.cpp:707
EFrameInclude
The frames to include in a partial bitstream. Use eFrameIncludeOnlyDirtyFrames to include only dirty...
ECommand
Configuration command enumeration for eRegisterCMD.
Definition: Virtex4.hpp:62
VirtexFrameBlocks getXdlFrames(uint32_t inBlockCount, uint32_t inXdlCol, uint32_t inFrameRow=0)
Returns frames for queried xdl coordinates.
Definition: Virtex4.cpp:804
std::vector< uint32_t > IndexVector
Array of vectors to store frame indexes of each block type.
Definition: Virtex4.hpp:267
boost::uint32_t uint32_t
Imported type name.
friend class torc::bitstream::bitstream::Virtex4UnitTest
Definition: Virtex4.hpp:41
virtual VirtexPacketVector generatePartialBitstreamPackets(EFrameInclude inFrameInclusion)
Return a packet vector with partial frame data.
Definition: Virtex4.hpp:172
virtual VirtexPacketVector generateFullBitstreamSuffix(void)
Return a packet vector with the full bitstream suffix.
Definition: Virtex4.cpp:573
virtual VirtexPacketVector::iterator deleteFramePackets(void)
Discard the existing frame packets and return an iterator to the start position.
Definition: Virtex4.hpp:159
EFar
Frame Address Register subfields.
Definition: Virtex4.hpp:68
friend std::ostream & operator<<(std::ostream &os, const Virtex4::FrameAddress &rhs)
Definition: Virtex4.hpp:252
static const char * sPacketTypeName[ePacketTypeCount]
Packet type names.
Definition: Virtex4.hpp:99
Bitstream column definition for Xilinx bitstreams. For every block type 0 through 8...
Definition: DeviceInfo.hpp:35
VirtexFrameBlocks getBitstreamFrames(uint32_t inBlockCount, uint32_t inBitCol, uint32_t inFrameRow=0)
Returns frames for queried bitstream coordinates.
Definition: Virtex4.cpp:778
std::map< Virtex4::FrameAddress, uint32_t > FrameAddressToIndex
Map from frame address to frame index.
Definition: Virtex4.hpp:265
virtual void readFramePackets(void)
Read frame data into the frame blocks structure.
Definition: Virtex4.hpp:154
virtual bool operator==(const VirtexFrameAddress &vrhs) const
Definition: Virtex4.hpp:228
Virtex4(void)
Basic constructor.
Definition: Virtex4.hpp:117
static const char * sCommandName[eCommandCount]
Configuration command names.
Definition: Virtex4.hpp:105
void testVirtex4PartialMapping(const boost::filesystem::path &inWorkingPath)
static const Subfield sCTL[]
Control Register (CTL) subfields.
Definition: Virtex4.hpp:111
std::map< uint32_t, Virtex4::FrameAddress > FrameIndexToAddress
Map from frame index to frame address.
Definition: Virtex4.hpp:263
DEPRECATED void initializeFullFrameBlocks(void)
Loads full bitstream frames into block data structure.
Definition: Virtex4.cpp:756
std::string string
uint32_t mFrameRowCount
Number of frame rows.
Definition: Virtex4.hpp:283
uint32_t mBlockFrameIndexBounds[Virtex4::eFarBlockTypeCount]
Array to hold frame index boundaries for blocks.
Definition: Virtex4.hpp:279
static const char * sRegisterName[eRegisterCount]
Configuration register names.
Definition: Virtex4.hpp:103
Virtex Frame Address base-class.
static const Subfield sSTAT[]
Status Register (STAT) subfields.
Definition: Virtex4.hpp:109
FrameAddressToIndex mFrameAddressToIndex
Map of frame addressee to frame indexes.
Definition: Virtex4.hpp:273
virtual uint32_t getFrameLength(void) const
Return the frame length for the current device.
Definition: Virtex4.hpp:200
EFarBlockType
Frame Address Register block type constants.
Definition: Virtex4.hpp:79
void testVirtex4FullMapping(const boost::filesystem::path &inWorkingPath)
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
IndexVector mBitColumnIndexes[Virtex4::eFarBlockTypeCount]
Vector to store frame indexes of XDL columns.
Definition: Virtex4.hpp:275
static const Subfield sMASK[]
Control Mask Register (MASK) subfields.
Definition: Virtex4.hpp:113
std::vector< VirtexPacket > VirtexPacketVector
Vector of Virtex packets.
Virtex4 bitstream.
Definition: Virtex4.hpp:40
IndexVector mXdlColumnIndexes[Virtex4::eFarBlockTypeCount]
Vector to store frame indexes of Bitstream columns.
Definition: Virtex4.hpp:277
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: Virtex4.cpp:223
friend std::ostream & operator<<(std::ostream &os, const Virtex4 &rhs)
Insert the bitstream header into an output stream.
FrameAddress(EFarTopBottom inTopBottom, EFarBlockType inBlockType, uint32_t inRow, uint32_t inMajor, uint32_t inMinor)
Definition: Virtex4.hpp:219
static const Subfield sCOR[]
Configuration Options Register (COR) subfields.
Definition: Virtex4.hpp:107
boost::uint32_t uint32_t
Imported type name.
Definition: Virtex4.hpp:50
virtual void assign(uint32_t inAddress)
Definition: Virtex4.hpp:209
Header for the VirtexBitstream class.
virtual VirtexPacketVector generateFullBitstreamPrefix(void)
Return a packet vector with the full bitstream prefix.
Definition: Virtex4.cpp:472