46 print_status(
"IncrementalBELPacker Pairing LUTs and FFs.");
54 int LUTTO1FFPackedCnt = 0;
55 int LUTTOMultiFFPackedCnt = 0;
56 for (
auto unpackedCell : oriPlacementUnpackedCells)
68 if (curCell->
getOutputPins()[0]->getNet()->getPinsBeDriven().size() == 1)
70 auto pinBeDriven = curCell->
getOutputPins()[0]->getNet()->getPinsBeDriven()[0];
71 assert(pinBeDriven->getCell());
72 auto FFBeDriven = pinBeDriven->getCell();
83 unpackedCell->setPacked();
91 curMacro->
addCell(FFBeDriven, FFBeDriven->getCellType(), 0, 0.0);
93 cellLoc[FFBeDriven->getCellId()].X * FFBeDriven->getPins().size()) /
94 (curCell->
getPins().size() + FFBeDriven->getPins().size());
96 cellLoc[FFBeDriven->getCellId()].Y * FFBeDriven->getPins().size()) /
97 (curCell->
getPins().size() + FFBeDriven->getPins().size());
100 cellLoc[curCell->
getCellId()].X = cellLoc[FFBeDriven->getCellId()].X = newX;
101 cellLoc[curCell->
getCellId()].Y = cellLoc[FFBeDriven->getCellId()].Y = newY;
118 else if (curCell->
getOutputPins()[0]->getNet()->getPinsBeDriven().size() <= 4)
120 float minDis = 1000000000;
123 for (
auto pinBeDriven : curCell->
getOutputPins()[0]->getNet()->getPinsBeDriven())
125 assert(pinBeDriven->getCell());
126 auto FFBeDriven = pinBeDriven->getCell();
131 if (curDis < disThreshold)
136 FFToPack = FFBeDriven;
143 if (FFToPack && drivenFFNum <= 4)
145 if (FFToPack->
isFF())
155 unpackedCell->setPacked();
176 ->cellType2sharedBELTypeOccupation[FFToPack->
getCellType()] +
187 LUTTOMultiFFPackedCnt++;
200 print_info(
"IncrementalBELPacker: LUTTO1FFPackedCnt=" + std::to_string(LUTTO1FFPackedCnt));
201 print_info(
"IncrementalBELPacker: LUTTOMultiFFPackedCnt=" + std::to_string(LUTTOMultiFFPackedCnt));
203 for (
auto unpackedCell : oriPlacementUnpackedCells)
205 if (!unpackedCell->isPacked())
217 print_status(
"IncrementalBELPacker Updating Cell-PlacementUnit Mapping");
224 std::map<DesignInfo::DesignCell *, PlacementInfo::PlacementUnit *> cell2PUMap;
230 assert(cell2PUMap.find(curCell) == cell2PUMap.end());
231 cell2PUMap[curCell] = unpackedCell;
236 for (
auto curCell : curMacro->getCells())
238 if (cell2PUMap.find(curCell) != cell2PUMap.end())
240 std::cout <<
"recorded PU:" << cell2PUMap[curCell] <<
"\n";
241 std::cout <<
"another PU:" << curMacro <<
"\n";
244 assert(cell2PUMap.find(curCell) == cell2PUMap.end());
245 cell2PUMap[curCell] = curMacro;
249 print_status(
"IncrementalBELPacker Paired LUTs and FFs (#Pairs = " + std::to_string(
LUTFFPairs.size()) +
")");
262 std::set<PlacementInfo::PlacementUnpackedCell *> packedCells;
264 int FFCouldBePackedCnt = 0;
268 auto &FFs = CS->getFFs();
269 std::vector<FFLocation> FFpoints;
272 for (
auto curFF : FFs)
277 FFpoints.emplace_back(unpackedCell);
278 FFCouldBePackedCnt++;
283 kdt::KDTree<FFLocation> kdtree(FFpoints,
y2xRatio);
285 for (
auto &FFTmpPoint : FFpoints)
287 auto FF0 = FFTmpPoint.getUnpackedCell();
289 if (packedCells.find(FF0) != packedCells.end())
294 std::vector<int> indices = kdtree.knnSearch(query, k);
296 float closetDis = 10000000;
297 for (
auto tmpInd : indices)
299 auto tmpPU1 = FFpoints[tmpInd].getUnpackedCell();
302 if (packedCells.find(FF1) != packedCells.end())
309 if (dis < disThreshold)
322 auto FF1 = FFpoints[closestInd].getUnpackedCell();
358 packedCells.insert(FF0);
359 packedCells.insert(FF1);
366 print_info(
"IncrementalBELPacker: 2FFPairedCnt=" + std::to_string(FFPairedCnt));
367 print_info(
"IncrementalBELPacker: FFCouldBePackedCnt=" + std::to_string(FFCouldBePackedCnt));
369 for (
auto unpackedCell : oriPlacementUnpackedCells)
371 if (!unpackedCell->isPacked())
383 print_status(
"IncrementalBELPacker Updating Cell-PlacementUnit Mapping");
390 std::map<DesignInfo::DesignCell *, PlacementInfo::PlacementUnit *> cell2PUMap;
396 assert(cell2PUMap.find(curCell) == cell2PUMap.end());
397 cell2PUMap[curCell] = unpackedCell;
402 for (
auto curCell : curMacro->getCells())
404 if (cell2PUMap.find(curCell) != cell2PUMap.end())
406 std::cout <<
"recorded PU:" << cell2PUMap[curCell] <<
"\n";
407 std::cout <<
"another PU:" << curMacro <<
"\n";
410 assert(cell2PUMap.find(curCell) == cell2PUMap.end());
411 cell2PUMap[curCell] = curMacro;
415 print_status(
"IncrementalBELPacker Paired LUTs and FFs (#Pairs = " + std::to_string(
LUTFFPairs.size()) +
")");
424 print_status(
"IncrementalBELPacker: dumping LUTFFPair archieve to: " + dumpFile);
428 std::stringstream outfile0;
431 outfile0 << curPair.first->getName() <<
" " << curPair.second->getName() <<
"\n";
434 print_status(
"IncrementalBELPacker: dumped LUTFFPair archieve to: " + dumpFile);