00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef TORC_BITSTREAM_VIRTEX6_HPP
00020 #define TORC_BITSTREAM_VIRTEX6_HPP
00021
00022 #include <boost/cstdint.hpp>
00023 #include <boost/filesystem.hpp>
00024 #include "torc/bitstream/VirtexBitstream.hpp"
00025 #include "torc/bitstream/VirtexFrameAddress.hpp"
00026 #include <map>
00027
00028 namespace torc { namespace architecture { class DDB; } }
00029
00030 namespace torc {
00031 namespace bitstream {
00032
00033 namespace bitstream { class Virtex6UnitTest; }
00034 namespace bitstream { class Virtex6FarUnitTest; }
00035 namespace bitstream { void testVirtex6Device(const std::string& inDeviceName,
00036 const boost::filesystem::path& inWorkingPath); }
00037 namespace bitstream { void testVirtex6FullMapping(const boost::filesystem::path& inWorkingPath); }
00038 namespace bitstream { void testVirtex6PartialMapping(const boost::filesystem::path& inWorkingPath); }
00039
00040
00041 class Virtex6 : public VirtexBitstream {
00042 friend class torc::bitstream::bitstream::Virtex6UnitTest;
00043 friend class torc::bitstream::bitstream::Virtex6FarUnitTest;
00044 friend void torc::bitstream::bitstream::testVirtex6Device(const std::string& inDeviceName,
00045 const boost::filesystem::path& inWorkingPath);
00046 friend void torc::bitstream::bitstream::testVirtex6FullMapping(const boost::filesystem::path& inWorkingPath);
00047 friend void torc::bitstream::bitstream::testVirtex6PartialMapping(const boost::filesystem::path& inWorkingPath);
00048 protected:
00049
00050
00051 typedef boost::uint32_t uint32_t;
00052 public:
00053
00054
00055
00056 enum ERegister { eRegisterCRC = 0, eRegisterFAR, eRegisterFDRI, eRegisterFDRO,
00057 eRegisterCMD, eRegisterCTL0, eRegisterMASK, eRegisterSTAT, eRegisterLOUT,
00058 eRegisterCOR0, eRegisterMFWR, eRegisterCBC, eRegisterIDCODE, eRegisterAXSS,
00059 eRegisterCOR1, eRegisterCSOB, eRegisterWBSTAR, eRegisterTIMER, eRegisterBOOTSTS = 22,
00060 eRegisterCTL1 = 24, eRegisterDWC = 26, eRegisterCount };
00061
00062
00063
00064 enum ECommand { eCommandNULL = 0, eCommandWCFG, eCommandMFW, eCommandDGHIGH,
00065 eCommandLFRM = eCommandDGHIGH, eCommandRCFG, eCommandSTART, eCommandRCAP,
00066 eCommandRCRC, eCommandAGHIGH, eCommandSWITCH, eCommandGRESTORE, eCommandSHUTDOWN,
00067 eCommandGCAPTURE, eCommandDESYNCH, eCommandReserved, eCommandIPROG, eCommandCRCC,
00068 eCommandLTIMER, eCommandCount };
00069
00070
00071
00072 enum EFar {
00073 eFarMaskBlockType = 0x00e00000, eFarShiftBlockType = 21,
00074 eFarMaskTopBottom = 0x00100000, eFarShiftTopBottom = 20,
00075 eFarMaskRow = 0x000f8000, eFarShiftRow = 15,
00076 eFarMaskMajor = 0x00007f80, eFarShiftMajor = 7,
00077 eFarMaskMinor = 0x0000007f, eFarShiftMinor = 0
00078 };
00079
00080
00081
00082 enum EFarTopBottom { eFarTop = 0, eFarBottom = 1 };
00083
00084
00085 enum EFarBlockType { eFarBlockType0 = 0, eFarBlockType1, eFarBlockType2, eFarBlockType3,
00086 eFarBlockType4, eFarBlockType5, eFarBlockType6, eFarBlockType7, eFarBlockTypeCount };
00087
00088
00089
00090 enum {
00091 eStartAddr = 0x03ffffff,
00092 eTimerValue = 0x00ffffff
00093 };
00094
00095
00096
00097 enum EColumnType { eColumnTypeEmpty = 0, eColumnTypeBram, eColumnTypeClb, eColumnTypeClock,
00098 eColumnTypeDsp, eColumnTypeGtx, eColumnTypeIob, eColumnTypeCount };
00099
00100
00101
00102
00103 enum { eFrameLength = 81 };
00104 protected:
00105
00106
00107
00108
00109 static const char* sPacketTypeName[ePacketTypeCount];
00110
00111 static const char* sOpcodeName[eOpcodeCount];
00112
00113 static const char* sRegisterName[eRegisterCount];
00114
00115 static const char* sCommandName[eCommandCount];
00116
00117 static const Subfield sCOR0[];
00118
00119 static const Subfield sCOR1[];
00120
00121 static const Subfield sSTAT[];
00122
00123 static const Subfield sCTL0[];
00124
00125 static const Subfield sCTL1[];
00126
00127 static const Subfield sMASK0[];
00128
00129 static const Subfield sWBSTAR[];
00130
00131 static const Subfield sTIMER[];
00132
00133 static const Subfield sBOOTSTS[];
00134
00135 uint32_t mTopRowCount;
00136
00137 uint32_t mBottomRowCount;
00138
00139
00140 void setRowCounts(void);
00141 public:
00142
00143
00144 Virtex6(void) : VirtexBitstream(), mTopRowCount(0), mBottomRowCount(0) {
00145
00146
00147 mColumnDefs.resize(eColumnTypeCount);
00148 mColumnDefs[eColumnTypeEmpty] = ColumnDef("Empty", 0, 0, 0, 0, 0, 0, 0, 0);
00149 mColumnDefs[eColumnTypeBram] = ColumnDef("Bram", 28,128, 0, 0, 0, 0, 0, 0);
00150 mColumnDefs[eColumnTypeClb] = ColumnDef("Clb", 36, 0, 0, 0, 0, 0, 0, 0);
00151 mColumnDefs[eColumnTypeClock] = ColumnDef("Clock", 38, 0, 0, 0, 0, 0, 0, 0);
00152 mColumnDefs[eColumnTypeDsp] = ColumnDef("Dsp", 28, 0, 0, 0, 0, 0, 0, 0);
00153 mColumnDefs[eColumnTypeGtx] = ColumnDef("Gtx", 30, 0, 0, 0, 0, 0, 0, 0);
00154 mColumnDefs[eColumnTypeIob] = ColumnDef("Iob", 44, 0, 0, 0, 0, 0, 0, 0);
00155
00156 mTileTypeNameToColumnType["BRAM"] = eColumnTypeBram;
00157 mTileTypeNameToColumnType["PCIE_BRAM"] = eColumnTypeBram;
00158 mTileTypeNameToColumnType["CLBLL"] = eColumnTypeClb;
00159 mTileTypeNameToColumnType["CLBLM"] = eColumnTypeClb;
00160 mTileTypeNameToColumnType["CMT_TOP"] = eColumnTypeClock;
00161 mTileTypeNameToColumnType["DSP"] = eColumnTypeDsp;
00162 mTileTypeNameToColumnType["GTX"] = eColumnTypeGtx;
00163 mTileTypeNameToColumnType["GTX_LEFT"] = eColumnTypeGtx;
00164 mTileTypeNameToColumnType["GT3"] = eColumnTypeGtx;
00165 mTileTypeNameToColumnType["CIOB"] = eColumnTypeIob;
00166 mTileTypeNameToColumnType["LIOB"] = eColumnTypeIob;
00167 mTileTypeNameToColumnType["LIOB_FT"] = eColumnTypeIob;
00168 mTileTypeNameToColumnType["RIOB"] = eColumnTypeIob;
00169 }
00170
00171
00172 static uint32_t makeSubfield(ERegister inRegister, const std::string& inSubfield,
00173 const std::string& inSetting);
00174
00175 virtual void initializeDeviceInfo(const std::string& inDeviceName);
00176
00177
00178 virtual void initializeFrameMaps(void);
00179
00180 void initializeFullFrameBlocks(void);
00181
00182 VirtexFrameBlocks getBitstreamFrames(uint32_t inBlockCount, uint32_t inBitCol);
00183
00184 VirtexFrameBlocks getXdlFrames(uint32_t inBlockCount, uint32_t inXdlCol);
00185
00186
00187 virtual uint32_t getFrameLength(void) const { return eFrameLength; }
00188
00189
00190 friend std::ostream& operator<< (std::ostream& os, const Virtex6& rhs);
00191
00192 class FrameAddress : public VirtexFrameAddress {
00193 protected:
00194 virtual void assign(uint32_t inAddress) {
00195 mTopBottom = EFarTopBottom((inAddress & eFarMaskTopBottom) >> eFarShiftTopBottom);
00196 mBlockType = EFarBlockType((inAddress & eFarMaskBlockType) >> eFarShiftBlockType);
00197 mRow = (inAddress & eFarMaskRow) >> eFarShiftRow;
00198 mMajor = (inAddress & eFarMaskMajor) >> eFarShiftMajor;
00199 mMinor = (inAddress & eFarMaskMinor) >> eFarShiftMinor;
00200 }
00201 public:
00202 FrameAddress(void) : mTopBottom(eFarTop), mBlockType(eFarBlockType0), mRow(0),
00203 mMajor(0), mMinor(0) {}
00204 FrameAddress(EFarTopBottom inTopBottom, EFarBlockType inBlockType, uint32_t inRow,
00205 uint32_t inMajor, uint32_t inMinor) : mTopBottom(inTopBottom),
00206 mBlockType(inBlockType), mRow(inRow), mMajor(inMajor), mMinor(inMinor) {}
00207 FrameAddress(uint32_t inAddress) { assign(inAddress); }
00208 EFarTopBottom mTopBottom;
00209 EFarBlockType mBlockType;
00210 uint32_t mRow;
00211 uint32_t mMajor;
00212 uint32_t mMinor;
00213 virtual bool operator== (const VirtexFrameAddress& vrhs) const {
00214 const FrameAddress& rhs = reinterpret_cast<const FrameAddress&>(vrhs);
00215 return mTopBottom == rhs.mTopBottom && mBlockType == rhs.mBlockType
00216 && mRow == rhs.mRow && mMajor == rhs.mMajor && mMinor == rhs.mMinor;
00217 }
00218 virtual bool operator< (const VirtexFrameAddress& vrhs) const {
00219 const FrameAddress& rhs = reinterpret_cast<const FrameAddress&>(vrhs);
00220 int diffBlockType = mBlockType - rhs.mBlockType;
00221 if(diffBlockType) return diffBlockType < 0;
00222 int diffTopBottom = mTopBottom - rhs.mTopBottom;
00223 if(diffTopBottom) return diffTopBottom < 0;
00224 int diffRow = mRow - rhs.mRow;
00225 if(diffRow) return diffRow < 0;
00226 int diffMajor = mMajor - rhs.mMajor;
00227 if(diffMajor) return diffMajor < 0;
00228 return mMinor < rhs.mMinor;
00229 }
00230 private:
00231
00232
00233
00234
00235
00236
00237
00238
00239 };
00240 protected:
00241
00242
00243 typedef std::map<uint32_t, Virtex6::FrameAddress> FrameIndexToAddress;
00244
00245 typedef std::map<Virtex6::FrameAddress, uint32_t> FrameAddressToIndex;
00246
00247 typedef std::vector<uint32_t> IndexVector;
00248
00249
00250
00251 FrameIndexToAddress mFrameIndexToAddress;
00252
00253 FrameAddressToIndex mFrameAddressToIndex;
00254
00255 IndexVector mBitColumnIndexes [Virtex6::eFarBlockTypeCount];
00256
00257 IndexVector mXdlColumnIndexes [Virtex6::eFarBlockTypeCount];
00258
00259 uint32_t mBlockFrameIndexBounds [Virtex6::eFarBlockTypeCount];
00260
00261 std::map<uint32_t, uint32_t> mXdlIndexToBitIndex;
00262 };
00263
00264 }
00265 }
00266
00267 #endif // TORC_BITSTREAM_VIRTEX6_HPP