00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "torc/bitstream/Virtex2P.hpp"
00020 #include <iostream>
00021
00022
00023 #include "torc/architecture/DDB.hpp"
00024 #include "torc/architecture/XilinxDatabaseTypes.hpp"
00025 #include "torc/common/DirectoryTree.hpp"
00026 #include <fstream>
00027
00028
00029 namespace torc {
00030 namespace bitstream {
00031
00032
00033 #ifndef GENERATE_STATIC_DEVICE_INFO
00034
00035 extern DeviceInfo xc2vp2;
00036 extern DeviceInfo xc2vp4;
00037 extern DeviceInfo xc2vp7;
00038 extern DeviceInfo xc2vp20;
00039 extern DeviceInfo xc2vp30;
00040 extern DeviceInfo xc2vp40;
00041 extern DeviceInfo xc2vp50;
00042 extern DeviceInfo xc2vp70;
00043 extern DeviceInfo xc2vp100;
00044 extern DeviceInfo xc2vpx20;
00045 extern DeviceInfo xc2vpx70;
00046
00047 void Virtex2P::initializeDeviceInfo(const std::string& inDeviceName) {
00048 using namespace torc::common;
00049 switch(mDevice) {
00050 case eXC2VP2: setDeviceInfo(xc2vp2); break;
00051 case eXC2VP4: setDeviceInfo(xc2vp4); break;
00052 case eXC2VP7: setDeviceInfo(xc2vp7); break;
00053 case eXC2VP20: setDeviceInfo(xc2vp20); break;
00054 case eXC2VP30: setDeviceInfo(xc2vp30); break;
00055 case eXC2VP40: setDeviceInfo(xc2vp40); break;
00056 case eXC2VP50: setDeviceInfo(xc2vp50); break;
00057 case eXC2VP70: setDeviceInfo(xc2vp70); break;
00058 case eXC2VP100: setDeviceInfo(xc2vp100); break;
00059 case eXC2VPX20: setDeviceInfo(xc2vpx20); break;
00060 case eXC2VPX70: setDeviceInfo(xc2vpx70); break;
00061 default: break;
00062 }
00063 }
00064
00065 #else
00066
00067 void Virtex2P::initializeDeviceInfo(const std::string& inDeviceName) {
00068
00069 typedef torc::architecture::xilinx::TileCount TileCount;
00070 typedef torc::architecture::xilinx::TileRow TileRow;
00071 typedef torc::architecture::xilinx::TileCol TileCol;
00072 typedef torc::architecture::xilinx::TileTypeIndex TileTypeIndex;
00073 typedef torc::architecture::xilinx::TileTypeCount TileTypeCount;
00074
00075
00076 torc::architecture::DDB ddb(inDeviceName);
00077 const torc::architecture::Tiles& tiles = ddb.getTiles();
00078 uint32_t tileCount = tiles.getTileCount();
00079 uint16_t rowCount = tiles.getRowCount();
00080 uint16_t colCount = tiles.getColCount();
00081 ColumnTypeVector columnTypes;
00082
00083
00084 typedef std::map<TileTypeIndex, std::string> TileTypeIndexToName;
00085 typedef std::map<std::string, TileTypeIndex> TileTypeNameToIndex;
00086 TileTypeIndexToName tileTypeIndexToName;
00087 TileTypeNameToIndex tileTypeNameToIndex;
00088 TileTypeCount tileTypeCount = tiles.getTileTypeCount();
00089 for(TileTypeIndex tileTypeIndex(0); tileTypeIndex < tileTypeCount; tileTypeIndex++) {
00090 const std::string tileTypeName = tiles.getTileTypeName(tileTypeIndex);
00091 tileTypeIndexToName[tileTypeIndex] = tileTypeName;
00092 tileTypeNameToIndex[tileTypeName] = tileTypeIndex;
00093 TileTypeNameToColumnType::iterator ttwp = mTileTypeNameToColumnType.find(tileTypeName);
00094 TileTypeNameToColumnType::iterator ttwe = mTileTypeNameToColumnType.end();
00095 if(ttwp != ttwe) mTileTypeIndexToColumnType[tileTypeIndex] = EColumnType(ttwp->second);
00096 }
00097
00098
00099 columnTypes.resize(colCount);
00100 uint32_t frameCount = 0;
00101 for(uint32_t blockType = 0; blockType < Virtex2P::eFarBlockTypeCount; blockType++) {
00102 for(TileCol col; col < colCount; col++) {
00103 columnTypes[col] = eColumnTypeEmpty;
00104 TileTypeIndexToColumnType::iterator ttwe = mTileTypeIndexToColumnType.end();
00105 TileTypeIndexToColumnType::iterator ttwp = ttwe;
00106 for(TileRow row; row < rowCount; row++) {
00107
00108 const torc::architecture::TileInfo& tileInfo
00109 = tiles.getTileInfo(tiles.getTileIndex(row, col));
00110 TileTypeIndex tileTypeIndex = tileInfo.getTypeIndex();
00111
00112 ttwp = mTileTypeIndexToColumnType.find(tileTypeIndex);
00113 if(ttwp != ttwe) {
00114 uint32_t width = mColumnDefs[ttwp->second][blockType];
00115 frameCount += width;
00116
00117
00118 columnTypes[col] = static_cast<EColumnType>(ttwp->second);
00119 break;
00120 }
00121 }
00122 }
00123
00124 if(blockType == 2) break;
00125 }
00126
00127 boost::filesystem::path workingPath = torc::common::DirectoryTree::getWorkingPath();
00128 boost::filesystem::path generatedMap = workingPath / (inDeviceName + ".map.csv");
00129 std::fstream tilemapStream(generatedMap.string().c_str(), std::ios::out);
00130 for(TileRow row; row < rowCount; row++) {
00131 for(TileCol col; col < colCount; col++) {
00132 const torc::architecture::TileInfo& tileInfo
00133 = tiles.getTileInfo(tiles.getTileIndex(row, col));
00134 TileTypeIndex tileTypeIndex = tileInfo.getTypeIndex();
00135 tilemapStream << tiles.getTileTypeName(tileTypeIndex);
00136 if(col + 1 < colCount) tilemapStream << ",";
00137 }
00138 tilemapStream << std::endl;
00139 }
00140 tilemapStream.close();
00141
00142
00143 setDeviceInfo(DeviceInfo(tileCount, rowCount, colCount, columnTypes));
00144 }
00145 #endif
00146
00147 }
00148 }