torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Spartan3E.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 Spartan3E class.
18 
19 #ifndef TORC_BITSTREAM_SPARTAN3E_HPP
20 #define TORC_BITSTREAM_SPARTAN3E_HPP
21 
22 #include <boost/cstdint.hpp>
23 #include <boost/filesystem.hpp>
25 #include <map>
26 
27 namespace torc { namespace architecture { class DDB; } }
28 
29 namespace torc {
30 namespace bitstream {
31 
32 namespace bitstream { class Spartan3EUnitTest; }
33 namespace bitstream { class Spartan3EFarUnitTest; }
34 namespace bitstream { void testSpartan3EDevice(const std::string& inDeviceName,
35  const boost::filesystem::path& inWorkingPath); }
36 
37  /// \brief Spartan3E bitstream.
38  class Spartan3E : public SpartanBitstream {
41  friend void torc::bitstream::bitstream::testSpartan3EDevice(const std::string& inDeviceName,
42  const boost::filesystem::path& inWorkingPath);
43  protected:
44  // typedefs
45  /// \brief Imported type name.
46  typedef boost::uint32_t uint32_t;
47  public:
48  // enumerations
49  //
50  /// \brief Configuration register enumeration.
51  /// \see configuration registers: XAPP452, v1.1, June 25, 2008, Table 1.
55  //
56  /// \brief Configuration command enumeration for eRegisterCMD.
57  /// \see CMD register commands: XAPP452, v1.1, June 25, 2008, Table 2.
61  //
62  /// \brief Frame Address Register subfields.
63  /// \see Frame Address Register Description: XAPP452, v1.1, June 25, 2008, Figure 2.
64  enum EFar {
65  eFarMaskColumn = 0x06000000, eFarShiftColumn = 25,
66  eFarMaskMajor = 0x01fe0000, eFarShiftMajor = 17,
67  eFarMaskMinor = 0x0001fe00, eFarShiftMinor = 9
68  };
69  //
70  /// \brief Frame Address Register top and bottom constants.
71  enum EFarTopBottom { eFarTop = 0, eFarBottom = 1 };
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[];
100  public:
101  // constructors
102  /// \brief Basic constructor.
104 // for(int i = 0; i < eRegisterCount; i++) mRegister[i] = 0;
105  // initialize the column type widths for this family
107  mColumnDefs[eColumnTypeEmpty] = ColumnDef("Empty", 0, 0, 0, 0, 0, 0, 0, 0);
108  mColumnDefs[eColumnTypeBram] = ColumnDef("Bram", 0, 76, 0, 0, 0, 0, 0, 0);
109  mColumnDefs[eColumnTypeBramInt] = ColumnDef("BramInt", 0, 0, 19, 0, 0, 0, 0, 0);
110  mColumnDefs[eColumnTypeClb] = ColumnDef("Clb", 19, 0, 0, 0, 0, 0, 0, 0);
111  mColumnDefs[eColumnTypeClock] = ColumnDef("Clock", 3, 0, 0, 0, 0, 0, 0, 0);
112  mColumnDefs[eColumnTypeClockLL] = ColumnDef("ClockLL", 4, 0, 0, 0, 0, 0, 0, 0);
113  mColumnDefs[eColumnTypeIob] = ColumnDef("Iob", 19, 0, 0, 0, 0, 0, 0, 0);
114  mColumnDefs[eColumnTypeTerm] = ColumnDef("Term", 2, 0, 0, 0, 0, 0, 0, 0);
115  // map type type names to column types
118  mTileTypeNameToColumnType["CENTER_SMALL"] = eColumnTypeClb;
125  }
126  // functions
127  /// \brief Return the masked value for a subfield of the specified register.
128  static uint32_t makeSubfield(ERegister inRegister, const std::string& inSubfield,
129  const std::string& inSetting);
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  // inserters
137  /// \brief Insert the bitstream header into an output stream.
138  friend std::ostream& operator<< (std::ostream& os, const Spartan3E& rhs);
139  // inner classes
140  class FrameAddress {
141  protected:
142  void assign(uint32_t inAddress) {
143  mColumn = (inAddress & eFarMaskColumn) >> eFarShiftColumn;
144  mMajor = (inAddress & eFarMaskMajor) >> eFarShiftMajor;
145  mMinor = (inAddress & eFarMaskMinor) >> eFarShiftMinor;
146  }
147  public:
148  FrameAddress(void) : mColumn(0), mMajor(0), mMinor(0) {}
149  FrameAddress(uint32_t inColumn, uint32_t inMajor, uint32_t inMinor) :
150  mColumn(inColumn), mMajor(inMajor), mMinor(inMinor) {}
151  FrameAddress(uint32_t inAddress) { assign(inAddress); }
155  bool operator== (const FrameAddress& rhs) const {
156  return mColumn == rhs.mColumn && mMajor == rhs.mMajor && mMinor == rhs.mMinor;
157  }
158  bool operator< (const FrameAddress& rhs) const {
159  int diffColumn = mColumn - rhs.mColumn;
160  if(diffColumn) return diffColumn < 0;
161  int diffMajor = mMajor - rhs.mMajor;
162  if(diffMajor) return diffMajor < 0;
163  return mMinor < rhs.mMinor;
164  }
165  friend std::ostream& operator<< (std::ostream& os, const Spartan3E::FrameAddress& rhs) {
166  return os << rhs.mColumn << "(" << rhs.mMajor << "." << rhs.mMinor << ")";
167  }
168  };
169  // accessors
170  virtual uint32_t getFrameLength(void) const {
171  using namespace torc::common;
172  // lengths obtained directly from bitstream Frame Length Register
173  switch(mDevice) {
174  case eXC3S100E: return 49;
175  case eXC3S250E: return 73;
176  case eXC3S500E: return 97;
177  case eXC3S1200E: return 125;
178  case eXC3S1600E: return 157;
179  default: return 0;
180  }
181  }
182  protected:
183  // typedefs
184  /// \brief Map from frame index to frame address.
185  typedef std::map<uint32_t, Spartan3E::FrameAddress> FrameIndexToAddress;
186  /// \brief Map from frame address to frame index.
187  typedef std::map<Spartan3E::FrameAddress, uint32_t> FrameAddressToIndex;
188  /// \brief Array of vectors to store frame indexes of each block type
189  typedef std::vector<uint32_t> ColumnIndexVector;
190 
191  // members
192  /// \brief Map of frame indexes to frame addresses.
193  FrameIndexToAddress mFrameIndexToAddress;
194  /// \brief Map of frame addressee to frame indexes.
195  FrameAddressToIndex mFrameAddressToIndex;
196  /// \brief Vector to store frame indexes of XDL columns.
198  /// \brief Vector to store frame indexes of Bitstream columns.
200  };
201 
202 } // namespace bitstream
203 } // namespace torc
204 
205 #endif // TORC_BITSTREAM_SPARTAN3E_HPP
EColumnType
Major column types.
Definition: Spartan3E.hpp:78
static const char * sOpcodeName[eOpcodeCount]
Packet opcode names.
Definition: Spartan3E.hpp:87
ColumnDefVector mColumnDefs
Column type widths.
static const Subfield sMASK[]
Control Mask Register (MASK) subfields.
Definition: Spartan3E.hpp:99
FrameIndexToAddress mFrameIndexToAddress
Map of frame indexes to frame addresses.
Definition: Spartan3E.hpp:193
FrameAddressToIndex mFrameAddressToIndex
Map of frame addressee to frame indexes.
Definition: Spartan3E.hpp:195
bool operator<(const FrameAddress &rhs) const
Definition: Spartan3E.hpp:158
TileTypeNameToColumnType mTileTypeNameToColumnType
static const char * sRegisterName[eRegisterCount]
Configuration register names.
Definition: Spartan3E.hpp:89
friend std::ostream & operator<<(std::ostream &os, const Spartan3E &rhs)
Insert the bitstream header into an output stream.
friend class torc::bitstream::bitstream::Spartan3EUnitTest
Definition: Spartan3E.hpp:39
std::map< Spartan3E::FrameAddress, uint32_t > FrameAddressToIndex
Map from frame address to frame index.
Definition: Spartan3E.hpp:187
static const char * sCommandName[eCommandCount]
Configuration command names.
Definition: Spartan3E.hpp:91
EFar
Frame Address Register subfields.
Definition: Spartan3E.hpp:64
static const Subfield sCTL[]
Control Register (CTL) subfields.
Definition: Spartan3E.hpp:97
virtual uint32_t getFrameLength(void) const
Definition: Spartan3E.hpp:170
static const char * sPacketTypeName[ePacketTypeCount]
Packet type names.
Definition: Spartan3E.hpp:85
Bitstream column definition for Xilinx bitstreams. For every block type 0 through 8...
Definition: DeviceInfo.hpp:35
void testSpartan3EDevice(const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)
EDevice mDevice
Bitstream device enumeration.
virtual void initializeFrameMaps(void)
Initialize the maps between frame indexes and frame addresses. This is generally only useful for int...
Definition: Spartan3E.cpp:313
std::string string
friend std::ostream & operator<<(std::ostream &os, const Spartan3E::FrameAddress &rhs)
Definition: Spartan3E.hpp:165
boost::uint32_t uint32_t
Imported type name.
static const Subfield sCOR[]
Configuration Options Register (COR) subfields.
Definition: Spartan3E.hpp:93
ECommand
Configuration command enumeration for eRegisterCMD.
Definition: Spartan3E.hpp:58
boost::filesystem::path path
Spartan3E(void)
Basic constructor.
Definition: Spartan3E.hpp:103
virtual void initializeDeviceInfo(const std::string &inDeviceName)
Initialize the device information.
Definition: Spartan3E.cpp:218
Header for the SpartanBitstream class.
std::map< uint32_t, Spartan3E::FrameAddress > FrameIndexToAddress
Map from frame index to frame address.
Definition: Spartan3E.hpp:185
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: Spartan3E.cpp:186
static const Subfield sSTAT[]
Status Register (STAT) subfields.
Definition: Spartan3E.hpp:95
FrameAddress(uint32_t inColumn, uint32_t inMajor, uint32_t inMinor)
Definition: Spartan3E.hpp:149
EFarTopBottom
Frame Address Register top and bottom constants.
Definition: Spartan3E.hpp:71
std::vector< uint32_t > ColumnIndexVector
Array of vectors to store frame indexes of each block type.
Definition: Spartan3E.hpp:189
friend class torc::bitstream::bitstream::Spartan3EFarUnitTest
Definition: Spartan3E.hpp:40
EFarBlockType
Frame Address Register block type constants.
Definition: Spartan3E.hpp:73
Spartan3E bitstream.
Definition: Spartan3E.hpp:38
boost::uint32_t uint32_t
Imported type name.
Definition: Spartan3E.hpp:46
ColumnIndexVector mBitColumnIndexes[Spartan3E::eFarBlockTypeCount]
Vector to store frame indexes of XDL columns.
Definition: Spartan3E.hpp:197
ERegister
Configuration register enumeration.
Definition: Spartan3E.hpp:52
ColumnIndexVector mXdlColumnIndexes[Spartan3E::eFarBlockTypeCount]
Vector to store frame indexes of Bitstream columns.
Definition: Spartan3E.hpp:199
bool operator==(const FrameAddress &rhs) const
Definition: Spartan3E.hpp:155