00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "torc/bitstream/Spartan6.hpp"
00020 #include <iostream>
00021
00022 namespace torc {
00023 namespace bitstream {
00024
00025 const char* Spartan6::sPacketTypeName[ePacketTypeCount] = {
00026 "[UNKNOWN TYPE 0]", "TYPE1", "TYPE2", "[UNKNOWN TYPE 3]", "[UNKNOWN TYPE 4]",
00027 "[UNKNOWN TYPE 5]", "[UNKNOWN TYPE 6]", "[UNKNOWN TYPE 7]"
00028 };
00029
00030 const char* Spartan6::sOpcodeName[eOpcodeCount] = {
00031 "NOP", "READ", "WRITE", "RESERVED"
00032 };
00033
00034 const char* Spartan6::sRegisterName[eRegisterCount] = {
00035 "CRC", "FARMAJ", "FARMIN", "FDRI", "FDRO", "CMD", "CTL", "MASK", "STAT", "LOUT", "COR1", "COR2", "PWRDN_REG", "FLR",
00036 "IDCODE", "CWDT", "HC_OPT_REG", "CSBO", "GENERAL1", "GENERAL2", "GENERAL3", "GENERAL4", "GENERAL5", "MODE_REG",
00037 "PU_GWE", "PU_GTS", "MFWR", "CCLK_FREQ", "SEU_OPT", "EXP_SIGN", "RDBK_SIGN", "BOOSTS", "EYE_MASK", "CBC_REG"
00038 };
00039
00040 const char* Spartan6::sCommandName[eCommandCount] = {
00041 "NULL", "WCFG", "MFW", "LFRM", "RCFG", "START", "[UNKNOWN COMMAND 6]", "RCRC", "AGHIGH", "[UNKNOWN COMMAND 9]",
00042 "GRESTORE", "SHUTDOWN", "[UNKNOWN COMMAND 12]", "DESYNC", "IPROG"
00043 };
00044
00045 #define VALUES (const char*[])
00046
00047
00048 const Bitstream::Subfield Spartan6::sCOR1[] = {
00049 {0x0003, 0, "StartupClk", "SSCLKSRC", 0,
00050
00051
00052 VALUES{"Cclk", "UserClk", "JtagClk", "TCK", 0}},
00053 {0x0004, 2, "DriveDone", "DRIVE_DONE", 0,
00054
00055
00056 VALUES{"No", "Yes", 0}},
00057 {0x0008, 3, "DonePipe", "DONE_PIPE", 0,
00058
00059
00060 VALUES{"No", "Yes", 0}},
00061 {0x0010, 4, "CRC_Bypass", "CRC_BYPASS", 0,
00062
00063
00064 VALUES{"0", "1", 0}},
00065 {0x1000, 15, "Drive_Awake", "DRIVE_AWAKE", 0,
00066
00067
00068 VALUES{"0", "1", 0}},
00069 {0, 0, 0, 0, 0, 0}
00070 };
00071
00072
00073
00074 const Bitstream::Subfield Spartan6::sCOR2[] = {
00075 {0x0007, 0, "GWE_cycle", "GWE_CYCLE", 6,
00076
00077
00078 VALUES{"[UNDEFINED 0]", "2", "3", "4", "5", "6", "[UNDEFINED 6]", "[UNDEFINED 7]", 0}},
00079 {0x0038, 3, "GTS_cycle", "GTS_CYCLE", 5,
00080
00081
00082 VALUES{"[UNDEFINED 0]", "2", "3", "4", "5", "6", "[UNDEFINED 6]", "[UNDEFINED 7]", 0}},
00083 {0x01c0, 6, "LCK_cycle", "LOCK_CYCLE", 7,
00084
00085
00086 VALUES{"1", "2", "3", "4", "5", "6", "[UNDEFINED 6]", "NoWait", 0}},
00087 {0x0E00, 9, "DONE_cycle", "DONE_CYCLE", 4,
00088
00089
00090 VALUES{"[UNDEFINED 0]", "2", "3", "4", "5", "6", "[UNDEFINED 6]", "[UNDEFINED 7]", 0}},
00091 {0x8000, 15, "Reset_on_err", "RESET_ON_ERROR", 0,
00092
00093
00094 VALUES{"Disable", "Enable", 0}},
00095 {0, 0, 0, 0, 0, 0}
00096 };
00097
00098
00099
00100 const Bitstream::Subfield Spartan6::sSTAT[] = {
00101 {0x0001, 0, "CRC_error", "CRC_ERROR", 0,
00102
00103
00104 VALUES{"No", "Yes", 0}},
00105 {0x0002, 1, "ID_error", "ID_ERROR", 0,
00106
00107
00108 VALUES{"No", "Yes", 0}},
00109 {0x0004, 2, "DCM_locked", "DCM_LOCK", 0,
00110
00111
00112 VALUES{"No", "Yes", 0}},
00113 {0x0008, 3, "GTS_CFG", "GTS_CFG_B", 0,
00114
00115
00116 VALUES{"No", "Yes", 0}},
00117 {0x0010, 4, "GWE", "GWE", 0,
00118
00119
00120 VALUES{"No", "Yes", 0}},
00121 {0x0020, 5, "GWHIGH", "GWHIGH_B", 0,
00122
00123
00124 VALUES{"No", "Yes", 0}},
00125 {0x0040, 6, "DEC_ERROR", "DEC_ERROR", 0,
00126
00127
00128 VALUES{"No", "Yes", 0}},
00129 {0x0080, 7, "PART_SECURED", "PART_SECURED", 0,
00130
00131
00132 VALUES{"No", "Yes", 0}},
00133 {0x0100, 8, "HSWAPEN", "HSWAPEN", 0,
00134
00135
00136 VALUES{"No", "Yes", 0}},
00137 {0x0800, 9, "Mode", "MODE", 0,
00138
00139
00140 VALUES{"MasterSerial", "SlaveSelectMap32", "[UNDEFINED 2]", "MasterSelectMap",
00141 "[UNDEFINED 3]", "JTAG", "SlaveSelectMap8", "[UNDEFINED 6]", "SlaveSerial", 0}},
00142 {0x1000, 12, "INIT", "INIT_B", 0,
00143
00144
00145 VALUES{"Deasserted", "Asserted", 0}},
00146 {0x2000, 13, "Done", "DONE", 0,
00147
00148
00149 VALUES{"Deasserted", "Asserted", 0}},
00150 {0x4000, 14, "IN_PWRDN", "IN_PWRDN", 0,
00151
00152
00153 VALUES{"No", "Yes", 0}},
00154 {0x4000, 15, "SWWD_Strikeout", "SWWD_strikeout", 0,
00155
00156
00157
00158
00159
00160
00161 VALUES{"No", "Yes", 0}},
00162 {0, 0, 0, 0, 0, 0}
00163 };
00164
00165
00166 const Bitstream::Subfield Spartan6::sCTL[] = {
00167 {0x0002, 1, "CRC_EXTSTAT_DISABLE", "CRC_EXTSTAT_DISABLE", 0,
00168
00169
00170 VALUES{"0", "1", 0}},
00171 {0x0004, 2, "USE_EFUSE_KEY", "USE_EFUSE_KEY", 0,
00172
00173
00174 VALUES{"0", "1", 0}},
00175 {0x0008, 3, "Persist", "PERSIST", 0,
00176
00177
00178 VALUES{"No", "Yes", 0}},
00179 {0x0030, 4, "Security", "SBITS", 0,
00180
00181
00182
00183 VALUES{"None", "Level1", "Level2", "Level2", 0}},
00184 {0x0040, 6, "DEC", "DEC", 0,
00185
00186
00187 VALUES{"No", "Yes", 0}},
00188 {0, 0, 0, 0, 0, 0}
00189 };
00190
00191
00192 const Bitstream::Subfield Spartan6::sMASK[] = {
00193 {0x0001, 0, "RESERVED", "RESERVED", 0, VALUES{"Protected", "Writable", 0}},
00194 {0x0002, 1, "CRC_EXTSTAT_DISABLE", "CRC_EXTSTAT_DISABLE", 0, VALUES{"Protected", "Writable", 0}},
00195 {0x0004, 2, "USE_EFUSE_KEY", "USE_EFUSE_KEY", 0, VALUES{"Protected", "Writable", 0}},
00196 {0x0008, 3, "Persist", "PERSIST", 0, VALUES{"Protected", "Writable", 0}},
00197 {0x0030, 4, "Security", "SBITS", 0,
00198 VALUES{"Protected", "[UNKNOWN 1]", "[UNKNOWN 2]", "Writable", 0}},
00199 {0x0040, 6, "DEC", "DEC", 0, VALUES{"Protected", "Writable", 0}},
00200 {0, 0, 0, 0, 0, 0}
00201 };
00202
00203
00204 const Bitstream::Subfield Spartan6::sPWRDN_REG[] = {
00205 {0x0001, 0, "KEEP_SCLK", "KEEP_SCLK", 1,
00206
00207
00208
00209 VALUES{"0", "1", 0}},
00210 {0x0004, 2, "EN_PWRDN", "EN_PWRDN", 0,
00211
00212
00213 VALUES{"0", "1", 0}},
00214 {0x0010, 4, "EN_PGSR", "EN_PGSR", 0,
00215
00216
00217
00218 VALUES{"No", "Yes", 0}},
00219 {0x0020, 5, "FILTER", "FILTER_B", 0,
00220
00221
00222 VALUES{"0", "1", 0}},
00223 {0x4000, 14, "EN_EYES", "EN_EYES", 0,
00224
00225
00226 VALUES{"Disable", "Enable", 0}},
00227 {0, 0, 0, 0, 0, 0}
00228 };
00229
00230
00231 const Bitstream::Subfield Spartan6::sHC_OPT_REG[] = {
00232 {0x0040, 6, "INIT_SKIP", "INIT_SKIP", 0,
00233
00234
00235 VALUES{"0", "1", 0}},
00236 {0, 0, 0, 0, 0, 0}
00237 };
00238
00239
00240 const Bitstream::Subfield Spartan6::sMODE_REG[] = {
00241 {0x0080, 0, "BOOTVSEL", "BOOTVSEL", 0,
00242
00243
00244 VALUES{"[READ ONLY]", 0}},
00245 {0x0400, 8, "BOOTMODE", "BOOTMODE", 1,
00246
00247
00248 VALUES{"0", "1", 0}},
00249 {0x1000, 11, "BUSWIDTH", "BUSWIDTH", 0,
00250
00251
00252 VALUES{"0", "1", "2", 0}},
00253 {0x2000, 13, "NEW_MODE", "NEW_MODE", 0,
00254
00255
00256 VALUES{"No", "Yes", 0}},
00257 {0, 0, 0, 0, 0, 0}
00258 };
00259
00260
00261 const Bitstream::Subfield Spartan6::sBOOSTS[] = {
00262 {0x0001, 0, "VALID_0", "VALID_O", 0,
00263
00264
00265 VALUES{"0", "1", 0}},
00266 {0x0002, 1, "FALLBACK_O", "FALLBACK_0", 0,
00267
00268
00269 VALUES{"0", "1", 0}},
00270 {0x0008, 3, "WTO_ERROR_0", "WTO_ERROR_0", 0,
00271
00272
00273 VALUES{"0", "1", 0}},
00274 {0x0010, 4, "ID_ERROR_0", "ID_ERROR_0", 0,
00275
00276
00277 VALUES{"0", "1", 0}},
00278 {0x0020, 5, "CRC_ERROR_0", "CRC_ERROR_0", 0,
00279
00280
00281 VALUES{"0", "1", 0}},
00282 {0x0040, 6, "VALID_1", "VALID_1", 0,
00283
00284
00285 VALUES{"0", "1", 0}},
00286 {0x0080, 7, "FALLBACK_1", "FALLBACK_1", 0,
00287
00288
00289 VALUES{"0", "1", 0}},
00290 {0x0200, 9, "WTO_ERROR_1", "WTO_ERROR_1", 0,
00291
00292
00293 VALUES{"0", "1", 0}},
00294 {0x0400, 10, "ID_ERROR_1", "ID_ERROR_1", 0,
00295
00296
00297 VALUES{"0", "1", 0}},
00298 {0x0800, 11, "CRC_ERROR_1", "CRC_ERROR_1", 0,
00299
00300
00301 VALUES{"0", "1", 0}},
00302 {0, 0, 0, 0, 0, 0}
00303 };
00304
00305
00306 const Bitstream::Subfield Spartan6::sSEU_OPT[] = {
00307 {0x0001, 0, "SEU_ENABLE", "SEU_ENABLE", 0,
00308
00309
00310 VALUES{"DISABLE", "ENABLE", 0}},
00311 {0x0002, 1, "GLUT_MASK", "GLUT_MASK", 1,
00312
00313
00314 VALUES{"Unmask", "Mask LUTRAM/SRL", 0}},
00315 {0x0008, 3, "SEU_RUN_ON_ERR", "SEU_RUN_ON_ERR", 0,
00316
00317
00318 VALUES{"Halt", "Run", 0}},
00319 {0x0010, 4, "SEU_FREQ", "SEU_FREQ", 0,
00320
00321
00322 VALUES{"1be", 0}},
00323 {0, 0, 0, 0, 0, 0}
00324 };
00325
00326
00327 uint16_t Spartan6::makeSubfield(ERegister inRegister, const std::string& inSubfield,
00328 const std::string& inSetting) {
00329 const Subfield* subfields;
00330 switch(inRegister) {
00331 case eRegisterCOR1: subfields = sCOR1; break;
00332 case eRegisterCOR2: subfields = sCOR2; break;
00333 case eRegisterSTAT: subfields = sSTAT; break;
00334 case eRegisterCTL: subfields = sCTL; break;
00335 case eRegisterMASK: subfields = sMASK; break;
00336 case eRegisterPWRDN_REG: subfields = sPWRDN_REG; break;
00337 case eRegisterHC_OPT_REG: subfields = sHC_OPT_REG; break;
00338 case eRegisterMODE_REG: subfields = sMODE_REG; break;
00339 case eRegisterBOOSTS: subfields = sBOOSTS; break;
00340 case eRegisterSEU_OPT: subfields = sSEU_OPT; break;
00341 default: return 0;
00342 }
00343 for(uint16_t field = 0; subfields[field].mMask != 0; field++) {
00344 const Subfield& subfield = subfields[field];
00345 if(inSubfield != subfield.mBitgenName && inSubfield != subfield.mConfigGuideName)
00346 continue;
00347 const char** ptr = subfield.mValues;
00348 for(uint32_t i = 0; *ptr != 0; i++, ptr++) {
00349 if(inSetting == *ptr) return (i << subfield.mShift) & subfield.mMask;
00350 }
00351 }
00352 return 0;
00353 }
00354
00355
00356 }
00357 }