00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "torc/bitstream/Virtex6.hpp"
00017 #include <iostream>
00018
00019
00020
00021
00022 #include "torc/architecture/DDB.hpp"
00023 #include "torc/architecture/XilinxDatabaseTypes.hpp"
00024 #include "torc/common/DirectoryTree.hpp"
00025 #include <fstream>
00026
00027
00028 namespace torc {
00029 namespace bitstream {
00030
00031 const char* Virtex6::sPacketTypeName[ePacketTypeCount] = {
00032 "[UNKNOWN TYPE 0]", "TYPE1", "TYPE2", "[UNKNOWN TYPE 3]", "[UNKNOWN TYPE 4]",
00033 "[UNKNOWN TYPE 5]", "[UNKNOWN TYPE 6]", "[UNKNOWN TYPE 7]"
00034 };
00035
00036 const char* Virtex6::sOpcodeName[eOpcodeCount] = {
00037 "NOP", "READ", "WRITE", "RESERVED"
00038 };
00039
00040 const char* Virtex6::sRegisterName[eRegisterCount] = {
00041 "CRC", "FAR", "FDRI", "FDRO", "CMD", "CTL0", "MASK", "STAT", "LOUT", "COR0", "MFWR", "CBC",
00042 "IDCODE", "AXSS", "COR1", "CSOB", "WBSTAR", "TIMER", "[UNKNOWN REG 18]",
00043 "[UNKNOWN REG 19]", "[UNKNOWN REG 20]", "[UNKNOWN REG 21]", "BOOTSTS", "[UNKNOWN REG 23]",
00044 "CTL1", "[UNKNOWN REG 25]", "DWC"
00045 };
00046
00047 const char* Virtex6::sCommandName[eCommandCount] = {
00048 "NULL", "WCFG", "MFW", "DGHIGH/LFRM", "RCFG", "START", "RCAP", "RCRC", "AGHIGH", "SWITCH",
00049 "GRESTORE", "SHUTDOWN", "GCAPTURE", "DESYNCH", "Reserved", "IPROG", "CRCC",
00050 "LTIMER"
00051 };
00052
00053 #define VALUES (const char*[])
00054
00055
00056 const Bitstream::Subfield Virtex6::sCTL0[] = {
00057 {0x00000001, 0, "GTS_USER_B", "GTS_USER_B", 0,
00058
00059
00060 VALUES{"IoDisabled", "IoActive", 0}},
00061 {0x00000008, 3, "Persist", "PERSIST", 0,
00062
00063
00064 VALUES{"No", "Yes", 0}},
00065 {0x00000030, 4, "Security", "SBITS", 0,
00066
00067
00068
00069 VALUES{"None", "Level1", "Level2", "Level2", 0}},
00070 {0x00000040, 6, "Encrypt", "DEC", 0,
00071
00072
00073 VALUES{"No", "Yes", 0}},
00074 {0x00000080, 7, "FARSRC", "FARSRC", 0,
00075
00076
00077 VALUES{"FAR", "EFAR", 0}},
00078 {0x00000100, 8, "GLUTMASK", "GLUTMASK", 0,
00079
00080
00081
00082
00083 VALUES{"Masked", "Dynamic", 0}},
00084 {0x00001000, 12, "OverTempPowerDown", "OverTempPowerDown", 0,
00085
00086
00087 VALUES{"Disable", "Enable", 0}},
00088 {0x40000000, 30, "ICAP_sel", "ICAP_SEL", 0,
00089
00090
00091 VALUES{"Top", "Bottom", 0}},
00092 {0x80000000, 31, "EFUSE_key", "EFUSE_KEY", 0,
00093
00094
00095 VALUES{"No", "Yes", 0}},
00096 {0, 0, 0, 0, 0, 0}
00097 };
00098
00099
00100 const Bitstream::Subfield Virtex6::sMASK0[] = {
00101 {0x00000001, 0, "GTS_USER_B", "GTS_USER_B", 0, VALUES{"Protected", "Writable", 0}},
00102 {0x00000008, 3, "Persist", "PERSIST", 0, VALUES{"Protected", "Writable", 0}},
00103 {0x00000030, 4, "Security", "SBITS", 0,
00104 VALUES{"Protected", "[UNKNOWN 1]", "[UNKNOWN 2]", "Writable", 0}},
00105 {0x00000040, 6, "Encrypt", "DEC", 0, VALUES{"Protected", "Writable", 0}},
00106 {0x00000080, 7, "FARSRC", "FARSRC", 0, VALUES{"Protected", "Writable", 0}},
00107 {0x00000100, 8, "GLUTMASK", "GLUTMASK", 0, VALUES{"Protected", "Writable", 0}},
00108 {0x00001000, 12, "OverTempPowerDown", "OverTempPowerDown", 0, VALUES{"Protected",
00109 "Writable", 0}},
00110 {0x40000000, 30, "ICAP_sel", "ICAP_SEL", 0, VALUES{"Protected", "Writable", 0}},
00111 {0x80000000, 31, "EFUSE_key", "EFUSE_KEY", 0, VALUES{"Protected", "Writable", 0}},
00112 {0, 0, 0, 0, 0, 0}
00113 };
00114
00115
00116 const Bitstream::Subfield Virtex6::sCTL1[] = {
00117 {0, 0, 0, 0, 0, 0}
00118 };
00119
00120
00121 const Bitstream::Subfield Virtex6::sCOR0[] = {
00122 {0x00000007, 0, "GWE_cycle", "GWE_CYCLE", 5,
00123
00124
00125
00126 VALUES{"1", "2", "3", "4", "5", "6", "Done", "Keep", 0}},
00127 {0x00000038, 3, "GTS_cycle", "GTS_CYCLE", 4,
00128
00129
00130
00131 VALUES{"1", "2", "3", "4", "5", "6", "Done", "Keep", 0}},
00132 {0x00000E00, 9, "Match_cycle", "MATCH_CYCLE", 0,
00133
00134
00135 VALUES{"0", "1", "2", "3", "4", "5", "6", "NoWait", 0}},
00136 {0x00007000, 12, "DONE_cycle", "DONE_CYCLE", 3,
00137
00138
00139 VALUES{"1", "2", "3", "4", "5", "6", "7", "KEEP", 0}},
00140 {0x00018000, 15, "StartupClk", "SSCLKSRC", 0,
00141
00142
00143 VALUES{"Cclk", "UserClk", "JtagClk", "JtagClk", 0}},
00144 {0x007e0000, 17, "ConfigRate", "OSCFSEL", 0,
00145
00146
00147 VALUES{
00148 "[UNKNOWN 0]", "[UNKNOWN 1]", "[UNKNOWN 2]", "[UNKNOWN 3]",
00149 "[UNKNOWN 4]", "[UNKNOWN 5]", "[UNKNOWN 6]", "[UNKNOWN 7]",
00150 "[UNKNOWN 8]", "[UNKNOWN 9]", "[UNKNOWN 10]", "[UNKNOWN 11]",
00151 "[UNKNOWN 12]", "[UNKNOWN 13]", "[UNKNOWN 14]", "[UNKNOWN 15]",
00152 "[UNKNOWN 16]", "[UNKNOWN 17]", "[UNKNOWN 18]", "[UNKNOWN 19]",
00153 "[UNKNOWN 20]", "[UNKNOWN 21]", "[UNKNOWN 22]", "[UNKNOWN 23]",
00154 "[UNKNOWN 24]", "[UNKNOWN 25]", "[UNKNOWN 26]", "[UNKNOWN 27]",
00155 "[UNKNOWN 28]", "[UNKNOWN 29]", "[UNKNOWN 30]", "[UNKNOWN 31]",
00156 0}},
00157 {0x00800000, 23, "Capture", "SINGLE", 0,
00158
00159
00160 VALUES{"Continuous", "OneShot", 0}},
00161 {0x01000000, 24, "DriveDone", "DRIVE_DONE", 0,
00162
00163
00164 VALUES{"No", "Yes", 0}},
00165 {0x02000000, 25, "DonePipe", "DONE_PIPE", 0,
00166
00167
00168 VALUES{"No", "Yes", 0}},
00169 {0x08000000, 27, "DONE_status", "PWRDWN_STAT", 0,
00170
00171
00172 VALUES{"DonePin", "PowerdownPin", 0}},
00173 {0, 0, 0, 0, 0, 0}
00174 };
00175
00176
00177 const Bitstream::Subfield Virtex6::sCOR1[] = {
00178 {0x00000003, 0, "BPI_page_size", "BPI_PAGE_SIZE", 0,
00179
00180
00181 VALUES{"1", "4", "8", "Reserved", 0}},
00182 {0x0000000C, 2, "BPI_1st_read_cycle", "BPI_1ST_READ_CYCLES", 0,
00183
00184
00185 VALUES{"1", "4", "8", "Reserved", 0}},
00186 {0x00000100, 8, "ContinuousReadbackCRC", "RBCRC_EN", 0,
00187
00188
00189 VALUES{"Disabled", "Enabled", 0}},
00190 {0x00000200, 9, "InitAsCRCErrorPin", "RBCRC_NO_PIN", 0,
00191
00192
00193 VALUES{"Disabled", "Enabled", 0}},
00194 {0x00018000, 15, "ActionReadbackCRC", "RBCRC_ACTION", 0,
00195
00196
00197 VALUES{"Continue", "Halt", "CorrectAndHalt", "CorrectAndContinue", 0}},
00198 {0x00020000, 17, "PersistDeassertAtDesynch", "PERSIST_DEASSERT_AT_DESYNCH", 0,
00199
00200
00201 VALUES{"Disabled", "Enabled", 0}},
00202 {0, 0, 0, 0, 0, 0}
00203 };
00204
00205
00206 const Bitstream::Subfield Virtex6::sWBSTAR[] = {
00207 {0x18000000, 27, "NextRevisionSelect", "RS[1:0]", 0,
00208
00209 VALUES{"00", "01", "10", "11", 0}},
00210 {0x04000000, 26, "RevisionSelectTristate", "RS_TS_B", 0,
00211
00212 VALUES{"Disabled", "Enabled", 0}},
00213 {0, 0, 0, 0, 0, 0}
00214 };
00215
00216
00217 const Bitstream::Subfield Virtex6::sTIMER[] = {
00218 {0x01000000, 24, "TimerForConfig", "TIMER_CFG_MON", 0,
00219
00220 VALUES{"Disabled", "Enabled", 0}},
00221 {0x02000000, 25, "TimerForUser", "TIMER_USR_MON", 0,
00222
00223 VALUES{"Disabled", "Enabled", 0}},
00224 {0, 0, 0, 0, 0, 0}
00225 };
00226
00227
00228 const Bitstream::Subfield Virtex6::sBOOTSTS[] = {
00229 {0x00000001, 0, "RegisterStatus0", "VALID_0", 0,
00230
00231 VALUES{"Valid", "Invalid", 0}},
00232 {0x00000002, 1, "FallbackStatus0", "FALLBACK_0", 0,
00233
00234
00235 VALUES{"Normal", "Fallback", 0}},
00236 {0x00000004, 2, "InternalTrigger0", "IPROG_0", 0,
00237
00238 VALUES{"External", "Internal", 0}},
00239 {0x00000008, 3, "WatchdogTimeout0", "WTO_ERROR_0", 0,
00240
00241 VALUES{"Valid", "Invalid", 0}},
00242 {0x00000010, 4, "ID_error0", "ID_ERROR_0", 0,
00243
00244 VALUES{"NoError", "Error", 0}},
00245 {0x00000020, 5, "CRC_error0", "CRC_ERROR_0", 0,
00246
00247 VALUES{"NoError", "Error", 0}},
00248 {0x00000040, 6, "BPI_wraparound_error0", "WRAP_ERROR_0", 0,
00249
00250 VALUES{"NoError", "Error", 0}},
00251 {0x00000100, 8, "RegisterStatus1", "VALID_1", 0,
00252
00253 VALUES{"Valid", "Invalid", 0}},
00254 {0x00000200, 9, "FallbackStatus1", "FALLBACK_1", 0,
00255
00256
00257 VALUES{"Normal", "Fallback", 0}},
00258 {0x00000400, 10, "InternalTrigger1", "IPROG_1", 0,
00259
00260 VALUES{"External", "Internal", 0}},
00261 {0x00000800, 11, "WatchdogTimeout1", "WTO_ERROR_1", 0,
00262
00263 VALUES{"Valid", "Invalid", 0}},
00264 {0x00001000, 12, "ID_error1", "ID_ERROR_1", 0,
00265
00266 VALUES{"NoError", "Error", 0}},
00267 {0x00002000, 13, "CRC_error1", "CRC_ERROR_1", 0,
00268
00269 VALUES{"NoError", "Error", 0}},
00270 {0x00004000, 14, "BPI_wraparound_error1", "WRAP_ERROR_1", 0,
00271
00272 VALUES{"NoError", "Error", 0}},
00273 {0, 0, 0, 0, 0, 0}
00274 };
00275
00276
00277 const Bitstream::Subfield Virtex6::sSTAT[] = {
00278 {0x00000001, 0, "CRC_error", "CRC_ERROR", 0,
00279
00280
00281 VALUES{"No", "Yes", 0}},
00282 {0x00000002, 1, "DecryptorSecuritySet", "PART_SECURED", 0,
00283
00284
00285 VALUES{"No", "Yes", 0}},
00286 {0x00000004, 2, "MMCM_locked", "MMCM_LOCK", 0,
00287
00288
00289 VALUES{"No", "Yes", 0}},
00290 {0x00000008, 3, "DCI_matched", "DCI_MATCH", 0,
00291
00292
00293 VALUES{"No", "Yes", 0}},
00294 {0x00000010, 4, "StartupFinished", "EOS", 0,
00295
00296
00297 VALUES{"No", "Yes", 0}},
00298 {0x00000020, 5, "GTS_CFG_B", "GTS_CFG_B", 0,
00299
00300
00301 VALUES{"IoDisabled", "IoEnabled", 0}},
00302 {0x00000040, 6, "GWE", "GWE", 0,
00303
00304
00305
00306 VALUES{"WriteDisabled", "WriteEnabled", 0}},
00307 {0x00000080, 7, "GHIGH_B", "GHIGH_B", 0,
00308
00309
00310 VALUES{"InterconnectDisabled", "InterconnectEnabled", 0}},
00311 {0x00000700, 8, "Mode", "MODE", 0,
00312
00313
00314 VALUES{"MasterSerial", "MasterSPI", "MasterBPI-Up", "MasterBPI-Down",
00315 "MasterSelectMap", "JTAG", "SlaveSelectMap", "SlaveSerial", 0}},
00316 {0x00000800, 11, "INIT_complete", "INIT_COMPLETE", 0,
00317
00318
00319 VALUES{"No", "Yes", 0}},
00320 {0x00001000, 12, "INIT_B", "INIT_B", 0,
00321
00322
00323 VALUES{"Deasserted", "Asserted", 0}},
00324 {0x00002000, 13, "DONE_released", "RELEASE_DONE", 0,
00325
00326
00327 VALUES{"DrivenLow", "Released", 0}},
00328 {0x00004000, 14, "DONE", "DONE", 0,
00329
00330
00331 VALUES{"NotDone", "Done", 0}},
00332 {0x00008000, 15, "ID_error", "ID_ERROR", 0,
00333
00334
00335 VALUES{"NoError", "Error", 0}},
00336 {0x00010000, 16, "Decrypt_error", "DEC_ERROR", 0,
00337
00338
00339 VALUES{"NoError", "Error", 0}},
00340 {0x00020000, 17, "Decrypt_error", "SYSMON_OVER_TEMP", 0,
00341
00342
00343 VALUES{"NoError", "Error", 0}},
00344 {0x001c0000, 18, "StartupState", "STARTUP_STATE", 0,
00345
00346
00347 VALUES{"0", "1", "3", "2", "7", "6", "4", "5", 0}},
00348 {0x01c00000, 22, "FlashTypeSelect", "FS", 0,
00349
00350
00351 VALUES{0}},
00352 {0x06000000, 25, "BusWidth", "BUS_WIDTH", 0,
00353
00354
00355 VALUES{"1", "8", "16", "32", 0}},
00356 {0x06000000, 28, "HswapenPin", "HSWAPEN_B", 0,
00357
00358
00359 VALUES{"0", "1", "16", "32", 0}},
00360 {0, 0, 0, 0, 0, 0}
00361 };
00362
00363
00364 uint32_t Virtex6::makeSubfield(ERegister inRegister, const std::string& inSubfield,
00365 const std::string& inSetting) {
00366 const Subfield* subfields;
00367 switch(inRegister) {
00368 case eRegisterCOR0: subfields = sCOR0; break;
00369 case eRegisterCOR1: subfields = sCOR1; break;
00370 case eRegisterSTAT: subfields = sSTAT; break;
00371 case eRegisterCTL0: subfields = sCTL0; break;
00372 case eRegisterCTL1: subfields = sCTL1; break;
00373 case eRegisterMASK: subfields = sMASK0; break;
00374 case eRegisterWBSTAR: subfields = sWBSTAR; break;
00375 case eRegisterTIMER: subfields = sTIMER; break;
00376 case eRegisterBOOTSTS: subfields = sBOOTSTS; break;
00377 default: return 0;
00378 }
00379 for(uint32_t field = 0; subfields[field].mMask != 0; field++) {
00380 const Subfield& subfield = subfields[field];
00381 if(inSubfield != subfield.mBitgenName && inSubfield != subfield.mConfigGuideName)
00382 continue;
00383 const char** ptr = subfield.mValues;
00384 for(uint32_t i = 0; *ptr != 0; i++, ptr++) {
00385 if(inSetting == *ptr) return (i << subfield.mShift) & subfield.mMask;
00386 }
00387 }
00388 return 0;
00389 }
00390
00391
00392 #ifndef GENERATE_STATIC_DEVICE_INFO
00393
00394 extern DeviceInfo xc6vcx75t;
00395 extern DeviceInfo xc6vcx130t;
00396 extern DeviceInfo xc6vcx195t;
00397 extern DeviceInfo xc6vcx240t;
00398 extern DeviceInfo xc6vhx250t;
00399 extern DeviceInfo xc6vhx255t;
00400 extern DeviceInfo xc6vhx380t;
00401 extern DeviceInfo xc6vhx565t;
00402 extern DeviceInfo xc6vlx75t;
00403 extern DeviceInfo xc6vlx130t;
00404 extern DeviceInfo xc6vlx195t;
00405 extern DeviceInfo xc6vlx240t;
00406 extern DeviceInfo xc6vlx365t;
00407 extern DeviceInfo xc6vlx550t;
00408 extern DeviceInfo xc6vlx760;
00409 extern DeviceInfo xc6vsx315t;
00410 extern DeviceInfo xc6vsx475t;
00411 extern DeviceInfo xc6vlx75tl;
00412 extern DeviceInfo xc6vlx130tl;
00413 extern DeviceInfo xc6vlx195tl;
00414 extern DeviceInfo xc6vlx240tl;
00415 extern DeviceInfo xc6vlx365tl;
00416 extern DeviceInfo xc6vlx550tl;
00417 extern DeviceInfo xc6vlx760l;
00418 extern DeviceInfo xc6vsx315tl;
00419 extern DeviceInfo xc6vsx475tl;
00420
00421 void Virtex6::initializeDeviceInfo(const std::string& inDeviceName) {
00422 using namespace torc::common;
00423 switch(mDevice) {
00424 case eXC6VCX75T: setDeviceInfo(xc6vcx75t); break;
00425 case eXC6VCX130T: setDeviceInfo(xc6vcx130t); break;
00426 case eXC6VCX195T: setDeviceInfo(xc6vcx195t); break;
00427 case eXC6VCX240T: setDeviceInfo(xc6vcx240t); break;
00428 case eXC6VHX250T: setDeviceInfo(xc6vhx250t); break;
00429 case eXC6VHX255T: setDeviceInfo(xc6vhx255t); break;
00430 case eXC6VHX380T: setDeviceInfo(xc6vhx380t); break;
00431 case eXC6VHX565T: setDeviceInfo(xc6vhx565t); break;
00432 case eXC6VLX75T: setDeviceInfo(xc6vlx75t); break;
00433 case eXC6VLX130T: setDeviceInfo(xc6vlx130t); break;
00434 case eXC6VLX195T: setDeviceInfo(xc6vlx195t); break;
00435 case eXC6VLX240T: setDeviceInfo(xc6vlx240t); break;
00436 case eXC6VLX365T: setDeviceInfo(xc6vlx365t); break;
00437 case eXC6VLX550T: setDeviceInfo(xc6vlx550t); break;
00438 case eXC6VLX760: setDeviceInfo(xc6vlx760); break;
00439 case eXC6VSX315T: setDeviceInfo(xc6vsx315t); break;
00440 case eXC6VSX475T: setDeviceInfo(xc6vsx475t); break;
00441 case eXC6VLX75TL: setDeviceInfo(xc6vlx75tl); break;
00442 case eXC6VLX130TL: setDeviceInfo(xc6vlx130tl); break;
00443 case eXC6VLX195TL: setDeviceInfo(xc6vlx195tl); break;
00444 case eXC6VLX240TL: setDeviceInfo(xc6vlx240tl); break;
00445 case eXC6VLX365TL: setDeviceInfo(xc6vlx365tl); break;
00446 case eXC6VLX550TL: setDeviceInfo(xc6vlx550tl); break;
00447 case eXC6VLX760L: setDeviceInfo(xc6vlx760l); break;
00448 case eXC6VSX315TL: setDeviceInfo(xc6vsx315tl); break;
00449 case eXC6VSX475TL: setDeviceInfo(xc6vsx475tl); break;
00450 default: break;
00451 }
00452
00453
00454 setRowCounts();
00455 }
00456
00457 #else
00458
00459 void Virtex6::initializeDeviceInfo(const std::string& inDeviceName) {
00460
00461 typedef torc::architecture::xilinx::TileCount TileCount;
00462 typedef torc::architecture::xilinx::TileRow TileRow;
00463 typedef torc::architecture::xilinx::TileCol TileCol;
00464 typedef torc::architecture::xilinx::TileTypeIndex TileTypeIndex;
00465 typedef torc::architecture::xilinx::TileTypeCount TileTypeCount;
00466
00467
00468
00469 torc::architecture::DDB ddb(inDeviceName);
00470 const torc::architecture::Tiles& tiles = ddb.getTiles();
00471 uint32_t tileCount = tiles.getTileCount();
00472 uint16_t rowCount = tiles.getRowCount();
00473 uint16_t colCount = tiles.getColCount();
00474 ColumnTypeVector columnTypes;
00475
00476
00477 typedef std::map<TileTypeIndex, std::string> TileTypeIndexToName;
00478 typedef std::map<std::string, TileTypeIndex> TileTypeNameToIndex;
00479 TileTypeIndexToName tileTypeIndexToName;
00480 TileTypeNameToIndex tileTypeNameToIndex;
00481 TileTypeCount tileTypeCount = tiles.getTileTypeCount();
00482 for(TileTypeIndex tileTypeIndex(0); tileTypeIndex < tileTypeCount; tileTypeIndex++) {
00483 const std::string tileTypeName = tiles.getTileTypeName(tileTypeIndex);
00484 tileTypeIndexToName[tileTypeIndex] = tileTypeName;
00485 tileTypeNameToIndex[tileTypeName] = tileTypeIndex;
00486 TileTypeNameToColumnType::iterator ttwp = mTileTypeNameToColumnType.find(tileTypeName);
00487 TileTypeNameToColumnType::iterator ttwe = mTileTypeNameToColumnType.end();
00488 if(ttwp != ttwe) mTileTypeIndexToColumnType[tileTypeIndex] = EColumnType(ttwp->second);
00489 if(ttwp != ttwe) {
00490 std::cout << "Mapping: " << tileTypeName << "(" << tileTypeIndex << ") = ColumnType " << ttwp->second << std::endl;
00491 }
00492 }
00493
00494
00495 columnTypes.resize(colCount);
00496 uint32_t frameCount = 0;
00497 for(uint32_t blockType = 0; blockType < Virtex6::eFarBlockTypeCount; blockType++) {
00498 for(TileCol col; col < colCount; col++) {
00499
00500 columnTypes[col] = eColumnTypeEmpty;
00501 TileTypeIndexToColumnType::iterator ttwe = mTileTypeIndexToColumnType.end();
00502 TileTypeIndexToColumnType::iterator ttwp = ttwe;
00503 for(TileRow row; row < rowCount; row++) {
00504
00505 const torc::architecture::TileInfo& tileInfo
00506 = tiles.getTileInfo(tiles.getTileIndex(row, col));
00507 TileTypeIndex tileTypeIndex = tileInfo.getTypeIndex();
00508
00509 ttwp = mTileTypeIndexToColumnType.find(tileTypeIndex);
00510 if(ttwp != ttwe) {
00511 uint32_t width = mColumnDefs[ttwp->second][blockType];
00512 frameCount += width;
00513
00514
00515
00516 columnTypes[col] = static_cast<EColumnType>(ttwp->second);
00517 break;
00518 }
00519 }
00520
00521 }
00522
00523 if(blockType == 2) break;
00524 }
00525
00526 boost::filesystem::path workingPath = torc::common::DirectoryTree::getWorkingPath();
00527 boost::filesystem::path generatedMap = workingPath / (inDeviceName + ".map.csv");
00528 std::fstream tilemapStream(generatedMap.string().c_str(), std::ios::out);
00529 for(TileRow row; row < rowCount; row++) {
00530 for(TileCol col; col < colCount; col++) {
00531 const torc::architecture::TileInfo& tileInfo
00532 = tiles.getTileInfo(tiles.getTileIndex(row, col));
00533 TileTypeIndex tileTypeIndex = tileInfo.getTypeIndex();
00534 tilemapStream << tiles.getTileTypeName(tileTypeIndex);
00535 if(col + 1 < colCount) tilemapStream << ",";
00536 }
00537 tilemapStream << std::endl;
00538 }
00539 tilemapStream.close();
00540
00541
00542 setDeviceInfo(DeviceInfo(tileCount, rowCount, colCount, columnTypes));
00543 setRowCounts();
00544 }
00545
00546 #endif
00547
00548 void Virtex6::setRowCounts(void) {
00549
00550
00551
00552
00553
00554 using namespace torc::common;
00555 switch(mDevice) {
00556 case eXC6VCX75T: mTopRowCount = 2; mBottomRowCount = 1; break;
00557 case eXC6VCX130T: mTopRowCount = 2; mBottomRowCount = 3; break;
00558 case eXC6VCX195T: mTopRowCount = 2; mBottomRowCount = 3; break;
00559 case eXC6VCX240T: mTopRowCount = 3; mBottomRowCount = 3; break;
00560 case eXC6VHX250T: mTopRowCount = 1; mBottomRowCount = 5; break;
00561 case eXC6VHX255T: mTopRowCount = 4; mBottomRowCount = 2; break;
00562 case eXC6VHX380T: mTopRowCount = 4; mBottomRowCount = 5; break;
00563 case eXC6VHX565T: mTopRowCount = 4; mBottomRowCount = 5; break;
00564 case eXC6VLX75T: mTopRowCount = 2; mBottomRowCount = 1; break;
00565 case eXC6VLX130T: mTopRowCount = 2; mBottomRowCount = 3; break;
00566 case eXC6VLX195T: mTopRowCount = 2; mBottomRowCount = 3; break;
00567 case eXC6VLX240T: mTopRowCount = 3; mBottomRowCount = 3; break;
00568 case eXC6VLX365T: mTopRowCount = 3; mBottomRowCount = 3; break;
00569 case eXC6VLX550T: mTopRowCount = 4; mBottomRowCount = 5; break;
00570 case eXC6VLX760: mTopRowCount = 4; mBottomRowCount = 5; break;
00571 case eXC6VSX315T: mTopRowCount = 3; mBottomRowCount = 3; break;
00572 case eXC6VSX475T: mTopRowCount = 4; mBottomRowCount = 5; break;
00573 case eXC6VLX75TL: mTopRowCount = 2; mBottomRowCount = 1; break;
00574 case eXC6VLX130TL: mTopRowCount = 2; mBottomRowCount = 3; break;
00575 case eXC6VLX195TL: mTopRowCount = 2; mBottomRowCount = 3; break;
00576 case eXC6VLX240TL: mTopRowCount = 3; mBottomRowCount = 3; break;
00577 case eXC6VLX365TL: mTopRowCount = 3; mBottomRowCount = 3; break;
00578 case eXC6VLX550TL: mTopRowCount = 4; mBottomRowCount = 5; break;
00579 case eXC6VLX760L: mTopRowCount = 4; mBottomRowCount = 5; break;
00580 case eXC6VSX315TL: mTopRowCount = 3; mBottomRowCount = 3; break;
00581 case eXC6VSX475TL: mTopRowCount = 4; mBottomRowCount = 5; break;
00582 default: break;
00583 }
00584 }
00585
00586 void Virtex6::initializeFrameMaps(void) {
00587
00588 bool debug = 0;
00589 uint32_t frameCount = 0;
00590 uint32_t farRowCount = ((mDeviceInfo.getRowCount() - 1) / 42) >> 1;
00591 (void) farRowCount;
00592
00593
00594
00595
00596 uint32_t bottomRowCount = mBottomRowCount;
00597 uint32_t topRowCount = mTopRowCount;
00598 uint32_t frameIndex = 0;
00599 for(uint32_t i = 0; i < Virtex6::eFarBlockTypeCount; i++) {
00600 Virtex6::EFarBlockType blockType = Virtex6::EFarBlockType(i);
00601 uint32_t blockFrameIndexBounds = 0;
00602
00603 uint32_t bitIndex = 0;
00604 uint32_t xdlIndex = 0;
00605 mBitColumnIndexes[i].push_back(bitIndex);
00606 mXdlColumnIndexes[i].push_back(xdlIndex);
00607 for(uint32_t half = 0; half < 2; half++) {
00608 uint32_t rowCount = (half == eFarBottom ? bottomRowCount : topRowCount);
00609 for(uint32_t farRow = 0; farRow < rowCount; farRow++) {
00610
00611 uint32_t farMajor = 0;
00612 typedef torc::common::EncapsulatedInteger<uint16_t> ColumnIndex;
00613 uint16_t finalColumn = mDeviceInfo.getColCount()-1;
00614 uint32_t xdlColumnCount = 0;
00615 uint32_t bitColumnCount = 0;
00616 for(ColumnIndex col; col < mDeviceInfo.getColCount();
00617 col++) {
00618 uint32_t width = mColumnDefs[mDeviceInfo.getColumnTypes()[col]][i];
00619
00620 for(uint32_t farMinor = 0; farMinor < width; farMinor++) {
00621 Virtex6::FrameAddress far(Virtex6::EFarTopBottom(half), blockType,
00622 farRow, farMajor, farMinor);
00623 mFrameIndexToAddress[frameIndex] = far;
00624 mFrameAddressToIndex[far] = frameIndex;
00625 frameIndex++;
00626 blockFrameIndexBounds++;
00627 }
00628 if(width > 0) farMajor++;
00629 frameCount += width;
00630
00631
00632 if(farRow == 0 && half == 0) {
00633
00634 if(mDeviceInfo.getColumnTypes()[col] != Virtex6::eColumnTypeEmpty) {
00635 mXdlIndexToBitIndex[bitColumnCount] = xdlColumnCount;
00636 bitColumnCount++;
00637 bitIndex += width;
00638 mBitColumnIndexes[i].push_back(bitIndex);
00639 if(col == finalColumn) {
00640 bitIndex += mColumnDefs[mDeviceInfo.getColumnTypes()[col]][i];
00641 mBitColumnIndexes[i].push_back(bitIndex);
00642 }
00643 }
00644
00645
00646 xdlIndex += width;
00647 mXdlColumnIndexes[i].push_back(xdlIndex);
00648 xdlColumnCount++;
00649 if(col == finalColumn)
00650 {
00651 xdlIndex += mColumnDefs[mDeviceInfo.getColumnTypes()[col]][i];
00652 mXdlColumnIndexes[i].push_back(xdlIndex);
00653 }
00654 }
00655 }
00656 if (debug) std::cout << "Last frame index: [" << i << ", " << frameIndex << "]" << std::endl;
00657 }
00658 }
00659
00660 mBlockFrameIndexBounds[i] = blockFrameIndexBounds;
00661 if (debug) std::cout << "***Block frame index bounds: " << mBlockFrameIndexBounds[i] << std::endl;
00662 }
00663
00664 if (debug) {
00665 for(uint32_t i = 0; i < Virtex6::eFarBlockTypeCount; i++) {
00666 for(uint32_t j = 0; j < mBitColumnIndexes[i].size(); j++)
00667 std::cout << "Bit Value at index: (" << i << ", " << j << ") : " << mBitColumnIndexes[i][j] << std::endl;
00668 for(uint32_t k = 0; k < mXdlColumnIndexes[i].size(); k++)
00669 std::cout << "Xdl Value at index: (" << i << ", " << k << ") : " << mXdlColumnIndexes[i][k] << std::endl;
00670 }
00671 }
00672 }
00673
00674 void Virtex6::initializeFullFrameBlocks (void) {
00675 boost::shared_array<uint32_t> frameWords;
00676
00677 Virtex6::iterator p = begin();
00678 Virtex6::iterator e = end();
00679 while (p < e) {
00680 const VirtexPacket& packet = *p++;
00681 if (packet.isType2() && packet.isWrite())
00682 frameWords = packet.getWords();
00683 }
00684 uint32_t index = 0;
00685 for (uint32_t i = 0; i < VirtexFrameBlocks::eBlockTypeCount; i++) {
00686
00687 for (uint32_t j = 0; j < mBlockFrameIndexBounds[i]; j++) {
00688 mFrameBlocks.mBlock[i].push_back(VirtexFrameSet::FrameSharedPtr
00689 (new VirtexFrame(getFrameLength(), &frameWords[index])));
00690 index += getFrameLength();
00691 }
00692 }
00693 }
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720 VirtexFrameBlocks Virtex6::getBitstreamFrames (uint32_t blockCount, uint32_t bitCol) {
00721
00722
00723 int32_t bitColumnIndex [blockCount];
00724 int32_t bitColumnBound [blockCount];
00725
00726 for (uint32_t i = 0; i < blockCount; i++) {
00727
00728 bitColumnIndex[i] = mBitColumnIndexes[i][bitCol];
00729
00730 bitColumnBound[i] = mColumnDefs[mDeviceInfo.getColumnTypes()
00731 [mXdlIndexToBitIndex[bitCol]]][i];
00732 }
00733
00734 VirtexFrameBlocks frameBlocks;
00735 for (uint32_t i = 0; i < blockCount; i++) {
00736 int startIndex = bitColumnIndex[i];
00737 for (int j = 0; j < bitColumnBound[i]; j++)
00738 frameBlocks.mBlock[i].push_back(mFrameBlocks.mBlock[i][startIndex+j]);
00739 }
00740 return frameBlocks;
00741 }
00742
00743 VirtexFrameBlocks Virtex6::getXdlFrames (uint32_t blockCount, uint32_t xdlCol) {
00744
00745
00746 int32_t xdlColumnIndex [blockCount];
00747 int32_t xdlColumnBound [blockCount];
00748 for (uint32_t i = 0; i < blockCount; i++) {
00749
00750 xdlColumnIndex[i] = mXdlColumnIndexes[i][xdlCol];
00751
00752 xdlColumnBound[i] = mColumnDefs[mDeviceInfo.getColumnTypes()[xdlCol]][i];
00753 }
00754
00755 VirtexFrameBlocks frameBlocks;
00756 for (uint32_t i = 0; i < blockCount; i++) {
00757 int startIndex = xdlColumnIndex[i];
00758 for (int j = 0; j < xdlColumnBound[i]; j++)
00759 frameBlocks.mBlock[i].push_back(mFrameBlocks.mBlock[i][startIndex+j]);
00760 }
00761 return frameBlocks;
00762 }
00763
00764
00765 }
00766 }