00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef TORC_BITSTREAM_SPARTAN3E_HPP
00020 #define TORC_BITSTREAM_SPARTAN3E_HPP
00021
00022 #include <boost/cstdint.hpp>
00023 #include <boost/filesystem.hpp>
00024 #include "torc/bitstream/SpartanBitstream.hpp"
00025 #include <map>
00026
00027 namespace torc { namespace architecture { class DDB; } }
00028
00029 namespace torc {
00030 namespace bitstream {
00031
00032 namespace bitstream { class Spartan3EUnitTest; }
00033 namespace bitstream { class Spartan3EFarUnitTest; }
00034 namespace bitstream { void testSpartan3EDevice(const std::string& inDeviceName,
00035 const boost::filesystem::path& inWorkingPath); }
00036
00037
00038 class Spartan3E : public SpartanBitstream {
00039 friend class torc::bitstream::bitstream::Spartan3EUnitTest;
00040 friend class torc::bitstream::bitstream::Spartan3EFarUnitTest;
00041 friend void torc::bitstream::bitstream::testSpartan3EDevice(const std::string& inDeviceName,
00042 const boost::filesystem::path& inWorkingPath);
00043 protected:
00044
00045
00046 typedef boost::uint32_t uint32_t;
00047 public:
00048
00049
00050
00051
00052 enum ERegister { eRegisterCRC = 0, eRegisterFAR, eRegisterFDRI, eRegisterFDRO,
00053 eRegisterCMD, eRegisterCTL, eRegisterMASK, eRegisterSTAT, eRegisterLOUT, eRegisterCOR,
00054 eRegisterMFWR, eRegisterFLR, eRegisterIDCODE = 14, eRegisterCount };
00055
00056
00057
00058 enum ECommand { eCommandNULL = 0, eCommandWCFG, eCommandMFWR, eCommandLFRM, eCommandRCFG,
00059 eCommandSTART, eCommandRCAP, eCommandRCRC, eCommandAGHIGH, eCommandSWITCH,
00060 eCommandGRESTORE, eCommandSHUTDOWN, eCommandGCAPTURE, eCommandDESYNCH, eCommandCount };
00061
00062
00063
00064 enum EFar {
00065 eFarMaskColumn = 0x06000000, eFarShiftColumn = 25,
00066 eFarMaskMajor = 0x01fe0000, eFarShiftMajor = 17,
00067 eFarMaskMinor = 0x0001fe00, eFarShiftMinor = 9
00068 };
00069
00070
00071 enum EFarTopBottom { eFarTop = 0, eFarBottom = 1 };
00072
00073 enum EFarBlockType { eFarBlockType0 = 0, eFarBlockType1, eFarBlockType2, eFarBlockType3,
00074 eFarBlockType4, eFarBlockType5, eFarBlockType6, eFarBlockType7, eFarBlockTypeCount };
00075
00076
00077
00078 enum EColumnType { eColumnTypeEmpty = 0, eColumnTypeBram, eColumnTypeBramInt, eColumnTypeClb,
00079 eColumnTypeClock, eColumnTypeClockLL, eColumnTypeTerm, 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 public:
00101
00102
00103 Spartan3E(void) : SpartanBitstream() {
00104
00105
00106 mColumnDefs.resize(eColumnTypeCount);
00107 mColumnDefs[eColumnTypeEmpty] = ColumnDef("Empty", 0, 0, 0, 0, 0, 0, 0, 0);
00108 mColumnDefs[eColumnTypeBram] = ColumnDef("Bram", 0, 76, 0, 0, 0, 0, 0, 0);
00109 mColumnDefs[eColumnTypeBramInt] = ColumnDef("BramInt", 0, 0, 19, 0, 0, 0, 0, 0);
00110 mColumnDefs[eColumnTypeClb] = ColumnDef("Clb", 19, 0, 0, 0, 0, 0, 0, 0);
00111 mColumnDefs[eColumnTypeClock] = ColumnDef("Clock", 3, 0, 0, 0, 0, 0, 0, 0);
00112 mColumnDefs[eColumnTypeClockLL] = ColumnDef("ClockLL", 4, 0, 0, 0, 0, 0, 0, 0);
00113 mColumnDefs[eColumnTypeIob] = ColumnDef("Iob", 19, 0, 0, 0, 0, 0, 0, 0);
00114 mColumnDefs[eColumnTypeTerm] = ColumnDef("Term", 2, 0, 0, 0, 0, 0, 0, 0);
00115
00116 mTileTypeNameToColumnType["BRAMSITE2"] = eColumnTypeBram;
00117 mTileTypeNameToColumnType["BRAM3_SMALL"] = eColumnTypeBramInt;
00118 mTileTypeNameToColumnType["CENTER_SMALL"] = eColumnTypeClb;
00119 mTileTypeNameToColumnType["CLKV"] = eColumnTypeClock;
00120 mTileTypeNameToColumnType["CLKV_LL"] = eColumnTypeClockLL;
00121 mTileTypeNameToColumnType["LIOIS"] = eColumnTypeIob;
00122 mTileTypeNameToColumnType["RIOIS"] = eColumnTypeIob;
00123 mTileTypeNameToColumnType["LTERM"] = eColumnTypeTerm;
00124 mTileTypeNameToColumnType["RTERM"] = eColumnTypeTerm;
00125 }
00126
00127
00128 static uint32_t makeSubfield(ERegister inRegister, const std::string& inSubfield,
00129 const std::string& inSetting);
00130
00131
00132 virtual void initializeDeviceInfo(const std::string& inDeviceName);
00133
00134
00135 virtual void initializeFrameMaps(void);
00136
00137
00138 friend std::ostream& operator<< (std::ostream& os, const Spartan3E& rhs);
00139
00140 class FrameAddress {
00141 protected:
00142 void assign(uint32_t inAddress) {
00143 mColumn = (inAddress & eFarMaskColumn) >> eFarShiftColumn;
00144 mMajor = (inAddress & eFarMaskMajor) >> eFarShiftMajor;
00145 mMinor = (inAddress & eFarMaskMinor) >> eFarShiftMinor;
00146 }
00147 public:
00148 FrameAddress(void) : mColumn(0), mMajor(0), mMinor(0) {}
00149 FrameAddress(uint32_t inColumn, uint32_t inMajor, uint32_t inMinor) :
00150 mColumn(inColumn), mMajor(inMajor), mMinor(inMinor) {}
00151 FrameAddress(uint32_t inAddress) { assign(inAddress); }
00152 uint32_t mColumn;
00153 uint32_t mMajor;
00154 uint32_t mMinor;
00155 bool operator== (const FrameAddress& rhs) const {
00156 return mColumn == rhs.mColumn && mMajor == rhs.mMajor && mMinor == rhs.mMinor;
00157 }
00158 bool operator< (const FrameAddress& rhs) const {
00159 int diffColumn = mColumn - rhs.mColumn;
00160 if(diffColumn) return diffColumn < 0;
00161 int diffMajor = mMajor - rhs.mMajor;
00162 if(diffMajor) return diffMajor < 0;
00163 return mMinor < rhs.mMinor;
00164 }
00165 };
00166
00167 virtual uint32_t getFrameLength(void) const {
00168 using namespace torc::common;
00169
00170 switch(mDevice) {
00171 case eXC3S100E: return 49;
00172 case eXC3S250E: return 73;
00173 case eXC3S500E: return 97;
00174 case eXC3S1200E: return 125;
00175 case eXC3S1600E: return 157;
00176 default: return 0;
00177 }
00178 }
00179 protected:
00180
00181
00182 typedef std::map<uint32_t, Spartan3E::FrameAddress> FrameIndexToAddress;
00183
00184 typedef std::map<Spartan3E::FrameAddress, uint32_t> FrameAddressToIndex;
00185
00186 typedef std::vector<uint32_t> ColumnIndexVector;
00187
00188
00189
00190 FrameIndexToAddress mFrameIndexToAddress;
00191
00192 FrameAddressToIndex mFrameAddressToIndex;
00193
00194 ColumnIndexVector mBitColumnIndexes [Spartan3E::eFarBlockTypeCount];
00195
00196 ColumnIndexVector mXdlColumnIndexes [Spartan3E::eFarBlockTypeCount];
00197 };
00198
00199 }
00200 }
00201
00202 #endif // TORC_BITSTREAM_SPARTAN3E_HPP