torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AssemblerLibGen.cpp
Go to the documentation of this file.
1 // Torc - Copyright 2013-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 /// \brief Implementation of class to encapsulate micro-bitstream library generation code
17 
18 #include "AssemblerLibGen.hpp"
19 #include <iostream>
20 #include <fstream>
21 #include <iomanip>
22 #include <ctime>
23 #include "torc/Physical.hpp"
24 #include "torc/Bitstream.hpp"
27 #include "../Assembler.hpp"
28 
29 namespace torc {
30 namespace bitstream {
31 
32 /// static const initialization
33 const char *AssemblerLibGen::sNameSeparator = "-";
34 const char *AssemblerLibGen::sConfigValueOff = "#OFF";
35 const char *AssemblerLibGen::sXdlExtension = ".xdl";
36 const char *AssemblerLibGen::sLibExtension = ".ldb";
37 
38 /// \brief Initialie function called from constructor
40  std::cout << "Initializing AssemblerLibGen object for family " << mDB.getFamilyName() << "... " << std::endl;
41  // Attach architecture family name to harness folder and check if it exists
43  if(!boost::filesystem::exists(mHarnessFolder)) {
44  std::cerr << "ERROR: Folder " << mHarnessFolder.string() << " does not exist" << std::endl;
45  throw -1;
46  }
47 
48  // Create xdl generation folders
50  boost::filesystem::create_directory(mXdlGenerationFolder);
51  boost::filesystem::create_directory(mXdlGenerationReferenceFolder);
52 
53  mLibraryFolder = torc::common::DirectoryTree::getExecutablePath() / "torc/bitstream/assembler/libraries";
54 
56 
57  std::cout << "Harness folder - " << mHarnessFolder.string() << std::endl;
58  std::cout << "Xdl generation folder - " << mXdlGenerationFolder.string() << std::endl;
59 }
60 
61 /// \brief Generate micro-Xdl for logic sites
63  std::cout << "Generating micro Xdls for Logic element..." << std::endl;
64  // Poplulate tile type to site types map
65  TileTypeToSiteTypeSet tileTypeToSiteType = getTileTypeToSiteTypeMap();
66  // Populate primitive name to structure map
68 
69  // Iterate through tile types and then site types
70  TileTypeToSiteTypeSet::const_iterator pTileTypes = tileTypeToSiteType.begin();
71  TileTypeToSiteTypeSet::const_iterator eTileTypes = tileTypeToSiteType.end();
72 
73  // For every tile type
74  while(pTileTypes != eTileTypes) {
75  //std::cout << " Tile type: " << pTileTypes->first << std::endl;
76  mCurTileType = pTileTypes->first;
77  std::set<std::string>::iterator pSites = pTileTypes->second.begin();
78  std::set<std::string>::iterator eSites = pTileTypes->second.end();
79  pTileTypes++;
80  while(pSites != eSites) {
81 
82  // look up the PrimitiveDef name and the PrimitiveStructureSharedPtr
83  std::string primitiveDefName = *pSites;
84  PrimitiveStructureSharedPtr primitiveStructurePtr =
85  primitiveStructures[primitiveDefName];
86  pSites++;
87  //std::cout << " Site type: " << primitiveDefName << std::endl;
88  // If the site type is to be supported
89  if(isSiteTypeSupported(primitiveDefName)) {
90 
91  // Get the designPtr for test harness for this site type
93  primitiveDefName);
94 
95  if(!harnessDesignPtr) {
96  std::cout << "WARNING: No harness design for site type " << primitiveDefName << std::endl;
97  continue;
98  }
99 
100  std::cout << "Tile: " << mCurTileType << " Site: " << primitiveDefName << std::endl;
101 
102  // Create the XDL file name (partial)
103  // XDL file is in the form <Family>-<TileType>-<SiteType>-<Config>-<Value>.xdl
104  std::stringstream ssXdlFileNamePartial;
105  ssXdlFileNamePartial << mDB.getFamilyName() << sNameSeparator << mCurTileType << sNameSeparator << primitiveDefName;
106 
107  if(isRambSite(primitiveDefName)) {
108  createRambBaseXdl(primitiveDefName, harnessDesignPtr);
109  }
110 
111  // For Dsp site, MASK and PATTER config have hex config value.
112  // The allowed values of these hex cofig are not present in Xdlrc and have to be created
113  if(isDspSite(primitiveDefName)) {
114  createHexConfigXdl("MASK", ssXdlFileNamePartial.str(), 12, harnessDesignPtr);
115  createHexConfigXdl("PATTERN", ssXdlFileNamePartial.str(), 12, harnessDesignPtr);
116  }
117 
118  // We know the design has only one instance. So, get the first one in the iterator.
119  torc::physical::InstanceSharedPtr harnessInstancePtr = *(harnessDesignPtr->instancesBegin());
120 
121  const torc::architecture::PrimitiveDef* primitiveDefPtr =
122  primitiveStructurePtr->getPrimitiveDefPtr();
123 
124  const PrimitiveElementArray& elements = primitiveDefPtr->getElements();
125  PrimitiveElementArray::const_iterator pElements = elements.begin();
126  PrimitiveElementArray::const_iterator eElements = elements.end();
127 
128  // Iterate over config settings/elements of the site
129  while(pElements != eElements) {
130  const torc::architecture::PrimitiveElement &element = *pElements++;
131  //std::cout << " " << element.getName() << std::endl << " " ;
132  // Cache the current setting of the element in harness design
133  std::string harnessConfigName;
134  std::string harnessConfigVal;
135  // We know harness XDL design has only one instance
136  harnessInstancePtr = *(harnessDesignPtr->instancesBegin());
137  harnessInstancePtr->getConfig(element.getName(), harnessConfigName, harnessConfigVal);
138 
139  // Ignore the route through elements
140  if(!primitiveStructurePtr->isRoutethrough(element)) {
141 
142  // Generate XDLs only if the element has a config to be set.
143  if(element.getCfgs().size() > 0) {
144 
145  // ToDo: Not all config setting require reference Xdl with harness as base. E.g. LUT configs.
146  // These configs can retain their setting and Xdls for them are not built up on harness.
147  createReferenceXdlForConfigSetting(element.getName(), harnessDesignPtr,
148  ssXdlFileNamePartial.str());
149 
150  // Generate XDL for each config of the element.
151  createXdlsForConfigSetting(element, primitiveStructurePtr, ssXdlFileNamePartial.str(),
152  harnessDesignPtr);
153  }
154  }
155 
156  // Store back the previous setting of the element in harness Design
157  harnessInstancePtr->setConfig(element.getName(), harnessConfigName, harnessConfigVal);
158 
159  }
160  }
161  }
162  }
163 
164 }
165 
166 /// \brief Generate XDL files for tiles supported for PIPs
168  std::cout << "Generating micro XDLs for routing PIPs..." << std::endl;
169  TileCount tileCount = mTiles.getTileCount();
170 
171  // Go over tiles supported for PIPs
172  std::vector<std::string> tilesSupported = getTilesSupportedForPips();
173  std::vector<std::string>::const_iterator pTiles = tilesSupported.begin();
174  std::vector<std::string>::const_iterator eTiles = tilesSupported.end();
175  while(pTiles != eTiles) {
176 
177  std::string currTileName = *pTiles++;
178  bool firstTile = true; //Torc doesn't handle first tile well. So ignore it.
179  for(TileIndex i; i < tileCount; i++) {
180  const TileInfo& tileInfo = mTiles.getTileInfo(i);
181  TileTypeIndex tileTypeIndex = tileInfo.getTypeIndex();
182  std::string tileTypeName = mTiles.getTileTypeName(tileTypeIndex);
183  if(tileTypeName.compare(currTileName) == 0) {
184  if(firstTile) {
185  firstTile = false;
186  continue;
187  } else {
188  exportTileSinks(i);
189  break;
190  }
191  }
192  }
193  }
194 
195 }
196 
197 
198 /// \brief Export all pips within the specified tile
200 
201  const TileInfo& tileInfo = mTiles.getTileInfo(inTileIndex);
202 
203  torc::architecture::xilinx::TileTypeIndex tileTypeIndex = tileInfo.getTypeIndex();
204 
205  std::cout << " Tile name: " << tileInfo.getName() << ", Tile type: "
206  << mTiles.getTileTypeName(tileTypeIndex) << std::endl;
207 
208  torc::architecture::xilinx::WireCount wireCount = mTiles.getWireCount(tileTypeIndex);
209 
210  // iterate through all the wires in the tile
211  for(torc::architecture::xilinx::WireIndex wireIndex /* implicitly initialized to 0 */; wireIndex < wireCount; wireIndex++) {
212  // join the tile index and the wire index into a "tilewire"
213  Tilewire source(inTileIndex, wireIndex);
214  // expand all of the sinks of interest in this tile
216  mDB.expandTilewireSinks(source, sinks, false, true, true, true);
217  if(sinks.empty())
218  continue;
219  // iterate over all of the pips that we have found
220  torc::architecture::TilewireVector::iterator p = sinks.begin();
221  torc::architecture::TilewireVector::iterator e = sinks.end();
222  while(p < e) {
223  // look up the sink tilewire
224  Tilewire sink = *p++;
225  exportSink(source, sink);
226  }
227  }
228 }
229 
230 /// \brief Export a single pip.
232 
233  ExtendedWireInfo source(mDB, inSource);
234  ExtendedWireInfo sink(mDB, inSink);
235 
236  std::stringstream ss;
237  ss << mDB.getFamilyName() << sNameSeparator << source.mTileTypeName << sNameSeparator << "routing" << sNameSeparator << source.mWireName << sNameSeparator << sink.mWireName;
238  std::string designName(ss.str());
239 
240  // ToDo: Should load a design for routing from harness folder
243 
244  string dummyInstName = "dummyInst";
245  string dummyInstSiteType = "SLICEL";
246  string dummyInstSiteLocation = "SLICE_X1Y1";
248  dummyInstName, dummyInstSiteType, "DUMMY", dummyInstSiteLocation);
249 
250  designPtr->addInstance(instancePtr);
251 
255  net->addPip(pip);
256 
258  "BQ");
260  "B4");
261  net->addSource(sourcePin);
262  net->addSink(sinkPin);
263 
264  designPtr->addNet(net);
265 
266  // export the created design
267  boost::filesystem::path xdlFilePath = mXdlGenerationFolder / designName.append(sXdlExtension);
268  std::fstream xdlExport(xdlFilePath.string().c_str(), std::ios_base::out);
269  torc::physical::XdlExporter fileExporter(xdlExport);
270  fileExporter(designPtr);
271  xdlExport.close();
272 }
273 
274 
275 /// \details A tile can contain more than one site. This functions returns a map
276 /// from tile type to set of contained site types
278 
279  TileTypeToSiteTypeSet tileTypeToSiteTypeMap;
281 
282  for(uint i = 0; i < allSites.getSize(); i++) {
283 
284  const torc::architecture::Site& site = allSites[i];
285  std::string siteType = site.getPrimitiveDefPtr()->getName();
286 
287  // Some sites can be instantiated via multiple primitives
288  // We are interested in one particular primitive only.
289  if(isRambSite(siteType))
290  siteType = getRambPrimaryPrimitive();
291 
292  TileIndex tileIndex = site.getTileIndex();
293  const TileInfo& tileInfo = mTiles.getTileInfo(tileIndex);
294  const std::string &tileType = mTiles.getTileTypeName(tileInfo.getTypeIndex());
295 
296  // There is no entry in map corresponding to this tile type
297  if(tileTypeToSiteTypeMap.find(tileType) == tileTypeToSiteTypeMap.end()) {
298  std::set<std::string> siteTypeSet;
299  // There are two slices contained in a tile. Micro bitstream for both the slices should be
300  // stored in library.
301  if(!isSlicelType(siteType)) {
302  siteTypeSet.insert(siteType);
303  } else {
304  string sliceEven = siteType + "E";
305  string sliceOdd = siteType + "O";
306  siteTypeSet.insert(sliceEven);
307  siteTypeSet.insert(sliceOdd);
308  }
309  tileTypeToSiteTypeMap.insert(std::pair<std::string, std::set<std::string> >(tileType,
310  siteTypeSet));
311  } else {
312  // There are 2 slices in a tile. The two sites should be treated differently.
313  if(!isSlicelType(siteType)) {
314  tileTypeToSiteTypeMap[tileType].insert(siteType);
315  } else {
316  string sliceEven = siteType + "E";
317  string sliceOdd = siteType + "O";
318  tileTypeToSiteTypeMap[tileType].insert(sliceEven);
319  tileTypeToSiteTypeMap[tileType].insert(sliceOdd);
320  }
321  }
322  }
323  return tileTypeToSiteTypeMap;
324 }
325 
326 /// \details Prints list of tile types and the site types in each of the tile types
328  TileTypeToSiteTypeSet::const_iterator p = tileTypeToSiteType.begin();
329  TileTypeToSiteTypeSet::const_iterator e = tileTypeToSiteType.end();
330  std::cout << "Tile type to Site type info:" << std::endl;
331  while(p != e) {
332  std::cout << " Tile: " << p->first << std::endl;
333  std::set<std::string>::iterator pSites = p->second.begin();
334  std::set<std::string>::iterator eSites = p->second.end();
335  while(pSites != eSites) {
336  std::cout << "\t" << *pSites;
337  pSites++;
338  }
339  std::cout << std::endl;
340  p++;
341  }
342 }
343 
344 
345 /// \details Every site type has a harness design which serves as base generating Xdl
346 /// for all configurations of the site type
348 
349  // Harness file name is of format <tile_type>-<site_type>.xdl
350  string harnessFileName = mCurTileType + sNameSeparator + inSiteType + sXdlExtension;
351  path harnessFilePath = mHarnessFolder / harnessFileName;
352 
353  DesignSharedPtr harnessDesignPtr;
354  std::ifstream fileStream(harnessFilePath.string().c_str());
355  if(!fileStream.good()) {
356  std::cerr << "Could not open file " << harnessFilePath.string() << std::endl;
357  return harnessDesignPtr;
358  }
360  importer(fileStream, harnessFilePath.string());
361 
362  fileStream.close();
363 
364  // Return the design pointer
365  harnessDesignPtr = importer.getDesignPtr();
366  return harnessDesignPtr;
367 }
368 
369 /// \details Returns reference config value for give config setting.
371  // if element present in the map of Element->ReferenceConfig, return it.
372  std::map<std::string, std::string>::const_iterator pElementConfigMap;
373  std::map<std::string, std::string>::const_iterator eElementConfigMap =
374  mReferenceConfigMap.end();
375  pElementConfigMap = mReferenceConfigMap.find(inConfigSetting);
376  if(pElementConfigMap != eElementConfigMap) {
377  return pElementConfigMap->second;
378  }
379  return string(sConfigValueOff);
380 }
381 
382 /// \details Return empty design with same metadata
384  DesignSharedPtr emptyDesign = torc::physical::Factory::newDesignPtr(inDesignPtr->getName(),
385  inDesignPtr->getDevice(), inDesignPtr->getPackage(), inDesignPtr->getSpeedGrade(),
386  inDesignPtr->getXdlVersion());
387 
388  return emptyDesign;
389 }
390 
391 /// \brief Set config value and create Xdl
392 void AssemblerLibGen::createXdlForGeneralConfigSetting(const string &inConfigSetting, const string &inConfigVal,
393  const string &inXdlFileNamePartial, DesignSharedPtr inHarnessDesignPtr) {
394 
395  std::string xdlFileName = inXdlFileNamePartial + sNameSeparator + inConfigVal + sXdlExtension;
396 
397  setConfigAndGenerateXdl(inConfigSetting, inConfigVal, xdlFileName, inHarnessDesignPtr);
398 }
399 
400 /// \breif Create Xdls for each config value of the config setting
402  PrimitiveStructureSharedPtr const inPrimitiveStructurePtr, const string &inXdlFileNamePartial,
403  DesignSharedPtr inHarnessDesignPtr) {
404 
405  std::string configSetting = inElement.getName();
406 
407  if(isCompoundSettingHead(inElement.getName())) {
408  createXdlForCompoundSettings(inElement, inXdlFileNamePartial, inPrimitiveStructurePtr, inHarnessDesignPtr);
409 // } // The use of orphan elements is still debatable
410 // else if(inPrimitiveStructurePtr->isOrphan(inElement) && inElement.getName() != "SYNC_ATTR" &&
411 // inElement.getName().substr(1) != "5FFSR") {
412 // createXdlForOrphanElements(inElement, inXdlFileNamePartial, inHarnessDesignPtr);
413  } else {
414 
415  std::string xdlFileNameConfig = inXdlFileNamePartial + sNameSeparator + configSetting;
416 
417  const torc::architecture::PrimitiveElement::StringSet &configs = inElement.getCfgs();
418  torc::architecture::PrimitiveElement::StringSet::const_iterator pConfigs = configs.begin();
419  torc::architecture::PrimitiveElement::StringSet::const_iterator eConfigs = configs.end();
420 
421  // Iterate over configs of the primitive
422  while(pConfigs != eConfigs) {
423 
424  if(inPrimitiveStructurePtr->isLUT(inElement, *pConfigs)) {
425  createXdlForLut(inElement, inXdlFileNamePartial, inHarnessDesignPtr);
426  } else {
427  createXdlForGeneralConfigSetting(inElement.getName(), *pConfigs, xdlFileNameConfig, inHarnessDesignPtr);
428  }
429 
430  pConfigs++;
431  }
432  }
433 }
434 
435 /// \details Create Xdl with just Ramb site instantiated.
436 void AssemblerLibGen::createRambBaseXdl(const string &inSiteType, DesignSharedPtr inHarnessDesignPtr) {
437  // Create XDL file name of the pattern <Family>-<TileType>-<SiteType>-<Element>-<Config>.xdl
438  std::stringstream ssXDLFileName;
439  ssXDLFileName << mDB.getFamilyName() << sNameSeparator << mCurTileType << sNameSeparator << inSiteType << sNameSeparator
440  << inSiteType << sNameSeparator << "BASE.xdl";
441  boost::filesystem::path xdlFilePath = mXdlGenerationFolder / ssXDLFileName.str();
442  std::fstream xdlExport(xdlFilePath.string().c_str(), std::ios::out);
443  torc::physical::XdlExporter fileExporter(xdlExport);
444  DesignSharedPtr emptyDesignPtr = createEmptyDesignWithSameMetadata(inHarnessDesignPtr);
445  // add a bram instance
446  // Add an empty instance of same site type and location
447  InstanceSharedPtr instancePtr = *(inHarnessDesignPtr->instancesBegin());
448 
449  InstanceSharedPtr emptyInstance = torc::physical::Factory::newInstancePtr(instancePtr->getName(),
450  instancePtr->getType(), instancePtr->getTile(), instancePtr->getSite(),
451  instancePtr->getBonding());
452 
453  emptyDesignPtr->addInstance(emptyInstance);
454 
455  fileExporter(emptyDesignPtr);
456  xdlExport.close();
457 
458 }
459 
460 /// \brief Create Xdl for configurations with values as hex string
461 void AssemblerLibGen::createHexConfigXdl(const string &inConfigSetting, const string &inXdlFileNamePartial, int inNumHexChars,
462  DesignSharedPtr inHarnessDesignPtr) {
463  // We know for Virtex 5 DSP's mask and pattern have 12 hex characters as config value.
464  long long configValNumber = 1;
465 
466  std::string siteTypeAndElement = inXdlFileNamePartial + sNameSeparator + inConfigSetting;
467 
468  std::stringstream xdlReferenceFileName;
469  xdlReferenceFileName << siteTypeAndElement << sXdlExtension;
470  createReferenceXdlForConfigSetting(inConfigSetting, inHarnessDesignPtr, inXdlFileNamePartial);
471 
472  for(int bitPosition = 0; bitPosition < inNumHexChars*4; bitPosition++) {
473  std::stringstream ssConfigVal;
474  ssConfigVal << std::setfill('0') << std::setw(inNumHexChars) << std::hex << configValNumber;
475 
476  std::stringstream xdlFileName;
477  xdlFileName << siteTypeAndElement << sNameSeparator << bitPosition << sXdlExtension;
478 
479  setConfigAndGenerateXdl(inConfigSetting, ssConfigVal.str(), xdlFileName.str(), inHarnessDesignPtr);
480 
481  configValNumber = configValNumber << 1;
482 
483  }
484 
485  // Set the config to default again
486  InstanceSharedPtr instancePtr = *(inHarnessDesignPtr->instancesBegin());
487  instancePtr->setConfig(inConfigSetting, "", getReferenceConfigValue(inConfigSetting));
488 }
489 
490 /// \brief Create Xdls for compound settings
491 void AssemblerLibGen::createXdlForCompoundSettings(const PrimitiveElement &inElement1, const string &inSiteType, PrimitiveStructureSharedPtr inPrimitiveStructurePtr, DesignSharedPtr inHarnessDesignPtr) {
492  std::vector<std::string> compoundElements = mCompoundSettingMap[inElement1.getName()];
493  // For now assume there is only on element in the vector, i.e. there is a compound
494  // setting with only two elements.
495  if(compoundElements.size() != 1) {
496  std::cerr << "WARNING: Compound setting with more than two elements not handled currently"
497  << std::endl;
498  } else {
499 
500  // Generate XDLs with all permutations of configs of the two elements
501  // The two element names will be concatenated to form a compound element name Element1Element2.
502  // Similarly two config settings will be concatenated to form a compound config name.
503  std::string element1Name = inElement1.getName();
504  std::string element2Name = compoundElements[0];
505  std::string compoundElementName = element1Name + element2Name;
506 
507  // Get the other element
508  int elementIndex = getElementIndexFromName(element2Name, inPrimitiveStructurePtr);
509 
510  if(elementIndex == -1) {
511  std::cerr << "WARNING: Compound setting " << element2Name << " not found" << std::endl;
512  return;
513  }
514 
515  const PrimitiveElement &element2 = inPrimitiveStructurePtr->getPrimitiveDefPtr()->getElements()[elementIndex];
516 
517  // Get the first instance
518  InstanceSharedPtr instancePtr = *(inHarnessDesignPtr->instancesBegin());
519 
520  // Store the 2nd elements harness config
521  std::string harnessConfig2Val, harnessConfig2Name;
522  instancePtr->getConfig(element2Name, harnessConfig2Name, harnessConfig2Val);
523 
524  // Set element1 OFF and generate harness
525  std::string referenceXdlFileName = inSiteType + sNameSeparator + compoundElementName + sXdlExtension;
526  instancePtr->setConfig(element1Name, "", getReferenceConfigValue(element1Name));
527  instancePtr->setConfig(element2Name, "", getReferenceConfigValue(element2Name));
528 
529  boost::filesystem::path referenceXDLFilePath = mXdlGenerationReferenceFolder / referenceXdlFileName;
530 
531  std::ofstream fileStream(referenceXDLFilePath.string().c_str());
532  if(!fileStream.good()) {
533  std::cerr << "Could not open file " << referenceXDLFilePath.string() << std::endl;
534  return;
535  }
536 
537  // Export design as XDL (create referene Xdl)
538  torc::physical::XdlExporter exporter(fileStream);
539  exporter(inHarnessDesignPtr);
540  fileStream.close();
541 
542  // Iterate over configs of 1st element
543  const PrimitiveElement::StringSet &configs1 = inElement1.getCfgs();
544  PrimitiveElement::StringSet::const_iterator pConfigs1 = configs1.begin();
545  PrimitiveElement::StringSet::const_iterator eConfigs1 = configs1.end();
546 
547  while(pConfigs1 != eConfigs1) {
548 
549  // Iterate over configs of 2nd element.
550  const PrimitiveElement::StringSet &configs2 = element2.getCfgs();
551  PrimitiveElement::StringSet::const_iterator pConfigs2 = configs2.begin();
552  PrimitiveElement::StringSet::const_iterator eConfigs2 = configs2.end();
553 
554  while(pConfigs2 != eConfigs2) {
555 
556  // Form the XDL file name
557  std::string compoundConfigName = *pConfigs1 + *pConfigs2;
558  std::string xdlFileName = inSiteType + sNameSeparator + compoundElementName
559  + sNameSeparator + compoundConfigName + sXdlExtension;
560 
561  // Set element1 config and generate primary XDL
562  instancePtr->setConfig(element1Name, "", *pConfigs1);
563  setConfigAndGenerateXdl(element2Name, *pConfigs2, xdlFileName, inHarnessDesignPtr);
564  pConfigs2++;
565  }
566 
567  pConfigs1++;
568  }
569 
570  // Set original value of element2
571  instancePtr->setConfig(element2Name, harnessConfig2Name, harnessConfig2Val);
572  }
573 }
574 
575 /// \brief Create Xdls for orphan elements with empty reference Xdl
577  const string &inXdlFileNamePartial,
578  DesignSharedPtr inHarnessDesignPtr) {
579 
580  std::string elementName = inElement.getName();
581  std::string siteTypeAndElem;
582  std::cout << "Found Orphan Element " << elementName << std::endl;
583  // Get and empty design with same metadata
584  DesignSharedPtr emptyDesign = createEmptyDesignWithSameMetadata(inHarnessDesignPtr);
585 
586  // Add an empty instance of same site type and location
587  InstanceSharedPtr instancePtr = *(inHarnessDesignPtr->instancesBegin());
588 
589  InstanceSharedPtr emptyInstance = torc::physical::Factory::newInstancePtr(instancePtr->getName(),
590  instancePtr->getType(), instancePtr->getTile(), instancePtr->getSite(),
591  instancePtr->getBonding());
592 
593  emptyDesign->addInstance(emptyInstance);
594 
595  createReferenceXdlForConfigSetting(elementName, emptyDesign, inXdlFileNamePartial);
596 
597  // Go over all the configs
598  const PrimitiveElement::StringSet &configs = inElement.getCfgs();
599  PrimitiveElement::StringSet::const_iterator pConfigs = configs.begin();
600  PrimitiveElement::StringSet::const_iterator eConfigs = configs.end();
601 
602  std::string xdlFileNameSetting = inXdlFileNamePartial + sNameSeparator + elementName;
603  // Iterate over configs of the primitive
604  while(pConfigs != eConfigs) {
605  std::string xdlFileName = xdlFileNameSetting + sNameSeparator + *pConfigs + sXdlExtension;
606  //std::cout << "\t\tConfig " << *pConfigs << ". File " << xdlFileName << std::endl;
607  setConfigAndGenerateXdl(elementName, *pConfigs, xdlFileName, emptyDesign);
608  pConfigs++;
609  }
610 
611 }
612 
613 /// \brief Create Xdl for Lut
614 void AssemblerLibGen::createXdlForLut(const torc::architecture::PrimitiveElement &inElement, const string &inXdlFileNameSitetype,
615  DesignSharedPtr inHarnessDesignPtr) {
616  std::string configSetting = inElement.getName();
617 
618 // std::cout << "Found a LUT " << configSetting << std::endl;
619 
620  DesignSharedPtr emptyDesign = createEmptyDesignWithSameMetadata(inHarnessDesignPtr);
621  InstanceSharedPtr instancePtr = *(inHarnessDesignPtr->instancesBegin());
622  InstanceSharedPtr emptyInstance = torc::physical::Factory::newInstancePtr(instancePtr->getName(),
623  instancePtr->getType(), instancePtr->getTile(), instancePtr->getSite(),
624  instancePtr->getBonding());
625  emptyDesign->addInstance(emptyInstance);
626 
627  // Generate reference XDL for LUT
628  createReferenceXdlForConfigSetting(configSetting, emptyDesign, inXdlFileNameSitetype);
629  string xdlFileNameSetting = inXdlFileNameSitetype + sNameSeparator + configSetting;
630 
631  const PrimitiveElementPinArray &pins = inElement.getPins();
634  //For every output-input pin combination
635  while(pPinsOut != ePinsOut) {
636 
637  // Handly only input Ax assigned to output O5/O6
638  if(pPinsOut->isOutput() && boost::iequals(pPinsOut->getName().substr(0, 1), "O")) {
639 
642 
643  while(pPinsIn != ePinsIn && boost::iequals(pPinsIn->getName().substr(0, 1), "A")) {
644  if(pPinsIn->isInput()) {
645 
646  std::string configVal = "#LUT:" + pPinsOut->getName() + "=" + pPinsIn->getName();
647  std::string xdlFileName = xdlFileNameSetting + sNameSeparator + configVal + sXdlExtension;
648  setConfigAndGenerateXdl(configSetting, configVal, xdlFileName, emptyDesign);
649  }
650  pPinsIn++;
651  }
652 
653  // Generate XDLs for output 1 also
654  std::string configVal = "#LUT:" + pPinsOut->getName() + "=" + "1";
655  std::stringstream xdlFileName1;
656  xdlFileName1 << xdlFileNameSetting << sNameSeparator << configVal << sXdlExtension;
657  setConfigAndGenerateXdl(configSetting, configVal, xdlFileName1.str(), emptyDesign);
658 
659  configVal = "#LUT:" + pPinsOut->getName() + "=" + "0";
660  std::stringstream xdlFileName0;
661  xdlFileName0 << xdlFileNameSetting << sNameSeparator << configVal << sXdlExtension;
662  setConfigAndGenerateXdl(configSetting, configVal, xdlFileName0.str(), emptyDesign);
663  }
664  pPinsOut++;
665  }
666 }
667 
668 /// \brief Create reference Xdl for given config setting
669 void AssemblerLibGen::createReferenceXdlForConfigSetting(const string &inConfigSetting, DesignSharedPtr inHarnessDesignPtr,
670  const string &inXdlFileNamePartial) {
671 
672  InstanceSharedPtr instancePtr = *(inHarnessDesignPtr->instancesBegin());
673  // If no instance found, just return
674  if(!instancePtr) {
675  std::cerr << "No instance found in the harness " << inHarnessDesignPtr->getName()
676  << std::endl;
677  return;
678  }
679 
680  // Set config value to #OFF for the given element
681  std::string referenceConfigValue = getReferenceConfigValue(inConfigSetting);
682  instancePtr->setConfig(inConfigSetting, "", referenceConfigValue);
683 
684  // Generate an reference XDL file for this element's custom harness
685  std::stringstream ssReferenceXdlFileName;
686  ssReferenceXdlFileName << inXdlFileNamePartial << sNameSeparator
687  << inConfigSetting << sXdlExtension;
688  boost::filesystem::path referenceXDLFilePath = mXdlGenerationReferenceFolder / ssReferenceXdlFileName.str();
689 
690  std::ofstream fileStream(referenceXDLFilePath.string().c_str());
691  if(!fileStream.good()) {
692  std::cerr << "Could not open file " << referenceXDLFilePath.string() << std::endl;
693  return;
694  }
695 
696  // Export design as XDL
697  torc::physical::XdlExporter exporter(fileStream);
698  exporter(inHarnessDesignPtr);
699  fileStream.close();
700 }
701 
702 /// \brief Set given config and generate Xdl
703 void AssemblerLibGen::setConfigAndGenerateXdl(const string &inConfigSetting, const string & inConfigValue,
704  const string &inXdlFileName, DesignSharedPtr inOutDesignPtr) {
705 
706  InstanceSharedPtr instancePtr = *(inOutDesignPtr->instancesBegin());
707 
708  instancePtr->setConfig(inConfigSetting, "", inConfigValue);
709  // create the appropriate file paths
710  path xdlFilePath = mXdlGenerationFolder / inXdlFileName;
711 
712  // Export the design as XDL
713  std::fstream xdlExport(xdlFilePath.string().c_str(), std::ios_base::out);
714  torc::physical::XdlExporter fileExporter(xdlExport);
715  fileExporter(inOutDesignPtr);
716 }
717 
718 /// \details Generates bitstream for all Xdls be calling a perl script which iterates over Xdls and
719 /// calls Xilinxs tools to create bitstream
721  // Call perl script to convert Xdl to Bitstream.
722  path buildFolder = torc::common::DirectoryTree::getExecutablePath() / "torc/bitstream/assembler/build";
723  string systemCommand = "perl " + buildFolder.string() + "/xdl2bit.pl " + mXdlGenerationFolder.string();
724  int systemReturn = system(systemCommand.c_str());
725  if(systemReturn != 0) {
726  std::cerr << "Error calling perl script xdl2bit.pl " << std::endl;
727  }
728  systemCommand = "perl " + buildFolder.string() + "/xdl2bit.pl " + mXdlGenerationReferenceFolder.string();
729  systemReturn = system(systemCommand.c_str());
730  if(systemReturn != 0) {
731  std::cerr << "Error calling perl script xdl2bit.pl " << std::endl;
732  }
733 }
734 
735 /// \brief Compress all Xilinx bitfiles in mXdlGenerationFolder
737  // Go over all the .bit files
738  // Go over all the files in the directory
739  boost::filesystem::directory_iterator eFiles;
740  boost::filesystem::directory_iterator pFiles(mXdlGenerationFolder);
741  while(pFiles != eFiles) {
742  // If it is a Xilinx bit file (.bit extension)
743  path filePath = pFiles->path();
744  pFiles++;
745  if(filePath.extension() == ".bit") {
746 
747  // Check if bit file in newer then compressed bit file
748  path cBitPath = filePath;
749  cBitPath.replace_extension(".cbit");
750  if(boost::filesystem::exists(cBitPath)) {
751  std::time_t bitFileModTime = boost::filesystem::last_write_time(filePath);
752  std::time_t cBitFileModTime = boost::filesystem::last_write_time(cBitPath);
753  // If compressed bit file modification time later than bitgen bit, continue
754  if(cBitFileModTime > bitFileModTime)
755  continue;
756  }
757 
758  // Check for reference file
759  // (Note: Wrapping filename() as a path for compatibility with Boost.Filesystem V2)
760  string referenceBitFileName
761  = boost::filesystem::path(filePath.filename()).string();
762  path referenceBitFilePath = mXdlGenerationReferenceFolder / referenceBitFileName;
763  if(!boost::filesystem::exists(referenceBitFilePath)) {
764  // Remove last part of Xdl file name (config value)
765  unsigned position = referenceBitFileName.find_last_of('-');
766  referenceBitFileName.replace(position, string::npos, ".bit");
767  referenceBitFilePath = mXdlGenerationReferenceFolder / referenceBitFileName;
768  if(!boost::filesystem::exists(referenceBitFilePath)) {
769  // Get null bitstream path
770  referenceBitFilePath = mLibraryFolder / "null_bitstreams" / mDB.getDeviceName();
771  referenceBitFilePath.replace_extension(".bit");
772 
773  }
774 
775  }
776  compressBitFile(filePath, referenceBitFilePath);
777  // std::cout << "Bitfile: " << filePath.filename() << ". Reference: " << referenceBitFilePath.filename() << std::endl;
778  }
779  }
780 
782 }
783 
784 
785 /// \details Stitch micro-bitstreams in folder mXdlGenerationFolder
786 /// Go over all files with extension .cbit, split file name on '-' to get family, tile type,
787 /// site type, config setting, and config value. The vector of address and names are
788 /// stored in map data structure and then stored in a file. File format is -
789 /// <<<<BITLIBDB>>>>
790 /// Number of tile types
791 /// Tile type name char count
792 /// Tile type
793 /// Number of sites
794 /// Site type name char count
795 /// Site type
796 /// Config seting name char count
797 /// Config setting
798 /// Config value name char count
799 /// Config value
800 /// Number of 32bit words in compressed bitstream
801 /// words
803  std::cout << "Stitching micro bitstream files..." << std::endl;
804  // Maps to store the information on tile type, elements and configs
805  std::vector<ConfigValuesToBits> configMapVector;
806  std::vector<ConfigSettingsToValues> settingsToValuesMap;
807  std::vector<SiteTypeToConfigSettings> siteToSettingsMap;
808  TileTypeToSiteType library;
809 
810  // Go over all the files in the directory
811  boost::filesystem::directory_iterator eFiles;
812  boost::filesystem::directory_iterator pFiles(mXdlGenerationFolder);
813  while(pFiles != eFiles) {
814 
815  // If it is a compressed bit file (.cbit extension)
816  if(pFiles->path().extension() == ".cbit") {
817 
818  std::ifstream libBitFile(pFiles->path().string().c_str(), std::ios::binary);
819  if(!libBitFile.good()) {
820  std::cerr << "ERROR: Could not open micro-bitstream file " << pFiles->path().string() << std::endl;
821  return;
822  }
823 
824  // Get number of bits set and put the bit addresses in a vector
825  int32_t numSetBits, bitAddr;
826  libBitFile.read((char *) &numSetBits, 4);
827  std::cout << "\t" << pFiles->path().filename() << " opened. Bit count " << numSetBits << std::endl;
828  std::vector<uint32_t> bitAddresses;
829  for(int i = 0; i < numSetBits && !libBitFile.eof(); i++) {
830  libBitFile.read((char *) &bitAddr, 4);
831  bitAddresses.push_back(bitAddr);
832  }
833 
834  // Get the file name without extension and split the name to get tile type, site type element/source wire and config/sink wire.
835  boost::filesystem::path filePath(pFiles->path());
836  // (Note: Wrapping filename() as a path for compatibility with Boost.Filesystem V2)
837  std::string fileName(boost::filesystem::path(filePath.replace_extension().filename()).string());
838 
839  std::vector<std::string> splitVector;
840  boost::algorithm::split(splitVector, fileName, boost::algorithm::is_any_of(sNameSeparator));
841 
842  // Get the tile type, element(source wire) and config (sink wire)from the split string
843  string tileType(splitVector[1]);
844  string siteType(splitVector[2]);
845  string configSetting(splitVector[3]);
846  string configValue(splitVector[4]);
847 
848  // if tile not found in map, a new tile type has come up. Add it to the map.
849  // Create another map for Element-config and push it in vector so that it is not destroyed.
850  if(library.find(tileType) == library.end()) {
851  SiteTypeToConfigSettings siteToSettings;
852  siteToSettingsMap.push_back(siteToSettings);
853  library[tileType] = siteToSettingsMap.back();
854  }
855 
856  // Check if site type is present in map
857  if(library[tileType].find(siteType) == library[tileType].end()) {
858  ConfigSettingsToValues settingToValues;
859  settingsToValuesMap.push_back(settingToValues);
860  library[tileType][siteType] = settingsToValuesMap.back();
861  }
862 
863  // Check if config setting is present in library
864  if(library[tileType][siteType].find(configSetting) == library[tileType][siteType].end()) {
865  ConfigValuesToBits valuesToBits;
866  configMapVector.push_back(valuesToBits);
867  library[tileType][siteType][configSetting] = configMapVector.back();
868  }
869 
870  // Mapping the config to bit addresses
871  library[tileType][siteType][configSetting][configValue] = bitAddresses;
872 
873  }
874 
875  pFiles++;
876  }
877 
878  saveLibraryMapToFile(library);
879 
880 }
881 
882 /// \brief Get word offset from Xdl
883 uint32_t AssemblerLibGen::getWordOffsetFromXdlFile(path inBitstreamPath, BitstreamSharedPtr inBitstreamPtr) {
884 
885  path xdlFilePath = inBitstreamPath.replace_extension(".xdl");
886  std::ifstream xdlStream(xdlFilePath.string().c_str());
887  if(!xdlStream.good()) {
888  std::cout << "File " << xdlFilePath.string() << " not found" << std::endl;
889  return 0;
890  }
891  torc::physical::XdlImporter xdlImporter;
892  xdlImporter(xdlFilePath);
893 
894  // Get design pointer and related data base
895  torc::physical::DesignSharedPtr designPtr = xdlImporter.getDesignPtr();
896 
897  torc::architecture::DDB ddb(designPtr->getDevice());
898  const Tiles &tiles = ddb.getTiles();
899 
902 
903  bool pipDesign = false;
904  // We know this XDL has only one NET and one PIP
905  if(designPtr->netsBegin() != designPtr->netsEnd()) {
906  torc::physical::NetSharedPtr netPtr = *(designPtr->netsBegin());
907  if(netPtr->pipsBegin() != netPtr->pipsEnd()) {
908  std::cout << "\tProcessing NET" << std::endl;
909  pipDesign = true;
910  torc::physical::Pip pip = *(netPtr->pipsBegin());
911  torc::architecture::xilinx::TileIndex tileIndex = tiles.findTileIndex(pip.getTileName());
912  const torc::architecture::TileInfo& tileInfo = tiles.getTileInfo(tileIndex);
913  tileRow = tileInfo.getRow();
914  tileCol = tileInfo.getCol();
915  }
916  }
917 
918  // If there is no pip, it is an XDL for logic element.
919  if(pipDesign == false) {
920  const Sites &sites = ddb.getSites();
921  torc::physical::InstanceSharedPtr instancePtr = *(designPtr->instancesBegin());
922  SiteIndex siteIndex = sites.findSiteIndex(instancePtr->getSite());
923  const Site& site = sites.getSite(siteIndex);
924 
925  // look up the site tile index
926  TileIndex tileIndex = site.getTileIndex();
927  const TileInfo& tileInfo = tiles.getTileInfo(tileIndex);
928  tileRow = tileInfo.getRow();
929  tileCol = tileInfo.getCol();
930  }
931 
932  return getWordOffsetFromTileLocation(tileRow, tileCol, inBitstreamPtr);
933 
934 }
935 
936 /// \brief Get index in Element array
937 int AssemblerLibGen::getElementIndexFromName(const string inElementName, PrimitiveStructureSharedPtr inPrimitiveStructurePtr) {
938  int elementIndex = -1, index = 0;
939  const PrimitiveElementArray& elementsArray = inPrimitiveStructurePtr->getPrimitiveDefPtr()->getElements();
940  PrimitiveElementArray::const_iterator pElements = elementsArray.begin();
941  PrimitiveElementArray::const_iterator eElements = elementsArray.end();
942 
943  // For every primitive element (BEL) in the site
944  while(pElements != eElements) {
945  if(pElements->getName().compare(inElementName) == 0) {
946  elementIndex = index;
947  break;
948  }
949  pElements++; index++;
950  }
951  return elementIndex;
952 }
953 
954 /// \details Saves the library map structure in database format
956 
958  path dbFilePath = mLibraryFolder / dbFileName;
959  std::ofstream dbFile(dbFilePath.string().c_str(), std::ofstream::binary);
960  if(!dbFile.is_open()) {
961  std::cout << "Could not open file " << dbFilePath.string() << " to write" << std::endl;
962  return;
963  }
964 
965  std::cout << "Storing combined micro-bitstream in " << dbFilePath.string() << std::endl;
966  dbFile.write("<<<<BITLIBDB>>>>", 16);
967 // std::cout << "Tile map size " << sizeof(tileMap.size()) << std::endl;
968  uint32_t dataSize;
969  dataSize = inLibrary.size();
970  dbFile.write((char *) (&dataSize), sizeof(dataSize));
971  std::cout << "Total tiles " << dataSize << std::endl;
972 
973  // Now go over the map data structure and write it to a file
974  // File format is given at the top of this file
975  TileTypeToSiteType::const_iterator pTiletypes = inLibrary.begin();
976  TileTypeToSiteType::const_iterator eTiletypes = inLibrary.end();
977  while(pTiletypes != eTiletypes) {
978  // Write the tile name char count, name string and element count
979  dataSize = pTiletypes->first.size();
980  dbFile.write((const char *) &dataSize, sizeof(dataSize));
981  dbFile.write((const char *) pTiletypes->first.c_str(), pTiletypes->first.size());
982  dataSize = pTiletypes->second.size();
983  dbFile.write((const char*) &dataSize, sizeof(dataSize));
984  std::cout << "Tile type " << pTiletypes->first << " has " << pTiletypes->second.size()
985  << " sites." << std::endl;
986 
987  // Iterate over elements
988  SiteTypeToConfigSettings::const_iterator pSiteTypes = pTiletypes->second.begin();
989  SiteTypeToConfigSettings::const_iterator eSiteTypes = pTiletypes->second.end();
990  while(pSiteTypes != eSiteTypes) {
991 
992  // Write site type name char count, name string and config setting count
993  dataSize = pSiteTypes->first.size();
994  dbFile.write((const char *) &dataSize, sizeof(dataSize));
995  dbFile.write((const char *) pSiteTypes->first.c_str(), pSiteTypes->first.size());
996  dataSize = pSiteTypes->second.size();
997  dbFile.write((const char *) &dataSize, sizeof(dataSize));
998 // std::cout << " Element type " << pSiteTypes->first << " has "
999 // << pSiteTypes->second.size() << " configs." << std::endl;
1000 
1001  // Itereate over configs
1002  ConfigSettingsToValues::const_iterator pConfigSettings = pSiteTypes->second.begin();
1003  ConfigSettingsToValues::const_iterator eConfigSettings = pSiteTypes->second.end();
1004  while(pConfigSettings != eConfigSettings) {
1005  // Write config namem char count, name string and count of bit addresses
1006  dataSize = pConfigSettings->first.size();
1007  dbFile.write((const char *) &dataSize, sizeof(dataSize));
1008  dbFile.write(pConfigSettings->first.c_str(), pConfigSettings->first.size());
1009  dataSize = pConfigSettings->second.size();
1010  dbFile.write((const char *) &dataSize, sizeof(dataSize));
1011 
1012  ConfigValuesToBits::const_iterator pConfigValues = pConfigSettings->second.begin();
1013  ConfigValuesToBits::const_iterator eConfigValues = pConfigSettings->second.end();
1014 
1015  while(pConfigValues != eConfigValues) {
1016 
1017  dataSize = pConfigValues->first.size();
1018  dbFile.write((const char *) &dataSize, sizeof(dataSize));
1019  dbFile.write(pConfigValues->first.c_str(), pConfigValues->first.size());
1020  dataSize = pConfigValues->second.size();
1021  dbFile.write((const char *) &dataSize, sizeof(dataSize));
1022  // Write the bit addresses
1023  for(std::vector<uint32_t>::const_iterator iter = pConfigValues->second.begin(); iter
1024  != pConfigValues->second.end(); iter++) {
1025  dbFile.write((char *) &*iter, sizeof(uint32_t));
1026  }
1027 // std::cout << "\t" << pConfigSettings->first << " " << pConfigSettings->second.size();
1028  pConfigValues++;
1029  }
1030  pConfigSettings++;
1031  }
1032 // std::cout << std::endl;
1033  pSiteTypes++;
1034  }
1035  pTiletypes++;
1036  }
1037 
1038  // Close file
1039  dbFile.close();
1040 
1041 }
1042 
1043 } // namepsace bitstream
1044 } // namespace torc
void generateWireXdls()
Generate Xdls for routing pips.
std::string string
Imported type name.
const char * mTileTypeName
The tile type name.
Encapsulation of a tile index in an unsigned 32-bit integer.
const TileCol & getCol(void) const
Returns the column for this tile.
Definition: TileInfo.hpp:96
torc::physical::InstanceSharedPtr InstanceSharedPtr
Imported type name.
const std::string dummyInstName
Encapsulation of a tile row in an unsigned 16-bit integer.
path mXdlGenerationFolder
Folder in which Xdls will be generated.
const const PrimitiveElement * const_iterator
Constant T iterator type.
Definition: Array.hpp:83
torc::bitstream::Assembler::ConfigValuesToBits ConfigValuesToBits
std::vector< Tilewire > TilewireVector
Vector of Tilewire objects.
Definition: Tilewire.hpp:101
const TileRow & getRow(void) const
Returns the row for this tile.
Definition: TileInfo.hpp:94
static const char * sLibExtension
.ldb
void createXdlForOrphanElements(const torc::architecture::PrimitiveElement &inElement, const string &inXdlFileNamePartial, DesignSharedPtr inHarnessDesignPtr)
Create Xdls for orphan elements with empty reference Xdl.
Encapsulation of a tile column in an unsigned 16-bit integer.
const string & getDeviceName(void) const
Returns the device name.
Definition: DDB.hpp:132
const PrimitiveDef * getPrimitiveDefPtr(void) const
Returns a pointer to the associated primitive definition.
Definition: Site.hpp:81
std::map< string, string > getDeviceToPackageMap()
Get a map from device to default package.
Device database, including complete wiring and logic support.
Definition: DDB.hpp:42
void printTileTypeToSiteTypeMapInfo(TileTypeToSiteTypeSet tileTypeToSiteType)
Print the tile type to site type information.
bool isRambSite(const string &inSiteType)
Returns true if input is a RAMB site.
const string & getFamilyName(void) const
Returns the family name.
Definition: DDB.hpp:134
const Sites & mSites
Sites from the database object.
Header for the Virtex5PrimitiveStructure class.
DesignSharedPtr getDesignPtr(void)
Returns a shared pointer for the design.
Header for the DirectoryTree class.
const char * mWireName
The wire name.
const TileInfo & getTileInfo(TileIndex inTileIndex) const
Returns the TileInfo object for the specified tile.
Definition: Tiles.hpp:137
Encapsulation of primitive site definition, with associated connections, elements, and pins.
T * end(void)
Returns the non-constant end iterator.
Definition: Array.hpp:97
const std::string dummyInstSiteType
void createXdlForGeneralConfigSetting(const string &inConfigSetting, const string &inConfigVal, const string &inXdlFileNamePartial, DesignSharedPtr inHarnessDesignPtr)
Set config value and create Xdl.
Main torc::bitstream namespace header.
void exportTileSinks(TileIndex inTileIndex)
Export all pips within the specified tile.
static NetSharedPtr newNetPtr(const string &inName, ENetType inNetType=eNetTypeNormal)
Create and return a new Net share pointer.
path mXdlGenerationReferenceFolder
Folder in which reference Xdls will be genered.
bool isSlicelType(const string &inSiteType)
Return true if site type is SLICEL.
Encapsulation of a wire index in an unsigned 16-bit integer.
static const char * sNameSeparator
Symbol to separate out parts of file name.
boost::shared_ptr< class InstancePin > InstancePinSharedPtr
Shared pointer encapsulation of an InstancePin.
TileCount getTileCount(void) const
Returns the tile count for this device.
Definition: Tiles.hpp:149
void setConfigAndGenerateXdl(const string &inConfigSetting, const string &inConfigValue, const string &inXdlFileName, DesignSharedPtr inOutDesignPtr)
Set given config and generate Xdl.
virtual void generateMemoryMicroBitstream()=0
Generate micro-bitstreams for memory elements like LUT in RAM mode.
int getElementIndexFromName(const string inElementName, PrimitiveStructureSharedPtr inPrimitiveStructurePtr)
Get index in Element array.
std::string string
uint32_t getWordOffsetFromXdlFile(path inBitstreamPath, BitstreamSharedPtr inBitstreamPtr)
Get word offset in frame for the site/pip in corresponding Xdl.
const string & getName(void) const
Returns the name of the element.
std::map< std::string, std::set< std::string > > TileTypeToSiteTypeSet
Typedef of map from tile type to set of site type.
void saveLibraryMapToFile(TileTypeToSiteType &inLibrary)
Save library map to file.
void expandTilewireSinks(const Tilewire &inTilewire, TilewireVector &outSinks, bool inUseTied=true, bool inUseRegular=true, bool inUseIrregular=true, bool inUseRoutethrough=true)
Expands the given tilewire's arc sinks.
Definition: DDB.cpp:214
virtual void compressBitFile(path primaryFile, path referenceFile)=0
Compress the diff of primary bitstream and reference bitstream.
PrimitiveElementPinArray & getPins(void)
Returns a non-constant array of element pins. This function should only be used by the Sites class d...
string getReferenceConfigValue(const string &inConfigSetting)
Return config value which results in off bit in bitstream.
void createRambBaseXdl(const string &inSiteType, DesignSharedPtr inHarnessDesignPtr)
Create Xdl with a Ramb instane and no configuration.
void exportSink(Tilewire &inSource, Tilewire &inSink)
Export a single pip.
virtual uint32_t getWordOffsetFromTileLocation(TileRow tileRow, TileCol tileCol, BitstreamSharedPtr inBitstreamPtr)=0
Get word offset from tile location.
const char * mTileName
The tile name.
Encapsulation of a device logic site.
Definition: Site.hpp:30
std::map< string, string > mReferenceConfigMap
Map from config setting to reference config value.
Main torc::physical namespace header.
CompoundSettingMap mCompoundSettingMap
Map from one compound setting to vector of other related settings.
string mCurTileType
Tile type for which Xdl are being generated currently.
Site type and population data for the family and the device.
Definition: Sites.hpp:45
static const char * sConfigValueOff
Config value to switch off element (#OFF)
Encapsulation of a device tile and wire pair.
Definition: Tilewire.hpp:39
const Tiles & mTiles
Tiles from the database object.
Tile map, tile type, and wire information for the family and device.
Definition: Tiles.hpp:36
const Array< const Site > & getSites(void) const
Returns the sites for this family.
Definition: Sites.hpp:127
virtual bool isSiteTypeSupported(const string &inSiteType)=0
Returns true if site type is supported.
Encapsulation of a wire count in an unsigned 16-bit integer.
Encapsulation of a tile count in an unsigned 32-bit integer.
Encapsulation of a tile within a device tile map.
Definition: TileInfo.hpp:33
static torc::physical::Pip newPip(const string &inTileName, const string &inSourceWireName, const string &inSinkWireName, EPipDirection inPipDirection, RoutethroughSharedPtr inRoutethroughPtr=RoutethroughSharedPtr())
Construct a pip and return it.
boost::shared_ptr< Net > NetSharedPtr
Shared pointer encapsulation of a Net.
const char * getTileTypeName(TileTypeIndex inTileTypeIndex) const
Returns the tile type name for the given tile type index.
Definition: Tiles.hpp:164
Verbose encapsulation of a wire's information.
SiteIndex findSiteIndex(const string &inName) const
Returns the site index for the given site name.
Definition: Sites.hpp:134
TileIndex getTileIndex(void) const
Returns the index of the containing tile.
Definition: Site.hpp:83
static InstanceSharedPtr newInstancePtr(const string &inName, const string &inType, const string &inTile, const string &inSite, EInstanceBonding inBonding=eInstanceBondingUnknown, InstanceReferenceSharedPtr inInstanceReferencePtr=InstanceReferenceSharedPtr())
Construct and return a new Instance shared pointer.
void createXdlsForConfigSetting(const torc::architecture::PrimitiveElement &inElement, PrimitiveStructureSharedPtr const inPrimitiveStructurePtr, const string &inSiteType, DesignSharedPtr inHarnessDesignPtr)
Create Xdls for each config value of the config setting
boost::filesystem::path path
const TileTypeIndex & getTypeIndex(void) const
Returns the tile type index for this tile.
Definition: TileInfo.hpp:92
virtual std::string getRambPrimaryPrimitive()=0
Returns primary primitivie for RAMB site type
boost::shared_ptr< Instance > InstanceSharedPtr
Shared pointer encapsulation of an Instance.
void createXdlForCompoundSettings(const PrimitiveElement &inElement, const string &inSiteType, PrimitiveStructureSharedPtr inPrimitiveStructurePtr, DesignSharedPtr inHarnessDesignPtr)
Create Xdls for compound settings.
TileTypeToSiteTypeSet getTileTypeToSiteTypeMap(void)
Populate map of tile type to set of include site types.
std::map< std::string, PrimitiveStructureSharedPtr > PrimitiveStructuresSharedPtrMap
Typedef of map from primitive name to primitive structure shared pointer.
bool isCompoundSettingHead(const string &inSetting)
Is given setting head of compound setting group.
torc::bitstream::Assembler::ConfigSettingsToValues ConfigSettingsToValues
boost::shared_ptr< Design > DesignSharedPtr
Shared pointer encapsulation of a Design.
const Site & getSite(SiteIndex inSiteIndex) const
Returns the site for the specified index.
Definition: Sites.hpp:129
const PrimitiveElementArray & getElements(void) const
Returns a constant array of primitive elements.
DesignSharedPtr getHarnessDesignForSiteType(const string &inSiteType)
Returns harness design pointer for the given site type.
const TileName & getTileName(void) const
Returns the pip tile.
Definition: Pip.hpp:73
torc::bitstream::Assembler::SiteTypeToConfigSettings SiteTypeToConfigSettings
bool isDspSite(const string &inSiteType)
Returns true is input is a DSP site.
Physical design programmable interconnect point.
Definition: Pip.hpp:34
void createReferenceXdlForConfigSetting(const string &inConfigSetting, DesignSharedPtr outHarnessDesignPtr, const string &inXdlFileNamePartial)
Create reference Xdl for given config setting.
torc::physical::NetSharedPtr NetSharedPtr
Imported type name.
static const char * sXdlExtension
.xdl
Encapsulation of a primitive site element. Primitive elements are subcomponents of logic primitive s...
void stitchMicroBitstreams()
Stitch micro-bitstreams in mXdlGenerationFolder.
Encapsulation of a site index in an unsigned 32-bit integer.
void createHexConfigXdl(const string &inConfigSetting, const string &inSiteType, int numHexChars, DesignSharedPtr inHarnessDesignPtr)
Create Xdl for configurations which hex string values.
Encapsulation of a tile type index in an unsigned 16-bit integer.
void compressBitFiles()
Compress all Xilinx bitfiles in mXdlGenerationFolder.
T * begin(void)
Returns the non-constant begin iterator.
Definition: Array.hpp:95
void generateBitstreams()
Generate bitstream for all Xdls in mXdlGenerationFolder and mXdlGenerationReferenceFolder.
std::set< std::string > StringSet
A set of configuration values.
path mLibraryFolder
Path to library folder.
const char * getName(void) const
Returns the name for this tile.
Definition: TileInfo.hpp:98
const StringSet & getCfgs(void) const
Returns the set of allowable configuration values.
torc::bitstream::Assembler::TileTypeToSiteType TileTypeToSiteType
static InstancePinSharedPtr newInstancePinPtr(InstanceSharedPtr inInstancePtr, const string &inPinName)
Construct and return a new InstancePin shared pointer.
Importer from XDL format into a physical design.
void generateLogicXdls()
Generrate Xdls for logic sites.
static DesignSharedPtr newDesignPtr(const string &inName, const string &inDevice, const string &inPackage, const string &inSpeedGrade, const string &inXdlVersion)
Create and return a new Design shared pointer.
void initialize()
Initialize object of this class.
std::map< string, string > mDeviceToPackageMap
Map from device to pakcage.
virtual string getParentFamilyName()
Returns parent family name.
torc::bitstream::BitstreamSharedPtr BitstreamSharedPtr
Imported type name.
void createXdlForLut(const torc::architecture::PrimitiveElement &inElement, const string &inXdlFileNamePartial, DesignSharedPtr inHarnessDesignPtr)
Create Xdl for Lut.
WireCount getWireCount(TileTypeIndex inTileTypeIndex) const
Returns the wire count for the specified tile type.
Definition: Tiles.hpp:157
virtual std::vector< std::string > getTilesSupportedForPips()=0
Returns vector of supported tiles.
static const boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.
DesignSharedPtr createEmptyDesignWithSameMetadata(DesignSharedPtr inDesignPtr)
Create an empty design with same metadata. Does not copy configurations.
boost::filesystem::path path
Imported type name.
uint32_t getSize(void) const
Returns the array size.
Definition: Array.hpp:104
Physical design exporter for XDL.
Definition: XdlExporter.hpp:31
torc::physical::DesignSharedPtr DesignSharedPtr
Imported type name.
torc::packer::PrimitiveStructureSharedPtr PrimitiveStructureSharedPtr
Imported type name.
virtual PrimitiveStructuresSharedPtrMap getPrimitiveNameToStructreMap()=0
Populate primitive name to primitive structure map.
const string & getName(void) const
Returns the name of the primitive.