torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
torc::architecture::VprExporter Class Reference

Device database exporter for the University of Toronto's VPR. More...

#include <VprExporter.hpp>

+ Collaboration diagram for torc::architecture::VprExporter:

Data Structures

class  Node
 VPR node temporary class. More...
 

Public Member Functions

 VprExporter (DDB &inDDB)
 Public constructor. More...
 
void operator() (void)
 Exports routing graph information for VPR v6.0. More...
 

Protected Types

typedef std::fstream fstream
 Imported type name. More...
 
typedef std::string string
 Imported type name. More...
 
typedef std::vector< stringStringVector
 Vector type. More...
 
typedef std::vector< uint32_t > Uint32Vector
 Vector type. More...
 
typedef xilinx::WireFlags WireFlags
 Imported type name. More...
 
typedef xilinx::WireCount WireCount
 Imported type name. More...
 
typedef xilinx::WireIndex WireIndex
 Imported type name. More...
 
typedef xilinx::TileCount TileCount
 Imported type name. More...
 
typedef xilinx::TileIndex TileIndex
 Imported type name. More...
 
typedef xilinx::TileCol TileCol
 Imported type name. More...
 
typedef xilinx::TileRow TileRow
 Imported type name. More...
 
typedef xilinx::TileTypeIndex TileTypeIndex
 Imported type name. More...
 

Protected Attributes

DDBmDDB
 Reference to the database object. More...
 
const TilesmTiles
 Reference to the database Tiles object. More...
 
const SegmentsmSegments
 Reference to the database Segments object. More...
 
TileRow mMinTileRow
 Minimum row bounds. More...
 
TileCol mMinTileCol
 Minimum column bounds. More...
 
TileRow mMaxTileRow
 Maximum row bounds. More...
 
TileCol mMaxTileCol
 Maximum column bounds. More...
 
fstream mStream
 Output file stream for VPR data. More...
 

Detailed Description

Device database exporter for the University of Toronto's VPR.

Note
This is still experimental and under development.

Definition at line 31 of file VprExporter.hpp.

Member Typedef Documentation

typedef std::fstream torc::architecture::VprExporter::fstream
protected

Imported type name.

Definition at line 34 of file VprExporter.hpp.

typedef std::string torc::architecture::VprExporter::string
protected

Imported type name.

Definition at line 35 of file VprExporter.hpp.

typedef std::vector<string> torc::architecture::VprExporter::StringVector
protected

Vector type.

Definition at line 36 of file VprExporter.hpp.

Imported type name.

Definition at line 43 of file VprExporter.hpp.

Imported type name.

Definition at line 41 of file VprExporter.hpp.

Imported type name.

Definition at line 42 of file VprExporter.hpp.

Imported type name.

Definition at line 44 of file VprExporter.hpp.

Imported type name.

Definition at line 45 of file VprExporter.hpp.

typedef std::vector<uint32_t> torc::architecture::VprExporter::Uint32Vector
protected

Vector type.

Definition at line 37 of file VprExporter.hpp.

Imported type name.

Definition at line 39 of file VprExporter.hpp.

Imported type name.

Definition at line 38 of file VprExporter.hpp.

Imported type name.

Definition at line 40 of file VprExporter.hpp.

Constructor & Destructor Documentation

torc::architecture::VprExporter::VprExporter ( DDB inDDB)
inline

Public constructor.

Definition at line 83 of file VprExporter.hpp.

83  : mDDB(inDDB), mTiles(mDDB.getTiles()),
85  mMinTileRow(10), mMinTileCol(10),
86  mMaxTileRow(10), mMaxTileCol(10) {}
TileCol mMaxTileCol
Maximum column bounds.
Definition: VprExporter.hpp:77
const Tiles & getTiles(void) const
Returns a constant reference to the family and device tile data.
Definition: DDB.hpp:146
const Tiles & mTiles
Reference to the database Tiles object.
Definition: VprExporter.hpp:67
DDB & mDDB
Reference to the database object.
Definition: VprExporter.hpp:65
TileCol mMinTileCol
Minimum column bounds.
Definition: VprExporter.hpp:73
TileRow mMaxTileRow
Maximum row bounds.
Definition: VprExporter.hpp:75
TileRow mMinTileRow
Minimum row bounds.
Definition: VprExporter.hpp:71
const Segments & mSegments
Reference to the database Segments object.
Definition: VprExporter.hpp:69
const Segments & getSegments(void) const
Returns a constant reference to the device segment data.
Definition: DDB.hpp:142

Member Function Documentation

void torc::architecture::VprExporter::operator() ( void  )

Exports routing graph information for VPR v6.0.

Definition at line 97 of file VprExporter.cpp.

97  {
98 
99  bool debug = true;
100 
101  cout << mDDB;
102  cout << "sizeof(short) = " << sizeof(short) << endl;
103  cout << "sizeof(int) = " << sizeof(int) << endl;
104  cout << "sizeof(float) = " << sizeof(float) << endl;
105  cout << "sizeof(t_rr_node) = " << sizeof(t_rr_node) << endl;
106 
107  // name the output file
108  mMaxTileRow = min(mMaxTileRow, mDDB.getTiles().getRowCount());
109  mMaxTileCol = min(mMaxTileCol, mDDB.getTiles().getColCount());
110  stringstream ss;
111  ss << mDDB.getDeviceName() << "-[" << mMinTileRow << "," << mMinTileCol << "]-["
112  << mMaxTileRow << "," << mMaxTileCol << "].vpr";
114  / "regression" / ss.str();
115  mStream.open(generatedPath.string().c_str(), std::ios::out | std::ios::binary);
116 
117  // declare maps to track tilewires
118  typedef map<Tilewire, uint32_t> TilewireToIndex;
119  TilewireToIndex tilewireToIndex;
120  typedef map<Tilewire, bool> TilewireIsExcluded;
121  TilewireIsExcluded tilewireIsExcluded;
122  // iterate over every tile
123  TileCount tileCount = mTiles.getTileCount();
124  size_t size = 0;
125  for(TileIndex tileIndex(0); tileIndex < tileCount; tileIndex++) {
126  // iterate over every wire in the tile
127  const TileInfo& tileInfo = mTiles.getTileInfo(tileIndex);
128  TileTypeIndex tileTypeIndex = tileInfo.getTypeIndex();
129  // TileRow TileRow = tileInfo.getRow();
130  // TileCol TileCol = tileInfo.getCol();
131  WireCount wireCount = mTiles.getWireCount(tileTypeIndex);
132  for(WireIndex wireIndex(0); wireIndex < wireCount; wireIndex++) {
133  // take a quick exit if we've already looked at this segment
134  Tilewire currentTilewire(tileIndex, wireIndex);
135  if(tilewireIsExcluded.find(currentTilewire) != tilewireIsExcluded.end()) continue;
136  // look up the segment information for this tilewire
137  TilewireVector tilewires;
138  mDDB.expandSegment(currentTilewire, tilewires);
139  // if a segment is not real in this device, it won't have any tilewires
140  if(tilewires.empty()) continue;
141  // determine whether to include this segment or not
142  TilewireVector::iterator tp = tilewires.begin();
143  TilewireVector::iterator te = tilewires.end();
144  bool include = true;
145  while(include && tp < te) {
146  ExtendedWireInfo ewi(mDDB, *tp++);
147  if(ewi.mTileRow < mMinTileRow) include = false;
148  if(ewi.mTileCol < mMinTileCol) include = false;
149  if(ewi.mTileRow > mMaxTileRow) include = false;
150  if(ewi.mTileCol > mMaxTileCol) include = false;
151  }
152  // mark the tilewires as visited
153  tp = tilewires.begin();
154  while(tp < te) tilewireIsExcluded[*tp++] = !include;
155  if(!include) continue;
156  // push the anchor tilewire if we haven't seen it before
157  if(tilewireToIndex.find(tilewires[0]) == tilewireToIndex.end())
158  tilewireToIndex[tilewires[0]] = size++;
159  }
160  }
161  cout << "Found " << tilewireToIndex.size() << " total segments compared to expected "
162  << mSegments.getTotalSegmentCount() << endl;
163 
164  // create a vector of Node elements
165  typedef vector<Node> NodeVector;
166  NodeVector nodes;
167  nodes.resize(tilewireToIndex.size());
168  // iterate over every indexed wire and write it out
169  TilewireToIndex::const_iterator p = tilewireToIndex.begin();
170  TilewireToIndex::const_iterator e = tilewireToIndex.end();
171  while(p != e) {
172  TilewireToIndex::value_type value = *p++;
173  uint32_t index = value.second;
174  Tilewire tilewire = value.first;
175  nodes[index].mIndex = index;
176  nodes[index].mTilewire = tilewire;
177  // expand this segment's sinks
178  ArcVector arcVector;
179  mDDB.expandSegmentSinks(tilewire, arcVector, DDB::eExpandDirectionNone, true, true,
180  true, false);
181  ArcVector::const_iterator ap = arcVector.begin();
182  ArcVector::const_iterator ae = arcVector.end();
183  while(ap < ae) {
184  Arc arc = *ap++;
185  // expand the sink wire's segment to recover the anchor and segment index
186  TilewireVector tilewires;
187  mDDB.expandSegment(arc.getSinkTilewire(), tilewires);
188  // if we have deliberately pruned this sink tilewire, do not include it in the data
189  if(tilewireToIndex.find(tilewires[0]) == tilewireToIndex.end()) continue;
190  // convert the sink tilewire to an index
191  uint32_t sinkIndex = tilewireToIndex[tilewires[0]];
192  nodes[index].mEdges.push_back(sinkIndex);
193  }
194  // iterate over every segment wire to extract attributes
195  {
196  TilewireVector tilewires;
197  mDDB.expandSegment(tilewire, tilewires);
198  TilewireVector::iterator tp = tilewires.begin();
199  TilewireVector::iterator te = tilewires.end();
200  while(tp < te) {
201  ExtendedWireInfo ewi(mDDB, *tp++);
202  nodes[index].mMinRow = min(nodes[index].mMinRow, ewi.mTileRow);
203  nodes[index].mMinCol = min(nodes[index].mMinCol, ewi.mTileCol);
204  nodes[index].mMaxRow = max(nodes[index].mMaxRow, ewi.mTileRow);
205  nodes[index].mMaxCol = max(nodes[index].mMaxCol, ewi.mTileCol);
206  nodes[index].mRowRange = nodes[index].mMaxRow - nodes[index].mMinRow;
207  nodes[index].mColRange = nodes[index].mMaxCol - nodes[index].mMinCol;
208  nodes[index].mFlags |= ewi.mWireFlags;
209  }
210  }
211  }
212 
213  // iterate through the VPR nodes and output everything except for the edges
214  size_t nodeCount = tilewireToIndex.size();
215  size_t edgeCount = 0;
216  mStream.write(reinterpret_cast<char*>(&nodeCount), sizeof(nodeCount));
217  int* edgePtr = 0;
218  NodeVector::iterator np = nodes.begin();
219  NodeVector::iterator ne = nodes.end();
220  while(np < ne) {
221  Node& node = *np++;
222  if(debug) cout << node.mIndex << ": (" << node.mTilewire << "): ";
223  if(debug) cout << "[" << node.mMinRow << "," << node.mMinCol << "]-["
224  << node.mMaxRow << "," << node.mMaxCol << "] ";
225  if(debug) cout << (WireInfo::isInput(node.mFlags) ? "INPUT " : "");
226  if(debug) cout << (WireInfo::isOutput(node.mFlags) ? "OUTPUT " : "");
227  Uint32Vector::const_iterator ep = node.mEdges.begin();
228  Uint32Vector::const_iterator ee = node.mEdges.end();
229  if(debug) while(ep < ee) {
230  cout << *ep++ << " ";
231  }
232  if(debug) cout << endl;
233 
234  t_rr_node vpr_rr_node;
235  // segment bounds
236  vpr_rr_node.xlow = node.mMinCol;
237  vpr_rr_node.xhigh = node.mMaxCol;
238  vpr_rr_node.ylow = node.mMinRow;
239  vpr_rr_node.yhigh = node.mMaxRow;
240  // we don't have track numbers, but perhaps the wire index will do
241  vpr_rr_node.ptc_num = node.mTilewire.getWireIndex();
242  // no intrinsic cost, and current occupancy is zero
243  vpr_rr_node.cost_index = vpr_rr_node.occ = 0;
244  // the capacity of every XDLRC wire is one
245  vpr_rr_node.capacity = 1;
246  // does VPR really use fanin information? we can provide this if it's important
247  vpr_rr_node.fan_in = 0;
248  // fanout
249  vpr_rr_node.num_edges = node.mEdges.size();
250  // node type; not sure if this captures what Eddie Hung was saying about their types
251  if(WireInfo::isInput(node.mFlags)) { vpr_rr_node.type = SINK; }
252  else if(WireInfo::isOutput(node.mFlags)) { vpr_rr_node.type = SOURCE; }
253  else if(node.mColRange > node.mRowRange) { vpr_rr_node.type = CHANX; }
254  else if(node.mColRange < node.mRowRange) { vpr_rr_node.type = CHANY; }
255  else { vpr_rr_node.type = CHANX; /* what if we can't tell? */ }
256  // we will fill this in in a minute
257  vpr_rr_node.edges = edgePtr;
258  edgePtr += vpr_rr_node.num_edges + 1;
259  edgeCount += vpr_rr_node.num_edges + 1;
260  // Eddie is supposed to look this up
261  vpr_rr_node.switches = 0;
262  // we have no resistance or capacitance data
263  vpr_rr_node.R = vpr_rr_node.C = 0;
264  // all I know is that most wires are not bidirectional
265  vpr_rr_node.direction = INC_DIRECTION; // what does INC_DIRECTION mean?
266  // all XDLRC wires have a single driver
267  vpr_rr_node.drivers = SINGLE;
268  // what exactly do the following two fields mean?
269  vpr_rr_node.num_wire_drivers = 0; // unless it's important to provide this
270  vpr_rr_node.num_opin_drivers = 0; // unless it's important to provide this
271  // VPR will use this to trace back after routing
272  vpr_rr_node.prev_node = vpr_rr_node.prev_edge = vpr_rr_node.net_num = 0;
273  // we aren't populating graph or timing information
274  vpr_rr_node.pb_graph_pin = 0;
275  vpr_rr_node.tnode = 0;
276  // we currently provide no packing cost hints
277  vpr_rr_node.pack_intrinsic_cost = 0;
278 
279  // write the node to the file
280  mStream.write(reinterpret_cast<char*>(&vpr_rr_node), sizeof(t_rr_node));
281  }
282 
283  // iterate through the VPR nodes and output everything except for the edges
284  mStream.write(reinterpret_cast<char*>(&edgeCount), sizeof(edgeCount));
285  uint32_t delimiter = -1;
286  np = nodes.begin();
287  while(np < ne) {
288  Node& node = *np++;
289  Uint32Vector::const_iterator ep = node.mEdges.begin();
290  Uint32Vector::const_iterator ee = node.mEdges.end();
291  while(ep < ee) {
292  uint32_t edge = *ep++;
293  mStream.write(reinterpret_cast<char*>(&edge), sizeof(edge));
294  }
295  mStream.write(reinterpret_cast<char*>(&delimiter), sizeof(delimiter));
296  }
297 
298  }
short xhigh
Definition: VprExporter.cpp:52
short num_edges
Definition: VprExporter.cpp:62
TileCol mMaxTileCol
Maximum column bounds.
Definition: VprExporter.hpp:77
short cost_index
Definition: VprExporter.cpp:58
int * edges
Definition: VprExporter.cpp:64
bool isOutput(void) const
Returns true if the wire is a logic output.
Definition: WireInfo.hpp:132
std::vector< Tilewire > TilewireVector
Vector of Tilewire objects.
Definition: Tilewire.hpp:101
short ptc_num
Definition: VprExporter.cpp:56
t_tnode * tnode
Definition: VprExporter.cpp:80
xilinx::WireCount WireCount
Imported type name.
Definition: VprExporter.hpp:39
fstream mStream
Output file stream for VPR data.
Definition: VprExporter.hpp:79
uint32_t getTotalSegmentCount(void) const
Return the total number of full segments in the device.
Definition: Segments.hpp:176
short ylow
Definition: VprExporter.cpp:53
const TileInfo & getTileInfo(TileIndex inTileIndex) const
Returns the TileInfo object for the specified tile.
Definition: Tiles.hpp:137
bool isInput(void) const
Returns true if the wire is a logic input.
Definition: WireInfo.hpp:130
enum e_drivers drivers
Definition: VprExporter.cpp:71
enum e_direction direction
Definition: VprExporter.cpp:70
TileCount getTileCount(void) const
Returns the tile count for this device.
Definition: Tiles.hpp:149
std::vector< Arc > ArcVector
Vector of Arc objects.
Definition: Arc.hpp:78
const Tiles & mTiles
Reference to the database Tiles object.
Definition: VprExporter.hpp:67
xilinx::TileCount TileCount
Imported type name.
Definition: VprExporter.hpp:41
short capacity
Definition: VprExporter.cpp:60
boost::filesystem::path path
int num_opin_drivers
Definition: VprExporter.cpp:73
DDB & mDDB
Reference to the database object.
Definition: VprExporter.hpp:65
TileCol mMinTileCol
Minimum column bounds.
Definition: VprExporter.hpp:73
short fan_in
Definition: VprExporter.cpp:61
TileRow mMaxTileRow
Maximum row bounds.
Definition: VprExporter.hpp:75
short yhigh
Definition: VprExporter.cpp:54
xilinx::TileIndex TileIndex
Imported type name.
Definition: VprExporter.hpp:42
short * switches
Definition: VprExporter.cpp:65
struct s_rr_node t_rr_node
t_pb_graph_pin * pb_graph_pin
Definition: VprExporter.cpp:79
short xlow
Definition: VprExporter.cpp:51
TileRow mMinTileRow
Minimum row bounds.
Definition: VprExporter.hpp:71
float pack_intrinsic_cost
Definition: VprExporter.cpp:81
xilinx::WireIndex WireIndex
Imported type name.
Definition: VprExporter.hpp:40
WireCount getWireCount(TileTypeIndex inTileTypeIndex) const
Returns the wire count for the specified tile type.
Definition: Tiles.hpp:157
xilinx::TileTypeIndex TileTypeIndex
Imported type name.
Definition: VprExporter.hpp:45
static const boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.
t_rr_type type
Definition: VprExporter.cpp:63
const Segments & mSegments
Reference to the database Segments object.
Definition: VprExporter.hpp:69
int num_wire_drivers
Definition: VprExporter.cpp:72

+ Here is the call graph for this function:

Field Documentation

DDB& torc::architecture::VprExporter::mDDB
protected

Reference to the database object.

Definition at line 65 of file VprExporter.hpp.

TileCol torc::architecture::VprExporter::mMaxTileCol
protected

Maximum column bounds.

Definition at line 77 of file VprExporter.hpp.

TileRow torc::architecture::VprExporter::mMaxTileRow
protected

Maximum row bounds.

Definition at line 75 of file VprExporter.hpp.

TileCol torc::architecture::VprExporter::mMinTileCol
protected

Minimum column bounds.

Definition at line 73 of file VprExporter.hpp.

TileRow torc::architecture::VprExporter::mMinTileRow
protected

Minimum row bounds.

Definition at line 71 of file VprExporter.hpp.

const Segments& torc::architecture::VprExporter::mSegments
protected

Reference to the database Segments object.

Definition at line 69 of file VprExporter.hpp.

fstream torc::architecture::VprExporter::mStream
protected

Output file stream for VPR data.

Definition at line 79 of file VprExporter.hpp.

const Tiles& torc::architecture::VprExporter::mTiles
protected

Reference to the database Tiles object.

Definition at line 67 of file VprExporter.hpp.


The documentation for this class was generated from the following files: