torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Virtex2P.cpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 /// \file
17 /// \brief Source for the Virtex2P class.
18 
20 #include <iostream>
21 
22 /// \todo Warning: this will need to be moved elsewhere.
26 #include <fstream>
27 
28 
29 namespace torc {
30 namespace bitstream {
31 
32 //#define GENERATE_STATIC_DEVICE_INFO
33 #ifndef GENERATE_STATIC_DEVICE_INFO
34 
35  extern DeviceInfo xc2vp2;
36  extern DeviceInfo xc2vp4;
37  extern DeviceInfo xc2vp7;
38  extern DeviceInfo xc2vp20;
39  extern DeviceInfo xc2vp30;
40  extern DeviceInfo xc2vp40;
41  extern DeviceInfo xc2vp50;
42  extern DeviceInfo xc2vp70;
43  extern DeviceInfo xc2vp100;
44  extern DeviceInfo xc2vpx20;
45  extern DeviceInfo xc2vpx70;
46 
47  void Virtex2P::initializeDeviceInfo(const std::string& inDeviceName) {
48  using namespace torc::common;
49  switch(mDevice) {
50  case eXC2VP2: setDeviceInfo(xc2vp2); break;
51  case eXC2VP4: setDeviceInfo(xc2vp4); break;
52  case eXC2VP7: setDeviceInfo(xc2vp7); break;
53  case eXC2VP20: setDeviceInfo(xc2vp20); break;
54  case eXC2VP30: setDeviceInfo(xc2vp30); break;
55  case eXC2VP40: setDeviceInfo(xc2vp40); break;
56  case eXC2VP50: setDeviceInfo(xc2vp50); break;
57  case eXC2VP70: setDeviceInfo(xc2vp70); break;
58  case eXC2VP100: setDeviceInfo(xc2vp100); break;
59  case eXC2VPX20: setDeviceInfo(xc2vpx20); break;
60  case eXC2VPX70: setDeviceInfo(xc2vpx70); break;
61  default: break;
62  }
63  }
64 
65 #else
66 
67  void Virtex2P::initializeDeviceInfo(const std::string& inDeviceName) {
68 
74 
75  // look up the device tile map
76  torc::architecture::DDB ddb(inDeviceName);
77  const torc::architecture::Tiles& tiles = ddb.getTiles();
78  uint32_t tileCount = tiles.getTileCount();
79  uint16_t rowCount = tiles.getRowCount();
80  uint16_t colCount = tiles.getColCount();
81  ColumnTypeVector columnTypes;
82 
83  // set up the tile index and name mappings, and the index to column def mapping
84  typedef std::map<TileTypeIndex, std::string> TileTypeIndexToName;
85  typedef std::map<std::string, TileTypeIndex> TileTypeNameToIndex;
86  TileTypeIndexToName tileTypeIndexToName;
87  TileTypeNameToIndex tileTypeNameToIndex;
88  TileTypeCount tileTypeCount = tiles.getTileTypeCount();
89  for(TileTypeIndex tileTypeIndex(0); tileTypeIndex < tileTypeCount; tileTypeIndex++) {
90  const std::string tileTypeName = tiles.getTileTypeName(tileTypeIndex);
91  tileTypeIndexToName[tileTypeIndex] = tileTypeName;
92  tileTypeNameToIndex[tileTypeName] = tileTypeIndex;
93  TileTypeNameToColumnType::iterator ttwp = mTileTypeNameToColumnType.find(tileTypeName);
94  TileTypeNameToColumnType::iterator ttwe = mTileTypeNameToColumnType.end();
95  if(ttwp != ttwe) mTileTypeIndexToColumnType[tileTypeIndex] = EColumnType(ttwp->second);
96  }
97 
98  // identify every column that contains known frames
99  columnTypes.resize(colCount);
100  uint32_t frameCount = 0;
101  for(uint32_t blockType = 0; blockType < Virtex2P::eFarBlockTypeCount; blockType++) {
102  for(TileCol col; col < colCount; col++) {
103  columnTypes[col] = eColumnTypeEmpty;
104  TileTypeIndexToColumnType::iterator ttwe = mTileTypeIndexToColumnType.end();
105  TileTypeIndexToColumnType::iterator ttwp = ttwe;
106  for(TileRow row; row < rowCount; row++) {
107  // look up the tile info
108  const torc::architecture::TileInfo& tileInfo
109  = tiles.getTileInfo(tiles.getTileIndex(row, col));
110  TileTypeIndex tileTypeIndex = tileInfo.getTypeIndex();
111  // determine whether the tile type widths are defined
112  ttwp = mTileTypeIndexToColumnType.find(tileTypeIndex);
113  if(ttwp != ttwe) {
114  uint32_t width = mColumnDefs[ttwp->second][blockType];
115  frameCount += width;
116  //std::cout << " " << tiles.getTileTypeName(tileInfo.getTypeIndex())
117  // << ": " << width << " (" << frameCount << ")" << std::endl;
118  columnTypes[col] = static_cast<EColumnType>(ttwp->second);
119  break;
120  }
121  }
122  }
123  //std::cout << std::endl;
124  if(blockType == 2) break;
125  }
126 
128  boost::filesystem::path generatedMap = workingPath / (inDeviceName + ".map.csv");
129  std::fstream tilemapStream(generatedMap.string().c_str(), std::ios::out);
130  for(TileRow row; row < rowCount; row++) {
131  for(TileCol col; col < colCount; col++) {
132  const torc::architecture::TileInfo& tileInfo
133  = tiles.getTileInfo(tiles.getTileIndex(row, col));
134  TileTypeIndex tileTypeIndex = tileInfo.getTypeIndex();
135  tilemapStream << tiles.getTileTypeName(tileTypeIndex);
136  if(col + 1 < colCount) tilemapStream << ",";
137  }
138  tilemapStream << std::endl;
139  }
140  tilemapStream.close();
141 
142  // update bitstream device information
143  setDeviceInfo(DeviceInfo(tileCount, rowCount, colCount, columnTypes));
144  }
145 #endif
146 
147 } // namespace bitstream
148 } // namespace torc
DeviceInfo xc2vpx20
ColumnDefVector mColumnDefs
Column type widths.
Encapsulation of a tile row in an unsigned 16-bit integer.
TileTypeNameToColumnType mTileTypeNameToColumnType
DeviceInfo xc2vp100
DeviceInfo xc2vp4
Encapsulation of a tile column in an unsigned 16-bit integer.
DeviceInfo xc2vp20
Device database, including complete wiring and logic support.
Definition: DDB.hpp:42
TileTypeCount getTileTypeCount(void) const
Returns the tile type count for this device.
Definition: Tiles.hpp:151
TileRow getRowCount(void) const
Returns the row count for this device.
Definition: Tiles.hpp:153
Header for the Virtex2P class.
Header for the DirectoryTree class.
const TileInfo & getTileInfo(TileIndex inTileIndex) const
Returns the TileInfo object for the specified tile.
Definition: Tiles.hpp:137
DeviceInfo xc2vp7
TileTypeIndexToColumnType mTileTypeIndexToColumnType
TileCount getTileCount(void) const
Returns the tile count for this device.
Definition: Tiles.hpp:149
EDevice mDevice
Bitstream device enumeration.
std::string string
DeviceInfo xc2vpx70
DeviceInfo xc2vp40
Tile map, tile type, and wire information for the family and device.
Definition: Tiles.hpp:36
Encapsulation of a tile count in an unsigned 32-bit integer.
Encapsulation of a tile within a device tile map.
Definition: TileInfo.hpp:33
const char * getTileTypeName(TileTypeIndex inTileTypeIndex) const
Returns the tile type name for the given tile type index.
Definition: Tiles.hpp:164
DeviceInfo xc2vp30
virtual void initializeDeviceInfo(const std::string &inDeviceName)
Initialize the device information.
Definition: Virtex2P.cpp:47
boost::filesystem::path path
const TileTypeIndex & getTypeIndex(void) const
Returns the tile type index for this tile.
Definition: TileInfo.hpp:92
DeviceInfo xc2vp50
DeviceInfo xc2vp2
static const boost::filesystem::path & getWorkingPath(void)
Returns the absolute path to the working directory.
Encapsulation of a tile type count in an unsigned 16-bit integer.
TileCol getColCount(void) const
Returns the column count for this device.
Definition: Tiles.hpp:155
Encapsulation of a tile type index in an unsigned 16-bit integer.
boost::uint16_t uint16_t
Imported type name.
boost::uint32_t uint32_t
Imported type name.
Definition: Virtex2.hpp:49
Header for the DDB class.
EColumnType
Major column types.
Definition: Virtex2.hpp:79
void setDeviceInfo(const DeviceInfo &rhs)
Assign static device information for the current bitstream.
TileIndex getTileIndex(TileRow inRow, TileCol inCol) const
Returns the tile index for the given [row,column] pair.
Definition: Tiles.hpp:161
DeviceInfo xc2vp70
Device database types for Xilinx architectures.