61 "No fixed cell in the design. Floating placement is not allowed temporarily.");
64 assert(
false &&
"No fixed cell in the design. Floating placement is not allowed temporarily.");
100 if (net->getDriverUnits().size() == 1)
102 if (net->getDriverUnits()[0]->isFixed())
104 net->getDesignNet()->enhanceOverallClusterNetEnhancement(1.5);
107 else if (net->getUnitsBeDriven().size() == 1)
109 if (net->getUnitsBeDriven()[0]->isFixed())
111 net->getDesignNet()->enhanceOverallClusterNetEnhancement(1.5);
117 std::vector<DesignInfo::DesignCell *>
120 std::set<DesignInfo::DesignCell *> tmpCellInMacros;
121 std::vector<DesignInfo::DesignCell *> res;
123 tmpCellInMacros.clear();
124 tmpCellInMacros.insert(startCell);
125 res.push_back(startCell);
127 std::queue<DesignInfo::DesignCell *> cellToBFS;
128 while (!cellToBFS.empty())
130 cellToBFS.push(startCell);
132 while (!cellToBFS.empty())
141 if ((exactMatch && pinBeDriven->getRefPinName() == portPattern) ||
142 (!exactMatch && pinBeDriven->getRefPinName().find(portPattern) == 0))
147 if (tmpCellInMacros.find(tmpCell) == tmpCellInMacros.end())
149 tmpCellInMacros.insert(tmpCell);
150 cellToBFS.push(tmpCell);
151 res.push_back(tmpCell);
164 std::set<DesignInfo::DesignCell *> tmpCellInMacros;
165 std::vector<DesignInfo::DesignCell *> res;
167 tmpCellInMacros.clear();
168 tmpCellInMacros.insert(startCell);
169 res.push_back(startCell);
171 std::queue<DesignInfo::DesignCell *> cellToBFS;
172 while (!cellToBFS.empty())
174 cellToBFS.push(startCell);
176 while (!cellToBFS.empty())
186 for (
auto portPattern : portPatterns)
188 if ((exactMatch && pinBeDriven->getRefPinName() == portPattern) ||
189 (!exactMatch && pinBeDriven->getRefPinName().find(portPattern) == 0))
201 if (tmpCellInMacros.find(tmpCell) == tmpCellInMacros.end())
203 tmpCellInMacros.insert(tmpCell);
204 cellToBFS.push(tmpCell);
205 res.push_back(tmpCell);
217 float DSPHeight = 2.5;
218 std::vector<PlacementInfo::PlacementMacro *> res;
224 std::vector<DesignInfo::DesignCell *> DSPTailsToBeCheckedRegisterAttr;
225 DSPTailsToBeCheckedRegisterAttr.clear();
227 for (
int curCellId = 0; curCellId < curNumCells; curCellId++)
229 auto curCell = curCellsInDesign[curCellId];
230 if (!curCell->isDSP())
236 bool noCASInput =
true;
240 if (pinBeDriven->getRefPinName().find(
"ACIN[") == 0 || pinBeDriven->getRefPinName().find(
"BCIN[") == 0 ||
241 pinBeDriven->getRefPinName().find(
"PCIN[") == 0 ||
242 pinBeDriven->getRefPinName().find(
"CARRYCASCIN") == 0)
244 if (pinBeDriven->getDriverPin())
255 std::vector<std::string> portPatterns{
"ACIN[",
"BCIN[",
"PCIN[",
"CARRYCASCIN"};
258 if (curMacroCores.size())
259 DSPTailsToBeCheckedRegisterAttr.push_back(curMacroCores[curMacroCores.size() - 1]);
260 if (curMacroCores.size() <= 1)
266 float coreOffset = 0;
267 for (
unsigned int i = 0;
i < curMacroCores.size();
i++)
270 curMacro->
addCell(curMacroCores[
i], curMacroCores[
i]->getCellType(), 0, coreOffset);
271 coreOffset += DSPHeight / 2;
274 for (
auto tmpCell : curMacro->
getCells())
282 res.push_back(curMacro);
287 int cellInDSPMacrosCnt = 0;
288 for (
auto macro : res)
289 cellInDSPMacrosCnt += macro->getCells().size();
302 print_info(
"#DSP Macro: " + std::to_string(res.size()));
303 print_info(
"#DSP Macro Cells: " + std::to_string(cellInDSPMacrosCnt));
311 for (
auto startCell : DSPTailsToBeCheckedRegisterAttr)
313 std::queue<DesignInfo::DesignCell *> nodeQ;
314 std::set<DesignInfo::DesignCell *> nodeSet;
316 nodeSet.insert(startCell);
317 nodeQ.push(startCell);
320 while (nodeQ.size() && !found)
322 auto curNode = nodeQ.front();
325 for (
auto outNet : curNode->getOutputNets())
329 for (
auto pin : outNet->getPinsBeDriven())
331 auto nextCell = pin->getCell();
334 if (nodeSet.find(nextCell) == nodeSet.end())
336 nodeSet.insert(nextCell);
338 if (!nextCell->isTimingEndPoint())
339 nodeQ.push(nextCell);
340 if (nextCell->isDSP())
345 startCell->setHasDSPReg(
true);
358 print_warning(std::to_string(DSPRegCount) +
" DSPs have set registered.\n");
364 std::vector<PlacementInfo::PlacementMacro *> res;
369 for (
int curCellId = 0; curCellId < curNumCells; curCellId++)
371 auto curCell = curCellsInDesign[curCellId];
372 if (!curCell->originallyIsLUTRAM())
382 curMacro->
addCell(curCell, curCell->getCellType(), 0, 0);
387 res.push_back(curMacro);
392 int cellInLUTRAMMacrosCnt = 0;
393 for (
auto macro : res)
394 cellInLUTRAMMacrosCnt += macro->getCells().size();
402 print_info(
"#LUTRAM Predictable Macro: " + std::to_string(res.size()));
403 print_info(
"#LUTRAM Predictable Macro Cells: " + std::to_string(cellInLUTRAMMacrosCnt));
410 float BRAM36Height = 5;
411 float BRAM18Height = 2.5;
412 std::vector<PlacementInfo::PlacementMacro *> res;
417 for (
int curCellId = 0; curCellId < curNumCells; curCellId++)
419 auto curCell = curCellsInDesign[curCellId];
420 if (!curCell->isBRAM())
426 bool noCASInput =
true;
430 if (pinBeDriven->getRefPinName().find(
"CASDI") == 0)
432 if (pinBeDriven->getDriverPin())
451 float coreOffset = 0;
452 for (
unsigned int i = 0;
i < curMacroCores.size();
i++)
458 curMacro->
addCell(curMacroCores[
i], curMacroCores[
i]->getCellType(), 0, coreOffset);
461 coreOffset + BRAM18Height);
467 curMacro->
addCell(curMacroCores[
i], curMacroCores[
i]->getCellType(), 0, coreOffset);
474 if (
i < curMacroCores.size() - 1)
478 coreOffset += BRAM36Height;
480 coreOffset += BRAM18Height;
484 for (
auto tmpCell : curMacro->
getCells())
492 res.push_back(curMacro);
497 int cellInBRAMMacrosCnt = 0;
498 for (
auto macro : res)
499 cellInBRAMMacrosCnt += macro->getCells().size();
501 print_info(
"#BRAM Macro: " + std::to_string(res.size()));
502 print_info(
"#BRAM Macro Cells: " + std::to_string(cellInBRAMMacrosCnt));
508 std::set<DesignInfo::DesignPin *> driverPins;
513 if (pinBeDriven->isUnconnected())
515 if (!pinBeDriven->getDriverPin())
519 driverPins.insert(pinBeDriven->getDriverPin());
523 if (pinBeDriven->isUnconnected())
525 if (!pinBeDriven->getDriverPin())
529 driverPins.insert(pinBeDriven->getDriverPin());
531 return driverPins.size() <= 5;
536 std::vector<PackedControlSet> FFControlSets;
537 const int MaxNum_ControlSet = 4;
539 for (
auto curFF : FFs)
541 assert(curFF->getControlSetInfo());
543 for (
unsigned int i = 0;
i < FFControlSets.size();
i++)
545 if (FFControlSets[
i].getCSId() == curFF->getControlSetInfo()->getId() &&
546 FFControlSets[
i].getFFs().size() < MaxNum_ControlSet)
548 FFControlSets[
i].addFF(curFF);
555 FFControlSets.emplace_back(curFF);
559 std::sort(FFControlSets.begin(), FFControlSets.end(),
561 return a.getFFs().size() > b.getFFs().size();
564 typedef struct _CLKSRCombination
568 unsigned int cnt = 0;
570 CLKSRCombination halfCLBSettings[1];
571 std::vector<DesignInfo::DesignCell *> resFF;
573 for (
auto &FFCS : FFControlSets)
575 auto curFF = FFCS.getFFs()[0];
576 assert(curFF->getControlSetInfo());
577 if (halfCLBSettings[0].
cnt == 0 || (halfCLBSettings[0].
cnt < MaxNum_ControlSet / 2 &&
578 halfCLBSettings[0].CLK == curFF->getControlSetInfo()->getCLK() &&
579 halfCLBSettings[0].SR == curFF->getControlSetInfo()->getSR()))
581 halfCLBSettings[0].CLK = curFF->getControlSetInfo()->getCLK();
582 halfCLBSettings[0].SR = curFF->getControlSetInfo()->getSR();
583 halfCLBSettings[0].cnt++;
584 for (
auto tmpFF : FFCS.getFFs())
585 resFF.push_back(tmpFF);
596 std::set<DesignInfo::DesignCell *> mappedCells;
597 std::set<DesignInfo::DesignCell *> mappedLUTs;
598 std::set<DesignInfo::DesignCell *> mappedFFs;
604 float siteHeight = 1.0;
605 float lowerBound = siteHeight * CARRYChainSiteOffset - (1e-2);
606 float uppwerBound = siteHeight * CARRYChainSiteOffset + (1e-2);
607 for (
auto curCell : CARRYChain->
getCells())
610 if (offsetY > lowerBound && offsetY < uppwerBound)
612 if (curCell->isCarry())
614 auto curCarry = curCell;
615 slotMapping.
Carry = curCarry;
616 mappedCells.insert(curCarry);
619 if (pinBeDriven->isUnconnected())
621 if (!pinBeDriven->getDriverPin())
624 if (pinBeDriven->getRefPinName().find(
"S[") == 0)
626 if (CARRYChain->
hasCell(pinBeDriven->getDriverPin()->getCell()) &&
627 pinBeDriven->getDriverPin()->getCell()->isLUT())
630 pinBeDriven->getRefPinName()[pinBeDriven->getRefPinName().find(
"[") + 1] -
'0';
631 slotMapping.
LUTs[SPinCellId / 4][0][SPinCellId % 4] =
632 pinBeDriven->getDriverPin()->getCell();
633 mappedCells.insert(pinBeDriven->getDriverPin()->getCell());
634 mappedLUTs.insert(pinBeDriven->getDriverPin()->getCell());
641 else if (pinBeDriven->getRefPinName().find(
"DI[") == 0)
643 if (CARRYChain->
hasCell(pinBeDriven->getDriverPin()->getCell()) &&
644 pinBeDriven->getDriverPin()->getCell()->isLUT())
647 pinBeDriven->getRefPinName()[pinBeDriven->getRefPinName().find(
"[") + 1] -
'0';
648 slotMapping.
LUTs[DIPinCellId / 4][1][DIPinCellId % 4] =
649 pinBeDriven->getDriverPin()->getCell();
650 mappedCells.insert(pinBeDriven->getDriverPin()->getCell());
651 mappedLUTs.insert(pinBeDriven->getDriverPin()->getCell());
659 std::vector<std::string> checkFFRefPins{
"O[",
"CO["};
662 if (driverPin->isUnconnected())
665 bool findMatchedInputPin =
false;
666 for (
auto patternPin : checkFFRefPins)
668 if (driverPin->getRefPinName().find(patternPin) == 0)
670 findMatchedInputPin =
true;
675 if (findMatchedInputPin)
681 if (pinBeDriven->getCell()->isFF())
684 if (pinBeDriven->getRefPinName().find(
"D") != std::string::npos)
686 if (CARRYChain->
hasCell(pinBeDriven->getCell()))
687 theFF = pinBeDriven->getCell();
691 if (FFcnt == 1 && theFF)
694 driverPin->getRefPinName()[driverPin->getRefPinName().find(
"[") + 1] -
'0';
695 if (driverPin->getRefPinName().find(
"CO[") != std::string::npos)
697 slotMapping.
FFs[FFPinCellId / 4][1][FFPinCellId % 4] = theFF;
698 mappedCells.insert(theFF);
699 mappedFFs.insert(theFF);
704 else if (driverPin->getRefPinName().find(
"O[") != std::string::npos)
706 slotMapping.
FFs[FFPinCellId / 4][0][FFPinCellId % 4] = theFF;
707 mappedCells.insert(theFF);
708 mappedFFs.insert(theFF);
718 if (curCell->isVirtualCell())
720 assert(mappedCells.find(curCell) == mappedCells.end());
721 if (curCell->isLUT())
723 assert(curCell->isLUT6());
724 assert(curCell->getName().find(
'(') != std::string::npos);
725 int slotId = curCell->getName()[curCell->getName().find(
'(') - 1] -
'0';
726 assert(slotId < 8 && slotId >= 0);
727 assert(!slotMapping.
LUTs[slotId / 4][0][slotId % 4]);
728 mappedCells.insert(curCell);
729 mappedLUTs.insert(curCell);
730 slotMapping.
LUTs[slotId / 4][0][slotId % 4] = curCell;
734 assert(curCell->isFF());
735 assert(curCell->getName().find(
'(') != std::string::npos);
736 int strOffset = curCell->getName().find(
'(');
737 int slotId = curCell->getName()[strOffset - 1] -
'0';
738 assert(curCell->getName()[strOffset - 2] ==
'2' || curCell->getName()[strOffset - 2] ==
'F');
739 int oddCLB = curCell->getName()[strOffset - 2] ==
'2';
740 assert(slotId < 8 && slotId >= 0);
741 assert(!slotMapping.
FFs[slotId / 4][oddCLB][slotId % 4]);
742 mappedCells.insert(curCell);
743 mappedFFs.insert(curCell);
744 slotMapping.
FFs[slotId / 4][oddCLB][slotId % 4] = curCell;
750 for (
int i = 0;
i < 2;
i++)
752 for (
int k = 0; k < 4; k++)
754 if (slotMapping.
FFs[
i][0][k] && slotMapping.
FFs[
i][1][k])
758 for (
int jj = 0; jj < 2; jj++)
760 for (
int kk = 0; kk < 4; kk++)
762 if (!slotMapping.
FFs[
i][jj][kk])
781 for (
int i = 0;
i < 2;
i++)
782 for (
int k = 0; k < 4; k++)
784 if (slotMapping.
LUTs[
i][0][k] && !slotMapping.
FFs[
i][0][k])
788 slotMapping.
FFs[
i][0][k] =
791 if (!slotMapping.
FFs[
i][1][k])
793 slotMapping.
FFs[
i][1][k] =
799 if (slotMapping.
LUTs[
i][1][k] && !slotMapping.
FFs[
i][1][k])
805 std::cout << slotMapping.
LUTs[
i][1][k] <<
"\n";
817 std::vector<PlacementInfo::PlacementMacro *> res;
822 for (
int curCellId = 0; curCellId < curNumCells; curCellId++)
824 auto curCell = curCellsInDesign[curCellId];
831 bool noCASInput =
true;
836 if (pinBeDriven->getRefPinName() ==
"CI")
838 if (pinBeDriven->getDriverPin())
854 if (curMacroCores.size() < 1)
862 std::vector<std::string> checkLUTRefPins{
"S["};
863 std::vector<std::string> checkFFRefPins{
"O[",
"CO["};
866 for (
auto coreCell : curMacroCores)
869 curMacro->
addCell(coreCell, coreCell->getCellType(), 0, coreOffset);
874 for (
auto coreCell : curMacroCores)
877 std::vector<std::pair<DesignInfo::DesignPin *, DesignInfo::DesignCell *>> SPinCell(0);
878 SPinCell.resize(8, std::pair<DesignInfo::DesignPin *, DesignInfo::DesignCell *>(
nullptr,
nullptr));
879 std::vector<std::pair<DesignInfo::DesignPin *, DesignInfo::DesignCell *>> DIPinCell(0);
880 DIPinCell.resize(8, std::pair<DesignInfo::DesignPin *, DesignInfo::DesignCell *>(
nullptr,
nullptr));
881 std::vector<bool> externalSignal(0);
882 externalSignal.resize(8,
false);
886 if (pinBeDriven->isUnconnected())
888 if (!pinBeDriven->getDriverPin())
890 if (pinBeDriven->getRefPinName().find(
"DI[") == 0)
893 pinBeDriven->getRefPinName()[pinBeDriven->getRefPinName().find(
"[") + 1] -
'0';
894 DIPinCell[DIPinCellId] =
895 std::pair<DesignInfo::DesignPin *, DesignInfo::DesignCell *>(pinBeDriven,
nullptr);
900 if (pinBeDriven->getRefPinName().find(
"DI[") == 0)
902 char DIPinCellId = pinBeDriven->getRefPinName()[pinBeDriven->getRefPinName().find(
"[") + 1] -
'0';
903 DIPinCell[DIPinCellId] = std::pair<DesignInfo::DesignPin *, DesignInfo::DesignCell *>(
904 pinBeDriven, pinBeDriven->getDriverPin()->getCell());
910 if (pinBeDriven->isUnconnected())
912 if (!pinBeDriven->getDriverPin())
914 if (pinBeDriven->getRefPinName().find(
"S[") == 0)
917 pinBeDriven->getRefPinName()[pinBeDriven->getRefPinName().find(
"[") + 1] -
'0';
918 SPinCell[SPinCellId] =
919 std::pair<DesignInfo::DesignPin *, DesignInfo::DesignCell *>(pinBeDriven,
nullptr);
924 if (pinBeDriven->getRefPinName().find(
"S[") == 0)
926 char SPinCellId = pinBeDriven->getRefPinName()[pinBeDriven->getRefPinName().find(
"[") + 1] -
'0';
927 SPinCell[SPinCellId] = std::pair<DesignInfo::DesignPin *, DesignInfo::DesignCell *>(
928 pinBeDriven, pinBeDriven->getDriverPin()->getCell());
932 for (
unsigned int i = 0;
i < 8;
i++)
934 if (AXUsed &&
i == 0 && coreOffset < 0.005)
936 if (DIPinCell[
i].second && SPinCell[
i].second)
938 bool DICanBeInSlice = DIPinCell[
i].second->isLUT() && !DIPinCell[
i].second->isLUT6() &&
939 DIPinCell[
i].first->getNet()->getPinsBeDriven().size() == 1;
941 SPinCell[
i].second->isLUT() && SPinCell[
i].first->getNet()->getPinsBeDriven().size() == 1;
942 if (DICanBeInSlice && SCanBeInSlice)
946 curMacro->
addCell(DIPinCell[
i].second, DIPinCell[
i].second->getCellType(), 0,
948 curMacro->
addCell(SPinCell[
i].second, SPinCell[
i].second->getCellType(), 0, coreOffset);
956 else if (SCanBeInSlice)
967 else if (SPinCell[
i].second && !DIPinCell[
i].first)
970 SPinCell[
i].second->
isLUT() && SPinCell[
i].first->getNet()->getPinsBeDriven().size() == 1;
971 if (SCanBeInSlice && !SPinCell[
i].second->isLUT6())
987 else if (DIPinCell[
i].second && SPinCell[
i].second)
989 bool DICanBeInSlice = DIPinCell[
i].second->
isLUT() && !DIPinCell[
i].second->isLUT6() &&
990 DIPinCell[
i].first->getNet()->getPinsBeDriven().size() == 1;
992 SPinCell[
i].second->isLUT() && SPinCell[
i].first->getNet()->getPinsBeDriven().size() == 1;
993 if (DICanBeInSlice && SCanBeInSlice)
997 curMacro->
addCell(DIPinCell[
i].second, DIPinCell[
i].second->getCellType(), 0, coreOffset);
998 curMacro->
addCell(SPinCell[
i].second, SPinCell[
i].second->getCellType(), 0, coreOffset);
1005 else if (SCanBeInSlice)
1015 else if (DIPinCell[
i].second && !SPinCell[
i].first)
1017 bool DICanBeInSlice = DIPinCell[
i].second->
isLUT() && !DIPinCell[
i].second->isLUT6() &&
1018 DIPinCell[
i].first->getNet()->getPinsBeDriven().size() == 1;
1021 curMacro->
addCell(DIPinCell[
i].second, DIPinCell[
i].second->getCellType(), 0, coreOffset);
1024 else if (SPinCell[
i].second)
1026 bool SCanBeInSlice =
1027 SPinCell[
i].second->isLUT() && SPinCell[
i].first->getNet()->getPinsBeDriven().size() == 1;
1038 else if (DIPinCell[
i].first || SPinCell[
i].first)
1045 std::vector<DesignInfo::DesignCell *> drivenTopFFs;
1046 std::vector<DesignInfo::DesignCell *> drivenBottomFFs;
1049 if (driverPin->isUnconnected())
1052 bool findMatchedInputPin =
false;
1053 for (
auto patternPin : checkFFRefPins)
1055 if (driverPin->getRefPinName().find(patternPin) == 0)
1057 findMatchedInputPin =
true;
1062 if (findMatchedInputPin)
1068 if (pinBeDriven->getCell()->isFF())
1071 if (pinBeDriven->getRefPinName().find(
"D") != std::string::npos)
1072 theFF = pinBeDriven->getCell();
1075 if (FFcnt == 1 && theFF)
1077 char FFPinCellId = driverPin->getRefPinName()[driverPin->getRefPinName().find(
"[") + 1] -
'0';
1078 if (FFPinCellId < 4)
1079 drivenBottomFFs.push_back(theFF);
1081 drivenTopFFs.push_back(theFF);
1087 std::set<DesignInfo::DesignCell *> addedFFs;
1090 for (
auto theFF : drivenBottomFFs)
1092 curMacro->
addCell(theFF, theFF->getCellType(), 0, coreOffset);
1093 addedFFs.insert(theFF);
1096 for (
auto theFF : drivenTopFFs)
1098 curMacro->
addCell(theFF, theFF->getCellType(), 0, coreOffset);
1099 addedFFs.insert(theFF);
1104 if (driverPin->isUnconnected())
1107 bool findMatchedInputPin =
false;
1108 for (
auto patternPin : checkFFRefPins)
1110 if (driverPin->getRefPinName().find(patternPin) == 0)
1112 findMatchedInputPin =
true;
1117 if (findMatchedInputPin)
1123 if (pinBeDriven->getCell()->isFF())
1126 if (pinBeDriven->getRefPinName().find(
"D") != std::string::npos)
1128 if (addedFFs.find(pinBeDriven->getCell()) != addedFFs.end())
1129 theFF = pinBeDriven->getCell();
1133 if (FFcnt == 1 && theFF)
1153 char FFPinCellId = driverPin->getRefPinName()[driverPin->getRefPinName().find(
"[") + 1] -
'0';
1154 if (driverPin->getRefPinName().find(
"CO[") != std::string::npos)
1156 curMacro->
addVirtualCell(coreCell->getName() +
"__FF2" + std::to_string(FFPinCellId),
1162 else if (driverPin->getRefPinName().find(
"O[") != std::string::npos)
1164 curMacro->
addVirtualCell(coreCell->getName() +
"__FF" + std::to_string(FFPinCellId),
1176 int totalWeight = 0;
1177 for (
auto tmpCell : curMacro->
getCells())
1182 if (tmpCell->isCarry())
1188 res.push_back(curMacro);
1193 int cellInCarryMacrosCnt = 0;
1194 for (
auto macro : res)
1195 cellInCarryMacrosCnt += macro->getCells().size();
1196 print_info(
"#CARRY Macro: " + std::to_string(res.size()));
1197 print_info(
"#CARRY Macro Cells: " + std::to_string(cellInCarryMacrosCnt));
1206 std::vector<PlacementInfo::PlacementMacro *> res;
1210 for (
int curCellId = 0; curCellId < curNumCells; curCellId++)
1212 auto curCell = curCellsInDesign[curCellId];
1219 std::vector<DesignInfo::DesignCell *> curMacroCores;
1220 curMacroCores.clear();
1221 curMacroCores.push_back(curCell);
1226 curMacro->
addCell(curCell, curCell->getCellType(), 0, 0);
1227 bool muxF8HasDirectFF =
1231 if (driverPin->getRefPinName() ==
"O")
1233 auto curOutputNet = driverPin->getNet();
1234 if (curOutputNet->getPinsBeDriven().size() != 1)
1236 auto pinBeDriven = curOutputNet->getPinsBeDriven()[0];
1237 if (pinBeDriven->getCell()->isFF())
1239 if (pinBeDriven->getRefPinName().find(
"D") != std::string::npos)
1241 muxF8HasDirectFF =
true;
1242 curMacro->
addCell(pinBeDriven->getCell(), pinBeDriven->getCell()->getCellType(), 0, 0);
1247 if (!muxF8HasDirectFF)
1253 if (pinBeDriven->getRefPinName() ==
"I0" || pinBeDriven->getRefPinName() ==
"I1")
1255 if (!pinBeDriven->getDriverPin())
1258 curMacro->
addVirtualCell(curCell->getName() +
"__MUXF7" + pinBeDriven->getRefPinName(),
1270 assert(pinBeDriven->getDriverPin());
1274 curMacro->
addCell(pinBeDriven->getDriverPin()->getCell(),
1275 pinBeDriven->getDriverPin()->getCell()->getCellType(), 0, 0);
1280 unsigned int lastMux = 0;
1281 assert(curMacro->
getCells().size() >= 4);
1283 for (
unsigned int i = lastMux + 1;
i < curMacro->
getCells().size();
i++)
1293 assert(tmpCell->
isMux());
1296 if (pinBeDriven->getRefPinName() ==
"I0" || pinBeDriven->getRefPinName() ==
"I1")
1298 if (pinBeDriven->isUnconnected())
1305 assert(pinBeDriven->getDriverPin()->getCell()->isLUT() &&
1306 "just a guess assert. maybe just to use a if-else branch");
1312 assert(curMacro->
getCells().size() >= 7);
1314 for (
unsigned int i = lastMux + 1;
i < curMacro->
getCells().size();
i++)
1324 assert(tmpCell->
isMux());
1325 if (tmpCell->
isMux())
1329 if (pinBeDriven->getRefPinName() ==
"I0" || pinBeDriven->getRefPinName() ==
"I1")
1331 if (pinBeDriven->isUnconnected())
1338 assert(pinBeDriven->getDriverPin()->getCell()->isLUT() &&
1339 "just a guess assert. maybe just to use a if-else branch");
1346 assert(curMacro->
getCells().size() == 10);
1347 int totalWeight = 0;
1348 for (
auto tmpCell : curMacro->
getCells())
1356 res.push_back(curMacro);
1362 for (
int curCellId = 0; curCellId < curNumCells; curCellId++)
1364 auto curCell = curCellsInDesign[curCellId];
1371 std::vector<DesignInfo::DesignCell *> curMacroCores;
1372 curMacroCores.clear();
1373 curMacroCores.push_back(curCell);
1377 curMacro->
addCell(curCell, curCell->getCellType(), 0, 0);
1381 if (driverPin->getRefPinName() ==
"O")
1383 auto curOutputNet = driverPin->getNet();
1384 if (curOutputNet->getPinsBeDriven().size() != 1)
1386 auto pinBeDriven = curOutputNet->getPinsBeDriven()[0];
1387 if (pinBeDriven->getCell()->isFF())
1389 if (pinBeDriven->getRefPinName().find(
"D") != std::string::npos)
1391 curMacro->
addCell(pinBeDriven->getCell(), pinBeDriven->getCell()->getCellType(), 0, 0);
1400 if (pinBeDriven->getRefPinName() ==
"I0" || pinBeDriven->getRefPinName() ==
"I1")
1402 if (pinBeDriven->isUnconnected())
1409 if (pinBeDriven->getDriverPin())
1411 assert(pinBeDriven->getDriverPin()->getCell()->isLUT() &&
1412 "just a guess assert. maybe just to use a if-else branch");
1423 assert(curMacro->
getCells().size() >= 4);
1424 int totalWeight = 0;
1425 for (
auto tmpCell : curMacro->
getCells())
1433 res.push_back(curMacro);
1438 int cellInMuxMacrosCnt = 0;
1439 for (
auto macro : res)
1440 cellInMuxMacrosCnt += macro->getCells().size();
1442 print_info(
"#Mux Macro: " + std::to_string(res.size()));
1443 print_info(
"#Mux Macro Cells: " + std::to_string(cellInMuxMacrosCnt));
1453 std::vector<PlacementInfo::PlacementMacro *> res;
1456 std::ifstream infile(RAMMacroListFromVivadoFileName.c_str());
1457 assert(infile.good() &&
"Unpredictable Macro file does not exist and please check your path settings");
1460 std::getline(infile,
line);
1461 std::string cellName, siteName, BELName, fill0, fill1, fill2;
1462 std::istringstream iss(
line);
1464 std::map<std::string, std::vector<std::string>> siteName2Cells;
1465 std::map<std::string, std::string> cellName2BELLoc;
1466 while (std::getline(infile,
line))
1468 std::istringstream iss(
line);
1469 iss >> fill0 >> cellName >> fill1 >> siteName >> fill2 >> BELName;
1472 if (siteName2Cells.find(siteName) == siteName2Cells.end())
1474 siteName2Cells[siteName] = std::vector<std::string>();
1476 siteName2Cells[siteName].push_back(cellName);
1477 cellName2BELLoc[cellName] = BELName;
1481 for (
auto it = siteName2Cells.begin(); it != siteName2Cells.end(); it++)
1483 auto curSiteName = it->first;
1485 std::set<DesignInfo::DesignCell *> macroCells;
1486 std::set<char> BELset;
1490 for (
auto cellName : it->second)
1493 BELset.insert(cellName2BELLoc[cellName][6]);
1498 if (curSite->getSiteType() ==
"SLICEM")
1505 std::vector<std::string> splited;
1506 strSplit(cellName2BELLoc[cell->getName()], splited,
".");
1508 if (cell->isLUT() || cell->isLUTRAM())
1517 curMacro->
addCell(cell, cell->getCellType(), 0, 0);
1531 curMacro->
addCell(cell, cell->getCellType(), 0, 0);
1540 int totalWeight = 0;
1541 for (
auto tmpCell : curMacro->
getCells())
1550 res.push_back(curMacro);
1555 int cellInMuxMacrosCnt = 0;
1556 for (
auto macro : res)
1557 cellInMuxMacrosCnt += macro->getCells().size();
1559 print_info(
"#CLB Macro: " + std::to_string(res.size()));
1560 print_info(
"#CLB Macro Cells: " + std::to_string(cellInMuxMacrosCnt));
1568 std::vector<std::pair<DesignInfo::DesignCell *, DesignInfo::DesignCell *>> LUTFFPairs;
1575 int LUTTO1FFPackedCnt = 0;
1579 for (
int curCellId = 0; curCellId < curNumCells; curCellId++)
1581 auto curCell = curCellsInDesign[curCellId];
1586 if (curCell->isLUT())
1588 assert(curCell->getOutputPins().size() > 0);
1589 if (curCell->getOutputPins().size() == 1)
1591 if (curCell->getOutputPins()[0]
1594 assert(curCell->getOutputPins()[0]->getNet());
1595 if (curCell->getOutputPins()[0]->getNet()->getPinsBeDriven().size() == 1)
1597 auto pinBeDriven = curCell->getOutputPins()[0]->getNet()->getPinsBeDriven()[0];
1598 assert(pinBeDriven->getCell());
1599 auto FFBeDriven = pinBeDriven->getCell();
1602 LUTFFPairs.emplace_back(curCell, FFBeDriven);
1609 curMacro->
addCell(curCell, curCell->getCellType(), 0, 0.0);
1610 curMacro->
addCell(FFBeDriven, FFBeDriven->getCellType(), 0, 0.0);
1624 LUTTO1FFPackedCnt++;
1635 print_info(
"InitialPacker: LUTTO1FFPackedCnt=" + std::to_string(LUTTO1FFPackedCnt));
1637 print_status(
"InitialPacker Paired LUTs and FFs (#Pairs = " + std::to_string(LUTFFPairs.size()) +
")");
1647 assert(!cell->isVirtualCell());
1663 std::string::size_type start_pos = 0;
1664 while ((start_pos = str.find(from, start_pos)) != std::string::npos)
1666 str.replace(start_pos, from.length(), to);
1667 start_pos += to.length();
1674 std::ifstream infile(fixedPlacementUnitsFromVivadoFileName.c_str());
1675 assert(infile.good() &&
"Fixed Element file does not exist and please check your path settings");
1678 std::getline(infile,
line);
1679 std::string cellName, siteName, BELName, fill0, fill1, fill2;
1680 std::istringstream iss(
line);
1682 while (std::getline(infile,
line))
1684 std::istringstream iss(
line);
1685 iss >> fill0 >> cellName >> fill1 >> siteName >> fill2 >> BELName;
1689 for (
auto tmpPin : curCell->getPins())
1692 if (tmpPin->getNet())
1694 tmpPin->getNet()->setContainFixedPins();
1700 unpackedPU->setLockedAt(siteName, BELName,
deviceInfo);
1708 assert(curMacro->getCells().size() == 2);
1711 curMacro->getCells()[1]->isVirtualCell());
1716 int locY = std::stoi(siteName.substr(siteName.find(
'Y') + 1, siteName.size() - siteName.find(
'Y') - 1));
1717 std::string newSiteName = siteName.substr(0, siteName.find(
'Y') + 1);
1718 std::string oriS =
"RAMB36_";
1719 std::string newS =
"RAMB18_";
1721 std::string newSiteNameA = newSiteName + std::to_string(locY * 2);
1722 std::string newSiteNameB = newSiteName + std::to_string(locY * 2 + 1);
1723 std::string newBELNameA =
"RAMB180.RAMB18E2_L";
1724 std::string newBELNameB =
"RAMB181.RAMB18E2_U";
1726 curMacro->addFixedCellInfo(curMacro->getCells()[0], newSiteNameA, newBELNameA);
1727 curMacro->addFixedCellInfo(curMacro->getCells()[1], newSiteNameB, newBELNameB);
1733 curMacro->setFixed();
1734 curMacro->setPlaced();
1735 curMacro->setLocked();
1746 std::ofstream tmpColorFile(
JSONCfg[
"dumpDirectory"] +
"/color.tcl");
1747 assert(tmpColorFile.is_open() && tmpColorFile.good() &&
1748 "The path for dumping elements' highlight colors does not exist and please check your path settings");
1755 tmpColorFile <<
"highlight -color_index 2 [ get_cells { \n";
1760 if (tmpMacro->getCells().size() == 1)
1762 for (
auto tmpCell : tmpMacro->getCells())
1764 if (!tmpCell->isVirtualCell())
1766 tmpColorFile << tmpCell->getName() <<
"\n";
1771 tmpColorFile <<
"}]\n";
1773 tmpColorFile <<
"highlight -color_index 1 [ get_cells { \n";
1778 if (tmpMacro->getCells().size() == 1)
1780 for (
auto tmpCell : tmpMacro->getCells())
1782 if (!tmpCell->isVirtualCell())
1784 tmpColorFile << tmpCell->getName() <<
"\n";
1789 tmpColorFile <<
"}]\n";
1791 tmpColorFile <<
"highlight -color_index 3 [ get_cells { \n";
1796 if (tmpMacro->getCells().size() == 1)
1798 for (
auto tmpCell : tmpMacro->getCells())
1800 if (!tmpCell->isVirtualCell())
1802 tmpColorFile << tmpCell->getName() <<
"\n";
1807 tmpColorFile <<
"}]\n";
1809 tmpColorFile <<
"highlight -color_index 4 [ get_cells { \n";
1814 if (tmpMacro->getCells().size() == 1)
1816 for (
auto tmpCell : tmpMacro->getCells())
1818 if (!tmpCell->isVirtualCell())
1820 tmpColorFile << tmpCell->getName() <<
"\n";
1825 tmpColorFile <<
"}]\n";
1827 tmpColorFile <<
"highlight -color_index 7 [ get_cells { \n";
1834 if (tmpMacro->getCells().size() == 1)
1836 for (
auto tmpCell : tmpMacro->getCells())
1838 if (!tmpCell->isVirtualCell())
1840 tmpColorFile << tmpCell->getName() <<
"\n";
1845 tmpColorFile <<
"}]\n";
1846 tmpColorFile.close();