torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Virtex.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 Virtex 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  const char* Virtex::sPacketTypeName[ePacketTypeCount] = {
33  "[UNKNOWN TYPE 0]", "TYPE1", "TYPE2", "[UNKNOWN TYPE 3]", "[UNKNOWN TYPE 4]",
34  "[UNKNOWN TYPE 5]", "[UNKNOWN TYPE 6]", "[UNKNOWN TYPE 7]"
35  };
36 
37  /// \see configuration data: XAPP151, v1.7, October 20, 2004, Figure 12.
38  const char* Virtex::sOpcodeName[eOpcodeCount] = {
39  "[UNKNOWN OP 0]", "READ", "WRITE", "[UNKNOWN OP 3]"
40  };
41 
42  const char* Virtex::sRegisterName[eRegisterCount] = {
43  "CRC", "FAR", "FDRI", "FDRO", "CMD", "CTL", "MASK", "STAT", "LOUT", "COR", "[UNKNOWN REG 0]", "FLR"
44  };
45 
46  const char* Virtex::sCommandName[eCommandCount] = {
47  "[UNKNOWN CMD 0]", "WCFG", "", "LFRM", "RCFG", "START", "RCAP", "RCRC", "AGHIGH", "SWITCH"
48  };
49 
50 #define VALUES (const char*[])
51 
52  /// \see Configuration Options Register Description: XAPP151, v1.7, October 20, 2004, Table 20.
53  const Bitstream::Subfield Virtex::sCOR[] = {
54  {0x00000007, 0, "GSR_cycle", "GSR_CYCLE", 5,
55  // bitgen: 6, 1, 2, 3, 4, 5, Done, Keep
56  // config: 001:"2", 010:"3", 011:"4", 100:"5", 101:"6"
57  VALUES{"[UNDEFINED 0]", "2", "3", "4", "5", "6", "[UNDEFINED 6]", "[UNDEFINED 7]", 0}},
58  {0x00000038, 3, "GWE_cycle", "GWE_CYCLE", 5,
59  // bitgen: 6, 1, 2, 3, 4, 5, Done, Keep
60  // config: 001:"2", 010:"3", 011:"4", 100:"5", 101:"6"
61  VALUES{"[UNDEFINED 0]", "2", "3", "4", "5", "6", "[UNDEFINED 6]", "[UNDEFINED 7]", 0}},
62  {0x000001c0, 6, "GTS_cycle", "GTS_CYCLE", 4,
63  // bitgen: 5, 1, 2, 3, 4, 6, Done, Keep
64  // config: 000:"1", 001:"2", 010:"3", 011:"4", 100:"5", 101:"6"
65  VALUES{"[UNDEFINED 0]", "2", "3", "4", "5", "6", "[UNDEFINED 6]", "[UNDEFINED 7]", 0}},
66  {0x00000e00, 9, "LCK_cycle", "LCK_CYCLE", 7,
67  // bitgen: NoWait, 0, 1, 2, 3, 4, 5, 6
68  // config: 000:"1", 001:"2", 010:"3", 011:"4", 100:"5", 101:"6", 111:"NO_WAIT"
69  VALUES{"1", "2", "3", "4", "5", "6", "[UNDEFINED 6]", "NoWait", 0}},
70  {0x00007000, 12, "DONE_cycle", "DONE_CYCLE", 3,
71  // bitgen: 4, 1, 2, 3, 5, 6
72  // config: 001:"2", 010:"3", 011:"4", 100:"5", 101:"6"
73  VALUES{"[UNDEFINED 0]", "2", "3", "4", "5", "6", "[UNDEFINED 6]", "[UNDEFINED 7]", 0}},
74  {0x00008000, 15, "", "SHUTDOWN", 0,
75  // config: 0:"Startup", 1:"Shutdown sequence"
76  VALUES{"0", "1", 0}},
77  {0x000f0000, 16, "", "LOCK_WAIT", 0,
78  // config: 000:"bottom-right", 001:"bottom-left", 010:"top-right", 011:"top-left"
79  VALUES{"1", "2", "3", "4", 0}},
80  {0x00300000, 20, "StartupClk", "SSCLKSRC", 0,
81  // bitgen: Cclk, UserClk, JtagClk
82  // config: 00:"CCLK", 01:"UserClk", 1x:"JTAGClk"
83  VALUES{"Cclk", "UserClk", "JtagClk", "JtagClk", 0}},
84  {0x0fc00000, 22, "ConfigRate", "OSCFSEL", 2,
85  // bitgen: 4, 5, 7, 8, 9, 10, 13, 15, 20, 26, 30, 34, 41, 45, 51, 55, 60
86  // config: values undefined
87  VALUES{
88  "[UNKNOWN 0]", "[UNKNOWN 1]", "[UNKNOWN 2]", "[UNKNOWN 3]",
89  "[UNKNOWN 4]", "[UNKNOWN 5]", "[UNKNOWN 6]", "[UNKNOWN 7]",
90  "[UNKNOWN 8]", "[UNKNOWN 9]", "[UNKNOWN 10]", "[UNKNOWN 11]",
91  "[UNKNOWN 12]", "[UNKNOWN 13]", "[UNKNOWN 14]", "[UNKNOWN 15]",
92  "[UNKNOWN 16]", "[UNKNOWN 17]", "[UNKNOWN 18]", "[UNKNOWN 19]",
93  "[UNKNOWN 20]", "[UNKNOWN 21]", "[UNKNOWN 22]", "[UNKNOWN 23]",
94  "[UNKNOWN 24]", "[UNKNOWN 25]", "[UNKNOWN 26]", "[UNKNOWN 27]",
95  "[UNKNOWN 28]", "[UNKNOWN 29]", "[UNKNOWN 30]", "[UNKNOWN 31]",
96  0}},
97  {0x10000000, 28, "Capture", "SINGLE", 0,
98  // bitgen: n/a -- this comes from the CAPTURE site ONESHOT setting
99  // config: 0:"Readback is not single-shot", 1:"Readback is single-shot"
100  VALUES{"Continuous", "OneShot", 0}},
101  {0x20000000, 29, "DriveDone", "DRIVE_DONE", 0,
102  // bitgen: No, Yes
103  // config: 0:"DONE pin is open drain", 1:"DONE is actively driven high"
104  VALUES{"No", "Yes", 0}},
105  {0x40000000, 30, "DonePipe", "DONE_PIPE", 0,
106  // bitgen: No, Yes
107  // config: 0:"No pipeline stage for DONEIN", 1:"Add pipeline stage for DONEIN"
108  VALUES{"No", "Yes", 0}},
109  {0, 0, 0, 0, 0, 0}
110  };
111 
112  /// \see Status Register Description: XAPP151, v1.7, October 20, 2004, Table 25.
113  /// \note The "bitgen" names attempt to mimic the general bitgen convention.
114  const Bitstream::Subfield Virtex::sSTAT[] = {
115  {0x00000001, 0, "CRC_error", "CRC_ERROR", 0,
116  // bitgen: n/a
117  // config: 0:"No CRC error", 1:"CRC error"
118  VALUES{"No", "Yes", 0}},
119  {0x00000002, 1, "TR_locked", "TR_LOCK", 0,
120  // TR - top right
121  // bitgen: n/a
122  // config: 0:"TR not locked", 1:"TR locked"
123  VALUES{"0", "1", 0}},
124  {0x00000004, 2, "TL_locked", "TL_LOCK", 0,
125  // TL - top left
126  // bitgen: n/a
127  // config: 0:"TL not locked", 1:"TL locked"
128  VALUES{"0", "1", 0}},
129  {0x00000008, 3, "BR_locked", "BR_LOCK", 0,
130  // BR - bottom right
131  // bitgen: n/a
132  // config: 0:"BR locked", 1:"BR locked
133  VALUES{"0", "1", 0}},
134  {0x00000010, 4, "BL_locked", "BL_LOCK", 0,
135  // BL - bottom left
136  // bitgen: n/a
137  // config: 0:"BL locked", 1:"BL locked"
138  VALUES{"No", "Yes", 0}},
139  {0x00000020, 5, "IN_error", "IN_ERROR", 0,
140  // bitgen: n/a
141  // config: 0:"Not In Error", 1:"In Error"
142  VALUES{"0", "1", 0}},
143  {0x00000040, 6, "GTS_cfg", "GTS_CFG", 0,
144  // bitgen: n/a
145  // config: 0:"I/O's tri-stated", 1:"I/O's not tri-stated"
146  VALUES{"0", "1", 0}},
147  {0x00000080, 7, "GWE_B", "GWE_B", 0,
148  // bitgen: n/a
149  // config: 0:"FF & BRAM are write enabled", 1:"FF & BRAM are write disabled"
150  VALUES{"0", "1", 0}},
151  {0x00000100, 8, "GSR_B", "GSR_B", 0,
152  // bitgen: n/a
153  // config: 0:"all FFs are Reset/Set", 1:"all FFs are not Reset/set"
154  VALUES{"0", "1", 0}},
155  {0x00000200, 9, "GHIGH_B", "GHIGH_B", 0,
156  // bitgen: n/a
157  // config: 0:"GHIGH_B asserted", 1:"GHIGH_B not asserted"
158  VALUES{"0", "1", 0}},
159  {0x000001c0, 10, "MODE", "MODE", 0,
160  // bitgen: n/a
161  // config: Status of the MODE pins (M2:M0)
162  VALUES{"MasterSerial", "SlaveSelectMap32", "[UNDEFINED 2]", "MasterSelectMap",
163  "[UNDEFINED 3]", "JTAG", "SlaveSelectMap8", "[UNDEFINED 6]", "SlaveSerial", 0}},
164  {0x00002000, 13, "INIT", "INIT", 0,
165  // bitgen: n/a
166  // config: Value on INIT pin
167  VALUES{"Deasserted", "Asserted", 0}},
168  {0x00004000, 14, "DONE", "DONE", 0,
169  // bitgen: n/a
170  // config: Value on DONE pin
171  VALUES{"NotDone", "Done", 0}},
172  {0, 0, 0, 0, 0, 0}
173  };
174 
175  /// \see Status Register Description: XAPP151, v1.7, October 20, 2004, Table 23.
176  const Bitstream::Subfield Virtex::sCTL[] = {
177  {0x00000001, 0, "GTS_USER_B", "GTS_USER_B", 0,
178  // bitgen: n/a?
179  // config: 0:"I/Os placed in high-Z state", 1:"I/Os active"
180  VALUES{"IoDisabled", "IoActive", 0}},
181  {0x00000040, 6, "Persist", "PERSIST", 0,
182  // bitgen: No, Yes
183  // config: 0:"No (default)", 1:"Yes"
184  VALUES{"No", "Yes", 0}},
185  {0x00000180, 7, "Security", "SBITS", 0,
186  // bitgen: None, Level1, Level2
187  // config: 00:"Read/Write OK (default)", 01:"Readback disabled", 1x:"Readback disabled,
188  // writing disabled except CRC register."
189  VALUES{"None", "Level1", "Level2", "Level2", 0}},
190  {0, 0, 0, 0, 0, 0}
191  };
192 
193  /// \see Control Mask Register Description: Inferred from Table 23.
194  const Bitstream::Subfield Virtex::sMASK[] = {
195  {0x00000001, 0, "GTS_USER_B", "GTS_USER_B", 0, VALUES{"Protected", "Writable", 0}},
196  {0x00000040, 6, "Persist", "PERSIST", 0, VALUES{"Protected", "Writable", 0}},
197  {0x00000180, 7, "Security", "SBITS", 0,
198  VALUES{"Protected", "[UNKNOWN 1]", "[UNKNOWN 2]", "Writable", 0}},
199  {0, 0, 0, 0, 0, 0}
200  };
201 
202  /// \brief Return the masked value for a subfield of the specified register.
203  uint32_t Virtex::makeSubfield(ERegister inRegister, const std::string& inSubfield,
204  const std::string& inSetting) {
205  const Subfield* subfields;
206  switch(inRegister) {
207  case eRegisterCOR: subfields = sCOR; break;
208  case eRegisterSTAT: subfields = sSTAT; break;
209  case eRegisterCTL: subfields = sCTL; break;
210  case eRegisterMASK: subfields = sMASK; break;
211  default: return 0;
212  }
213  for(uint32_t field = 0; subfields[field].mMask != 0; field++) {
214  const Subfield& subfield = subfields[field];
215  if(inSubfield != subfield.mBitgenName && inSubfield != subfield.mConfigGuideName)
216  continue;
217  const char** ptr = subfield.mValues;
218  for(uint32_t i = 0; *ptr != 0; i++, ptr++) {
219  if(inSetting == *ptr) return (i << subfield.mShift) & subfield.mMask;
220  }
221  }
222  return 0;
223  }
224 
225 
226 //#define GENERATE_STATIC_DEVICE_INFO
227 #ifndef GENERATE_STATIC_DEVICE_INFO
228 
229  extern DeviceInfo xcv50;
230  extern DeviceInfo xcv100;
231  extern DeviceInfo xcv150;
232  extern DeviceInfo xcv200;
233  extern DeviceInfo xcv300;
234  extern DeviceInfo xcv400;
235  extern DeviceInfo xcv600;
236  extern DeviceInfo xcv800;
237  extern DeviceInfo xcv1000;
238 
239  void Virtex::initializeDeviceInfo(const std::string& inDeviceName) {
240  using namespace torc::common;
241  switch(mDevice) {
242  case eXCV50: setDeviceInfo(xcv50); break;
243  case eXCV100: setDeviceInfo(xcv100); break;
244  case eXCV150: setDeviceInfo(xcv150); break;
245  case eXCV200: setDeviceInfo(xcv200); break;
246  case eXCV300: setDeviceInfo(xcv300); break;
247  case eXCV400: setDeviceInfo(xcv400); break;
248  case eXCV600: setDeviceInfo(xcv600); break;
249  case eXCV800: setDeviceInfo(xcv800); break;
250  case eXCV1000: setDeviceInfo(xcv1000); break;
251  default: break;
252  }
253  //setRowCounts(inDeviceName);
254  }
255 
256 #else
257 
258  void Virtex::initializeDeviceInfo(const std::string& inDeviceName) {
259 
265 
266  // look up the device tile map
267  torc::architecture::DDB ddb(inDeviceName);
268  const torc::architecture::Tiles& tiles = ddb.getTiles();
269  uint32_t tileCount = tiles.getTileCount();
270  uint16_t rowCount = tiles.getRowCount();
271  uint16_t colCount = tiles.getColCount();
272  ColumnTypeVector columnTypes;
273 
274  // set up the tile index and name mappings, and the index to column def mapping
275  typedef std::map<TileTypeIndex, std::string> TileTypeIndexToName;
276  typedef std::map<std::string, TileTypeIndex> TileTypeNameToIndex;
277  TileTypeIndexToName tileTypeIndexToName;
278  TileTypeNameToIndex tileTypeNameToIndex;
279  TileTypeCount tileTypeCount = tiles.getTileTypeCount();
280  for(TileTypeIndex tileTypeIndex(0); tileTypeIndex < tileTypeCount; tileTypeIndex++) {
281  const std::string tileTypeName = tiles.getTileTypeName(tileTypeIndex);
282  tileTypeIndexToName[tileTypeIndex] = tileTypeName;
283  tileTypeNameToIndex[tileTypeName] = tileTypeIndex;
284  TileTypeNameToColumnType::iterator ttwp = mTileTypeNameToColumnType.find(tileTypeName);
285  TileTypeNameToColumnType::iterator ttwe = mTileTypeNameToColumnType.end();
286  if(ttwp != ttwe) mTileTypeIndexToColumnType[tileTypeIndex] = EColumnType(ttwp->second);
287  }
288 
289  // identify every column that contains known frames
290  columnTypes.resize(colCount);
291  uint32_t frameCount = 0;
292  for(uint32_t blockType = 0; blockType < Virtex::eFarBlockTypeCount; blockType++) {
293  for(TileCol col; col < colCount; col++) {
294  bool found = false;
295  columnTypes[col] = eColumnTypeEmpty;
296  TileTypeIndexToColumnType::iterator ttwe = mTileTypeIndexToColumnType.end();
297  TileTypeIndexToColumnType::iterator ttwp = ttwe;
298  for(TileRow row; row < rowCount; row++) {
299  // look up the tile info
300  const torc::architecture::TileInfo& tileInfo
301  = tiles.getTileInfo(tiles.getTileIndex(row, col));
302  TileTypeIndex tileTypeIndex = tileInfo.getTypeIndex();
303  // determine whether the tile type widths are defined
304  ttwp = mTileTypeIndexToColumnType.find(tileTypeIndex);
305  if(ttwp != ttwe) {
306  uint32_t width = mColumnDefs[ttwp->second][blockType];
307  frameCount += width;
308  //std::cout << " " << tiles.getTileTypeName(tileInfo.getTypeIndex())
309  //<< ": " << width << " (" << frameCount << ")" << std::endl;
310  columnTypes[col] = static_cast<EColumnType>(ttwp->second);
311  found = true;
312  break;
313  }
314  }
315  (void) found;
316  }
317  //std::cout << std::endl;
318  if(blockType == 2) break;
319  }
320 
322  boost::filesystem::path generatedMap = workingPath / (inDeviceName + ".map.csv");
323  std::fstream tilemapStream(generatedMap.string().c_str(), std::ios::out);
324  for(TileRow row; row < rowCount; row++) {
325  for(TileCol col; col < colCount; col++) {
326  const torc::architecture::TileInfo& tileInfo
327  = tiles.getTileInfo(tiles.getTileIndex(row, col));
328  TileTypeIndex tileTypeIndex = tileInfo.getTypeIndex();
329  tilemapStream << tiles.getTileTypeName(tileTypeIndex);
330  if(col + 1 < colCount) tilemapStream << ",";
331  }
332  tilemapStream << std::endl;
333  }
334  tilemapStream.close();
335 
336  // update bitstream device information
337  setDeviceInfo(DeviceInfo(tileCount, rowCount, colCount, columnTypes));
338  // update the frame length
339  }
340 
341 #endif
342 
344 
345  bool debug = 0;
346  int center = 0;
347  int frameIndex = 0;
348  int frameCount = 0;
349  int farMajor = 0;
350  int width = 0;
351  ColumnIndex col;
352  for(uint32_t i = 0; i < Virtex::eFarBlockTypeCount; i++) {
353  farMajor = 0;
354  EFarBlockType blockType = Virtex::EFarBlockType(i);
355  mFrameIndexBounds = 0;
356  //Set first frame index to 0
357  uint32_t bitIndex = 0;
358  uint32_t xdlIndex = 0;
359  mBitColumnIndexes[i].push_back(bitIndex);
360  mXdlColumnIndexes[i].push_back(xdlIndex);
361  uint16_t finalColumn = mDeviceInfo.getColCount()-1;
362  uint32_t xdlColumnCount = 0;
363  uint32_t bitColumnCount = 0;
364  // Clock Column at the middle
365  center = mDeviceInfo.getColCount() / 2;
366  col = center;
367  prepareFrames(col, frameCount, frameIndex, blockType, farMajor, width);
368  int numBrams = 2;
369  int numIobs = 2;
370  int numClocks = 1;
371  int numClbs = mDeviceInfo.getColCount() - numClocks - numBrams - numIobs;
372  // CLB Columns alternate around the clock column
373  for(int j = 1; j <= numClbs / 2; j++) {
374  for(int k = -1; k < 2; k += 2) {
375  col = center - (j * k);
376  prepareFrames(col, frameCount, frameIndex, blockType, farMajor, width);
377  //Indexes for Bitstream Columns, only stores non-empty tile types
379  mXdlColumnToBitColumn[bitColumnCount] = xdlColumnCount;
380  bitColumnCount++;
381  bitIndex += width;
382  mBitColumnIndexes[i].push_back(bitIndex);
383  if(col == finalColumn) {
384  bitIndex += mColumnDefs[mDeviceInfo.getColumnTypes()[col]][i];
385  mBitColumnIndexes[i].push_back(bitIndex);
386  }
387  }
388  //Indexes for XDL Columns, stores interconnect and tile indexes for
389  //non-empty tiles
390  xdlIndex += width;
391  mXdlColumnIndexes[i].push_back(xdlIndex);
392  xdlColumnCount++;
393  if(col == finalColumn)
394  {
395  xdlIndex += mColumnDefs[mDeviceInfo.getColumnTypes()[col]][i];
396  mXdlColumnIndexes[i].push_back(xdlIndex);
397  }
398  }
399  }
400  // IOB Columns alternate after the CLB's
401  for(int j = center; j < (center + 1); j++) {
402  for(int k = -1; k < 2; k += 2) {
403  col = center - (j * k);
404  prepareFrames(col, frameCount, frameIndex, blockType, farMajor, width);
405  //Indexes for Bitstream Columns, only stores non-empty tile types
407  mXdlColumnToBitColumn[bitColumnCount] = xdlColumnCount;
408  bitColumnCount++;
409  bitIndex += width;
410  mBitColumnIndexes[i].push_back(bitIndex);
411  if(col == finalColumn) {
412  bitIndex += mColumnDefs[mDeviceInfo.getColumnTypes()[col]][i];
413  mBitColumnIndexes[i].push_back(bitIndex);
414  }
415  }
416  //Indexes for XDL Columns, stores interconnect and tile indexes for
417  //non-empty tiles
418  xdlIndex += width;
419  mXdlColumnIndexes[i].push_back(xdlIndex);
420  xdlColumnCount++;
421  if(col == finalColumn)
422  {
423  xdlIndex += mColumnDefs[mDeviceInfo.getColumnTypes()[col]][i];
424  mXdlColumnIndexes[i].push_back(xdlIndex);
425  }
426  }
427  }
428  // BRAM Columns alternate after the IOB's
429  for(int j = (center - 1); j < center; j++) {
430  for(int k = -1; k < 2; k += 2) {
431  col = center - (j * k);
432  prepareFrames(col, frameCount, frameIndex, blockType, farMajor, width);
433  //Indexes for Bitstream Columns, only stores non-empty tile types
435  mXdlColumnToBitColumn[bitColumnCount] = xdlColumnCount;
436  bitColumnCount++;
437  bitIndex += width;
438  mBitColumnIndexes[i].push_back(bitIndex);
439  if(col == finalColumn) {
440  bitIndex += mColumnDefs[mDeviceInfo.getColumnTypes()[col]][i];
441  mBitColumnIndexes[i].push_back(bitIndex);
442  }
443  }
444  //Indexes for XDL Columns, stores interconnect and tile indexes for
445  //non-empty tiles
446  xdlIndex += width;
447  mXdlColumnIndexes[i].push_back(xdlIndex);
448  xdlColumnCount++;
449  if(col == finalColumn)
450  {
451  xdlIndex += mColumnDefs[mDeviceInfo.getColumnTypes()[col]][i];
452  mXdlColumnIndexes[i].push_back(xdlIndex);
453  }
454  }
455  }
456  //stores frame index bounds for each block type
458  if(debug) std::cout << "***Block frame index bounds: " << mBlockFrameIndexBounds[i] << std::endl;
459  }
460  //Test to check proper indexing
461  if(debug) {
462  for(uint32_t i = 0; i < Virtex::eFarBlockTypeCount; i++) {
463  for(uint32_t j = 0; j < mBitColumnIndexes[i].size(); j++)
464  std::cout << "Bit Value at index: (" << i << ", " << j << ") : " << mBitColumnIndexes[i][j] << std::endl;
465  for(uint32_t k = 0; k < mXdlColumnIndexes[i].size(); k++)
466  std::cout << "Xdl Value at index: (" << i << ", " << k << ") : " << mXdlColumnIndexes[i][k] << std::endl;
467  }
468  }
469  }
470 
471  void Virtex::prepareFrames(ColumnIndex &inCol, int &inFrameCount, int &inFrameIndex, EFarBlockType &inBlockType, int &inFarMajor, int &inWidth) {
472  inWidth = mColumnDefs[mDeviceInfo.getColumnTypes()[inCol]][inBlockType];
473  if(inWidth == 0) return;
474  inFrameCount += inWidth;
475  for(int farMinor = 0; farMinor < inWidth; farMinor++) {
476  Virtex::FrameAddress far(inBlockType, inFarMajor, farMinor);
477  //std::cout << inBlockType << "(" << inFarMajor << "," << farMinor << ")" << std::endl;
478  mFrameIndexToAddress[inFrameIndex] = far;
479  mFrameAddressToIndex[far] = inFrameIndex;
480  inFrameIndex++;
482  }
483  if(inWidth > 0) inFarMajor++;
484  return;
485  }
486 
487 
489  boost::shared_array<uint32_t> frameWords;
490  // walk the bitstream and extract all frames
491  Virtex::iterator p = begin();
492  Virtex::iterator e = end();
493  while(p < e) {
494  const VirtexPacket& packet = *p++;
495  if(packet.isType2() && packet.isWrite())
496  frameWords = packet.getWords();
497  }
498  uint32_t index = 0;
499  for(uint32_t i = 0; i < Bitstream::eBlockTypeCount; i++) {
500  // all frames of block type are extracted
501  for(uint32_t j = 0; j < mBlockFrameIndexBounds[i]; j++) {
503  (new VirtexFrame(getFrameLength(), &frameWords[index])));
504  index += getFrameLength();
505  }
506  }
507  }
508 
509 
511 
512  // index and extract frames
513  int32_t bitColumnIndex[inBlockCount];
514  int32_t bitColumnBound[inBlockCount];
515 
516  for(uint32_t i = 0; i < inBlockCount; i++) {
517  // column Index of given frame index
518  bitColumnIndex[i] = mBitColumnIndexes[i][inBitCol];
519  // frame bounds for given column type
520  bitColumnBound[i] = mColumnDefs[mDeviceInfo.getColumnTypes()[inBitCol]][i];
521  }
522  // extract the tile frames for the specified FAR
523  VirtexFrameBlocks frameBlocks;
524  for(uint32_t i = 0; i < inBlockCount; i++) {
525  int startIndex = bitColumnIndex[i];
526  for(int j = 0; j < bitColumnBound[i]; j++)
527  frameBlocks.mBlock[i].push_back(mFrameBlocks.mBlock[i][startIndex+j]);
528  }
529  return frameBlocks;
530  }
531 
533 
534  // index and extract frames
535  int32_t xdlColumnIndex[inBlockCount];
536  int32_t xdlColumnBound[inBlockCount];
537  for(uint32_t i = 0; i < inBlockCount; i++) {
538  // column Index of given frame index
539  xdlColumnIndex[i] = mXdlColumnIndexes[i][inXdlCol];
540  // frame bounds for given column type
541  xdlColumnBound[i] =
543  }
544  // extract the tile frames for the specified FAR
545  VirtexFrameBlocks frameBlocks;
546  for(uint32_t i = 0; i < inBlockCount; i++) {
547  int startIndex = xdlColumnIndex[i];
548  for(int j = 0; j < xdlColumnBound[i]; j++)
549  frameBlocks.mBlock[i].push_back(mFrameBlocks.mBlock[i][startIndex+j]);
550  }
551  return frameBlocks;
552  }
553 } // namespace bitstream
554 } // namespace torc
ColumnDefVector mColumnDefs
Column type widths.
DeviceInfo xcv1000
DeviceInfo xcv50
Encapsulation of a tile row in an unsigned 16-bit integer.
TileTypeNameToColumnType mTileTypeNameToColumnType
uint32_t mFrameIndexBounds
Frame index bounds count.
Definition: Virtex.hpp:220
ERegister
Configuration register enumeration.
Definition: Virtex.hpp:55
Encapsulation of a tile column in an unsigned 16-bit integer.
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
DeviceInfo xcv150
Header for the DirectoryTree class.
VirtexFrameBlocks mFrameBlocks
Input Frame blocks.
IndexVector mXdlColumnIndexes[Virtex::eFarBlockTypeCount]
Vector to store frame indexes of Bitstream columns.
Definition: Virtex.hpp:216
static const char * sOpcodeName[eOpcodeCount]
Packet opcode names.
Definition: Virtex.hpp:87
Frame< uint32_t > VirtexFrame
Virtex frame type.
Definition: Frame.hpp:104
const TileInfo & getTileInfo(TileIndex inTileIndex) const
Returns the TileInfo object for the specified tile.
Definition: Tiles.hpp:137
TileTypeIndexToColumnType mTileTypeIndexToColumnType
DeviceInfo xcv600
Static device information class for Xilinx bitstreams. This class facilitates the creation of frame ...
Definition: DeviceInfo.hpp:75
virtual void initializeDeviceInfo(const std::string &inDeviceName)
Initialize the device information.
Definition: Virtex.cpp:239
uint16_t getColCount(void) const
Returns the column count.
Definition: DeviceInfo.hpp:114
static const char * sRegisterName[eRegisterCount]
Configuration register names.
Definition: Virtex.hpp:89
DeviceInfo xcv800
virtual void initializeFrameMaps(void)
Initialize the maps between frame indexes and frame addresses. This is generally only useful for int...
Definition: Virtex.cpp:343
void prepareFrames(ColumnIndex &inCol, int &inFrameCount, int &inFrameIndex, EFarBlockType &inBlockType, int &inFarMajor, int &inWidth)
Definition: Virtex.cpp:471
TileCount getTileCount(void) const
Returns the tile count for this device.
Definition: Tiles.hpp:149
EDevice mDevice
Bitstream device enumeration.
std::string string
uint32_t mShift
The subfield LSB position.
const char * mConfigGuideName
The subfield name documented in the configuration guide.
boost::uint32_t uint32_t
Imported type name.
FrameAddressToIndex mFrameAddressToIndex
Map of frame addressee to frame indexes.
Definition: Virtex.hpp:212
uint32_t mMask
The subfield bit mask.
DeviceInfo xcv100
uint32_t mBlockFrameIndexBounds[Virtex::eFarBlockTypeCount]
Array to hold frame index boundaries for blocks.
Definition: Virtex.hpp:218
IndexVector mBitColumnIndexes[Virtex::eFarBlockTypeCount]
Vector to store frame indexes of XDL columns.
Definition: Virtex.hpp:214
DeviceInfo mDeviceInfo
Device information.
Tile map, tile type, and wire information for the family and device.
Definition: Tiles.hpp:36
std::map< uint32_t, uint32_t > mXdlColumnToBitColumn
Map of XDL column indexes to bitstream column indexes.
Definition: Virtex.hpp:222
FrameSet< FRAME_TYPE > mBlock[Bitstream::eBlockTypeCount]
FrameSets for each of the eight block types.
Definition: FrameSet.hpp:88
Encapsulation of a tile count in an unsigned 32-bit integer.
static const Subfield sCOR[]
Configuration Options Register (COR) subfields.
Definition: Virtex.hpp:93
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
const ColumnTypeVector & getColumnTypes(void) const
Returns the column type vector.
Definition: DeviceInfo.hpp:116
static const Subfield sMASK[]
Control Mask Register (MASK) subfields.
Definition: Virtex.hpp:99
VirtexFrameBlocks getBitstreamFrames(uint32_t inBlockCount, uint32_t inBitCol)
Returns frames for queried bitstream coordinates.
Definition: Virtex.cpp:510
boost::filesystem::path path
const TileTypeIndex & getTypeIndex(void) const
Returns the tile type index for this tile.
Definition: TileInfo.hpp:92
EFarBlockType
Frame Address Register block type constants.
Definition: Virtex.hpp:73
boost::shared_ptr< VirtexFrame > FrameSharedPtr
Shared pointer encapsulation of a Frame.
Definition: FrameSet.hpp:44
const char * mBitgenName
The subfield name documented in bitgen.
static const Subfield sSTAT[]
Status Register (STAT) subfields.
Definition: Virtex.hpp:95
Header for the Virtex class.
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.
const WordSharedArray getWords(void) const
brief Returns the raw packet words, including the header word.
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::uint32_t uint32_t
Imported type name.
Definition: Virtex.hpp:49
DeviceInfo xcv400
#define VALUES
Definition: Virtex.cpp:50
static const char * sPacketTypeName[ePacketTypeCount]
Packet type names.
Definition: Virtex.hpp:85
boost::uint16_t uint16_t
Imported type name.
Header for the DDB class.
virtual uint32_t getFrameLength(void) const
Return the frame length for the current device.
Definition: Virtex.hpp:181
Template base for encapsulated integers, to enforce strong typing.
void setDeviceInfo(const DeviceInfo &rhs)
Assign static device information for the current bitstream.
static const Subfield sCTL[]
Control Register (CTL) subfields.
Definition: Virtex.hpp:97
static uint32_t makeSubfield(ERegister inRegister, const std::string &inSubfield, const std::string &inSetting)
Return the masked value for a subfield of the specified register.
Definition: Virtex.cpp:203
DeviceInfo xcv300
Bitstream packet for Virtex class architectures.
void initializeFullFrameBlocks(void)
Loads full bitstream frames into block data structure.
Definition: Virtex.cpp:488
const char ** mValues
The allowable subfield values.
static const char * sCommandName[eCommandCount]
Configuration command names.
Definition: Virtex.hpp:91
DeviceInfo xcv200
VirtexFrameBlocks getXdlFrames(uint32_t inBlockCount, uint32_t inXdlCol)
Returns frames for queried xdl coordinates.
Definition: Virtex.cpp:532
TileIndex getTileIndex(TileRow inRow, TileCol inCol) const
Returns the tile index for the given [row,column] pair.
Definition: Tiles.hpp:161
EColumnType
Major column types.
Definition: Virtex.hpp:78
FrameIndexToAddress mFrameIndexToAddress
Map of frame indexes to frame addresses.
Definition: Virtex.hpp:210
Device database types for Xilinx architectures.