torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Virtex.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 Virtex class.
18 
19 #ifndef TORC_BITSTREAM_VIRTEX_HPP
20 #define TORC_BITSTREAM_VIRTEX_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 VirtexUnitTest; }
34 namespace bitstream { class VirtexFarUnitTest; }
35 namespace bitstream { void testVirtexDevice(const std::string& inDeviceName,
36  const boost::filesystem::path& inWorkingPath); }
37 namespace bitstream { void testVirtexFullMapping(const boost::filesystem::path& inWorkingPath); }
38 
39  /// \brief Virtex bitstream.
40  class Virtex : public VirtexBitstream {
43  friend void torc::bitstream::bitstream::testVirtexDevice(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: XAPP151, v1.7, October 20, 2004, Table 18.
58  //
59  /// \brief Configuration command enumeration for eRegisterCMD.
60  /// \see CMD register commands: XAPP151, v1.7, October 20, 2004, Table 19.
63  //
64  /// \brief Frame Address Register subfields.
65  /// \see Frame Address Register Description: XAPP151, v1.7, October 20, 2004, Figure 19.
66  enum EFar {
68  eFarMaskMajor = 0x01FE0000, eFarShiftMajor = 17,
69  eFarMaskMinor = 0x0001FE00, eFarShiftMinor = 9,
70  };
71  //
72  /// \brief Frame Address Register block type constants.
75  /// \brief Major column types.
76  /// \details These are defined and used for internal purposes only, and are not derived
77  /// from any Xilinx documentation.
80  protected:
81  // members
82 // /// \brief Configuration controller registers.
83 // uint32_t mRegister[eRegisterCount];
84  /// \brief Packet type names.
85  static const char* sPacketTypeName[ePacketTypeCount];
86  /// \brief Packet opcode names.
87  static const char* sOpcodeName[eOpcodeCount];
88  /// \brief Configuration register names.
89  static const char* sRegisterName[eRegisterCount];
90  /// \brief Configuration command names.
91  static const char* sCommandName[eCommandCount];
92  /// \brief Configuration Options Register (COR) subfields.
93  static const Subfield sCOR[];
94  /// \brief Status Register (STAT) subfields.
95  static const Subfield sSTAT[];
96  /// \brief Control Register (CTL) subfields.
97  static const Subfield sCTL[];
98  /// \brief Control Mask Register (MASK) subfields.
99  static const Subfield sMASK[];
101  public:
102  // constructors
103  /// \brief Basic constructor.
105 // for(int i = 0; i < eRegisterCount; i++) mRegister[i] = 0;
106  // initialize the column type widths for this family
108  mColumnDefs[eColumnTypeEmpty] = ColumnDef("Empty", 0, 0, 0, 0, 0, 0, 0, 0);
109  mColumnDefs[eColumnTypeBram] = ColumnDef("Bram", 27, 64, 0, 0, 0, 0, 0, 0);
110  mColumnDefs[eColumnTypeClb] = ColumnDef("Clb", 48, 0, 0, 0, 0, 0, 0, 0);
111  mColumnDefs[eColumnTypeClock] = ColumnDef("Clock", 8, 0, 0, 0, 0, 0, 0, 0);
112  mColumnDefs[eColumnTypeIob] = ColumnDef("Iob", 54, 0, 0, 0, 0, 0, 0, 0);
113  // map type type names to column types
121  }
122  // functions
123  /// \brief Return the masked value for a subfield of the specified register.
124  static uint32_t makeSubfield(ERegister inRegister, const std::string& inSubfield,
125  const std::string& inSetting);
126  // functions
127  /// \brief Initialize the device information.
128  virtual void initializeDeviceInfo(const std::string& inDeviceName);
129  /// \brief Initialize the maps between frame indexes and frame addresses.
130  /// \detail This is generally only useful for internal purposes.
131  virtual void initializeFrameMaps(void);
132  /// \brief Prepares the frames to load them at the correct frame indexes
134  void prepareFrames(ColumnIndex &inCol, int &inFrameCount, int &inFrameIndex,
135  EFarBlockType &inBlockType, int &inFarMajor, int &inWidth);
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 Virtex& 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 Virtex::FrameAddress& rhs) {
174  return os << rhs.mBlockType << "(" << rhs.mMajor << "." << rhs.mMinor << ")";
175  }
176  private:
177  //
178  };
179  // accessors
180  /// \brief Return the frame length for the current device.
181  virtual uint32_t getFrameLength(void) const {
182  using namespace torc::common;
183  // Frame Length Register Value: XAPP151, v.1.7, October 20, 2004, Table 24.
184  switch(mDevice) {
185  case eXCV50: return 12;
186  case eXCV100: return 14;
187  case eXCV150: return 16;
188  case eXCV200: return 18;
189  case eXCV300: return 21;
190  case eXCV400: return 25;
191  case eXCV600: return 30;
192  case eXCV800: return 34;
193  case eXCV1000: return 39;
194  default: return 0;
195  }
196  }
197  /// \brief Return the number of frame rows for the current device.
198  virtual uint32_t getFrameRowCount(void) const { return 0; }
199  protected:
200  // typedefs
201  /// \brief Map from frame index to frame address.
202  typedef std::map<uint32_t, Virtex::FrameAddress> FrameIndexToAddress;
203  /// \brief Map from frame address to frame index.
204  typedef std::map<Virtex::FrameAddress, uint32_t> FrameAddressToIndex;
205  /// \brief Array of vectors to store frame indexes of each block type
206  typedef std::vector<uint32_t> IndexVector;
207 
208  // members
209  /// \brief Map of frame indexes to frame addresses.
210  FrameIndexToAddress mFrameIndexToAddress;
211  /// \brief Map of frame addressee to frame indexes.
212  FrameAddressToIndex mFrameAddressToIndex;
213  /// \brief Vector to store frame indexes of XDL columns.
215  /// \brief Vector to store frame indexes of Bitstream columns.
217  /// \brief Array to hold frame index boundaries for blocks.
219  /// \brief Frame index bounds count.
221  /// \brief Map of XDL column indexes to bitstream column indexes.
222  std::map<uint32_t, uint32_t> mXdlColumnToBitColumn;
223  };
224 
225 } // namespace bitstream
226 } // namespace torc
227 
228 #endif // TORC_BITSTREAM_VIRTEX_HPP
ColumnDefVector mColumnDefs
Column type widths.
Virtex-class bitstream.
TileTypeNameToColumnType mTileTypeNameToColumnType
uint32_t mFrameIndexBounds
Frame index bounds count.
Definition: Virtex.hpp:220
ERegister
Configuration register enumeration.
Definition: Virtex.hpp:55
Header for the VirtexBitstream class.
std::map< Virtex::FrameAddress, uint32_t > FrameAddressToIndex
Map from frame address to frame index.
Definition: Virtex.hpp:204
IndexVector mXdlColumnIndexes[Virtex::eFarBlockTypeCount]
Vector to store frame indexes of Bitstream columns.
Definition: Virtex.hpp:216
static const char * sOpcodeName[eOpcodeCount]
Packet opcode names.
Definition: Virtex.hpp:87
boost::uint32_t uint32_t
Imported type name.
FrameAddress(EFarBlockType inBlockType, uint32_t inMajor, uint32_t inMinor)
Definition: Virtex.hpp:155
virtual void initializeDeviceInfo(const std::string &inDeviceName)
Initialize the device information.
Definition: Virtex.cpp:239
Bitstream column definition for Xilinx bitstreams. For every block type 0 through 8...
Definition: DeviceInfo.hpp:35
static const char * sRegisterName[eRegisterCount]
Configuration register names.
Definition: Virtex.hpp:89
friend class torc::bitstream::bitstream::VirtexUnitTest
Definition: Virtex.hpp:41
void testVirtexDevice(const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)
virtual void initializeFrameMaps(void)
Initialize the maps between frame indexes and frame addresses. This is generally only useful for int...
Definition: Virtex.cpp:343
torc::common::EncapsulatedInteger< uint16_t > ColumnIndex
Prepares the frames to load them at the correct frame indexes.
Definition: Virtex.hpp:133
void prepareFrames(ColumnIndex &inCol, int &inFrameCount, int &inFrameIndex, EFarBlockType &inBlockType, int &inFarMajor, int &inWidth)
Definition: Virtex.cpp:471
EDevice mDevice
Bitstream device enumeration.
virtual uint32_t getFrameRowCount(void) const
Return the number of frame rows for the current device.
Definition: Virtex.hpp:198
std::string string
std::map< uint32_t, Virtex::FrameAddress > FrameIndexToAddress
Map from frame index to frame address.
Definition: Virtex.hpp:202
Virtex(void)
Basic constructor.
Definition: Virtex.hpp:104
friend std::ostream & operator<<(std::ostream &os, const Virtex::FrameAddress &rhs)
Definition: Virtex.hpp:173
boost::uint32_t uint32_t
Imported type name.
virtual void assign(uint32_t inAddress)
Definition: Virtex.hpp:148
Virtex Frame Address base-class.
FrameAddressToIndex mFrameAddressToIndex
Map of frame addressee to frame indexes.
Definition: Virtex.hpp:212
uint32_t mBlockFrameIndexBounds[Virtex::eFarBlockTypeCount]
Array to hold frame index boundaries for blocks.
Definition: Virtex.hpp:218
IndexVector mBitColumnIndexes[Virtex::eFarBlockTypeCount]
Vector to store frame indexes of XDL columns.
Definition: Virtex.hpp:214
std::map< uint32_t, uint32_t > mXdlColumnToBitColumn
Map of XDL column indexes to bitstream column indexes.
Definition: Virtex.hpp:222
friend class torc::bitstream::bitstream::VirtexFarUnitTest
Definition: Virtex.hpp:42
static const Subfield sCOR[]
Configuration Options Register (COR) subfields.
Definition: Virtex.hpp:93
static const Subfield sMASK[]
Control Mask Register (MASK) subfields.
Definition: Virtex.hpp:99
VirtexFrameBlocks getBitstreamFrames(uint32_t inBlockCount, uint32_t inBitCol)
Returns frames for queried bitstream coordinates.
Definition: Virtex.cpp:510
boost::filesystem::path path
EFarBlockType
Frame Address Register block type constants.
Definition: Virtex.hpp:73
friend std::ostream & operator<<(std::ostream &os, const Virtex &rhs)
Insert the bitstream header into an output stream.
void testVirtexFullMapping(const boost::filesystem::path &inWorkingPath)
ECommand
Configuration command enumeration for eRegisterCMD.
Definition: Virtex.hpp:61
FrameAddress(uint32_t inAddress)
Definition: Virtex.hpp:157
static const Subfield sSTAT[]
Status Register (STAT) subfields.
Definition: Virtex.hpp:95
Virtex bitstream.
Definition: Virtex.hpp:40
boost::uint32_t uint32_t
Imported type name.
Definition: Virtex.hpp:49
static const char * sPacketTypeName[ePacketTypeCount]
Packet type names.
Definition: Virtex.hpp:85
std::vector< uint32_t > IndexVector
Array of vectors to store frame indexes of each block type.
Definition: Virtex.hpp:206
virtual uint32_t getFrameLength(void) const
Return the frame length for the current device.
Definition: Virtex.hpp:181
Template base for encapsulated integers, to enforce strong typing.
EFar
Frame Address Register subfields.
Definition: Virtex.hpp:66
virtual bool operator<(const VirtexFrameAddress &vrhs) const
Definition: Virtex.hpp:165
static const Subfield sCTL[]
Control Register (CTL) subfields.
Definition: Virtex.hpp:97
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: Virtex.cpp:203
void initializeFullFrameBlocks(void)
Loads full bitstream frames into block data structure.
Definition: Virtex.cpp:488
static const char * sCommandName[eCommandCount]
Configuration command names.
Definition: Virtex.hpp:91
Header for the VirtexBitstream class.
VirtexFrameBlocks getXdlFrames(uint32_t inBlockCount, uint32_t inXdlCol)
Returns frames for queried xdl coordinates.
Definition: Virtex.cpp:532
EColumnType
Major column types.
Definition: Virtex.hpp:78
FrameIndexToAddress mFrameIndexToAddress
Map of frame indexes to frame addresses.
Definition: Virtex.hpp:210
virtual bool operator==(const VirtexFrameAddress &vrhs) const
Definition: Virtex.hpp:161