torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LogicXdlGenerator.cpp File Reference

XDL generator for supported logic sites. Generates an XDL for each config and also an harness XDL for each BEL or as required. More...

#include "torc/packer/Virtex5PrimitiveStructure.hpp"
#include "torc/architecture/DDB.hpp"
#include <iostream>
#include <fstream>
#include <map>
#include "iomanip"
#include "torc/common/DirectoryTree.hpp"
#include "torc/Physical.hpp"
#include "SharedFunctions.hpp"
+ Include dependency graph for LogicXdlGenerator.cpp:

Go to the source code of this file.

Functions

void InitializeElementReferenceConfigMap ()
 
std::string GetReferenceConfigValueForElement (std::string elementName)
 
void GenerateReferenceXDLForTheElement (const std::string &elementName, DesignSharedPtr harnessDesignPtr, const std::string &xdlFileName)
 
torc::physical::DesignSharedPtr GetTestHarnessDesignForSiteType (std::string siteType, const boost::filesystem::path &harnessFolderPath)
 
int FindPrimitiveElementByName (std::string elementName, PrimitiveStructureSharedPtr const primitiveStructurePtr)
 
void SetConfigAndGenerateXDL (const std::string &elementName, const std::string &configVal, const std::string &xdlFileName, torc::physical::DesignSharedPtr designPtr)
 
DesignSharedPtr GetEmptyDesignWithSameMetadata (torc::physical::DesignSharedPtr designPtr)
 
static void GenerateXdlForCompoundSettings (const PrimitiveElement &element1, std::string siteType, PrimitiveStructureSharedPtr const primitiveStructurePtr, torc::physical::DesignSharedPtr designPtr)
 
void GenerateXdlForDSPMaskAndPattern (const std::string &elementName, std::string siteType, torc::physical::DesignSharedPtr designPtr)
 
void GenerateXdlForLUT (const PrimitiveElement &elem, const std::string &xdlFileNamePartial, torc::physical::DesignSharedPtr designPtr)
 
void GenerateXdlForGenericElement (const PrimitiveElement &elem, const std::string &configVal, const std::string &xdlFileNamePartial, torc::physical::DesignSharedPtr designPtr)
 
void GenerateXdlForOrphanElements (const PrimitiveElement &elem, const std::string &siteType, torc::physical::DesignSharedPtr designPtr)
 
void GenerateXdlForElement (const PrimitiveElement &elem, PrimitiveStructureSharedPtr const primitiveStructurePtr, const std::string &siteType, DesignSharedPtr designPtr)
 
bool LibrarySupportForSiteType (const std::string &siteType)
 Returns true if the library supports the site type. More...
 
bool IsRAMBSite (const std::string &siteType)
 
bool IsDSPSite (const std::string &siteType)
 
void GenerateRAMBBaseFile (const std::string &primitiveDefName, torc::physical::DesignSharedPtr designPtr)
 
int main (int argc, char **argv)
 Generates XDLs for various site types. An XDL is generated for each. More...
 

Variables

static const std::string kXDLReferenceFolder = "reference"
 
static boost::filesystem::path gXDLGenerationFolder
 
static boost::filesystem::path gXDLReferenceGenerationFolder
 
static std::map< std::string,
std::string > 
gElementReferenceConfigMap
 

Detailed Description

XDL generator for supported logic sites. Generates an XDL for each config and also an harness XDL for each BEL or as required.

Definition in file LogicXdlGenerator.cpp.

Function Documentation

int FindPrimitiveElementByName ( std::string  elementName,
PrimitiveStructureSharedPtr const  primitiveStructurePtr 
)

Definition at line 129 of file LogicXdlGenerator.cpp.

129  {
130 
131  int elementIndex = -1, index = 0;
132  const PrimitiveElementArray& elementsArray = primitiveStructurePtr->getPrimitiveDefPtr()->getElements();
133  PrimitiveElementArray::const_iterator pElements = elementsArray.begin();
134  PrimitiveElementArray::const_iterator eElements = elementsArray.end();
135 
136  // For every primitive element (BEL) in the site
137  while(pElements != eElements) {
138  if(pElements->getName().compare(elementName) == 0) {
139  elementIndex = index;
140  break;
141  }
142  pElements++; index++;
143  }
144  return elementIndex;
145 }
const const PrimitiveElement * const_iterator
Constant T iterator type.
Definition: Array.hpp:83
T * end(void)
Returns the non-constant end iterator.
Definition: Array.hpp:97
T * begin(void)
Returns the non-constant begin iterator.
Definition: Array.hpp:95

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GenerateRAMBBaseFile ( const std::string &  primitiveDefName,
torc::physical::DesignSharedPtr  designPtr 
)

Definition at line 450 of file LogicXdlGenerator.cpp.

451  {
452 
453  /* Generate XDL for designPtr in libraryPath */
454 
455  // Create XDL file name of the pattern <Architecture>-<SiteType>-<Element>-<Config>.xdl
456  std::stringstream ssXDLFileName;
457  ssXDLFileName << kArchitectureName << kNameSeparator << primitiveDefName << kNameSeparator
458  << primitiveDefName << kNameSeparator << "BASE.xdl";
459  boost::filesystem::path xdlFilePath = gXDLGenerationFolder / ssXDLFileName.str();
460  std::fstream xdlExport(xdlFilePath.string().c_str(), std::ios::out);
461  torc::physical::XdlExporter fileExporter(xdlExport);
462  fileExporter(designPtr);
463  xdlExport.close();
464 
465  /* Generate XDL for an empty design in tempFolderPath */
466 
467  // Get empty design
468  DesignSharedPtr emptyDesign = GetEmptyDesignWithSameMetadata(designPtr);
469  // Get empty design XDL path and open the file
470  boost::filesystem::path emptyDesignPath = gXDLReferenceGenerationFolder / ssXDLFileName.str();
471  std::fstream emptyDesignStream(emptyDesignPath.string().c_str(), std::ios::out);
472  // Get XDL exporter and export the empty design
473  torc::physical::XdlExporter emptyDesignExporter(emptyDesignStream);
474  emptyDesignExporter(emptyDesign);
475  emptyDesignStream.close();
476 
477  return;
478 
479 }
DesignSharedPtr GetEmptyDesignWithSameMetadata(torc::physical::DesignSharedPtr designPtr)
const std::string kArchitectureName
static boost::filesystem::path gXDLGenerationFolder
boost::filesystem::path path
boost::shared_ptr< Design > DesignSharedPtr
Shared pointer encapsulation of a Design.
const std::string kNameSeparator
static boost::filesystem::path gXDLReferenceGenerationFolder
Physical design exporter for XDL.
Definition: XdlExporter.hpp:31

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GenerateReferenceXDLForTheElement ( const std::string &  elementName,
DesignSharedPtr  harnessDesignPtr,
const std::string &  xdlFileName 
)

Definition at line 69 of file LogicXdlGenerator.cpp.

70  {
71  // We know harness XDL design has only one instance
72  InstanceSharedPtr instancePtr = *(harnessDesignPtr->instancesBegin());
73  // If no instance found, just return
74  if(!instancePtr) {
75  std::cerr << "No instance found in the harness " << harnessDesignPtr->getName() << std::endl;
76  return;
77  }
78 
79  // Set config value to #OFF for the given element
80  std::string configValue = GetReferenceConfigValueForElement(elementName);
81  instancePtr->setConfig(elementName, "", configValue);
82 
83  /* Generate an reference XDL file for this element's custom harness */
84  boost::filesystem::path referenceXDLFilePath = gXDLReferenceGenerationFolder / xdlFileName;
85 
86  std::ofstream fileStream(referenceXDLFilePath.string().c_str());
87  if(!fileStream.good()) {
88  std::cerr << "Could not open file " << referenceXDLFilePath.string() << std::endl;
89  return;
90  }
91 
92  // Export design as XDL
93  torc::physical::XdlExporter exporter(fileStream);
94  exporter(harnessDesignPtr);
95  fileStream.close();
96 
97  std::cout << "\tGenerated reference XDL " << referenceXDLFilePath.string() << std::endl;
98 }
std::string GetReferenceConfigValueForElement(std::string elementName)
std::string string
boost::filesystem::path path
boost::shared_ptr< Instance > InstanceSharedPtr
Shared pointer encapsulation of an Instance.
static boost::filesystem::path gXDLReferenceGenerationFolder
Physical design exporter for XDL.
Definition: XdlExporter.hpp:31

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void GenerateXdlForCompoundSettings ( const PrimitiveElement element1,
std::string  siteType,
PrimitiveStructureSharedPtr const  primitiveStructurePtr,
torc::physical::DesignSharedPtr  designPtr 
)
static

Definition at line 175 of file LogicXdlGenerator.cpp.

176  {
177 
178  std::vector<std::string> compoundElements = gCompoundSettingsMap[element1.getName()];
179  // For now assume there is only on element in the vector, i.e. there is a compound
180  // setting with only two elements.
181  if(compoundElements.size() != 1) {
182  std::cout << "Compound setting with more than two elements not handled currently"
183  << std::endl;
184  } else {
185 
186  // Generate XDLs with all permutations of configs of the two elements
187  // The two element names will be concatenated to form a compound element name Element1Element2.
188  // Similarly two config settings will be concatenated to form a compound config name.
189  std::string element1Name = element1.getName();
190  std::string element2Name = compoundElements[0];
191  std::string compoundElementName = element1Name + element2Name;
192 
193  // Get the other element
194  int elementIndex = FindPrimitiveElementByName(element2Name, primitiveStructurePtr);
195 
196  if(elementIndex == -1) {
197  std::cout << "Primitive element " << element2Name << " not found" << std::endl;
198  return;
199  }
200 
201  const PrimitiveElement &element2 = primitiveStructurePtr->getPrimitiveDefPtr()->getElements()[elementIndex];
202 
203  // Get the first instance
204  InstanceSharedPtr instancePtr = *(designPtr->instancesBegin());
205 
206  // Store the 2nd elements harness config
207  std::string harnessConfig2Val, harnessConfig2Name;
208  instancePtr->getConfig(element2Name, harnessConfig2Name, harnessConfig2Val);
209 
210  // Set element1 OFF and generate harness
211  std::string referenceXdlFileName = siteType + kNameSeparator + compoundElementName + kXDLExtension;
212  instancePtr->setConfig(element1Name, "", kConfigOff);
213  GenerateReferenceXDLForTheElement(element2Name, designPtr, referenceXdlFileName);
214 
215  // Iterate over configs of 1st element
216  const PrimitiveElement::StringSet &configs1 = element1.getCfgs();
217  PrimitiveElement::StringSet::const_iterator pConfigs1 = configs1.begin();
218  PrimitiveElement::StringSet::const_iterator eConfigs1 = configs1.end();
219 
220  while(pConfigs1 != eConfigs1) {
221 
222  // Iterate over configs of 2nd element.
223  const PrimitiveElement::StringSet &configs2 = element2.getCfgs();
224  PrimitiveElement::StringSet::const_iterator pConfigs2 = configs2.begin();
225  PrimitiveElement::StringSet::const_iterator eConfigs2 = configs2.end();
226 
227  while(pConfigs2 != eConfigs2) {
228 
229  // Form the XDL file name
230  std::string compoundConfigName = *pConfigs1 + *pConfigs2;
231  std::string xdlFileName = siteType + kNameSeparator + compoundElementName
232  + kNameSeparator + compoundConfigName + kXDLExtension;
233 
234  // Set element1 config and generate primary XDL
235  instancePtr->setConfig(element1Name, "", *pConfigs1);
236  SetConfigAndGenerateXDL(element2Name, *pConfigs2, xdlFileName, designPtr);
237  pConfigs2++;
238  }
239 
240  pConfigs1++;
241  }
242 
243  // Set original value of element2
244  instancePtr->setConfig(element2Name, harnessConfig2Name, harnessConfig2Val);
245  }
246 }
const std::string kConfigOff
const std::string kXDLExtension
void SetConfigAndGenerateXDL(const std::string &elementName, const std::string &configVal, const std::string &xdlFileName, torc::physical::DesignSharedPtr designPtr)
std::string string
const string & getName(void) const
Returns the name of the element.
boost::shared_ptr< Instance > InstanceSharedPtr
Shared pointer encapsulation of an Instance.
const std::string kNameSeparator
Encapsulation of a primitive site element. Primitive elements are subcomponents of logic primitive s...
CompoundSettingMap gCompoundSettingsMap
std::set< std::string > StringSet
A set of configuration values.
const StringSet & getCfgs(void) const
Returns the set of allowable configuration values.
int FindPrimitiveElementByName(std::string elementName, PrimitiveStructureSharedPtr const primitiveStructurePtr)
void GenerateReferenceXDLForTheElement(const std::string &elementName, DesignSharedPtr harnessDesignPtr, const std::string &xdlFileName)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GenerateXdlForDSPMaskAndPattern ( const std::string &  elementName,
std::string  siteType,
torc::physical::DesignSharedPtr  designPtr 
)

Definition at line 248 of file LogicXdlGenerator.cpp.

249  {
250 
251  // We know for Virtex 5 DSP's mask and pattern have 12 hex characters as config value.
252  long long configValNumber = 1;
253 
254  std::string siteTypeAndElement = siteType + kNameSeparator + elementName;
255 
256  std::stringstream xdlReferenceFileName;
257  xdlReferenceFileName << siteTypeAndElement << kXDLExtension;
258  GenerateReferenceXDLForTheElement(elementName, designPtr, xdlReferenceFileName.str());
259 
260  for(int bitPosition = 0; bitPosition < 48; bitPosition++) {
261  std::stringstream ssConfigVal;
262  ssConfigVal << std::setfill('0') << std::setw(12) << std::hex << configValNumber;
263 
264  std::stringstream xdlFileName;
265  xdlFileName << siteTypeAndElement << kNameSeparator << bitPosition << kXDLExtension;
266 
267  SetConfigAndGenerateXDL(elementName, ssConfigVal.str(), xdlFileName.str(), designPtr);
268 
269  configValNumber = configValNumber << 1;
270 
271  }
272 
273  // Set the config to default again
274  InstanceSharedPtr instancePtr = *(designPtr->instancesBegin());
275  instancePtr->setConfig(elementName, "", GetReferenceConfigValueForElement(elementName));
276 }
const std::string kXDLExtension
void SetConfigAndGenerateXDL(const std::string &elementName, const std::string &configVal, const std::string &xdlFileName, torc::physical::DesignSharedPtr designPtr)
std::string GetReferenceConfigValueForElement(std::string elementName)
std::string string
boost::shared_ptr< Instance > InstanceSharedPtr
Shared pointer encapsulation of an Instance.
const std::string kNameSeparator
void GenerateReferenceXDLForTheElement(const std::string &elementName, DesignSharedPtr harnessDesignPtr, const std::string &xdlFileName)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GenerateXdlForElement ( const PrimitiveElement elem,
PrimitiveStructureSharedPtr const  primitiveStructurePtr,
const std::string &  siteType,
DesignSharedPtr  designPtr 
)

Definition at line 385 of file LogicXdlGenerator.cpp.

387  {
388 
389  std::cout << "Found a " << elem.getName() << std::endl;
390 
391  std::string elementName = elem.getName();
392 
394  GenerateXdlForCompoundSettings(elem, siteType, primitiveStructurePtr, designPtr);
395  } else if(primitiveStructurePtr->isOrphan(elem) && elem.getName() != "SYNC_ATTR") {
396  GenerateXdlForOrphanElements(elem, siteType, designPtr);
397  } else {
398 
399  std::string siteTypeAndElem = siteType + kNameSeparator + elementName;
400 
401  const PrimitiveElement::StringSet &configs = elem.getCfgs();
402  PrimitiveElement::StringSet::const_iterator pConfigs = configs.begin();
403  PrimitiveElement::StringSet::const_iterator eConfigs = configs.end();
404 
405  // Iterate over configs of the primitive
406  while(pConfigs != eConfigs) {
407 
408  if(primitiveStructurePtr->isLUT(elem, *pConfigs)) {
409  GenerateXdlForLUT(elem, siteTypeAndElem, designPtr);
410  } else {
411  GenerateXdlForGenericElement(elem, *pConfigs, siteTypeAndElem, designPtr);
412  }
413 
414  pConfigs++;
415  }
416  }
417 }
void GenerateXdlForGenericElement(const PrimitiveElement &elem, const std::string &configVal, const std::string &xdlFileNamePartial, torc::physical::DesignSharedPtr designPtr)
void GenerateXdlForLUT(const PrimitiveElement &elem, const std::string &xdlFileNamePartial, torc::physical::DesignSharedPtr designPtr)
bool ElementNeedsCompoundSetting(std::string elementName)
std::string string
const string & getName(void) const
Returns the name of the element.
static void GenerateXdlForCompoundSettings(const PrimitiveElement &element1, std::string siteType, PrimitiveStructureSharedPtr const primitiveStructurePtr, torc::physical::DesignSharedPtr designPtr)
const std::string kNameSeparator
void GenerateXdlForOrphanElements(const PrimitiveElement &elem, const std::string &siteType, torc::physical::DesignSharedPtr designPtr)
std::set< std::string > StringSet
A set of configuration values.
const StringSet & getCfgs(void) const
Returns the set of allowable configuration values.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GenerateXdlForGenericElement ( const PrimitiveElement elem,
const std::string &  configVal,
const std::string &  xdlFileNamePartial,
torc::physical::DesignSharedPtr  designPtr 
)

Definition at line 338 of file LogicXdlGenerator.cpp.

339  {
340 
341  std::stringstream xdlFileName;
342  xdlFileName << xdlFileNamePartial << kNameSeparator << configVal << ".xdl";
343 
344 // GenerateReferenceXDLForTheElement(elem.getName(), designPtr, xdlFileName.str());
345 
346  SetConfigAndGenerateXDL(elem.getName(), configVal, xdlFileName.str(), designPtr);
347 
348 }
void SetConfigAndGenerateXDL(const std::string &elementName, const std::string &configVal, const std::string &xdlFileName, torc::physical::DesignSharedPtr designPtr)
const string & getName(void) const
Returns the name of the element.
const std::string kNameSeparator

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GenerateXdlForLUT ( const PrimitiveElement elem,
const std::string &  xdlFileNamePartial,
torc::physical::DesignSharedPtr  designPtr 
)

Definition at line 278 of file LogicXdlGenerator.cpp.

279  {
280 
281  std::string elementName = elem.getName();
282 
283  std::cout << "Found a LUT " << elementName << std::endl;
284 
285  DesignSharedPtr emptyDesign = GetEmptyDesignWithSameMetadata(designPtr);
286  InstanceSharedPtr instancePtr = *(designPtr->instancesBegin());
287  InstanceSharedPtr emptyInstance = Factory::newInstancePtr(instancePtr->getName(),
288  instancePtr->getType(), instancePtr->getTile(), instancePtr->getSite(),
289  instancePtr->getBonding());
290  emptyDesign->addInstance(emptyInstance);
291 
292  const PrimitiveElementPinArray &pins = elem.getPins();
295 
296  // Generate reference XDL for LUT
297  std::string referenceXdlFileName = xdlFileNamePartial + kXDLExtension;
298  GenerateReferenceXDLForTheElement(elementName, emptyDesign, referenceXdlFileName);
299 
300  //For every output-input pin combination
301  while(pPins != ePins) {
302 
303  if(pPins->isOutput()) {
304 
307 
308  while(pPinsIn != ePinsIn) {
309  if(pPinsIn->isInput()) {
310 
311  std::string configVal = "#LUT:" + pPins->getName() + "=" + pPinsIn->getName();
312  std::stringstream xdlFileName;
313  xdlFileName << xdlFileNamePartial << kNameSeparator << configVal << ".xdl";
314 // GenerateReferenceXDLForTheElement(elementName, emptyDesign, xdlFileName.str());
315  SetConfigAndGenerateXDL(elementName, configVal, xdlFileName.str(), emptyDesign);
316  }
317  pPinsIn++;
318  }
319 
320  // Generate XDLs for output 1 also
321  std::string configVal = "#LUT:" + pPins->getName() + "=" + "1";
322  std::stringstream xdlFileName1;
323  xdlFileName1 << xdlFileNamePartial << kNameSeparator << configVal << ".xdl";
324 // GenerateReferenceXDLForTheElement(elementName, emptyDesign, xdlFileName1.str());
325  SetConfigAndGenerateXDL(elementName, configVal, xdlFileName1.str(), emptyDesign);
326 
327  configVal = "#LUT:" + pPins->getName() + "=" + "0";
328  std::stringstream xdlFileName0;
329  xdlFileName0 << xdlFileNamePartial << kNameSeparator << configVal << ".xdl";
330 // GenerateReferenceXDLForTheElement(elementName, emptyDesign, xdlFileName0.str());
331  SetConfigAndGenerateXDL(elementName, configVal, xdlFileName0.str(), emptyDesign);
332  }
333  pPins++;
334  }
335 
336 }
const std::string kXDLExtension
const const PrimitiveElementPin * const_iterator
Constant T iterator type.
Definition: Array.hpp:83
DesignSharedPtr GetEmptyDesignWithSameMetadata(torc::physical::DesignSharedPtr designPtr)
void SetConfigAndGenerateXDL(const std::string &elementName, const std::string &configVal, const std::string &xdlFileName, torc::physical::DesignSharedPtr designPtr)
T * end(void)
Returns the non-constant end iterator.
Definition: Array.hpp:97
std::string string
const string & getName(void) const
Returns the name of the element.
PrimitiveElementPinArray & getPins(void)
Returns a non-constant array of element pins. This function should only be used by the Sites class d...
boost::shared_ptr< Instance > InstanceSharedPtr
Shared pointer encapsulation of an Instance.
boost::shared_ptr< Design > DesignSharedPtr
Shared pointer encapsulation of a Design.
const std::string kNameSeparator
T * begin(void)
Returns the non-constant begin iterator.
Definition: Array.hpp:95
void GenerateReferenceXDLForTheElement(const std::string &elementName, DesignSharedPtr harnessDesignPtr, const std::string &xdlFileName)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GenerateXdlForOrphanElements ( const PrimitiveElement elem,
const std::string &  siteType,
torc::physical::DesignSharedPtr  designPtr 
)

Definition at line 350 of file LogicXdlGenerator.cpp.

351  {
352 
353  std::cout << " Found a Orphan element " << elem.getName() << std::endl;
354 
355  std::string elementName = elem.getName();
356  std::string siteTypeAndElem = siteType + kNameSeparator + elementName;
357 
358  // Get and empty design with same metadata
359  DesignSharedPtr emptyDesign = GetEmptyDesignWithSameMetadata(designPtr);
360 
361  // Add an empty instance of same site type and location
362  InstanceSharedPtr instancePtr = *(designPtr->instancesBegin());
363 
364  InstanceSharedPtr emptyInstance = Factory::newInstancePtr(instancePtr->getName(),
365  instancePtr->getType(), instancePtr->getTile(), instancePtr->getSite(),
366  instancePtr->getBonding());
367 
368  emptyDesign->addInstance(emptyInstance);
369 
370  std::string referenceXdlFileName = siteTypeAndElem + kXDLExtension;
371  GenerateReferenceXDLForTheElement(elementName, emptyDesign, referenceXdlFileName);
372 
373  // Go over all the configs
374  const PrimitiveElement::StringSet &configs = elem.getCfgs();
375  PrimitiveElement::StringSet::const_iterator pConfigs = configs.begin();
376  PrimitiveElement::StringSet::const_iterator eConfigs = configs.end();
377 
378  // Iterate over configs of the primitive
379  while(pConfigs != eConfigs) {
380  GenerateXdlForGenericElement(elem, *pConfigs, siteTypeAndElem, emptyDesign);
381  pConfigs++;
382  }
383 }
void GenerateXdlForGenericElement(const PrimitiveElement &elem, const std::string &configVal, const std::string &xdlFileNamePartial, torc::physical::DesignSharedPtr designPtr)
const std::string kXDLExtension
DesignSharedPtr GetEmptyDesignWithSameMetadata(torc::physical::DesignSharedPtr designPtr)
std::string string
const string & getName(void) const
Returns the name of the element.
boost::shared_ptr< Instance > InstanceSharedPtr
Shared pointer encapsulation of an Instance.
boost::shared_ptr< Design > DesignSharedPtr
Shared pointer encapsulation of a Design.
const std::string kNameSeparator
std::set< std::string > StringSet
A set of configuration values.
const StringSet & getCfgs(void) const
Returns the set of allowable configuration values.
void GenerateReferenceXDLForTheElement(const std::string &elementName, DesignSharedPtr harnessDesignPtr, const std::string &xdlFileName)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DesignSharedPtr GetEmptyDesignWithSameMetadata ( torc::physical::DesignSharedPtr  designPtr)

Definition at line 165 of file LogicXdlGenerator.cpp.

165  {
166  DesignSharedPtr emptyDesign = Factory::newDesignPtr(designPtr->getName(),
167  designPtr->getDevice(), designPtr->getPackage(), designPtr->getSpeedGrade(),
168  designPtr->getXdlVersion());
169 
170  return emptyDesign;
171 }
boost::shared_ptr< Design > DesignSharedPtr
Shared pointer encapsulation of a Design.

+ Here is the caller graph for this function:

std::string GetReferenceConfigValueForElement ( std::string  elementName)

Definition at line 54 of file LogicXdlGenerator.cpp.

54  {
55  std::string configValue;
56  // if element present in the map of Element->ReferenceConfig, return it.
57  std::map<std::string, std::string>::const_iterator pElementConfigMap;
58  std::map<std::string, std::string>::const_iterator eElementConfigMap =
60  pElementConfigMap = gElementReferenceConfigMap.find(elementName);
61  if(pElementConfigMap != eElementConfigMap) {
62  return pElementConfigMap->second;
63  }
64 
65  return kConfigOff;
66 }
const std::string kConfigOff
std::string string
static std::map< std::string, std::string > gElementReferenceConfigMap

+ Here is the caller graph for this function:

torc::physical::DesignSharedPtr GetTestHarnessDesignForSiteType ( std::string  siteType,
const boost::filesystem::path &  harnessFolderPath 
)

Definition at line 101 of file LogicXdlGenerator.cpp.

102  {
103 
104  boost::filesystem::path harnessFilePath(harnessFolderPath);
105 
106  torc::physical::DesignSharedPtr harnessDesignPtr;
107  std::stringstream ssHarnessFileName;
108  // ssHarnessFileName << "Virtex5_" << siteType << ".xdl";
109  ssHarnessFileName << kArchitectureName << kNameSeparator << siteType << ".xdl";
110 
111  harnessFilePath = harnessFilePath / ssHarnessFileName.str();
112 
113  std::ifstream fileStream(harnessFilePath.string().c_str());
114  if(!fileStream.good()) {
115  std::cerr << "Could not open file " << harnessFilePath.string() << std::endl;
116  return harnessDesignPtr;
117  }
119  importer(fileStream, ssHarnessFileName.str());
120 
121  fileStream.close();
122 
123  // Return the design pointer
124  harnessDesignPtr = importer.getDesignPtr();
125  return harnessDesignPtr;
126 }
DesignSharedPtr getDesignPtr(void)
Returns a shared pointer for the design.
const std::string kArchitectureName
boost::filesystem::path path
boost::shared_ptr< Design > DesignSharedPtr
Shared pointer encapsulation of a Design.
const std::string kNameSeparator
Importer from XDL format into a physical design.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void InitializeElementReferenceConfigMap ( )

Definition at line 44 of file LogicXdlGenerator.cpp.

44  {
45 
46  gElementReferenceConfigMap["LFSR_EN_SET"] = "SET";
47  gElementReferenceConfigMap["TEST_SET_P"] = "SET";
48  gElementReferenceConfigMap["MASK"] = "000000000000";
49  gElementReferenceConfigMap["PATTERN"] = "000000000000";
50 }
static std::map< std::string, std::string > gElementReferenceConfigMap

+ Here is the caller graph for this function:

bool IsDSPSite ( const std::string &  siteType)

Definition at line 442 of file LogicXdlGenerator.cpp.

442  {
443  if(siteType.length() > 3) {
444  return siteType.substr(0, 3).compare("DSP") == 0;
445  }
446  return false;
447 }

+ Here is the caller graph for this function:

bool IsRAMBSite ( const std::string &  siteType)

Definition at line 434 of file LogicXdlGenerator.cpp.

434  {
435  if(siteType.length() > 3) {
436  return siteType.substr(0, 4).compare("RAMB") == 0;
437  }
438  return false;
439 }

+ Here is the caller graph for this function:

bool LibrarySupportForSiteType ( const std::string &  siteType)

Returns true if the library supports the site type.

Definition at line 420 of file LogicXdlGenerator.cpp.

420  {
421  std::cout << "Site type: " << siteType << std::endl;
422  return ( siteType.compare("SLICEM") == 0 ||
423  siteType.compare("SLICEL") == 0 ||
424  siteType.compare("RAMB36_EXP") == 0 ||
425  siteType.compare("DSP48E") == 0 ||
426  siteType.compare("BUFGCTRL") == 0 ||
427  siteType.compare("BUFDS") == 0 ||
428  siteType.compare("BUFR") == 0 ||
429  siteType.compare("BUFG") == 0);
430  // return 1; //Generate library files for all types just for information.
431 }

+ Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Generates XDLs for various site types. An XDL is generated for each.

Definition at line 485 of file LogicXdlGenerator.cpp.

485  {
486 
487  if(argc != 3) {
488  std::cerr << "Invalid arguments. Usage: " << argv[0] <<
489  " <harness_folder> <xdl_generation_folder>" << std::endl;
490  exit (-1);
491  }
492  // get the part number
493  std::string partNumber = "xc5vfx130t";
494  // Initialize the DirectoryTree class
495  torc::common::DirectoryTree directoryTree(argv[0]);
496 
497  // Check if Harness folder path exists.
498  boost::filesystem::path harnessFolderPath = argv[1];
499  if(!boost::filesystem::exists(harnessFolderPath)) {
500  std::cout << "Folder " << harnessFolderPath.string() << " does not exist" << std::endl;
501  exit (-1);
502  }
503 
504  // Create the xdl generation folder if it doesn't exits
505  gXDLGenerationFolder = argv[2];
506  if(!boost::filesystem::exists(gXDLGenerationFolder))
507  boost::filesystem::create_directory(gXDLGenerationFolder);
509  if(!boost::filesystem::exists(gXDLReferenceGenerationFolder))
510  boost::filesystem::create_directory(gXDLReferenceGenerationFolder);
511 
512  // Initialize the map of element to reference config map
515 
516  // open and initialize a database
517  DDB ddb(partNumber);
518  // look up the logic sites in the device
519  const Sites& sites = ddb.getSites();
520  // define a vector of PrimitiveStructure objects
521  typedef std::map<std::string, PrimitiveStructureSharedPtr> PrimitiveStructuresSharedPtrMap;
522  PrimitiveStructuresSharedPtrMap primitiveStructures;
523  // look up the primitive def types
524  typedef const Array<const PrimitiveDef> PrimitiveDefArray;
525  PrimitiveDefArray& primitiveDefs = sites.getSiteTypes();
526  PrimitiveDefArray::const_iterator p = primitiveDefs.begin();
527  PrimitiveDefArray::const_iterator e = primitiveDefs.end();
528  // Store the corresponding primitive structures in a map.
529  while(p < e) {
530  // create a PrimitiveStructure object for this PrimitiveDef
531  PrimitiveStructureSharedPtr primitiveStructurePtr(new Virtex5PrimitiveStructure(&*p++));
532  const torc::architecture::PrimitiveDef* primitiveDefPtr =
533  primitiveStructurePtr->getPrimitiveDefPtr();
534  const std::string& primitiveDefName = primitiveDefPtr->getName();
535  // insert the PrimitiveStructure into the map
536  primitiveStructures[primitiveDefName] = primitiveStructurePtr;
537  }
538 
539  // iterate through the PrimitiveStructure entries in the map
540  PrimitiveStructuresSharedPtrMap::iterator psp = primitiveStructures.begin();
541  PrimitiveStructuresSharedPtrMap::iterator pse = primitiveStructures.end();
542 
543  // For every site type
544  while(psp != pse) {
545 
546  // look up the PrimitiveDef name and the PrimitiveStructureSharedPtr
547  std::string primitiveDefName = psp->first;
548  PrimitiveStructureSharedPtr primitiveStructurePtr = psp->second;
549 
550  psp++;
551  // If the site type is to be supported
552  if(LibrarySupportForSiteType(primitiveDefName)) {
553 
554  // Get the designPtr for test harness for this site type
556  primitiveDefName, harnessFolderPath);
557 
558  if(!designPtr) {
559  std::cout << "No test harness for site type " << primitiveDefName << std::endl;
560  continue;
561  }
562 
563  std::cout << "Working on site type " << primitiveDefName << std::endl;
564 
565  // Create the XDL file name (partial)
566  std::stringstream ssXdlFileName;
567  ssXdlFileName << kArchitectureName << kNameSeparator << primitiveDefName;
568 
569  if(IsRAMBSite(primitiveDefName)) {
570  GenerateRAMBBaseFile(primitiveDefName, designPtr);
571  }
572 
573  if(IsDSPSite(primitiveDefName)) {
574  GenerateXdlForDSPMaskAndPattern("MASK", ssXdlFileName.str(), designPtr);
575  GenerateXdlForDSPMaskAndPattern("PATTERN", ssXdlFileName.str(), designPtr);
576  }
577 
578  // We know the design has only one instance. So, get the first one in the iterator.
579  torc::physical::InstanceSharedPtr instancePtr = *(designPtr->instancesBegin());
580 
581  const torc::architecture::PrimitiveDef* primitiveDefPtr =
582  primitiveStructurePtr->getPrimitiveDefPtr();
583 
584  const PrimitiveElementArray& elements = primitiveDefPtr->getElements();
585 
586  PrimitiveElementArray::const_iterator pElements = elements.begin();
587  PrimitiveElementArray::const_iterator eElements = elements.end();
588 
589  // For every primitive element (BEL) in the site
590  while(pElements != eElements) {
591  const PrimitiveElement &elem = *pElements;
592  // Ignore the route through elements
593  if(!primitiveStructurePtr->isRoutethrough(elem)) {
594 
595  // Cache the current setting of the element
596  std::string harnessConfigName;
597  std::string harnessConfigVal;
598  instancePtr->getConfig(elem.getName(), harnessConfigName, harnessConfigVal);
599 
600 
601  // Generate XDLs only if the element has a config to be set.
602  if(elem.getCfgs().size() > 0) {
603  // First generate a generic reference XDL for all configs of the element, so that the special elements have option of over writing this harness
604  std::stringstream ssReferenceXdlFileName;
605  ssReferenceXdlFileName << ssXdlFileName.str() << kNameSeparator << elem.getName() << kXDLExtension;
606  GenerateReferenceXDLForTheElement(elem.getName(), designPtr, ssReferenceXdlFileName.str());
607 
608  // Generate XDL for each config of the element.
609  GenerateXdlForElement(elem, primitiveStructurePtr, ssXdlFileName.str(),
610  designPtr);
611  }
612 
613  // Store back the previous setting of the element
614  instancePtr->setConfig(elem.getName(), harnessConfigName, harnessConfigVal);
615  }
616 
617  pElements++;
618  }
619  }
620  }
621  return 0;
622 }
const std::string kXDLExtension
const const PrimitiveElement * const_iterator
Constant T iterator type.
Definition: Array.hpp:83
Device database, including complete wiring and logic support.
Definition: DDB.hpp:42
bool LibrarySupportForSiteType(const std::string &siteType)
Returns true if the library supports the site type.
void InitializeElementReferenceConfigMap()
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 kArchitectureName
void InitializeCompoundSettingsMap()
std::string string
const string & getName(void) const
Returns the name of the element.
static boost::filesystem::path gXDLGenerationFolder
const Array< const PrimitiveDef > & getSiteTypes(void) const
Returns the site types for this family.
Definition: Sites.hpp:125
Site type and population data for the family and the device.
Definition: Sites.hpp:45
const Array< const Site > & getSites(void) const
Returns the sites for this family.
Definition: Sites.hpp:127
Encapsulation of filesystem paths that are used by the library.
bool IsRAMBSite(const std::string &siteType)
boost::filesystem::path path
boost::shared_ptr< Instance > InstanceSharedPtr
Shared pointer encapsulation of an Instance.
static const std::string kXDLReferenceFolder
void GenerateRAMBBaseFile(const std::string &primitiveDefName, torc::physical::DesignSharedPtr designPtr)
boost::shared_ptr< Design > DesignSharedPtr
Shared pointer encapsulation of a Design.
const std::string kNameSeparator
const PrimitiveElementArray & getElements(void) const
Returns a constant array of primitive elements.
void GenerateXdlForElement(const PrimitiveElement &elem, PrimitiveStructureSharedPtr const primitiveStructurePtr, const std::string &siteType, DesignSharedPtr designPtr)
Encapsulation of a primitive site element. Primitive elements are subcomponents of logic primitive s...
T * begin(void)
Returns the non-constant begin iterator.
Definition: Array.hpp:95
static boost::filesystem::path gXDLReferenceGenerationFolder
boost::shared_ptr< PrimitiveStructure > PrimitiveStructureSharedPtr
Shared pointer encapsulation of a PrimitiveStructure.
const StringSet & getCfgs(void) const
Returns the set of allowable configuration values.
void GenerateXdlForDSPMaskAndPattern(const std::string &elementName, std::string siteType, torc::physical::DesignSharedPtr designPtr)
torc::physical::DesignSharedPtr GetTestHarnessDesignForSiteType(std::string siteType, const boost::filesystem::path &harnessFolderPath)
bool IsDSPSite(const std::string &siteType)
Subclass of PrimitiveStructure for Virtex5.
Encapsulation of a static array.
Definition: Array.hpp:39
void GenerateReferenceXDLForTheElement(const std::string &elementName, DesignSharedPtr harnessDesignPtr, const std::string &xdlFileName)
const string & getName(void) const
Returns the name of the primitive.

+ Here is the call graph for this function:

void SetConfigAndGenerateXDL ( const std::string &  elementName,
const std::string &  configVal,
const std::string &  xdlFileName,
torc::physical::DesignSharedPtr  designPtr 
)

Definition at line 148 of file LogicXdlGenerator.cpp.

149  {
150 
151  torc::physical::InstanceSharedPtr instancePtr = *(designPtr->instancesBegin());
152 
153  instancePtr->setConfig(elementName, "", configVal);
154  // create the appropriate file paths
155  boost::filesystem::path xdlFilePath = gXDLGenerationFolder / xdlFileName.c_str();
156 
157  // Export the design as XDL
158  std::fstream xdlExport(xdlFilePath.string().c_str(), std::ios_base::out);
159  torc::physical::XdlExporter fileExporter(xdlExport);
160  fileExporter(designPtr);
161  std::cout << "\tGenerated XDL file " << xdlFileName << std::endl;
162 }
static boost::filesystem::path gXDLGenerationFolder
boost::filesystem::path path
boost::shared_ptr< Instance > InstanceSharedPtr
Shared pointer encapsulation of an Instance.
Physical design exporter for XDL.
Definition: XdlExporter.hpp:31

+ Here is the caller graph for this function:

Variable Documentation

std::map<std::string, std::string> gElementReferenceConfigMap
static

Definition at line 40 of file LogicXdlGenerator.cpp.

boost::filesystem::path gXDLGenerationFolder
static

Definition at line 38 of file LogicXdlGenerator.cpp.

boost::filesystem::path gXDLReferenceGenerationFolder
static

Definition at line 39 of file LogicXdlGenerator.cpp.

const std::string kXDLReferenceFolder = "reference"
static

Definition at line 35 of file LogicXdlGenerator.cpp.