00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef TORC_BITSTREAM_VIRTEX_HPP
00020 #define TORC_BITSTREAM_VIRTEX_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 VirtexUnitTest; }
00034 namespace bitstream { class VirtexFarUnitTest; }
00035 namespace bitstream { void testVirtexDevice(const std::string& inDeviceName,
00036 const boost::filesystem::path& inWorkingPath); }
00037 namespace bitstream { void testVirtexFullMapping(const boost::filesystem::path& inWorkingPath); }
00038
00039
00040 class Virtex : public VirtexBitstream {
00041 friend class torc::bitstream::bitstream::VirtexUnitTest;
00042 friend class torc::bitstream::bitstream::VirtexFarUnitTest;
00043 friend void torc::bitstream::bitstream::testVirtexDevice(const std::string& inDeviceName,
00044 const boost::filesystem::path& inWorkingPath);
00045 friend void torc::bitstream::bitstream::testVirtexFullMapping(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 eRegisterFLR=11, eRegisterCount};
00058
00059
00060
00061 enum ECommand { eCommandWCFG = 1, eCommandLFRM = 3, eCommandRCFG,
00062 eCommandSTART, eCommandRCAP, eCommandRCRC, eCommandAGHIGH, eCommandSWITCH, eCommandCount};
00063
00064
00065
00066 enum EFar {
00067 eFarMaskBlockType = 0x06000000, eFarShiftBlockType = 25,
00068 eFarMaskMajor = 0x01FE0000, eFarShiftMajor = 17,
00069 eFarMaskMinor = 0x0001FE00, eFarShiftMinor = 9,
00070 };
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 string mPrivateDeviceName;
00101 public:
00102
00103
00104 Virtex(void) : VirtexBitstream() {
00105
00106
00107 mColumnDefs.resize(eColumnTypeCount);
00108 mColumnDefs[eColumnTypeEmpty] = ColumnDef("Empty", 0, 0, 0, 0, 0, 0, 0, 0);
00109 mColumnDefs[eColumnTypeBram] = ColumnDef("Bram", 27, 64, 0, 0, 0, 0, 0, 0);
00110 mColumnDefs[eColumnTypeClb] = ColumnDef("Clb", 48, 0, 0, 0, 0, 0, 0, 0);
00111 mColumnDefs[eColumnTypeClock] = ColumnDef("Clock", 8, 0, 0, 0, 0, 0, 0, 0);
00112 mColumnDefs[eColumnTypeIob] = ColumnDef("Iob", 54, 0, 0, 0, 0, 0, 0, 0);
00113
00114 mTileTypeNameToColumnType["LBRAM"] = eColumnTypeBram;
00115 mTileTypeNameToColumnType["RBRAM"] = eColumnTypeBram;
00116 mTileTypeNameToColumnType["MBRAM"] = eColumnTypeBram;
00117 mTileTypeNameToColumnType["CENTER"] = eColumnTypeClb;
00118 mTileTypeNameToColumnType["CLKV"] = eColumnTypeClock;
00119 mTileTypeNameToColumnType["LEFT"] = eColumnTypeIob;
00120 mTileTypeNameToColumnType["RIGHT"] = eColumnTypeIob;
00121 }
00122
00123
00124 static uint32_t makeSubfield(ERegister inRegister, const std::string& inSubfield,
00125 const std::string& inSetting);
00126
00127
00128 virtual void initializeDeviceInfo(const std::string& inDeviceName);
00129
00130
00131 virtual void initializeFrameMaps(void);
00132
00133 typedef torc::common::EncapsulatedInteger<uint16_t> ColumnIndex;
00134 void prepareFrames(ColumnIndex &inCol, int &inFrameCount, int &inFrameIndex, EFarBlockType &inBlockType, int &inFarMajor, int &inWidth);
00135
00136 void initializeFullFrameBlocks(void);
00137
00138 VirtexFrameBlocks getBitstreamFrames(uint32_t inBlockCount, uint32_t inBitCol);
00139
00140 VirtexFrameBlocks getXdlFrames(uint32_t inBlockCount, uint32_t inXdlCol);
00141
00142
00143 friend std::ostream& operator<< (std::ostream& os, const Virtex& rhs);
00144
00145 class FrameAddress : public VirtexFrameAddress {
00146 protected:
00147 virtual void assign(uint32_t inAddress) {
00148 mBlockType = EFarBlockType((inAddress & eFarMaskBlockType) >> eFarShiftBlockType);
00149 mMajor = (inAddress & eFarMaskMajor) >> eFarShiftMajor;
00150 mMinor = (inAddress & eFarMaskMinor) >> eFarShiftMinor;
00151 }
00152 public:
00153 FrameAddress(void) : mBlockType(eFarBlockType0), mMajor(0), mMinor(0) {}
00154 FrameAddress(EFarBlockType inBlockType, uint32_t inMajor, uint32_t inMinor) :
00155 mBlockType(inBlockType), mMajor(inMajor), mMinor(inMinor) {}
00156 FrameAddress(uint32_t inAddress) { assign(inAddress); }
00157 EFarBlockType mBlockType;
00158 uint32_t mMajor;
00159 uint32_t mMinor;
00160 virtual bool operator== (const VirtexFrameAddress& vrhs) const {
00161 const FrameAddress& rhs = reinterpret_cast<const FrameAddress&>(vrhs);
00162 return mBlockType == rhs.mBlockType && mMajor == rhs.mMajor && mMinor == rhs.mMinor;
00163 }
00164 virtual bool operator< (const VirtexFrameAddress& vrhs) const {
00165 const FrameAddress& rhs = reinterpret_cast<const FrameAddress&>(vrhs);
00166 int diffBlockType = mBlockType - rhs.mBlockType;
00167 if(diffBlockType) return diffBlockType < 0;
00168 int diffMajor = mMajor - rhs.mMajor;
00169 if(diffMajor) return diffMajor < 0;
00170 return mMinor < rhs.mMinor;
00171 }
00172 private:
00173
00174 };
00175
00176
00177 virtual uint32_t getFrameLength(void) const {
00178 using namespace torc::common;
00179
00180 switch(mDevice) {
00181 case eXCV50: return 12;
00182 case eXCV100: return 14;
00183 case eXCV150: return 16;
00184 case eXCV200: return 18;
00185 case eXCV300: return 21;
00186 case eXCV400: return 25;
00187 case eXCV600: return 30;
00188 case eXCV800: return 34;
00189 case eXCV1000: return 39;
00190 default: return 0;
00191 }
00192 }
00193 protected:
00194
00195
00196 typedef std::map<uint32_t, Virtex::FrameAddress> FrameIndexToAddress;
00197
00198 typedef std::map<Virtex::FrameAddress, uint32_t> FrameAddressToIndex;
00199
00200 typedef std::vector<uint32_t> IndexVector;
00201
00202
00203
00204 FrameIndexToAddress mFrameIndexToAddress;
00205
00206 FrameAddressToIndex mFrameAddressToIndex;
00207
00208 IndexVector mBitColumnIndexes [Virtex::eFarBlockTypeCount];
00209
00210 IndexVector mXdlColumnIndexes [Virtex::eFarBlockTypeCount];
00211
00212 uint32_t mBlockFrameIndexBounds [Virtex::eFarBlockTypeCount];
00213
00214 uint32_t mFrameIndexBounds;
00215
00216 std::map<uint32_t, uint32_t> mXdlIndexToBitIndex;
00217 };
00218
00219 }
00220 }
00221
00222 #endif // TORC_BITSTREAM_VIRTEX_HPP