00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef TORC_BITSTREAM_VIRTEX5_HPP
00020 #define TORC_BITSTREAM_VIRTEX5_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 Virtex5UnitTest; }
00034 namespace bitstream { class Virtex5FarUnitTest; }
00035 namespace bitstream { void testVirtex5Device(const std::string& inDeviceName,
00036 const boost::filesystem::path& inWorkingPath); }
00037 namespace bitstream { void testVirtex5FullMapping(const boost::filesystem::path& inWorkingPath); }
00038 namespace bitstream { void testVirtex5PartialMapping(const boost::filesystem::path& inWorkingPath); }
00039
00040
00041 class Virtex5 : public VirtexBitstream {
00042 friend class torc::bitstream::bitstream::Virtex5UnitTest;
00043 friend class torc::bitstream::bitstream::Virtex5FarUnitTest;
00044 friend void torc::bitstream::bitstream::testVirtex5Device(const std::string& inDeviceName,
00045 const boost::filesystem::path& inWorkingPath);
00046 friend void torc::bitstream::bitstream::testVirtex5FullMapping(const boost::filesystem::path& inWorkingPath);
00047 friend void torc::bitstream::bitstream::testVirtex5PartialMapping(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, 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,
00068 eCommandLTIMER = 17, 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 = 41 };
00104 protected:
00105
00106
00107
00108
00109
00110
00111
00112
00113 static const char* sPacketTypeName[ePacketTypeCount];
00114
00115 static const char* sOpcodeName[eOpcodeCount];
00116
00117 static const char* sRegisterName[eRegisterCount];
00118
00119 static const char* sCommandName[eCommandCount];
00120
00121 static const Subfield sCOR0[];
00122
00123 static const Subfield sCOR1[];
00124
00125 static const Subfield sSTAT[];
00126
00127 static const Subfield sCTL0[];
00128
00129 static const Subfield sCTL1[];
00130
00131 static const Subfield sMASK0[];
00132
00133 static const Subfield sWBSTAR[];
00134
00135 static const Subfield sTIMER[];
00136
00137 static const Subfield sBOOTSTS[];
00138 public:
00139
00140
00141 Virtex5(void) : VirtexBitstream() {
00142
00143
00144 mColumnDefs.resize(eColumnTypeCount);
00145 mColumnDefs[eColumnTypeEmpty] = ColumnDef("Empty", 0, 0, 0, 0, 0, 0, 0, 0);
00146 mColumnDefs[eColumnTypeBram] = ColumnDef("Bram", 30,128, 0, 0, 0, 0, 0, 0);
00147 mColumnDefs[eColumnTypeClb] = ColumnDef("Clb", 36, 0, 0, 0, 0, 0, 0, 0);
00148 mColumnDefs[eColumnTypeClock] = ColumnDef("Clock", 4, 0, 0, 0, 0, 0, 0, 0);
00149 mColumnDefs[eColumnTypeDsp] = ColumnDef("Dsp", 28, 0, 0, 0, 0, 0, 0, 0);
00150 mColumnDefs[eColumnTypeGtx] = ColumnDef("Gtx", 32, 0, 0, 0, 0, 0, 0, 0);
00151 mColumnDefs[eColumnTypeIob] = ColumnDef("Iob", 54, 0, 0, 0, 0, 0, 0, 0);
00152
00153 mTileTypeNameToColumnType["BRAM"] = eColumnTypeBram;
00154 mTileTypeNameToColumnType["PCIE_BRAM"] = eColumnTypeBram;
00155 mTileTypeNameToColumnType["CLBLL"] = eColumnTypeClb;
00156 mTileTypeNameToColumnType["CLBLM"] = eColumnTypeClb;
00157 mTileTypeNameToColumnType["CLKV"] = eColumnTypeClock;
00158 mTileTypeNameToColumnType["DSP"] = eColumnTypeDsp;
00159 mTileTypeNameToColumnType["GTX"] = eColumnTypeGtx;
00160 mTileTypeNameToColumnType["GTX_LEFT"] = eColumnTypeGtx;
00161 mTileTypeNameToColumnType["GT3"] = eColumnTypeGtx;
00162 mTileTypeNameToColumnType["CIOB"] = eColumnTypeIob;
00163 mTileTypeNameToColumnType["LIOB"] = eColumnTypeIob;
00164 mTileTypeNameToColumnType["RIOB"] = eColumnTypeIob;
00165 }
00166
00167
00168 static uint32_t makeSubfield(ERegister inRegister, const std::string& inSubfield,
00169 const std::string& inSetting);
00170
00171 virtual void initializeDeviceInfo(const std::string& inDeviceName);
00172
00173
00174 virtual void initializeFrameMaps(void);
00175
00176 void initializeFullFrameBlocks(void);
00177
00178
00179
00180 VirtexFrameBlocks getBitstreamFrames(uint32_t inBlockCount, uint32_t inBitCol);
00181
00182 VirtexFrameBlocks getXdlFrames(uint32_t inBlockCount, uint32_t inXdlCol);
00183
00184
00185 virtual uint32_t getFrameLength(void) const { return eFrameLength; }
00186
00187
00188 friend std::ostream& operator<< (std::ostream& os, const Virtex5& rhs);
00189
00190
00191 class FrameAddress : public VirtexFrameAddress {
00192 protected:
00193 virtual void assign(uint32_t inAddress) {
00194 mTopBottom = EFarTopBottom((inAddress & eFarMaskTopBottom) >> eFarShiftTopBottom);
00195 mBlockType = EFarBlockType((inAddress & eFarMaskBlockType) >> eFarShiftBlockType);
00196 mRow = (inAddress & eFarMaskRow) >> eFarShiftRow;
00197 mMajor = (inAddress & eFarMaskMajor) >> eFarShiftMajor;
00198 mMinor = (inAddress & eFarMaskMinor) >> eFarShiftMinor;
00199 }
00200 public:
00201 FrameAddress(void) : mTopBottom(eFarTop), mBlockType(eFarBlockType0), mRow(0),
00202 mMajor(0), mMinor(0) {}
00203 FrameAddress(EFarTopBottom inTopBottom, EFarBlockType inBlockType, uint32_t inRow,
00204 uint32_t inMajor, uint32_t inMinor) : mTopBottom(inTopBottom),
00205 mBlockType(inBlockType), mRow(inRow), mMajor(inMajor), mMinor(inMinor) {}
00206 FrameAddress(uint32_t inAddress) { assign(inAddress); }
00207 EFarTopBottom mTopBottom;
00208 EFarBlockType mBlockType;
00209 uint32_t mRow;
00210 uint32_t mMajor;
00211 uint32_t mMinor;
00212 virtual bool operator== (const VirtexFrameAddress& vrhs) const {
00213 const FrameAddress& rhs = reinterpret_cast<const FrameAddress&>(vrhs);
00214 return mTopBottom == rhs.mTopBottom && mBlockType == rhs.mBlockType
00215 && mRow == rhs.mRow && mMajor == rhs.mMajor && mMinor == rhs.mMinor;
00216 }
00217 virtual bool operator< (const VirtexFrameAddress& vrhs) const {
00218 const FrameAddress& rhs = reinterpret_cast<const FrameAddress&>(vrhs);
00219 int diffBlockType = mBlockType - rhs.mBlockType;
00220 if(diffBlockType) return diffBlockType < 0;
00221 int diffTopBottom = mTopBottom - rhs.mTopBottom;
00222 if(diffTopBottom) return diffTopBottom < 0;
00223 int diffRow = mRow - rhs.mRow;
00224 if(diffRow) return diffRow < 0;
00225 int diffMajor = mMajor - rhs.mMajor;
00226 if(diffMajor) return diffMajor < 0;
00227 return mMinor < rhs.mMinor;
00228 }
00229 operator uint32_t (void) const {
00230 return uint32_t(((mTopBottom << eFarShiftTopBottom) & eFarMaskTopBottom)
00231 | ((mBlockType << eFarShiftBlockType) & eFarMaskBlockType)
00232 | ((mRow << eFarShiftRow) & eFarMaskRow)
00233 | ((mMajor << eFarShiftMajor) & eFarMaskMajor)
00234 | ((mMinor << eFarShiftMinor) & eFarMaskMinor));
00235 }
00236 friend std::ostream& operator<< (std::ostream& os, const Virtex5::FrameAddress& rhs) {
00237 return os << (rhs.mTopBottom == Virtex5::eFarTop ? 'T' : 'B')
00238 << "" << rhs.mBlockType << "(" << rhs.mRow << "," << rhs.mMajor << "."
00239 << rhs.mMinor << ")";
00240 }
00241 private:
00242
00243 };
00244 protected:
00245
00246
00247 typedef std::map<uint32_t, Virtex5::FrameAddress> FrameIndexToAddress;
00248
00249 typedef std::map<Virtex5::FrameAddress, uint32_t> FrameAddressToIndex;
00250
00251 typedef std::vector<uint32_t> IndexVector;
00252
00253
00254
00255 FrameIndexToAddress mFrameIndexToAddress;
00256
00257 FrameAddressToIndex mFrameAddressToIndex;
00258
00259 IndexVector mBitColumnIndexes [Virtex5::eFarBlockTypeCount];
00260
00261 IndexVector mXdlColumnIndexes [Virtex5::eFarBlockTypeCount];
00262
00263 uint32_t mBlockFrameIndexBounds [Virtex5::eFarBlockTypeCount];
00264
00265 std::map<uint32_t, uint32_t> mXdlIndexToBitIndex;
00266 };
00267
00268 }
00269 }
00270
00271 #endif // TORC_BITSTREAM_VIRTEX5_HPP