torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Spartan6.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 Spartan6 class.
18 
19 #ifndef TORC_BITSTREAM_SPARTAN6_HPP
20 #define TORC_BITSTREAM_SPARTAN6_HPP
21 
22 #include <boost/cstdint.hpp>
24 
25 namespace torc {
26 namespace bitstream {
27 
28 namespace bitstream { class Spartan6UnitTest; }
29 
30  /// \brief Spartan6 bitstream.
31  class Spartan6 : public Spartan6Bitstream {
33  protected:
34  // typedefs
35  /// \brief Imported type name.
36  typedef boost::uint16_t uint16_t;
37  typedef boost::uint32_t uint32_t;
38  public:
39  // enumerations
40  //
41  /// \brief Configuration register enumeration.
42  /// \see configuration registers: UG380, v2.2, July 30, 2010 Table 5-30
51  //
52  /// \brief Configuration command enumeration for eRegisterCMD.
53  /// \see CMD register commands: UG380, v2.2, July 30, 2010 Table 5-33
57  //
58  /// \brief Frame Address Register Major subfields.
59  /// \see Frame Address Register Major Description: UG380, v2.2, July 30, 2010 Table 5-31
60  enum EFarMaj {
64  };
65  //
66  /// \brief Frame Address Register Minor subfields.
67  /// \see Frame Address Register Minor Description: UG380, v2.2, July 30, 2010 Table 5-32
68  enum EFarMin {
71  };
72  //
73  /// \brief Frame Address Register top and bottom constants.
74  //enum EFarTopBottom { eFarTop = 0, eFarBottom = 1 };
75  /// \brief Frame Address Register block type constants.
78  /// \brief Frame length.
79  /// \details Constant frame length of 41 32-bit words for the entire Spartan6 family. Note
80  /// that this length applies only to non-IOB frames. IOB frame lengths are defined by
81  /// the bitstream FLR register plus one.
82  enum { eFrameLength = 41 };
83  protected:
84  // members
85 // /// \brief Configuration controller registers.
86 // uint16_t mRegister[eRegisterCount];
87  /// \brief Packet type names.
88  static const char* sPacketTypeName[ePacketTypeCount];
89  /// \brief Packet opcode names.
90  static const char* sOpcodeName[eOpcodeCount];
91  /// \brief Configuration register names.
92  static const char* sRegisterName[eRegisterCount];
93  /// \brief Configuration command names.
94  static const char* sCommandName[eCommandCount];
95  /// \brief Configuration Options Register 1 (COR1) subfields.
96  static const Subfield sCOR1[];
97  /// \brief Configuration Options Register 2 (COR2) subfields.
98  static const Subfield sCOR2[];
99  /// \brief Status Register (STAT) subfields.
100  static const Subfield sSTAT[];
101  /// \brief Control Register 0 (CTL0) subfields.
102  static const Subfield sCTL[];
103  /// \brief Control Mask Register (MASK) subfields.
104  static const Subfield sMASK[];
105  /// \brief Suspend Register (PWRDN_REG) subfields.
106  static const Subfield sPWRDN_REG[];
107  /// \brief HC_OPT_REG Register (PWRDN_REG) subfields.
108  static const Subfield sHC_OPT_REG[];
109  /// \brief Mode Register (Mode) subfields.
110  static const Subfield sMODE_REG[];
111  /// \brief BOOSTS Register (BOOSTS) subfields.
112  static const Subfield sBOOSTS[];
113  /// \brief SEU_OPT Register (SEU_OPT) subfields.
114  static const Subfield sSEU_OPT[];
115  public:
116  static uint16_t makeSubfield(ERegister inRegister, const std::string& inSubfield,
117  const std::string& inSetting);
118  // inserters
119  /// \brief Insert the bitstream header into an output stream.
120  friend std::ostream& operator<< (std::ostream& os, const Spartan6& rhs);
121  // inner classes
123  protected:
124  void assign(uint16_t inMajAddress) {
125  mMajBlock = (inMajAddress & eFarMajMaskBlock) >> eFarMajShiftBlock;
126  mMajRow = (inMajAddress & eFarMajMaskRow) >> eFarMajShiftRow;
127  mMajMajor = (inMajAddress & eFarMajMaskMajor) >> eFarMajShiftMajor;
128  }
129  public:
131  FrameMajorAddress(uint16_t inMajBlock, uint16_t inMajRow, uint16_t inMajMajor)
132  : mMajBlock(inMajBlock), mMajRow(inMajRow), mMajMajor(inMajMajor) {}
133  FrameMajorAddress(uint16_t inMajAddress) { assign(inMajAddress); }
137 
138  bool operator== (const FrameMajorAddress& rhs) const {
139  return mMajBlock == rhs.mMajBlock && mMajRow == rhs.mMajRow
140  && mMajMajor == rhs.mMajMajor;
141  }
142  bool operator< (const FrameMajorAddress& rhs) const {
143  int diffMajBlock = mMajBlock - rhs.mMajBlock;
144  if(diffMajBlock) return diffMajBlock < 0;
145  int diffMajRow = mMajRow - rhs.mMajRow;
146  if(diffMajRow) return diffMajRow < 0;
147  return mMajMajor < rhs.mMajMajor;
148  }
149  private:
150  };
151 
153  protected:
154  void assign(uint16_t inMinAddress) {
155  mMinBlock = (inMinAddress & eFarMinMaskBlock) >> eFarMinShiftBlock;
156  mMinMinor = (inMinAddress & eFarMinMaskMinor) >> eFarMinShiftMinor;
157  }
158  public:
160  FrameMinorAddress(uint16_t inMinBlock, uint16_t inMinMinor) : mMinBlock(inMinBlock),
161  mMinMinor(inMinMinor) {}
162  FrameMinorAddress(uint16_t inMinAddress) { assign(inMinAddress); }
165 
166  bool operator== (const FrameMinorAddress& rhs) const {
167  return mMinBlock == rhs.mMinBlock && mMinMinor == rhs.mMinMinor;
168  }
169  bool operator< (const FrameMinorAddress& rhs) const {
170  int diffMinBlock = mMinBlock - rhs.mMinBlock;
171  if(diffMinBlock) return diffMinBlock < 0;
172  return mMinMinor < rhs.mMinMinor;
173  }
174  private:
175  };
176  // accessors
177  /// \brief Return the frame length for the current device.
178  virtual uint32_t getFrameLength(void) const { return eFrameLength; }
179 
180  };
181 
182 } // namespace bitstream
183 } // namespace torc
184 
185 #endif // TORC_BITSTREAM_SPARTAN6_HPP
static const char * sCommandName[eCommandCount]
Configuration command names.
Definition: Spartan6.hpp:94
Header for the Spartan6Bitstream class.
static const char * sOpcodeName[eOpcodeCount]
Packet opcode names.
Definition: Spartan6.hpp:90
void assign(uint16_t inMajAddress)
Definition: Spartan6.hpp:124
static const Subfield sMASK[]
Control Mask Register (MASK) subfields.
Definition: Spartan6.hpp:104
static const Subfield sCOR2[]
Configuration Options Register 2 (COR2) subfields.
Definition: Spartan6.hpp:98
bool operator<(const FrameMajorAddress &rhs) const
Definition: Spartan6.hpp:142
EFarMin
Frame Address Register Minor subfields.
Definition: Spartan6.hpp:68
static const Subfield sCTL[]
Control Register 0 (CTL0) subfields.
Definition: Spartan6.hpp:102
static const Subfield sMODE_REG[]
Mode Register (Mode) subfields.
Definition: Spartan6.hpp:110
boost::uint16_t uint16_t
Imported type name.
Definition: Spartan6.hpp:36
std::string string
EFarMaj
Frame Address Register Major subfields.
Definition: Spartan6.hpp:60
boost::uint32_t uint32_t
Imported type name.
static uint16_t makeSubfield(ERegister inRegister, const std::string &inSubfield, const std::string &inSetting)
Return the masked value for a subfield of the specified register.
Definition: Spartan6.cpp:329
static const char * sRegisterName[eRegisterCount]
Configuration register names.
Definition: Spartan6.hpp:92
FrameMinorAddress(uint16_t inMinBlock, uint16_t inMinMinor)
Definition: Spartan6.hpp:160
virtual uint32_t getFrameLength(void) const
Return the frame length for the current device.
Definition: Spartan6.hpp:178
FrameMajorAddress(uint16_t inMajBlock, uint16_t inMajRow, uint16_t inMajMajor)
Definition: Spartan6.hpp:131
static const char * sPacketTypeName[ePacketTypeCount]
Packet type names.
Definition: Spartan6.hpp:88
static const Subfield sHC_OPT_REG[]
HC_OPT_REG Register (PWRDN_REG) subfields.
Definition: Spartan6.hpp:108
static const Subfield sSEU_OPT[]
SEU_OPT Register (SEU_OPT) subfields.
Definition: Spartan6.hpp:114
friend std::ostream & operator<<(std::ostream &os, const Spartan6 &rhs)
Insert the bitstream header into an output stream.
static const Subfield sCOR1[]
Configuration Options Register 1 (COR1) subfields.
Definition: Spartan6.hpp:96
Spartan6 bitstream.
Definition: Spartan6.hpp:31
bool operator<(const FrameMinorAddress &rhs) const
Definition: Spartan6.hpp:169
bool operator==(const FrameMajorAddress &rhs) const
Definition: Spartan6.hpp:138
ERegister
Configuration register enumeration.
Definition: Spartan6.hpp:43
static const Subfield sBOOSTS[]
BOOSTS Register (BOOSTS) subfields.
Definition: Spartan6.hpp:112
ECommand
Configuration command enumeration for eRegisterCMD.
Definition: Spartan6.hpp:54
static const Subfield sSTAT[]
Status Register (STAT) subfields.
Definition: Spartan6.hpp:100
void assign(uint16_t inMinAddress)
Definition: Spartan6.hpp:154
boost::uint16_t uint16_t
Imported type name.
friend class torc::bitstream::bitstream::Spartan6UnitTest
Definition: Spartan6.hpp:32
bool operator==(const FrameMinorAddress &rhs) const
Definition: Spartan6.hpp:166
boost::uint32_t uint32_t
Definition: Spartan6.hpp:37
static const Subfield sPWRDN_REG[]
Suspend Register (PWRDN_REG) subfields.
Definition: Spartan6.hpp:106
EFarBlockType
Frame Address Register top and bottom constants.
Definition: Spartan6.hpp:76