30 using namespace torc::architecture;
31 using namespace torc::packer;
32 using namespace torc::physical;
57 std::map<std::string, std::string>::const_iterator pElementConfigMap;
58 std::map<std::string, std::string>::const_iterator eElementConfigMap =
61 if(pElementConfigMap != eElementConfigMap) {
62 return pElementConfigMap->second;
75 std::cerr <<
"No instance found in the harness " << harnessDesignPtr->getName() << std::endl;
81 instancePtr->setConfig(elementName,
"", configValue);
86 std::ofstream fileStream(referenceXDLFilePath.string().c_str());
87 if(!fileStream.good()) {
88 std::cerr <<
"Could not open file " << referenceXDLFilePath.string() << std::endl;
94 exporter(harnessDesignPtr);
97 std::cout <<
"\tGenerated reference XDL " << referenceXDLFilePath.string() << std::endl;
107 std::stringstream ssHarnessFileName;
111 harnessFilePath = harnessFilePath / ssHarnessFileName.str();
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;
119 importer(fileStream, ssHarnessFileName.str());
125 return harnessDesignPtr;
131 int elementIndex = -1, index = 0;
132 const PrimitiveElementArray& elementsArray = primitiveStructurePtr->getPrimitiveDefPtr()->getElements();
137 while(pElements != eElements) {
138 if(pElements->getName().compare(elementName) == 0) {
139 elementIndex = index;
142 pElements++; index++;
153 instancePtr->setConfig(elementName,
"", configVal);
158 std::fstream xdlExport(xdlFilePath.string().c_str(), std::ios_base::out);
160 fileExporter(designPtr);
161 std::cout <<
"\tGenerated XDL file " << xdlFileName << std::endl;
166 DesignSharedPtr emptyDesign = Factory::newDesignPtr(designPtr->getName(),
167 designPtr->getDevice(), designPtr->getPackage(), designPtr->getSpeedGrade(),
168 designPtr->getXdlVersion());
181 if(compoundElements.size() != 1) {
182 std::cout <<
"Compound setting with more than two elements not handled currently"
191 std::string compoundElementName = element1Name + element2Name;
196 if(elementIndex == -1) {
197 std::cout <<
"Primitive element " << element2Name <<
" not found" << std::endl;
201 const PrimitiveElement &element2 = primitiveStructurePtr->getPrimitiveDefPtr()->getElements()[elementIndex];
208 instancePtr->getConfig(element2Name, harnessConfig2Name, harnessConfig2Val);
212 instancePtr->setConfig(element1Name,
"",
kConfigOff);
217 PrimitiveElement::StringSet::const_iterator pConfigs1 = configs1.begin();
218 PrimitiveElement::StringSet::const_iterator eConfigs1 = configs1.end();
220 while(pConfigs1 != eConfigs1) {
224 PrimitiveElement::StringSet::const_iterator pConfigs2 = configs2.begin();
225 PrimitiveElement::StringSet::const_iterator eConfigs2 = configs2.end();
227 while(pConfigs2 != eConfigs2) {
230 std::string compoundConfigName = *pConfigs1 + *pConfigs2;
235 instancePtr->setConfig(element1Name,
"", *pConfigs1);
244 instancePtr->setConfig(element2Name, harnessConfig2Name, harnessConfig2Val);
252 long long configValNumber = 1;
256 std::stringstream xdlReferenceFileName;
260 for(
int bitPosition = 0; bitPosition < 48; bitPosition++) {
261 std::stringstream ssConfigVal;
262 ssConfigVal << std::setfill(
'0') << std::setw(12) << std::hex << configValNumber;
264 std::stringstream xdlFileName;
269 configValNumber = configValNumber << 1;
283 std::cout <<
"Found a LUT " << elementName << std::endl;
287 InstanceSharedPtr emptyInstance = Factory::newInstancePtr(instancePtr->getName(),
288 instancePtr->getType(), instancePtr->getTile(), instancePtr->getSite(),
289 instancePtr->getBonding());
290 emptyDesign->addInstance(emptyInstance);
301 while(pPins != ePins) {
303 if(pPins->isOutput()) {
308 while(pPinsIn != ePinsIn) {
309 if(pPinsIn->isInput()) {
311 std::string configVal =
"#LUT:" + pPins->getName() +
"=" + pPinsIn->getName();
312 std::stringstream xdlFileName;
313 xdlFileName << xdlFileNamePartial <<
kNameSeparator << configVal <<
".xdl";
321 std::string configVal =
"#LUT:" + pPins->getName() +
"=" +
"1";
322 std::stringstream xdlFileName1;
323 xdlFileName1 << xdlFileNamePartial <<
kNameSeparator << configVal <<
".xdl";
327 configVal =
"#LUT:" + pPins->getName() +
"=" +
"0";
328 std::stringstream xdlFileName0;
329 xdlFileName0 << xdlFileNamePartial <<
kNameSeparator << configVal <<
".xdl";
341 std::stringstream xdlFileName;
342 xdlFileName << xdlFileNamePartial <<
kNameSeparator << configVal <<
".xdl";
353 std::cout <<
" Found a Orphan element " << elem.
getName() << std::endl;
364 InstanceSharedPtr emptyInstance = Factory::newInstancePtr(instancePtr->getName(),
365 instancePtr->getType(), instancePtr->getTile(), instancePtr->getSite(),
366 instancePtr->getBonding());
368 emptyDesign->addInstance(emptyInstance);
375 PrimitiveElement::StringSet::const_iterator pConfigs = configs.begin();
376 PrimitiveElement::StringSet::const_iterator eConfigs = configs.end();
379 while(pConfigs != eConfigs) {
389 std::cout <<
"Found a " << elem.
getName() << std::endl;
395 }
else if(primitiveStructurePtr->isOrphan(elem) && elem.
getName() !=
"SYNC_ATTR") {
402 PrimitiveElement::StringSet::const_iterator pConfigs = configs.begin();
403 PrimitiveElement::StringSet::const_iterator eConfigs = configs.end();
406 while(pConfigs != eConfigs) {
408 if(primitiveStructurePtr->isLUT(elem, *pConfigs)) {
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);
435 if(siteType.length() > 3) {
436 return siteType.substr(0, 4).compare(
"RAMB") == 0;
443 if(siteType.length() > 3) {
444 return siteType.substr(0, 3).compare(
"DSP") == 0;
456 std::stringstream ssXDLFileName;
460 std::fstream xdlExport(xdlFilePath.string().c_str(), std::ios::out);
462 fileExporter(designPtr);
471 std::fstream emptyDesignStream(emptyDesignPath.string().c_str(), std::ios::out);
474 emptyDesignExporter(emptyDesign);
475 emptyDesignStream.close();
485 int main(
int argc,
char **argv) {
488 std::cerr <<
"Invalid arguments. Usage: " << argv[0] <<
489 " <harness_folder> <xdl_generation_folder>" << std::endl;
499 if(!boost::filesystem::exists(harnessFolderPath)) {
500 std::cout <<
"Folder " << harnessFolderPath.string() <<
" does not exist" << std::endl;
521 typedef std::map<std::string, PrimitiveStructureSharedPtr> PrimitiveStructuresSharedPtrMap;
522 PrimitiveStructuresSharedPtrMap primitiveStructures;
525 PrimitiveDefArray& primitiveDefs = sites.
getSiteTypes();
526 PrimitiveDefArray::const_iterator p = primitiveDefs.begin();
527 PrimitiveDefArray::const_iterator e = primitiveDefs.end();
533 primitiveStructurePtr->getPrimitiveDefPtr();
536 primitiveStructures[primitiveDefName] = primitiveStructurePtr;
540 PrimitiveStructuresSharedPtrMap::iterator psp = primitiveStructures.begin();
541 PrimitiveStructuresSharedPtrMap::iterator pse = primitiveStructures.end();
556 primitiveDefName, harnessFolderPath);
559 std::cout <<
"No test harness for site type " << primitiveDefName << std::endl;
563 std::cout <<
"Working on site type " << primitiveDefName << std::endl;
566 std::stringstream ssXdlFileName;
582 primitiveStructurePtr->getPrimitiveDefPtr();
590 while(pElements != eElements) {
593 if(!primitiveStructurePtr->isRoutethrough(elem)) {
598 instancePtr->getConfig(elem.
getName(), harnessConfigName, harnessConfigVal);
602 if(elem.
getCfgs().size() > 0) {
604 std::stringstream ssReferenceXdlFileName;
614 instancePtr->setConfig(elem.
getName(), harnessConfigName, harnessConfigVal);
void GenerateXdlForGenericElement(const PrimitiveElement &elem, const std::string &configVal, const std::string &xdlFileNamePartial, torc::physical::DesignSharedPtr designPtr)
const std::string kConfigOff
const std::string kXDLExtension
const const PrimitiveElement * const_iterator
Constant T iterator type.
DesignSharedPtr GetEmptyDesignWithSameMetadata(torc::physical::DesignSharedPtr designPtr)
Device database, including complete wiring and logic support.
bool LibrarySupportForSiteType(const std::string &siteType)
Returns true if the library supports the site type.
Header for the Virtex5PrimitiveStructure class.
DesignSharedPtr getDesignPtr(void)
Returns a shared pointer for the design.
Header for the DirectoryTree class.
void InitializeElementReferenceConfigMap()
void SetConfigAndGenerateXDL(const std::string &elementName, const std::string &configVal, const std::string &xdlFileName, torc::physical::DesignSharedPtr designPtr)
std::string GetReferenceConfigValueForElement(std::string elementName)
Encapsulation of primitive site definition, with associated connections, elements, and pins.
T * end(void)
Returns the non-constant end iterator.
void GenerateXdlForLUT(const PrimitiveElement &elem, const std::string &xdlFileNamePartial, torc::physical::DesignSharedPtr designPtr)
bool ElementNeedsCompoundSetting(std::string elementName)
const std::string kArchitectureName
void InitializeCompoundSettingsMap()
const Sites & getSites(void) const
Returns a constant reference to the family and device site data.
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...
static boost::filesystem::path gXDLGenerationFolder
const Array< const PrimitiveDef > & getSiteTypes(void) const
Returns the site types for this family.
Main torc::physical namespace header.
Site type and population data for the family and the device.
int main(int argc, char **argv)
Generates XDLs for various site types. An XDL is generated for each.
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 void GenerateXdlForCompoundSettings(const PrimitiveElement &element1, std::string siteType, PrimitiveStructureSharedPtr const primitiveStructurePtr, torc::physical::DesignSharedPtr designPtr)
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)
static std::map< std::string, std::string > gElementReferenceConfigMap
Encapsulation of a primitive site element. Primitive elements are subcomponents of logic primitive s...
void GenerateXdlForOrphanElements(const PrimitiveElement &elem, const std::string &siteType, torc::physical::DesignSharedPtr designPtr)
CompoundSettingMap gCompoundSettingsMap
T * begin(void)
Returns the non-constant begin iterator.
static boost::filesystem::path gXDLReferenceGenerationFolder
std::set< std::string > StringSet
A set of configuration values.
boost::shared_ptr< PrimitiveStructure > PrimitiveStructureSharedPtr
Shared pointer encapsulation of a PrimitiveStructure.
Header for the DDB class.
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)
Importer from XDL format into a physical design.
torc::physical::DesignSharedPtr GetTestHarnessDesignForSiteType(std::string siteType, const boost::filesystem::path &harnessFolderPath)
int FindPrimitiveElementByName(std::string elementName, PrimitiveStructureSharedPtr const primitiveStructurePtr)
bool IsDSPSite(const std::string &siteType)
Subclass of PrimitiveStructure for Virtex5.
Physical design exporter for XDL.
void GenerateReferenceXDLForTheElement(const std::string &elementName, DesignSharedPtr harnessDesignPtr, const std::string &xdlFileName)
const string & getName(void) const
Returns the name of the primitive.