00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef TORC_BITSTREAM_VIRTEX2_HPP
00020 #define TORC_BITSTREAM_VIRTEX2_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 Virtex2UnitTest; }
00034 namespace bitstream { class Virtex2FarUnitTest; }
00035 namespace bitstream { void testVirtex2Device(const std::string& inDeviceName,
00036 const boost::filesystem::path& inWorkingPath); }
00037 namespace bitstream { void testVirtex2FullMapping(const boost::filesystem::path& inWorkingPath); }
00038
00039
00040 class Virtex2 : public VirtexBitstream {
00041 friend class torc::bitstream::bitstream::Virtex2UnitTest;
00042 friend class torc::bitstream::bitstream::Virtex2FarUnitTest;
00043 friend void torc::bitstream::bitstream::testVirtex2Device(const std::string& inDeviceName,
00044 const boost::filesystem::path& inWorkingPath);
00045 friend void torc::bitstream::bitstream::testVirtex2FullMapping(const boost::filesystem::path& inWorkingPath);
00046 protected:
00047
00048
00049 typedef boost::uint32_t uint32_t;
00050 public:
00051
00052
00053
00054
00055 enum ERegister { eRegisterCRC = 0, eRegisterFAR, eRegisterFDRI, eRegisterFDRO,
00056 eRegisterCMD, eRegisterCTL, eRegisterMASK, eRegisterSTAT, eRegisterLOUT, eRegisterCOR,
00057 eRegisterMFWR, eRegisterFLR, eRegisterKEY, eRegisterCBC, eRegisterIDCODE, eRegisterCount };
00058
00059
00060
00061 enum ECommand { eCommandNULL = 0, eCommandWCFG, eCommandMFWR, eCommandLFRM, eCommandRCFG,
00062 eCommandSTART, eCommandRCAP, eCommandRCRC, eCommandAGHIGH, eCommandSWITCH,
00063 eCommandGRESTORE, eCommandSHUTDOWN, eCommandGCAPTURE, eCommandDESYNCH, eCommandCount };
00064
00065
00066
00067 enum EFar {
00068 eFarMaskBlockType = 0x06000000, eFarShiftBlockType = 25,
00069 eFarMaskMajor = 0x01fe0000, eFarShiftMajor = 17,
00070 eFarMaskMinor = 0x0001fe00, eFarShiftMinor = 9,
00071 };
00072
00073 enum EFarBlockType { eFarBlockType0 = 0, eFarBlockType1, eFarBlockType2, eFarBlockType3,
00074 eFarBlockType4, eFarBlockType5, eFarBlockType6, eFarBlockType7, eFarBlockTypeCount };
00075
00076
00077
00078 enum EColumnType { eColumnTypeEmpty = 0, eColumnTypeBram, eColumnTypeClb, eColumnTypeClock,
00079 eColumnTypeDsp, eColumnTypeGtx, eColumnTypeIob, eColumnTypeCount };
00080 protected:
00081
00082
00083
00084
00085 static const char* sPacketTypeName[ePacketTypeCount];
00086
00087 static const char* sOpcodeName[eOpcodeCount];
00088
00089 static const char* sRegisterName[eRegisterCount];
00090
00091 static const char* sCommandName[eCommandCount];
00092
00093 static const Subfield sCOR[];
00094
00095 static const Subfield sSTAT[];
00096
00097 static const Subfield sCTL[];
00098
00099 static const Subfield sMASK[];
00100
00101 string mPrivateDeviceName;
00102 public:
00103
00104
00105 Virtex2(void) : VirtexBitstream() {
00106
00107
00108 mColumnDefs.resize(eColumnTypeCount);
00109 mColumnDefs[eColumnTypeEmpty] = ColumnDef("Empty", 0, 0, 0, 0, 0, 0, 0, 0);
00110 mColumnDefs[eColumnTypeBram] = ColumnDef("Bram", 0, 64, 22, 0, 0, 0, 0, 0);
00111 mColumnDefs[eColumnTypeClb] = ColumnDef("Clb", 22, 0, 0, 0, 0, 0, 0, 0);
00112 mColumnDefs[eColumnTypeClock] = ColumnDef("Clock", 4, 0, 0, 0, 0, 0, 0, 0);
00113 mColumnDefs[eColumnTypeGtx] = ColumnDef("Gtx", 22, 0, 0, 0, 0, 0, 0, 0);
00114 mColumnDefs[eColumnTypeIob] = ColumnDef("Iob", 4, 0, 0, 0, 0, 0, 0, 0);
00115
00116 mTileTypeNameToColumnType["BRAM0"] = eColumnTypeBram;
00117 mTileTypeNameToColumnType["CENTER"] = eColumnTypeClb;
00118 mTileTypeNameToColumnType["CLKV"] = eColumnTypeClock;
00119 mTileTypeNameToColumnType["LR_IOIS"] = eColumnTypeGtx;
00120 mTileTypeNameToColumnType["LTERM010"] = eColumnTypeIob;
00121 mTileTypeNameToColumnType["RTERM010"] = eColumnTypeIob;
00122 }
00123
00124
00125 static uint32_t makeSubfield(ERegister inRegister, const std::string& inSubfield,
00126 const std::string& inSetting);
00127
00128
00129 virtual void initializeDeviceInfo(const std::string& inDeviceName);
00130
00131
00132 virtual void initializeFrameMaps(void);
00133
00134 void initializeFullFrameBlocks(void);
00135
00136 VirtexFrameBlocks getBitstreamFrames(uint32_t inBlockCount, uint32_t inBitCol);
00137
00138 VirtexFrameBlocks getXdlFrames(uint32_t inBlockCount, uint32_t inXdlCol);
00139
00140
00141 friend std::ostream& operator<< (std::ostream& os, const Virtex2& rhs);
00142
00143 class FrameAddress : public VirtexFrameAddress {
00144 protected:
00145 virtual void assign(uint32_t inAddress) {
00146 mBlockType = EFarBlockType((inAddress & eFarMaskBlockType) >> eFarShiftBlockType);
00147 mMajor = (inAddress & eFarMaskMajor) >> eFarShiftMajor;
00148 mMinor = (inAddress & eFarMaskMinor) >> eFarShiftMinor;
00149 }
00150 public:
00151 FrameAddress(void) : mBlockType(eFarBlockType0), mMajor(0), mMinor(0) {}
00152 FrameAddress(EFarBlockType inBlockType, uint32_t inMajor, uint32_t inMinor) :
00153 mBlockType(inBlockType), mMajor(inMajor), mMinor(inMinor) {}
00154 FrameAddress(uint32_t inAddress) { assign(inAddress); }
00155 EFarBlockType mBlockType;
00156 uint32_t mMajor;
00157 uint32_t mMinor;
00158 virtual bool operator== (const VirtexFrameAddress& vrhs) const {
00159 const FrameAddress& rhs = reinterpret_cast<const FrameAddress&>(vrhs);
00160 return mBlockType == rhs.mBlockType && mMajor == rhs.mMajor && mMinor == rhs.mMinor;
00161 }
00162 virtual bool operator< (const VirtexFrameAddress& vrhs) const {
00163 const FrameAddress& rhs = reinterpret_cast<const FrameAddress&>(vrhs);
00164 int diffBlockType = mBlockType - rhs.mBlockType;
00165 if(diffBlockType) return diffBlockType < 0;
00166 int diffMajor = mMajor - rhs.mMajor;
00167 if(diffMajor) return diffMajor < 0;
00168 return mMinor < rhs.mMinor;
00169 }
00170 friend std::ostream& operator<< (std::ostream& os, const Virtex2::FrameAddress& rhs) {
00171 return os << rhs.mBlockType << "(" << rhs.mMajor << "." << rhs.mMinor << ")";
00172 }
00173 private:
00174
00175
00176
00177
00178
00179
00180
00181
00182 };
00183
00184 virtual uint32_t getFrameLength(void) const {
00185 using namespace torc::common;
00186
00187 switch(mDevice) {
00188 case eXC2V40: return 26;
00189 case eXC2V80: return 46;
00190 case eXC2V250: return 66;
00191 case eXC2V500: return 86;
00192 case eXC2V1000: return 106;
00193 case eXC2V1500: return 126;
00194 case eXC2V2000: return 146;
00195 case eXC2V3000: return 166;
00196 case eXC2V4000: return 206;
00197 case eXC2V6000: return 246;
00198 case eXC2V8000: return 286;
00199 default: return 0;
00200 }
00201 }
00202 protected:
00203
00204
00205 typedef std::map<uint32_t, Virtex2::FrameAddress> FrameIndexToAddress;
00206
00207 typedef std::map<Virtex2::FrameAddress, uint32_t> FrameAddressToIndex;
00208
00209 typedef std::vector<uint32_t> IndexVector;
00210
00211
00212
00213 FrameIndexToAddress mFrameIndexToAddress;
00214
00215 FrameAddressToIndex mFrameAddressToIndex;
00216
00217 IndexVector mBitColumnIndexes [Virtex2::eFarBlockTypeCount];
00218
00219 IndexVector mXdlColumnIndexes [Virtex2::eFarBlockTypeCount];
00220
00221 uint32_t mBlockFrameIndexBounds [Virtex2::eFarBlockTypeCount];
00222
00223 std::map<uint32_t, uint32_t> mXdlIndexToBitIndex;
00224 };
00225
00226 }
00227 }
00228
00229 #endif // TORC_BITSTREAM_VIRTEX2_HPP