00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef TORC_BITSTREAM_VIRTEX7_HPP
00020 #define TORC_BITSTREAM_VIRTEX7_HPP
00021
00022 #include <boost/cstdint.hpp>
00023 #include <boost/filesystem.hpp>
00024 #include "torc/bitstream/VirtexBitstream.hpp"
00025 #include <map>
00026
00027 namespace torc { namespace architecture { class DDB; } }
00028
00029 namespace torc {
00030 namespace bitstream {
00031
00032
00033 namespace bitstream { class Virtex7UnitTest; }
00034 namespace bitstream { class Virtex7FarUnitTest; }
00035 namespace bitstream { void testVirtex7Device(const std::string& inDeviceName,
00036 const boost::filesystem::path& inWorkingPath); }
00037
00038
00039 class Virtex7 : public VirtexBitstream {
00040 friend class torc::bitstream::bitstream::Virtex7UnitTest;
00041 friend class torc::bitstream::bitstream::Virtex7FarUnitTest;
00042 friend void torc::bitstream::bitstream::testVirtex7Device(const std::string& inDeviceName,
00043 const boost::filesystem::path& inWorkingPath);
00044 protected:
00045
00046
00047 typedef boost::uint32_t uint32_t;
00048 public:
00049
00050
00051
00052
00053 enum ERegister { eRegisterCRC = 0, eRegisterFAR, eRegisterFDRI, eRegisterFDRO,
00054 eRegisterCMD, eRegisterCTL0, eRegisterMASK, eRegisterSTAT, eRegisterLOUT,
00055 eRegisterCOR0, eRegisterMFWR, eRegisterCBC, eRegisterIDCODE, eRegisterAXSS,
00056 eRegisterCOR1, eRegisterWBSTAR = 16, eRegisterTIMER, eRegisterBOOTSTS = 22,
00057 eRegisterCTL1 = 24, eRegisterCount };
00058
00059
00060
00061 enum ECommand { eCommandNULL = 0, eCommandWCFG, eCommandMFW, eCommandDGHIGH,
00062 eCommandLFRM = eCommandDGHIGH, eCommandRCFG, eCommandSTART, eCommandRCAP, eCommandRCRC,
00063 eCommandAGHIGH, eCommandSWITCH, eCommandGRESTORE, eCommandSHUTDOWN, eCommandGCAPTURE,
00064 eCommandDESYNCH, eCommandReserved, eCommandIPROG, eCommandCRCC, eCommandLTIMER,
00065 eCommandCount };
00066
00067
00068
00069 enum EFar {
00070 eFarMaskBlockType = 0x03800000, eFarShiftBlockType = 23,
00071 eFarMaskTopBottom = 0x00400000, eFarShiftTopBottom = 22,
00072 eFarMaskRow = 0x003e0000, eFarShiftRow = 17,
00073 eFarMaskMajor = 0x0001ff80, eFarShiftMajor = 7,
00074 eFarMaskMinor = 0x0000007f, eFarShiftMinor = 0
00075 };
00076
00077
00078
00079 enum EFarTopBottom { eFarTop = 0, eFarBottom = 1 };
00080
00081
00082 enum EFarBlockType { eFarBlockType0 = 0, eFarBlockType1, eFarBlockType2, eFarBlockType3,
00083 eFarBlockType4, eFarBlockType5, eFarBlockType6, eFarBlockType7, eFarBlockTypeCount };
00084
00085
00086
00087 enum {
00088 eStartAddr = 0x1fffffff,
00089 eTimerValue = 0x3fffffff,
00090 };
00091
00092
00093
00094
00095
00096 enum EColumnType { eColumnTypeEmpty = 0 };
00097
00098
00099
00100 enum { eFrameLength = 101 };
00101 protected:
00102
00103
00104
00105
00106 static const char* sPacketTypeName[ePacketTypeCount];
00107
00108 static const char* sOpcodeName[eOpcodeCount];
00109
00110 static const char* sRegisterName[eRegisterCount];
00111
00112 static const char* sCommandName[eCommandCount];
00113
00114 static const Subfield sCOR0[];
00115
00116 static const Subfield sCOR1[];
00117
00118 static const Subfield sSTAT[];
00119
00120 static const Subfield sCTL0[];
00121
00122 static const Subfield sCTL1[];
00123
00124 static const Subfield sMASK0[];
00125
00126 static const Subfield sWBSTAR[];
00127
00128 static const Subfield sTIMER[];
00129
00130 static const Subfield sBOOTSTS[];
00131
00132 uint32_t mTopRowCount;
00133
00134 uint32_t mBottomRowCount;
00135
00136
00137
00138
00139 public:
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152 static uint32_t makeSubfield(ERegister inRegister, const std::string& inSubfield,
00153 const std::string& inSetting);
00154
00155 virtual void initializeDeviceInfo(const std::string& inDeviceName);
00156
00157
00158
00159 virtual void initializeFrameMaps(void);
00160 */
00161
00162
00163 virtual uint32_t getFrameLength(void) const { return eFrameLength; }
00164
00165
00166 friend std::ostream& operator<< (std::ostream& os, const Virtex7& rhs);
00167
00168 class FrameAddress{
00169 protected:
00170 void assign(uint32_t inAddress) {
00171 mTopBottom = EFarTopBottom((inAddress & eFarMaskTopBottom) >> eFarShiftTopBottom);
00172 mBlockType = EFarBlockType((inAddress & eFarMaskBlockType) >> eFarShiftBlockType);
00173 mRow = (inAddress & eFarMaskRow) >> eFarShiftRow;
00174 mMajor = (inAddress & eFarMaskMajor) >> eFarShiftMajor;
00175 mMinor = (inAddress & eFarMaskMinor) >> eFarShiftMinor;
00176 }
00177 public:
00178 FrameAddress(void) : mTopBottom(eFarTop), mBlockType(eFarBlockType0), mRow(0),
00179 mMajor(0), mMinor(0) {}
00180 FrameAddress(EFarTopBottom inTopBottom, EFarBlockType inBlockType, uint32_t inRow,
00181 uint32_t inMajor, uint32_t inMinor) : mTopBottom(inTopBottom),
00182 mBlockType(inBlockType), mRow(inRow), mMajor(inMajor), mMinor(inMinor) {}
00183 FrameAddress(uint32_t inAddress) { assign(inAddress); }
00184 EFarTopBottom mTopBottom;
00185 EFarBlockType mBlockType;
00186 uint32_t mRow;
00187 uint32_t mMajor;
00188 uint32_t mMinor;
00189 bool operator == (const FrameAddress& rhs) const {
00190 return mTopBottom == rhs.mTopBottom && mBlockType == rhs.mBlockType &&
00191 mRow == rhs.mRow &&mMajor == rhs.mMajor && mMinor == rhs.mMinor;
00192 }
00193 bool operator< (const FrameAddress& rhs) const{
00194 int diffBlockType = mBlockType - rhs.mBlockType;
00195 if(diffBlockType) return diffBlockType < 0;
00196 int diffTopBottom = mTopBottom - rhs.mTopBottom;
00197 if(diffTopBottom) return diffTopBottom < 0;
00198 int diffRow = mRow - rhs.mRow;
00199 if(diffRow) return diffRow < 0;
00200 int diffMajor = mMajor - rhs.mMajor;
00201 if(diffMajor) return diffMajor < 0;
00202 return mMinor < rhs.mMinor;
00203 }
00204 private:
00205
00206
00207
00208
00209
00210
00211
00212
00213 };
00214 protected:
00215
00216
00217 typedef std::map<uint32_t, Virtex7::FrameAddress> FrameIndexToAddress;
00218
00219 typedef std::map<Virtex7::FrameAddress, uint32_t> FrameAddressToIndex;
00220
00221
00222 FrameIndexToAddress mFrameIndexToAddress;
00223
00224 FrameAddressToIndex mFrameAddressToIndex;
00225
00226 };
00227
00228 }
00229 }
00230
00231
00232 #endif // TORC_BITSTREAM_VIRTEX7_HPP