48 else if (cell->
isFF())
52 if (_refpinName ==
"R" || _refpinName ==
"S" || _refpinName ==
"SRI" || _refpinName ==
"CLR" ||
55 if (_refpinName ==
"C" || _refpinName ==
"G")
57 if (_refpinName ==
"D" || _refpinName ==
"DI")
59 if (_refpinName ==
"CE" || _refpinName ==
"GE")
62 assert(
false &&
"no such pin type");
67 if (_refpinName ==
"Q" || _refpinName ==
"O")
69 std::cout <<
"cell: " << cell <<
"\n";
71 assert(
false &&
"no such pin type");
83 pinNames.push_back(_pinName);
88 pinPtrs.push_back(_pinPtr);
90 driverPinPtrs.push_back(_pinPtr);
92 BeDrivenPinPtrs.push_back(_pinPtr);
97 netPtrs.push_back(_netPtr);
100 netNames.push_back(_netPtr->
getName());
103 outputNetPtrs.push_back(_netPtr);
107 inputNetPtrs.push_back(_netPtr);
112 netNames.push_back(std::string(
""));
118 pinPtrs.push_back(_pinPtr);
119 pinNames.push_back(_pinPtr->
getName());
122 outputPinPtrs.push_back(_pinPtr);
126 inputPinPtrs.push_back(_pinPtr);
180 FILEbuf sbuf(popen(unzipCmnd.c_str(),
"r"));
181 std::istream infile(&sbuf);
185 std::getline(infile,
line);
186 std::string cellType, cellName, targetName, dir, refpinname, netName, drivepinName, fill0, fill1, fill2, fill3,
188 std::istringstream iss(
line);
189 iss >> fill0 >> cellName >> fill1 >> cellType;
194 while (std::getline(infile,
line))
196 std::istringstream iss(
line);
197 iss >> fill0 >> targetName;
200 iss >> fill3 >> refpinname >> fill0 >> dir >> fill1 >> netName >> fill2 >> drivepinName;
203 dir == std::string(
"IN"), curCell,
pins.size());
204 pins.push_back(curPin);
206 aliasNetName = netName;
213 if (netName ==
"drivepin=>")
219 assert(drivepinName !=
"");
221 assert(fill1 ==
"net=>");
222 std::regex GNDpattern(
".*/<const0>");
223 if (std::regex_match(netName, GNDpattern))
225 netName = drivepinName =
"<const0>";
227 std::regex VCCpattern(
".*/<const1>");
228 if (std::regex_match(netName, VCCpattern))
230 netName = drivepinName =
"<const1>";
232 netName = drivepinName;
242 iss >> fill1 >> cellType;
247 assert(
false &&
"Parser Error");
252 for (
DesignPin *driverPin : curNet->getDriverPins())
253 for (
DesignPin *pinBeDriven : curNet->getPinsBeDriven())
255 pinBeDriven->setDriverPin(driverPin);
261 if (curNet->getPins().size() < 32)
263 for (
DesignPin *tmpDrivePin : curNet->getPins())
264 for (
DesignPin *tmpPinBeDriven : curNet->getPins())
266 if (tmpDrivePin != tmpPinBeDriven)
269 std::pair<DesignPin *, DesignPin *>(tmpDrivePin, tmpPinBeDriven));
277 std::string STR_PCIE_3_1 =
"PCIE_3_1";
279 assert(deviceInfo->
getSitesInType(STR_PCIE_3_1).size() > 0 &&
"info for PCIE should be included in deviceInfo.");
282 assert(PCIESitePinInfo);
285 for (
DesignPin *curPin : PCIECell->getPins())
288 curPin->setOffsetInCell(PCIESitePinInfo->
name2offsetX[curPin->getRefPinName()],
289 PCIESitePinInfo->
name2offsetY[curPin->getRefPinName()]);
297 std::string clockFileName = std::string(
JSONCfg[
"clock file"]);
302 print_warning(
"No clock file to specify clock signals in design! It might lead to clock partitioning error in "
303 "final placement in vendor tools!");
374 std::ifstream clockFile(clockFileName);
375 assert(clockFile.good() &&
"The clock file does not exist and please check your path settings");
377 while (clockFile.peek() != EOF)
379 std::string clockDriverPinName;
380 clockFile >> clockDriverPinName;
381 if (clockDriverPinName ==
"")
386 "] is not found in design info. It might not be a problem as long as it is an external pin "
387 "or only connected to one instance.");
395 name2Net[clockDriverPinName]->setGlobalClock();
400 for (
auto tmpCell :
cells)
402 for (
auto tmpPin : tmpCell->getPins())
404 if (!tmpPin->isUnconnected())
406 if (tmpPin->getNet())
411 tmpCell->addClockNet(tmpPin->getNet());
437 for (
auto curCell :
cells)
441 if (curCell->isVirtualCell())
443 int CLKId, SRId, CEId;
445 std::tuple<int, int, int, int> CS(CLKId, SRId, CEId,
getFFSRType(curCell->getOriCellType()));
450 curCell->setControlSetInfo(curCS);
457 curCell->setControlSetInfo(curCS);
459 curCS->
addFF(curCell);
472 if (CS->getCE()->getPins().size() < 5000 && CS->getCE()->getPins().size() > 25)
473 CS->getCE()->enhanceOverallClusterNetEnhancement(1.2);
477 if (CS->getSR()->getPins().size() < 5000 && CS->getSR()->getPins().size() > 25)
478 CS->getSR()->enhanceOverallClusterNetEnhancement(1.2);
488 std::string clusterFile = std::string(
JSONCfg[
"designCluster"]);
489 assert(
fileExists(clusterFile) &&
"designCluster file does not exist and please check your path settings");
490 print_status(
"Design User-Defined Cluster Information Loading.");
491 std::string unzipCmnd =
"unzip -p " + clusterFile;
492 FILEbuf sbuf(popen(unzipCmnd.c_str(),
"r"));
493 std::istream infile(&sbuf);
495 std::vector<std::string> strV;
496 std::set<DesignCell *> userDefinedClusterCells;
497 std::vector<DesignCell *> userDefinedClusterCellsVec;
498 std::set<DesignCell *> allCellsInClusters;
499 std::set<DesignNet *> enhancedNets;
500 enhancedNets.clear();
501 allCellsInClusters.clear();
503 while (std::getline(infile,
line))
506 userDefinedClusterCells.clear();
507 userDefinedClusterCellsVec.clear();
509 for (
auto tmpName : strV)
515 if (userDefinedClusterCells.find(curCell) == userDefinedClusterCells.end())
517 userDefinedClusterCellsVec.push_back(curCell);
518 userDefinedClusterCells.insert(curCell);
519 allCellsInClusters.insert(curCell);
522 if ((
float)userDefinedClusterCellsVec.size() / (
float)strV.size() < 0.8)
527 bool hasBRAM =
false;
528 for (
auto cellA : userDefinedClusterCells)
530 hasBRAM |= cellA->isBRAM();
531 hasDSP |= cellA->isDSP();
533 if (hasBRAM || hasDSP)
536 if (userDefinedClusterCells.size() > 200 || userDefinedClusterCells.size() < 16)
542 float enhanceRatio = 1.5 - (0.5 * userDefinedClusterCells.size() / 200.0);
543 if (enhanceRatio < 1)
545 for (
auto cellA : userDefinedClusterCells)
548 for (
DesignPin *curPinA : cellA->getPins())
550 if (curPinA->getNet())
552 if (curPinA->getNet()->getPins().size() > 64)
557 if (userDefinedClusterCells.find(pinInNet->getCell()) != userDefinedClusterCells.end())
559 if (pinInNet->getCell() != cellA)
575 curPinA->getNet()->enhance(pinAIdInNet, pinBIdInNet, enhanceRatio);
576 curPinA->getNet()->enhance(pinBIdInNet, pinAIdInNet, enhanceRatio);
577 enhancedNets.insert(curPinA->getNet());
590 for (
int i = 0;
i < numClusters;
i++)
592 for (
int j =
i + 1; j < numClusters; j++)
601 print_info(
"#Nets Enhanced for userDefinedClusters = " + std::to_string(enhancedNets.size()));
602 print_info(
"#Cells in userDefinedClusters = " + std::to_string(allCellsInClusters.size()));
613 print_error(
"no such type: " + typeName +
" for cell: " + cellName);
614 assert(
false &&
"no such type. Please check your DesignCellType enum definition and CELLTYPESTRS macro.");
622 print_warning(
"get duplicated cells from the design archieve. Maybe bug in Vivado Tcl Libs.");
623 std::cout <<
"duplicated cell: " << existingCell <<
"\n";
627 cells.push_back(curCell);
640 std::string existTypes =
"";
662 if (
isLUT(it->first))
663 LUTCnt += it->second.size();
665 FFCnt += it->second.size();
666 if (
isDSP(it->first))
667 DSPCnt += it->second.size();
669 BRAMCnt += it->second.size();
670 if (
isMux(it->first))
671 MuxCnt += it->second.size();
673 LUTRAMCnt += it->second.size();
675 CarryCnt += it->second.size();
677 print_info(
"#LUTCnt: " + std::to_string(LUTCnt));
678 print_info(
"#FFCnt: " + std::to_string(FFCnt));
679 print_info(
"#CarryCnt: " + std::to_string(CarryCnt));
680 print_info(
"#MuxCnt: " + std::to_string(MuxCnt));
681 print_info(
"#LUTRAMCnt: " + std::to_string(LUTRAMCnt));
682 print_info(
"#DSPCnt: " + std::to_string(DSPCnt));
683 print_info(
"#BRAMCnt: " + std::to_string(BRAMCnt));
688 static const char *DesignCellTypeStr_const[] = {
CELLTYPESTRS};
689 os <<
"DesignCell: (" << DesignCellTypeStr_const[cell->
getCellType()] <<
") " << cell->
getName();
696 static const char *DesignCellTypeStr_const[] = {
CELLTYPESTRS};
698 <<
" (" << DesignCellTypeStr_const[cell->getCellType()] <<
") " << cell->getName();