00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef TORC_BITSTREAM_VIRTEX4_HPP
00020 #define TORC_BITSTREAM_VIRTEX4_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
00027 namespace torc { namespace architecture { class DDB; } }
00028
00029 namespace torc {
00030 namespace bitstream {
00031
00032 namespace bitstream { class Virtex4UnitTest; }
00033 namespace bitstream { class Virtex4FarUnitTest; }
00034 namespace bitstream { void testVirtex4Device(const std::string& inDeviceName,
00035 const boost::filesystem::path& inWorkingPath); }
00036 namespace bitstream { void testVirtex4FullMapping(const boost::filesystem::path& inWorkingPath); }
00037 namespace bitstream { void testVirtex4PartialMapping(const boost::filesystem::path& inWorkingPath); }
00038
00039
00040 class Virtex4 : public VirtexBitstream {
00041 friend class torc::bitstream::bitstream::Virtex4UnitTest;
00042 friend class torc::bitstream::bitstream::Virtex4FarUnitTest;
00043 friend void torc::bitstream::bitstream::testVirtex4Device(const std::string& inDeviceName,
00044 const boost::filesystem::path& inWorkingPath);
00045 friend void torc::bitstream::bitstream::testVirtex4FullMapping(const boost::filesystem::path& inWorkingPath);
00046 friend void torc::bitstream::bitstream::testVirtex4PartialMapping(const boost::filesystem::path& inWorkingPath);
00047 protected:
00048
00049
00050 typedef boost::uint32_t uint32_t;
00051 public:
00052
00053
00054
00055
00056 enum ERegister { eRegisterCRC = 0, eRegisterFAR, eRegisterFDRI, eRegisterFDRO,
00057 eRegisterCMD, eRegisterCTL, eRegisterMASK, eRegisterSTAT, eRegisterLOUT, eRegisterCOR,
00058 eRegisterMFWR, eRegisterCBC, eRegisterIDCODE, eRegisterAXSS, eRegisterCount };
00059
00060
00061
00062 enum ECommand { eCommandNULL = 0, eCommandWCFG, eCommandMFWR, eCommandLFRM, eCommandRCFG,
00063 eCommandSTART, eCommandRCAP, eCommandRCRC, eCommandAGHIGH, eCommandSWITCH,
00064 eCommandGRESTORE, eCommandSHUTDOWN, eCommandGCAPTURE, eCommandDESYNC, eCommandCount };
00065
00066
00067
00068 enum EFar {
00069 eFarMaskTopBottom = 0x00400000, eFarShiftTopBottom = 22,
00070 eFarMaskBlockType = 0x00380000, eFarShiftBlockType = 19,
00071 eFarMaskRow = 0x0007c000, eFarShiftRow = 14,
00072 eFarMaskMajor = 0x00003fc0, eFarShiftMajor = 6,
00073 eFarMaskMinor = 0x0000003f, eFarShiftMinor = 0,
00074 };
00075
00076
00077 enum EFarTopBottom { eFarTop = 0, eFarBottom = 1 };
00078
00079 enum EFarBlockType { eFarBlockType0 = 0, eFarBlockType1, eFarBlockType2, eFarBlockType3,
00080 eFarBlockType4, eFarBlockType5, eFarBlockType6, eFarBlockType7, eFarBlockTypeCount };
00081
00082
00083
00084 enum EColumnType { eColumnTypeEmpty = 0, eColumnTypeBram, eColumnTypeClb, eColumnTypeClock,
00085 eColumnTypeDsp, eColumnTypeGtx, eColumnTypeIob, eColumnTypeCount };
00086
00087
00088
00089
00090 enum { eFrameLength = 41 };
00091 protected:
00092
00093
00094
00095
00096 static const char* sPacketTypeName[ePacketTypeCount];
00097
00098 static const char* sOpcodeName[eOpcodeCount];
00099
00100 static const char* sRegisterName[eRegisterCount];
00101
00102 static const char* sCommandName[eCommandCount];
00103
00104 static const Subfield sCOR[];
00105
00106 static const Subfield sSTAT[];
00107
00108 static const Subfield sCTL[];
00109
00110 static const Subfield sMASK[];
00111 public:
00112
00113
00114 Virtex4(void) : VirtexBitstream() {
00115
00116
00117 mColumnDefs.resize(eColumnTypeCount);
00118 mColumnDefs[eColumnTypeEmpty] = ColumnDef("Empty", 0, 0, 0, 0, 0, 0, 0, 0);
00119 mColumnDefs[eColumnTypeBram] = ColumnDef("Bram", 0, 20, 64, 0, 0, 0, 0, 0);
00120 mColumnDefs[eColumnTypeClb] = ColumnDef("Clb", 22, 0, 0, 0, 0, 0, 0, 0);
00121 mColumnDefs[eColumnTypeClock] = ColumnDef("Clock", 3, 0, 0, 0, 0, 0, 0, 0);
00122 mColumnDefs[eColumnTypeDsp] = ColumnDef("Dsp", 21, 0, 0, 0, 0, 0, 0, 0);
00123 mColumnDefs[eColumnTypeGtx] = ColumnDef("Gtx", 20, 0, 0, 0, 0, 0, 0, 0);
00124 mColumnDefs[eColumnTypeIob] = ColumnDef("Iob", 30, 0, 0, 0, 0, 0, 0, 0);
00125
00126 mTileTypeNameToColumnType["BRAM"] = eColumnTypeBram;
00127 mTileTypeNameToColumnType["CLB"] = eColumnTypeClb;
00128 mTileTypeNameToColumnType["CLKV_DCM_T"] = eColumnTypeClock;
00129 mTileTypeNameToColumnType["DSP"] = eColumnTypeDsp;
00130 mTileTypeNameToColumnType["MGT_AL"] = eColumnTypeGtx;
00131 mTileTypeNameToColumnType["MGT_BL"] = eColumnTypeGtx;
00132 mTileTypeNameToColumnType["MGT_AR"] = eColumnTypeGtx;
00133 mTileTypeNameToColumnType["MGT_BR"] = eColumnTypeGtx;
00134 mTileTypeNameToColumnType["IOIS_LC"] = eColumnTypeIob;
00135 mTileTypeNameToColumnType["IOIS_LC_L"] = eColumnTypeIob;
00136 mTileTypeNameToColumnType["IOIS_NC"] = eColumnTypeIob;
00137 mTileTypeNameToColumnType["IOIS_NC_L"] = eColumnTypeIob;
00138 }
00139
00140
00141 static uint32_t makeSubfield(ERegister inRegister, const std::string& inSubfield,
00142 const std::string& inSetting);
00143
00144 virtual void initializeDeviceInfo(const std::string& inDeviceName);
00145
00146
00147 virtual void initializeFrameMaps(void);
00148
00149 void initializeFullFrameBlocks(void);
00150
00151 VirtexFrameBlocks getBitstreamFrames(uint32_t inBlockCount, uint32_t inBitCol);
00152
00153 VirtexFrameBlocks getXdlFrames(uint32_t inBlockCount, uint32_t inXdlCol);
00154
00155
00156 virtual uint32_t getFrameLength(void) const { return eFrameLength; }
00157
00158
00159 friend std::ostream& operator<< (std::ostream& os, const Virtex4& rhs);
00160
00161 class FrameAddress : public VirtexFrameAddress {
00162 protected:
00163 virtual void assign(uint32_t inAddress) {
00164 mTopBottom = EFarTopBottom((inAddress & eFarMaskTopBottom) >> eFarShiftTopBottom);
00165 mBlockType = EFarBlockType((inAddress & eFarMaskBlockType) >> eFarShiftBlockType);
00166 mRow = (inAddress & eFarMaskRow) >> eFarShiftRow;
00167 mMajor = (inAddress & eFarMaskMajor) >> eFarShiftMajor;
00168 mMinor = (inAddress & eFarMaskMinor) >> eFarShiftMinor;
00169 }
00170 public:
00171 FrameAddress(void) : mTopBottom(eFarTop), mBlockType(eFarBlockType0), mRow(0),
00172 mMajor(0), mMinor(0) {}
00173 FrameAddress(EFarTopBottom inTopBottom, EFarBlockType inBlockType, uint32_t inRow,
00174 uint32_t inMajor, uint32_t inMinor) : mTopBottom(inTopBottom),
00175 mBlockType(inBlockType), mRow(inRow), mMajor(inMajor), mMinor(inMinor) {}
00176 FrameAddress(uint32_t inAddress) { assign(inAddress); }
00177 EFarTopBottom mTopBottom;
00178 EFarBlockType mBlockType;
00179 uint32_t mRow;
00180 uint32_t mMajor;
00181 uint32_t mMinor;
00182 virtual bool operator== (const VirtexFrameAddress& vrhs) const {
00183 const FrameAddress& rhs = reinterpret_cast<const FrameAddress&>(vrhs);
00184 return mTopBottom == rhs.mTopBottom && mBlockType == rhs.mBlockType
00185 && mRow == rhs.mRow && mMajor == rhs.mMajor && mMinor == rhs.mMinor;
00186 }
00187 virtual bool operator< (const VirtexFrameAddress& vrhs) const {
00188 const FrameAddress& rhs = reinterpret_cast<const FrameAddress&>(vrhs);
00189 int diffBlockType = mBlockType - rhs.mBlockType;
00190 if(diffBlockType) return diffBlockType < 0;
00191 int diffTopBottom = mTopBottom - rhs.mTopBottom;
00192 if(diffTopBottom) return diffTopBottom < 0;
00193 int diffRow = mRow - rhs.mRow;
00194 if(diffRow) return diffRow < 0;
00195 int diffMajor = mMajor - rhs.mMajor;
00196 if(diffMajor) return diffMajor < 0;
00197 return mMinor < rhs.mMinor;
00198 }
00199 operator uint32_t (void) const {
00200 return uint32_t(((mTopBottom << eFarShiftTopBottom) & eFarMaskTopBottom)
00201 | ((mBlockType << eFarShiftBlockType) & eFarMaskBlockType)
00202 | ((mRow << eFarShiftRow) & eFarMaskRow)
00203 | ((mMajor << eFarShiftMajor) & eFarMaskMajor)
00204 | ((mMinor << eFarShiftMinor) & eFarMaskMinor));
00205 }
00206 friend std::ostream& operator<< (std::ostream& os, const Virtex4::FrameAddress& rhs) {
00207 return os << (rhs.mTopBottom == Virtex4::eFarTop ? 'T' : 'B')
00208 << "" << rhs.mBlockType << "(" << rhs.mRow << "," << rhs.mMajor << "."
00209 << rhs.mMinor << ")";
00210 }
00211 private:
00212
00213 };
00214 protected:
00215
00216
00217 typedef std::map<uint32_t, Virtex4::FrameAddress> FrameIndexToAddress;
00218
00219 typedef std::map<Virtex4::FrameAddress, uint32_t> FrameAddressToIndex;
00220
00221 typedef std::vector<uint32_t> IndexVector;
00222
00223
00224
00225 FrameIndexToAddress mFrameIndexToAddress;
00226
00227 FrameAddressToIndex mFrameAddressToIndex;
00228
00229 IndexVector mBitColumnIndexes [Virtex4::eFarBlockTypeCount];
00230
00231 IndexVector mXdlColumnIndexes [Virtex4::eFarBlockTypeCount];
00232
00233 uint32_t mBlockFrameIndexBounds [Virtex4::eFarBlockTypeCount];
00234
00235 std::map<uint32_t, uint32_t> mXdlIndexToBitIndex;
00236 };
00237
00238 }
00239 }
00240
00241 #endif // TORC_BITSTREAM_VIRTEX4_HPP