00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "torc/bitstream/VirtexE.hpp"
00019 #include <iostream>
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
00032 #ifndef GENERATE_STATIC_DEVICE_INFO
00033
00034 extern DeviceInfo xcv50e;
00035 extern DeviceInfo xcv100e;
00036 extern DeviceInfo xcv200e;
00037 extern DeviceInfo xcv300e;
00038 extern DeviceInfo xcv400e;
00039 extern DeviceInfo xcv405e;
00040 extern DeviceInfo xcv600e;
00041 extern DeviceInfo xcv812e;
00042 extern DeviceInfo xcv1000e;
00043 extern DeviceInfo xcv1600e;
00044 extern DeviceInfo xcv2000e;
00045 extern DeviceInfo xcv2600e;
00046 extern DeviceInfo xcv3200e;
00047
00048 void VirtexE::initializeDeviceInfo(const std::string& inDeviceName) {
00049 using namespace torc::common;
00050 switch(mDevice) {
00051 case eXCV50E: setDeviceInfo(xcv50e); break;
00052 case eXCV100E: setDeviceInfo(xcv100e); break;
00053 case eXCV200E: setDeviceInfo(xcv200e); break;
00054 case eXCV300E: setDeviceInfo(xcv300e); break;
00055 case eXCV400E: setDeviceInfo(xcv400e); break;
00056 case eXCV405E: setDeviceInfo(xcv405e); break;
00057 case eXCV600E: setDeviceInfo(xcv600e); break;
00058 case eXCV812E: setDeviceInfo(xcv812e); break;
00059 case eXCV1000E: setDeviceInfo(xcv1000e); break;
00060 case eXCV1600E: setDeviceInfo(xcv1600e); break;
00061 case eXCV2000E: setDeviceInfo(xcv2000e); break;
00062 case eXCV2600E: setDeviceInfo(xcv2600e); break;
00063 case eXCV3200E: setDeviceInfo(xcv3200e); break;
00064 default: break;
00065 }
00066 }
00067
00068 #else
00069
00070 void VirtexE::initializeDeviceInfo(const std::string& inDeviceName) {
00071
00072 typedef torc::architecture::xilinx::TileCount TileCount;
00073 typedef torc::architecture::xilinx::TileRow TileRow;
00074 typedef torc::architecture::xilinx::TileCol TileCol;
00075 typedef torc::architecture::xilinx::TileTypeIndex TileTypeIndex;
00076 typedef torc::architecture::xilinx::TileTypeCount TileTypeCount;
00077
00078
00079 torc::architecture::DDB ddb(inDeviceName);
00080 const torc::architecture::Tiles& tiles = ddb.getTiles();
00081 uint32_t tileCount = tiles.getTileCount();
00082 uint16_t rowCount = tiles.getRowCount();
00083 uint16_t colCount = tiles.getColCount();
00084 ColumnTypeVector columnTypes;
00085
00086
00087 typedef std::map<TileTypeIndex, std::string> TileTypeIndexToName;
00088 typedef std::map<std::string, TileTypeIndex> TileTypeNameToIndex;
00089 TileTypeIndexToName tileTypeIndexToName;
00090 TileTypeNameToIndex tileTypeNameToIndex;
00091 TileTypeCount tileTypeCount = tiles.getTileTypeCount();
00092 for(TileTypeIndex tileTypeIndex(0); tileTypeIndex < tileTypeCount; tileTypeIndex++) {
00093 const std::string tileTypeName = tiles.getTileTypeName(tileTypeIndex);
00094 tileTypeIndexToName[tileTypeIndex] = tileTypeName;
00095 tileTypeNameToIndex[tileTypeName] = tileTypeIndex;
00096 TileTypeNameToColumnType::iterator ttwp = mTileTypeNameToColumnType.find(tileTypeName);
00097 TileTypeNameToColumnType::iterator ttwe = mTileTypeNameToColumnType.end();
00098 if(ttwp != ttwe) mTileTypeIndexToColumnType[tileTypeIndex] = EColumnType(ttwp->second);
00099 }
00100
00101
00102 columnTypes.resize(colCount);
00103 uint32_t frameCount = 0;
00104 for(uint32_t blockType = 0; blockType < Virtex::eFarBlockTypeCount; blockType++) {
00105 for(TileCol col; col < colCount; col++) {
00106 bool found = false;
00107 columnTypes[col] = eColumnTypeEmpty;
00108 TileTypeIndexToColumnType::iterator ttwe = mTileTypeIndexToColumnType.end();
00109 TileTypeIndexToColumnType::iterator ttwp = ttwe;
00110 for(TileRow row; row < rowCount; row++) {
00111
00112 const torc::architecture::TileInfo& tileInfo
00113 = tiles.getTileInfo(tiles.getTileIndex(row, col));
00114 TileTypeIndex tileTypeIndex = tileInfo.getTypeIndex();
00115
00116 ttwp = mTileTypeIndexToColumnType.find(tileTypeIndex);
00117 if(ttwp != ttwe) {
00118 uint32_t width = mColumnDefs[ttwp->second][blockType];
00119 frameCount += width;
00120
00121
00122 columnTypes[col] = static_cast<EColumnType>(ttwp->second);
00123 found = true;
00124 break;
00125 }
00126 }
00127 (void) found;
00128 }
00129
00130 if(blockType == 2) break;
00131 }
00132
00133 boost::filesystem::path workingPath = torc::common::DirectoryTree::getWorkingPath();
00134 boost::filesystem::path generatedMap = workingPath / (inDeviceName + ".map.csv");
00135 std::fstream tilemapStream(generatedMap.string().c_str(), std::ios::out);
00136 for(TileRow row; row < rowCount; row++) {
00137 for(TileCol col; col < colCount; col++) {
00138 const torc::architecture::TileInfo& tileInfo
00139 = tiles.getTileInfo(tiles.getTileIndex(row, col));
00140 TileTypeIndex tileTypeIndex = tileInfo.getTypeIndex();
00141 tilemapStream << tiles.getTileTypeName(tileTypeIndex);
00142 if(col + 1 < colCount) tilemapStream << ",";
00143 }
00144 tilemapStream << std::endl;
00145 }
00146 tilemapStream.close();
00147
00148
00149 setDeviceInfo(DeviceInfo(tileCount, rowCount, colCount, columnTypes));
00150
00151 }
00152
00153 #endif
00154
00155 void VirtexE::initializeFrameMaps(void) {
00156
00157 bool debug = 0;
00158 int center = 0;
00159 int frameIndex = 0;
00160 int frameCount = 0;
00161 int farMajor = 0;
00162 int width = 0;
00163 ColumnIndex col;
00164 const ColumnTypeVector& columnTypes = mDeviceInfo.getColumnTypes();
00165 for(uint32_t i = 0; i < VirtexE::eFarBlockTypeCount; i++) {
00166 farMajor = i;
00167 mFrameIndexBounds = 0;
00168 EFarBlockType blockType = VirtexE::EFarBlockType(i);
00169
00170 uint32_t bitIndex = 0;
00171 uint32_t xdlIndex = 0;
00172 mBitColumnIndexes[i].push_back(bitIndex);
00173 mXdlColumnIndexes[i].push_back(xdlIndex);
00174 uint16_t finalColumn = mDeviceInfo.getColCount()-1;
00175 uint32_t xdlColumnCount = 0;
00176 uint32_t bitColumnCount = 0;
00177
00178 center = mDeviceInfo.getColCount()/2;
00179 col = center;
00180 prepareFrames(col, frameCount, frameIndex, blockType, farMajor, width);
00181 int numBrams = 4;
00182 int numIobs = 2;
00183 int numClocks = 1;
00184 int numClbs = mDeviceInfo.getColCount() - numClocks - numBrams - numIobs;
00185
00186 if(mDevice == torc::common::eXCV405E || mDevice == torc::common::eXCV812E) {
00187
00188 for (int j = 1; j < center; j++) {
00189 for (int k = -1; k < 2; k += 2) {
00190 col = center - (j * k);
00191 if(columnTypes[col] == eColumnTypeClb) {
00192 prepareFrames(col, frameCount, frameIndex, blockType, farMajor, width);
00193 }
00194
00195 if(mDeviceInfo.getColumnTypes()[col] != Virtex::eColumnTypeEmpty) {
00196 mXdlIndexToBitIndex[bitColumnCount] = xdlColumnCount;
00197 bitColumnCount++;
00198 bitIndex += width;
00199 mBitColumnIndexes[i].push_back(bitIndex);
00200 if(col == finalColumn) {
00201 bitIndex += mColumnDefs[mDeviceInfo.getColumnTypes()[col]][i];
00202 mBitColumnIndexes[i].push_back(bitIndex);
00203 }
00204 }
00205
00206
00207 xdlIndex += width;
00208 mXdlColumnIndexes[i].push_back(xdlIndex);
00209 xdlColumnCount++;
00210 if(col == finalColumn)
00211 {
00212 xdlIndex += mColumnDefs[mDeviceInfo.getColumnTypes()[col]][i];
00213 mXdlColumnIndexes[i].push_back(xdlIndex);
00214 }
00215 }
00216 }
00217
00218 for (int j = center; j < (center + 1); j++) {
00219 for (int k = -1; k < 2; k += 2) {
00220 col = center - (j * k);
00221 prepareFrames(col, frameCount, frameIndex, blockType, farMajor, width);
00222
00223 if(mDeviceInfo.getColumnTypes()[col] != Virtex::eColumnTypeEmpty) {
00224 mXdlIndexToBitIndex[bitColumnCount] = xdlColumnCount;
00225 bitColumnCount++;
00226 bitIndex += width;
00227 mBitColumnIndexes[i].push_back(bitIndex);
00228 if(col == finalColumn) {
00229 bitIndex += mColumnDefs[mDeviceInfo.getColumnTypes()[col]][i];
00230 mBitColumnIndexes[i].push_back(bitIndex);
00231 }
00232 }
00233
00234
00235 xdlIndex += width;
00236 mXdlColumnIndexes[i].push_back(xdlIndex);
00237 xdlColumnCount++;
00238 if(col == finalColumn)
00239 {
00240 xdlIndex += mColumnDefs[mDeviceInfo.getColumnTypes()[col]][i];
00241 mXdlColumnIndexes[i].push_back(xdlIndex);
00242 }
00243 }
00244 }
00245
00246 for (int j = 1; j < center; j++) {
00247 for (int k = -1; k < 2; k += 2) {
00248 col = center - (j * k);
00249 if(columnTypes[col] == eColumnTypeBram) {
00250 prepareFrames(col, frameCount, frameIndex, blockType, farMajor, width);
00251 }
00252
00253 if(mDeviceInfo.getColumnTypes()[col] != Virtex::eColumnTypeEmpty) {
00254 mXdlIndexToBitIndex[bitColumnCount] = xdlColumnCount;
00255 bitColumnCount++;
00256 bitIndex += width;
00257 mBitColumnIndexes[i].push_back(bitIndex);
00258 if(col == finalColumn) {
00259 bitIndex += mColumnDefs[mDeviceInfo.getColumnTypes()[col]][i];
00260 mBitColumnIndexes[i].push_back(bitIndex);
00261 }
00262 }
00263
00264
00265 xdlIndex += width;
00266 mXdlColumnIndexes[i].push_back(xdlIndex);
00267 xdlColumnCount++;
00268 if(col == finalColumn)
00269 {
00270 xdlIndex += mColumnDefs[mDeviceInfo.getColumnTypes()[col]][i];
00271 mXdlColumnIndexes[i].push_back(xdlIndex);
00272 }
00273 }
00274 }
00275 }
00276 else {
00277
00278 for (int j = 1; j <= (numClbs + numBrams) / 2; j++) {
00279 for (int k = -1; k < 2; k += 2) {
00280 col = center - (j * k);
00281 prepareFrames(col, frameCount, frameIndex, blockType, farMajor, width);
00282
00283 if(mDeviceInfo.getColumnTypes()[col] != Virtex::eColumnTypeEmpty) {
00284 mXdlIndexToBitIndex[bitColumnCount] = xdlColumnCount;
00285 bitColumnCount++;
00286 bitIndex += width;
00287 mBitColumnIndexes[i].push_back(bitIndex);
00288 if(col == finalColumn) {
00289 bitIndex += mColumnDefs[mDeviceInfo.getColumnTypes()[col]][i];
00290 mBitColumnIndexes[i].push_back(bitIndex);
00291 }
00292 }
00293
00294
00295 xdlIndex += width;
00296 mXdlColumnIndexes[i].push_back(xdlIndex);
00297 xdlColumnCount++;
00298 if(col == finalColumn)
00299 {
00300 xdlIndex += mColumnDefs[mDeviceInfo.getColumnTypes()[col]][i];
00301 mXdlColumnIndexes[i].push_back(xdlIndex);
00302 }
00303 }
00304 }
00305
00306 for (int j = center; j < (center + 1); j++) {
00307 for (int k = -1; k < 2; k += 2) {
00308 col = center - (j * k);
00309 prepareFrames(col, frameCount, frameIndex, blockType, farMajor, width);
00310
00311 if(mDeviceInfo.getColumnTypes()[col] != Virtex::eColumnTypeEmpty) {
00312 mXdlIndexToBitIndex[bitColumnCount] = xdlColumnCount;
00313 bitColumnCount++;
00314 bitIndex += width;
00315 mBitColumnIndexes[i].push_back(bitIndex);
00316 if(col == finalColumn) {
00317 bitIndex += mColumnDefs[mDeviceInfo.getColumnTypes()[col]][i];
00318 mBitColumnIndexes[i].push_back(bitIndex);
00319 }
00320 }
00321
00322
00323 xdlIndex += width;
00324 mXdlColumnIndexes[i].push_back(xdlIndex);
00325 xdlColumnCount++;
00326 if(col == finalColumn)
00327 {
00328 xdlIndex += mColumnDefs[mDeviceInfo.getColumnTypes()[col]][i];
00329 mXdlColumnIndexes[i].push_back(xdlIndex);
00330 }
00331 }
00332 }
00333 }
00334
00335 mBlockFrameIndexBounds[i] = mFrameIndexBounds;
00336 if (debug) std::cout << "***Block frame index bounds: " << mBlockFrameIndexBounds[i] << std::endl;
00337 }
00338
00339 if (debug) {
00340 for(uint32_t i = 0; i < Virtex::eFarBlockTypeCount; i++) {
00341 for(uint32_t j = 0; j < mBitColumnIndexes[i].size(); j++)
00342 std::cout << "Bit Value at index: (" << i << ", " << j << ") : " << mBitColumnIndexes[i][j] << std::endl;
00343 for(uint32_t k = 0; k < mXdlColumnIndexes[i].size(); k++)
00344 std::cout << "Xdl Value at index: (" << i << ", " << k << ") : " << mXdlColumnIndexes[i][k] << std::endl;
00345 }
00346 }
00347 }
00348
00349 }
00350 }