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