AMF-Placer  2.0
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
PlacementInfo.cc
Go to the documentation of this file.
1 
26 #include "PlacementInfo.h"
27 #include "readZip.h"
28 #include "strPrint.h"
29 #include "stringCheck.h"
30 #include <assert.h>
31 #include <cmath>
32 #include <iomanip>
33 #include <queue>
34 #include <sys/stat.h>
35 
37  std::map<std::string, std::string> &JSONCfg)
38  : designInfo(designInfo), deviceInfo(deviceInfo), JSONCfg(JSONCfg)
39 {
40 
41  cellType2fixedAmoFileName = std::string(JSONCfg["cellType2fixedAmo file"]);
42  cellType2sharedCellTypeFileName = std::string(JSONCfg["cellType2sharedCellType file"]);
43  sharedCellType2BELtypeFileName = std::string(JSONCfg["sharedCellType2BELtype file"]);
44 
45  if (JSONCfg.find("y2xRatio") != JSONCfg.end())
46  {
47  y2xRatio = std::stof(JSONCfg["y2xRatio"]);
48  }
49 
50  if (JSONCfg.find("guiEnable") != JSONCfg.end())
51  {
52  guiEnable = JSONCfg["guiEnable"] == "true";
53  }
54 
55  print_status("Loading compatiblePlacementTable");
62 
63  cellId2PlacementUnit.clear();
64  placementUnits.clear();
65  placementMacros.clear();
66  cellInMacros.clear();
67  placementNets.clear();
68  placementUnpackedCells.clear();
69  clockCol2ClockNets.clear();
70 
71  for (auto curClockRegionRow : deviceInfo->getClockRegions())
72  {
73  for (auto curClockRegion : curClockRegionRow)
74  {
75  for (auto curColRows : curClockRegion->getClockColumns())
76  {
77  for (auto curCol : curColRows)
78  {
79  clockCol2ClockNets[curCol] = std::set<DesignInfo::DesignNet *>();
80  }
81  }
82  }
83  }
84 
86 
87  print_status("New Placement Info Created.");
88 }
89 
91  std::string cellType2sharedCellTypeFileName,
92  std::string sharedCellType2BELtypeFileName,
93  DesignInfo *designInfo, DeviceInfo *deviceInfo)
94  : designInfo(designInfo), deviceInfo(deviceInfo)
95 {
96 
97  realBELTypes.clear();
98  realBELTypeName2ID.clear();
99  sharedCellBELTypes.clear();
100  sharedCellBELTypeName2ID.clear();
102  cellType2sharedBELTypes.clear();
104  sharedCellType2SiteType.clear();
105  sharedCellType2BELNames.clear();
106 
107  // get the list of BEL type
108  std::set<std::string>::iterator typeIt;
109  for (typeIt = deviceInfo->getBELTypes().begin(); typeIt != deviceInfo->getBELTypes().end(); typeIt++)
110  {
111  realBELTypeName2ID[*typeIt] = realBELTypes.size();
112  realBELTypes.push_back(*typeIt);
113  }
114 
115  // load cell occupation of BELs
116  std::ifstream infile0(cellType2fixedAmoFileName.c_str());
117  assert(infile0.good() && "cellType2fixedAmoFile file does not exist and please check your path settings");
118 
119  std::string line;
120 
121  std::string cellTypeStr;
122  int occupationAmo;
123  std::string CompatiblePlacementTableLoading = "CompatiblePlacementTableLoading";
124 
125  while (std::getline(infile0, line))
126  {
127  std::istringstream iss(line);
128  iss >> cellTypeStr >> occupationAmo;
129  DesignInfo::DesignCellType cellType =
130  designInfo->fromStringToCellType(CompatiblePlacementTableLoading, cellTypeStr);
131  cellType2sharedBELTypeOccupation[cellType] = occupationAmo;
132  }
133 
134  for (auto &tmppair : designInfo->getType2Cells())
135  {
137  {
138  std::cout << "cellType: " << tmppair.first
139  << " is not defined with resource demand. Check your compatibale table setting.\n";
140  }
141  assert(cellType2sharedBELTypeOccupation.find(tmppair.first) != cellType2sharedBELTypeOccupation.end() &&
142  "each type should be defined with resource demand.");
143  }
144 
145  // load cell mapping to BEL shared virtual type
146  std::ifstream infile1(cellType2sharedCellTypeFileName.c_str());
147  assert(infile1.good() && "cellType2sharedCellType file does not exist and please check your path settings");
148  std::string cell2BELType;
149 
150  std::set<std::string> involvedSharedBELStr;
151  involvedSharedBELStr.clear();
152 
153  while (std::getline(infile1, line))
154  {
155  std::istringstream iss(line);
156  iss >> cellTypeStr >> cell2BELType;
157  std::vector<std::string> cellTypeStrVec;
158  strSplit(cellTypeStr, cellTypeStrVec, ",");
159  std::vector<std::string> BELTypeStrVec;
160  strSplit(cell2BELType, BELTypeStrVec, ",");
161 
162  for (auto tmpCellTypeStr : cellTypeStrVec)
163  {
164  DesignInfo::DesignCellType cellType =
165  designInfo->fromStringToCellType(CompatiblePlacementTableLoading, tmpCellTypeStr);
166  cellType2sharedBELTypes[cellType] = BELTypeStrVec;
167  }
168 
169  for (auto tmpSharedBELStr : BELTypeStrVec)
170  {
171  involvedSharedBELStr.insert(tmpSharedBELStr);
172  if (sharedCellBELTypeName2ID.find(tmpSharedBELStr) == sharedCellBELTypeName2ID.end())
173  {
174  sharedCellBELTypeName2ID[tmpSharedBELStr] = sharedCellBELTypes.size();
175  sharedCellBELTypes.push_back(tmpSharedBELStr);
176  }
177  }
178  for (auto tmpCellTypeStr : cellTypeStrVec)
179  {
180  DesignInfo::DesignCellType cellType =
181  designInfo->fromStringToCellType(CompatiblePlacementTableLoading, tmpCellTypeStr);
182  if (cellType2sharedBELTypeIDs.find(cellType) == cellType2sharedBELTypeIDs.end())
183  {
184  cellType2sharedBELTypeIDs[cellType] = std::vector<int>();
185  for (auto tmpSharedBELStr : BELTypeStrVec)
186  cellType2sharedBELTypeIDs[cellType].push_back(sharedCellBELTypeName2ID[tmpSharedBELStr]);
187  }
188  }
189  }
190 
191  // load BEL shared virtual type to real compatible BEL type
192  std::ifstream infile2(sharedCellType2BELtypeFileName.c_str());
193  assert(infile2.good() && "sharedCellType2BELtype file does not exist and please check your path settings");
194  std::string compatibleBELTypeStrs, sharedCellTypeStr, siteTypeStr;
195 
196  while (std::getline(infile2, line))
197  {
198  std::istringstream iss(line);
199  iss >> sharedCellTypeStr >> siteTypeStr >> compatibleBELTypeStrs;
200  std::vector<std::string> CompatibleBELStrVec;
201  strSplit(compatibleBELTypeStrs, CompatibleBELStrVec, ",");
202 
203  sharedCellType2SiteType[sharedCellTypeStr] = siteTypeStr;
204  sharedCellType2BELNames[sharedCellTypeStr] = CompatibleBELStrVec;
205  print_info("There are " + std::to_string(CompatibleBELStrVec.size()) + " slot(s) in a site for cell type : (" +
206  sharedCellTypeStr + "). They are :" + compatibleBELTypeStrs);
207  }
208 
209  for (auto it = involvedSharedBELStr.begin(); it != involvedSharedBELStr.end(); it++)
210  {
211  assert(sharedCellType2SiteType.find(*it) != sharedCellType2SiteType.end());
212  }
213 
214  print_status("New Compatible Placement Table Loaded.");
215 }
216 
218 {
219  cellId2SharedCellBELTypeID.resize(designInfo->getNumCells());
220  cellId2Occupation.resize(designInfo->getNumCells());
221  cellId2InfationRatio.resize(designInfo->getNumCells());
222  for (auto cell : designInfo->getCells())
223  {
224  assert(cellId2SharedCellBELTypeID[cell->getCellId()].size() == 0);
225 
226  cellId2Occupation[cell->getCellId()] = cellType2sharedBELTypeOccupation[cell->getCellType()];
227  cellId2InfationRatio[cell->getCellId()] = 1.0;
228  for (auto sharedBELTypeStr : cellType2sharedBELTypes[cell->getCellType()])
229  {
230  // map some BEL type to the same BEL id tomporarily for cell spreading, e.g., SLICEM_LUT -> SLICEL_LUT
231  int sharedBELTypeID = sharedCellBELTypeName2ID[deviceInfo->getBELType2FalseBELType(sharedBELTypeStr)];
232  cellId2SharedCellBELTypeID[cell->getCellId()].push_back(sharedBELTypeID);
233  }
234 
235  assert(cellId2SharedCellBELTypeID[cell->getCellId()].size() != 0);
236  }
237  defaultCellId2Occupation = cellId2Occupation;
238  print_status("set BEL type for each cell");
239 }
240 
242 {
243  cellId2Occupation = defaultCellId2Occupation;
244  for (unsigned int i = 0; i < cellId2Occupation.size(); i++)
245  {
246  cellId2InfationRatio[i] = 1.0;
247  }
248 }
249 
250 float PlacementInfo::getMinXFromSites(std::vector<DeviceInfo::DeviceSite *> &sites)
251 {
252  float minX = 100000;
253  for (auto curSite : sites)
254  {
255  if (curSite->X() < minX)
256  minX = curSite->X();
257  }
258  return minX;
259 }
260 
261 float PlacementInfo::getMinYFromSites(std::vector<DeviceInfo::DeviceSite *> &sites)
262 {
263  float minY = 100000;
264  for (auto curSite : sites)
265  {
266  if (curSite->Y() < minY)
267  minY = curSite->Y();
268  }
269  return minY;
270 }
271 
272 float PlacementInfo::getMaxXFromSites(std::vector<DeviceInfo::DeviceSite *> &sites)
273 {
274  float maxX = -100000;
275  for (auto curSite : sites)
276  {
277  if (curSite->X() > maxX)
278  maxX = curSite->X();
279  }
280  return maxX;
281 }
282 
283 float PlacementInfo::getMaxYFromSites(std::vector<DeviceInfo::DeviceSite *> &sites)
284 {
285  float maxY = -100000;
286  for (auto curSite : sites)
287  {
288  if (curSite->Y() > maxY)
289  maxY = curSite->Y();
290  }
291  return maxY;
292 }
293 
294 void PlacementInfo::printStat(bool verbose)
295 {
296  print_info("globalMinX: " + std::to_string(globalMinX));
297  print_info("globalMinY: " + std::to_string(globalMinY));
298  print_info("globalMaxX: " + std::to_string(globalMaxX));
299  print_info("globalMaxY: " + std::to_string(globalMaxY));
300  print_info("Total Placement Unit(s): " + std::to_string(placementUnits.size()));
301  print_info("Total Unpacked Placement Unit(s): " + std::to_string(designInfo->getNumCells() - cellInMacros.size()));
302  print_info("Total Macro Placement Unit(s): " +
303  std::to_string(placementUnits.size() - (designInfo->getNumCells() - cellInMacros.size())));
304  print_info("Cells in Macros Percentage: " +
305  std::to_string((float)(cellInMacros.size()) / (float)designInfo->getNumCells()));
306 }
307 
309 {
310  if (inRange(curSite->X(), curSite->Y()))
311  {
312  correspondingSites.push_back(curSite);
313  capacity += compatiblePlacementTable->sharedCellType2BELNames[sharedCellType].size();
314  setClockRegionX(curSite->getClockRegionX());
315  }
316  else
317  {
318  print_error("leftX: " + std::to_string(leftX) + "rightX: " + std::to_string(rightX) +
319  "topY: " + std::to_string(topY) + "bottomY: " + std::to_string(bottomY));
320  print_error("curSite: " + curSite->getName());
321  assert(false && "some sites are out of the scope");
322  }
323 }
324 
325 void PlacementInfo::createGridBins(float _binWidth, float _binHeight)
326 {
331  eps = 1e-6;
332  binWidth = _binWidth;
333  binHeight = _binHeight;
334 
335  if (SharedBELTypeBinGrid.size())
336  {
337  for (auto &tmpBinGrid : SharedBELTypeBinGrid)
338  {
339  for (auto &tmpRow : tmpBinGrid)
340  for (auto &curBin : tmpRow)
341  {
342  delete curBin;
343  }
344  }
345  }
346  if (LUTFFBinGrid.size())
347  {
348  for (auto &tmpRow : LUTFFBinGrid)
349  for (auto &curBin : tmpRow)
350  {
351  delete curBin;
352  }
353  }
354  if (globalBinGrid.size())
355  {
356  for (auto &tmpRow : globalBinGrid)
357  for (auto &curBin : tmpRow)
358  {
359  delete curBin;
360  }
361  }
362 
363  SharedBELTypeBinGrid.clear();
364  globalBinGrid.clear();
365 
366  int i = 0, j = 0;
367  float curBottomY, curLeftX;
368  for (std::string sharedBELStr : compatiblePlacementTable->sharedCellBELTypes)
369  {
370  std::vector<std::vector<PlacementBinInfo *>> tmpSharedBELGrid;
371  tmpSharedBELGrid.clear();
372  for (curBottomY = startY, i = 0; curBottomY < endY - eps; curBottomY += binHeight, i++)
373  {
374  std::vector<PlacementBinInfo *> tmpBELGridRow;
375  tmpBELGridRow.clear();
376  for (curLeftX = startX, j = 0; curLeftX < endX - eps; curLeftX += binWidth, j++)
377  {
378  PlacementBinInfo *newBin = new PlacementBinInfo(sharedBELStr, curLeftX, curLeftX + binWidth, curBottomY,
379  curBottomY + binHeight, i, j, compatiblePlacementTable);
380  tmpBELGridRow.push_back(newBin);
381  }
382  tmpSharedBELGrid.push_back(tmpBELGridRow);
383  }
384  SharedBELTypeBinGrid.push_back(tmpSharedBELGrid);
385  }
386 
387  // extra binGrid for LUTFF utilization adjustment and a global bin grid for all types of elememnts to evelaute
388  // routability
389  LUTFFBinGrid.clear();
390  for (curBottomY = startY, i = 0; curBottomY < endY - eps; curBottomY += binHeight, i++)
391  {
392  std::vector<PlacementBinInfo *> tmpBELGridRow;
393  tmpBELGridRow.clear();
394  std::vector<PlacementBinInfo *> tmpGlobalBELGridRow;
395  tmpGlobalBELGridRow.clear();
396  for (curLeftX = startX, j = 0; curLeftX < endX - eps; curLeftX += binWidth, j++)
397  {
398  PlacementBinInfo *newBin =
399  new PlacementBinInfo("LUTFF_BECAREFUL", curLeftX, curLeftX + binWidth, curBottomY,
400  curBottomY + binHeight, i, j, compatiblePlacementTable);
401  PlacementBinInfo *globalNewBin =
402  new PlacementBinInfo("globalInfo_BECAREFUL", curLeftX, curLeftX + binWidth, curBottomY,
403  curBottomY + binHeight, i, j, compatiblePlacementTable);
404  tmpBELGridRow.push_back(newBin);
405  tmpGlobalBELGridRow.push_back(globalNewBin);
406  }
407  LUTFFBinGrid.push_back(tmpBELGridRow);
408  globalBinGrid.push_back(tmpGlobalBELGridRow);
409  }
410  // a set for grid check
411  std::set<DeviceInfo::DeviceSite *> countedSites;
412  countedSites.clear();
413 
414  for (std::string sharedBELStr : compatiblePlacementTable->sharedCellBELTypes)
415  {
416  if (compatiblePlacementTable->sharedCellType2SiteType.find(sharedBELStr) ==
418  {
419  print_error(sharedBELStr + " is not found in sharedCellType2SiteType.");
420 
421  for (auto it = compatiblePlacementTable->sharedCellType2SiteType.begin();
423  print_error("sharedCellType2SiteType Key: " + it->first);
424  }
425  assert(compatiblePlacementTable->sharedCellType2SiteType.find(sharedBELStr) !=
427  std::string targetSiteType = compatiblePlacementTable->sharedCellType2SiteType[sharedBELStr];
428 
429  std::vector<DeviceInfo::DeviceSite *> &sitesInType = deviceInfo->getSitesInType(targetSiteType);
430 
431  // map some BEL type to the same BEL id tomporarily for cell spreading, e.g., SLICEM_LUT -> SLICEL_LUT
432  std::string targetSharedBELStr = getBELType2FalseBELType(sharedBELStr);
433  int targetSharedBELTypeId = compatiblePlacementTable->getSharedBELTypeId(targetSharedBELStr);
434  int actualSharedBELTypeId = compatiblePlacementTable->getSharedBELTypeId(sharedBELStr);
435 
436  unsigned int siteIndex = 0;
437  for (curBottomY = startY, i = 0; curBottomY < endY - eps; curBottomY += binHeight, i++)
438  {
439  while (SharedBELTypeBinGrid[targetSharedBELTypeId][i][0]->inRangeY(sitesInType[siteIndex]->Y()))
440  {
441  for (curLeftX = startX, j = 0; curLeftX < endX - eps; curLeftX += binWidth, j++)
442  {
443  while (SharedBELTypeBinGrid[targetSharedBELTypeId][i][j]->inRange(sitesInType[siteIndex]->X(),
444  sitesInType[siteIndex]->Y()))
445  {
446  SharedBELTypeBinGrid[targetSharedBELTypeId][i][j]->addSiteIntoBin(sitesInType[siteIndex]);
447  globalBinGrid[i][j]->addSiteIntoBin(sitesInType[siteIndex]);
448  if (actualSharedBELTypeId != targetSharedBELTypeId)
449  SharedBELTypeBinGrid[actualSharedBELTypeId][i][j]->addSiteIntoBin(sitesInType[siteIndex]);
450  countedSites.insert(sitesInType[siteIndex]);
451  siteIndex++;
452  if (siteIndex >= sitesInType.size())
453  break;
454  }
455  if (siteIndex >= sitesInType.size())
456  break;
457  }
458  if (siteIndex >= sitesInType.size())
459  break;
460  }
461  if (siteIndex >= sitesInType.size())
462  break;
463  }
464  }
465 
466  // for (auto &tmpBinGrid : SharedBELTypeBinGrid)
467  // {
468  // for (auto &tmpRow : tmpBinGrid)
469  // for (unsigned int i = 2; i < tmpRow.size(); i++)
470  // {
471  // if (tmpRow[i]->getClockRegionX() != tmpRow[i - 1]->getClockRegionX())
472  // {
473  // tmpRow[i - 1]->setRequiredBinShrinkRatio(0.75);
474  // tmpRow[i]->setRequiredBinShrinkRatio(0.75);
475  // }
476  // }
477  // }
478 
479  std::set<std::string> siteTypeNotMapped;
480  if (countedSites.size() < deviceInfo->getSites().size())
481  {
482  for (auto site : deviceInfo->getSites())
483  {
484  if (countedSites.find(site) == countedSites.end() &&
485  siteTypeNotMapped.find(site->getSiteType()) == siteTypeNotMapped.end())
486  {
487  print_warning("Site Type (" + site->getSiteType() + ") is not mapped to bin grid. e.g. [" +
488  site->getName() +
489  "]. It might be not critical if the design will not utilize this kind of sites. Please "
490  "check the compatible table you defined.");
491  siteTypeNotMapped.insert(site->getSiteType());
492  }
493  }
494  }
495  // assert(countedSites.size()==deviceInfo->getSites().size() && "all sites should be mapped into bins.");
496 
497  std::string SLICEL_LUT_STR = "SLICEL_LUT";
498  print_status(
499  "Bin Grid Size: Y: " +
500  std::to_string(SharedBELTypeBinGrid[compatiblePlacementTable->getSharedBELTypeId(SLICEL_LUT_STR)].size()) +
501  " X:" +
502  std::to_string(SharedBELTypeBinGrid[compatiblePlacementTable->getSharedBELTypeId(SLICEL_LUT_STR)][0].size()));
503 
504  print_status("Bin Grid for Density Control Created");
505 }
506 
508 {
509  if (!placementNets.empty())
510  {
511  for (auto net : placementNets)
512  {
513  delete net;
514  }
515  }
516  placementNets.clear();
517  clockNets.clear();
518  designNetId2PlacementNet.resize(designInfo->getNets().size(), nullptr);
520  {
521  PlacementNet *newPNet = new PlacementNet(net, placementNets.size(), cellId2PlacementUnitVec, this);
522  PlacementUnit *PUInNet = nullptr;
523  bool isInternalNet = true;
524  for (auto tmpPU : newPNet->getUnits())
525  {
526  if (!PUInNet)
527  PUInNet = tmpPU;
528  else
529  {
530  if (PUInNet != tmpPU)
531  {
532  isInternalNet = false;
533  }
534  }
535  }
536  if (isInternalNet)
537  {
538  delete newPNet;
539  continue;
540  }
541  designNetId2PlacementNet[net->getElementIdInType()] = newPNet;
542  placementNets.push_back(newPNet);
543  if (newPNet->isGlobalClock())
544  clockNets.push_back(newPNet);
545  }
546 
547  std::vector<std::set<PlacementNet *>> placementUnitId2NetSet;
548  placementUnitId2NetSet.clear();
549  placementUnitId2NetSet.resize(placementUnits.size(), std::set<PlacementNet *>());
550  placementUnitId2Nets.clear();
551  placementUnitId2Nets.resize(placementUnits.size(), std::vector<PlacementNet *>());
552 
553  for (auto curNet : placementNets)
554  {
555  for (auto curPU : curNet->getUnits())
556  {
557  if (placementUnitId2NetSet[curPU->getId()].find(curNet) == placementUnitId2NetSet[curPU->getId()].end())
558  {
559  placementUnitId2NetSet[curPU->getId()].insert(curNet);
560  placementUnitId2Nets[curPU->getId()].push_back(curNet);
561  }
562  }
563  }
564 
565  for (auto curPU : placementUnits)
566  {
567  curPU->setNetsSetPtr(&placementUnitId2Nets[curPU->getId()]);
568  }
569 
570  PUSetContainingFF.clear();
571  PUsContainingFF.clear();
572 
573  for (auto curPU : placementUnits)
574  {
575  if (curPU->hasRegister())
576  {
577  if (PUSetContainingFF.find(curPU) == PUSetContainingFF.end())
578  {
579  PUSetContainingFF.insert(curPU);
580  PUsContainingFF.push_back(curPU);
581  }
582  }
583  }
584 
585  for (int i = 0; i <= 7; i++)
586  netDistribution[i] = 0;
587 
588  for (auto curNet : placementNets)
589  {
590  bool overflow = true;
591  int i = 0;
592  for (i = 0; i < 7; i++)
593  {
594  if (curNet->getPinOffsetsInUnit().size() <= netPinNumDistribution[i] + 1)
595  {
596  overflow = false;
597  netDistribution[i]++;
598  break;
599  }
600  }
601  if (overflow)
602  {
603  netDistribution[i]++;
604  }
605  }
606 
607  std::string outputStr = "net interconnection density: ";
608  for (int i = 0; i <= 7; i++)
609  {
610  outputStr +=
611  "netPin<" + std::to_string(netPinNumDistribution[i]) + ": " + std::to_string(netDistribution[i]) + ", ";
612  if (netDistribution[i] > 1000 && netPinNumDistribution[i] > 64)
613  {
614  if (netDistribution[i] > netDistribution[i - 1] * 2)
615  {
617  print_warning("PlacementInfo: High Fanout Thr=" + std::to_string(highFanOutThr));
618  }
619  }
620  }
621  print_info("PlacementInfo: " + outputStr);
622 
624  {
626  {
627  timingNode->setClusterId(cellId2PlacementUnit[timingNode->getId()]->getId());
628  }
629  }
630 
631  // updateLongPaths();
632  print_status("reload placementNets and #register-related PU=" + std::to_string(PUsContainingFF.size()));
633 }
634 
636 {
637  print_status("updating long paths and #PUsContainingFF=" + std::to_string(PUsContainingFF.size()));
638  std::set<PlacementUnit *> visitedPUs;
639 
640  longPaths.clear();
641  visitedPUs.clear();
642 
643  int restartNum = 1000000;
644  int pathMexLen = 100;
645 
646  for (int restartIter = 0; restartIter < restartNum; restartIter++)
647  {
648  PlacementUnit *curPU = PUsContainingFF[restartIter % PUsContainingFF.size()];
649  // if (visitedPUs.find(curPU) != visitedPUs.end())
650  // {
651  // continue;
652  // }
653  std::vector<PlacementUnit *> curPath(0);
654  curPath.push_back(curPU);
655  // visitedPUs.insert(curPU);
656 
657  for (int pathEleId = 0; pathEleId < pathMexLen; pathEleId++)
658  {
659  std::vector<PlacementNet *> outputNets;
660  outputNets.clear();
661  for (auto curNet : *(curPU->getNetsSetPtr()))
662  {
663  if (curNet->getDriverUnits().size() == 1)
664  {
665  if (curNet->getDriverUnits()[0] == curPU && curNet->getUnitsBeDriven().size() > 0)
666  {
667  outputNets.push_back(curNet);
668  }
669  }
670  }
671 
672  PlacementUnit *nextPU = nullptr;
673  if (outputNets.size())
674  {
675  int tryCnt = 40;
676  while (tryCnt--)
677  {
678  auto selectedNet = outputNets[random() % outputNets.size()];
679 
680  nextPU =
681  selectedNet->getUnitsBeDriven()[random() * random() % selectedNet->getUnitsBeDriven().size()];
682 
683  if (curPU == nextPU || !nextPU->hasLogic() || visitedPUs.find(nextPU) != visitedPUs.end())
684  {
685  nextPU = nullptr;
686  continue;
687  }
688  else
689  {
690  break;
691  }
692  }
693  }
694  if (nextPU)
695  {
696  curPath.push_back(nextPU);
697 
698  if (nextPU->hasRegister())
699  break;
700  curPU = nextPU;
701  }
702  }
703  if (curPath.size() > 5)
704  {
705  longPaths.push_back(curPath);
706  for (unsigned int i = 1; i < curPath.size() - 1; i++)
707  {
708  visitedPUs.insert(curPath[i]);
709  }
710  }
711  }
712 
713  std::sort(longPaths.begin(), longPaths.end(),
714  [](const std::vector<PlacementUnit *> &a, const std::vector<PlacementUnit *> &b) -> bool {
715  return a.size() > b.size();
716  });
717 
718  // longPaths.resize(longPaths.size() / 4);
719  print_status("Found #path = " + std::to_string(longPaths.size()));
720  print_status("Found longest path with " + std::to_string(longPaths[0].size()) + " PUs");
721 }
722 
724 {
725  return;
726  for (auto &path : longPaths)
727  {
728  float totalWeight = 0;
729  float totalX = 0;
730  float totalY = 0;
731  for (auto tmpPU : path)
732  {
733  float curWeight = 0;
734  if (tmpPU->checkHasBRAM() || tmpPU->checkHasCARRY() || tmpPU->checkHasDSP())
735  {
736  totalWeight += 20;
737  curWeight = 20;
738  }
739  else
740  {
741  totalWeight += 1;
742  curWeight = 1;
743  }
744  totalX += tmpPU->X() * curWeight;
745  totalY += tmpPU->Y() * curWeight;
746  }
747  float avgX = totalX / totalWeight;
748  float avgY = totalY / totalWeight;
749  for (auto tmpPU : path)
750  {
751  if (tmpPU->checkHasDSP() || tmpPU->checkHasBRAM())
752  continue;
753  tmpPU->setAnchorLocationAndForgetTheOriginalOne(avgX, avgY);
755  }
756  }
757  print_warning("Update the locations of PUs in long paths");
758 }
759 
760 void PlacementInfo::PlacementNet::drawNet(float generalWeight)
761 {
762  std::vector<std::pair<float, float>> nodexy;
763  std::vector<std::pair<int, int>> lines;
764  for (unsigned int pinId_net = 0; pinId_net < unitsOfNetPins.size(); pinId_net++)
765  {
766  auto tmpPU = unitsOfNetPins[pinId_net];
767  auto tmpPinOffset = pinOffsetsInUnit[pinId_net];
768  float curX = tmpPU->X() + tmpPinOffset.x;
769  float curY = tmpPU->Y() + tmpPinOffset.y;
770  nodexy.push_back(std::pair<float, float>(curX, curY));
771  }
772  lines.push_back(std::pair<int, int>(leftPinId_net, rightPinId_net));
773  lines.push_back(std::pair<int, int>(bottomPinId_net, bottomPinId_net));
774 
775  for (unsigned int pinId_net = 0; pinId_net < unitsOfNetPins.size(); pinId_net++)
776  {
777  if (pinId_net != leftPinId_net && pinId_net != rightPinId_net)
778  {
779  lines.push_back(std::pair<int, int>(leftPinId_net, pinId_net));
780  lines.push_back(std::pair<int, int>(rightPinId_net, pinId_net));
781  }
782  if (pinId_net != topPinId_net && pinId_net != bottomPinId_net)
783  {
784  lines.push_back(std::pair<int, int>(bottomPinId_net, pinId_net));
785  lines.push_back(std::pair<int, int>(topPinId_net, pinId_net));
786  }
787  }
788 }
789 
791 {
792  for (DesignInfo::DesignCell *curCell : designInfo->getCells())
793  {
794  DesignInfo::DesignCellType cellType = curCell->getCellType();
795  assert(compatiblePlacementTable->cellType2sharedBELTypes.find(cellType) !=
797  "all cells in the design should be placable in the device.");
798  }
799  print_status("Device Information Verified for Design Information");
800 }
801 
802 std::ostream &operator<<(std::ostream &os, PlacementInfo::PlacementMacro *curMacro)
803 {
804  // std::vector<DesignInfo::DesignCell *> cells;
805  // std::set<DesignInfo::DesignCell *> cellSet;
806  // std::map<DesignInfo::DesignCell *, short> cell2VirtualCellId;
807  // std::vector<DesignInfo::DesignCell *> VirtualCellId2cell;
808  // std::vector<DesignInfo::DesignCellType>
809  // virtualCellTypes; // BELTypeOccupation.size()>=realCells.size() because somtime a cell or a connection net
810  // // can occupy multiple BEL
811  // std::vector<float> offsetX, offsetY; // offsetX.size() == BELTypeOccupation.size()
812  // std::vector<fixedPlacementInfo_inMacro> fixedCells;
813  // float left, right, top, bottom;
814  // PlacementMacroType macroType;
815  os << "Macro: " << curMacro->getId() << " " << curMacro->getName() << "\n";
816 
818  os << " macroType: PlacementMacroType_LUTFFPair\n";
820  os << " macroType: PlacementMacroType_FFFFPair\n";
822  os << " macroType: PlacementMacroType_HALFCLB\n";
824  os << " macroType: PlacementMacroType_LCLB\n";
826  os << " macroType: PlacementMacroType_MCLB\n";
828  os << " macroType: PlacementMacroType_CARRY\n";
830  os << " macroType: PlacementMacroType_DSP\n";
832  os << " macroType: PlacementMacroType_BRAM\n";
834  os << " macroType: PlacementMacroType_MUX7\n";
836  os << " macroType: PlacementMacroType_MUX8\n";
838  os << " macroType: PlacementMacroType_LUTLUTSeires\n";
839  else
840  assert(false && "undefined macro type.");
841 
842  os << " placedAt: " << curMacro->X() << " " << curMacro->Y() << "\n";
843  os << " isPlaced: " << curMacro->isPlaced() << "\n";
844  os << " isFixed: " << curMacro->isFixed() << "\n";
845  os << " isLocked: " << curMacro->isLocked() << "\n";
846  os << " left, right, top, bottom: " << curMacro->getLeftOffset() << " " << curMacro->getRightOffset() << " "
847  << curMacro->getTopOffset() << " " << curMacro->getBottomOffset() << "\n";
848 
849  os << " numCell: " << curMacro->getCells().size() << "\n";
850  for (unsigned int i = 0; i < curMacro->getCells().size(); i++)
851  {
852  DesignInfo::DesignCell *curCell = curMacro->getCells()[i];
853  os << " CellId: " << curCell->getCellId() << " targetCellTypeEnumId: " << curMacro->getVirtualCellType(i)
854  << " name: " << curCell->getName() << " " << curMacro->getCellOffsetXInMacro(curCell) << " "
855  << curMacro->getCellOffsetYInMacro(curCell) << "\n";
856  }
857 
858  os << " numFixedCell: " << curMacro->getFixedCellInfoVec().size() << "\n";
859  for (unsigned int i = 0; i < curMacro->getFixedCellInfoVec().size(); i++)
860  {
861  DesignInfo::DesignCell *curCell = curMacro->getFixedCellInfoVec()[i].cell;
862  os << " CellId: " << curCell->getCellId() << " siteName: " << curMacro->getFixedCellInfoVec()[i].siteName
863  << " BELName: " << curMacro->getFixedCellInfoVec()[i].BELName << "\n";
864  }
865 
866  return os;
867 }
868 
869 std::ostream &operator<<(std::ostream &os, PlacementInfo::PlacementUnpackedCell *curUnpackedCell)
870 {
871  os << "UnpackedCell: " << curUnpackedCell->getId() << " " << curUnpackedCell->getName() << "\n";
872  os << " cellId: " << curUnpackedCell->getCell()->getCellId() << " name: " << curUnpackedCell->getCell()->getName()
873  << "\n";
874  os << " placedAt: " << curUnpackedCell->X() << " " << curUnpackedCell->Y() << "\n";
875  os << " isPlaced: " << curUnpackedCell->isPlaced() << "\n";
876  os << " isFixed: " << curUnpackedCell->isFixed() << "\n";
877  os << " isLocked: " << curUnpackedCell->isLocked() << "\n";
878  if (curUnpackedCell->isFixed())
879  {
880  os << " fixedAt: siteName: " << curUnpackedCell->getFixedSiteName()
881  << " BELName: " << curUnpackedCell->getFixedBELName() << "\n";
882  }
883 
884  return os;
885 }
886 
887 std::ostream &operator<<(std::ostream &os, PlacementInfo::PlacementUnit *curPU)
888 {
889  if (auto curMacro = dynamic_cast<PlacementInfo::PlacementMacro *>(curPU))
890  os << curMacro;
891  else if (auto curCell = dynamic_cast<PlacementInfo::PlacementUnpackedCell *>(curPU))
892  os << curCell;
893  else
894  assert(false && "placement unit type error.");
895  return os;
896 }
897 
899 {
900  for (auto &typeGrid : SharedBELTypeBinGrid)
901  for (auto &curRow : typeGrid)
902  for (auto curBin : curRow)
903  curBin->reset();
904 }
905 
907 {
910 
911  for (auto curPU : placementUnits)
912  {
913  if (auto curUnpackedCell = dynamic_cast<PlacementUnpackedCell *>(curPU))
914  {
915  int binIdX, binIdY;
916  float cellX = curUnpackedCell->X();
917  float cellY = curUnpackedCell->Y();
918  DesignInfo::DesignCell *curCell = curUnpackedCell->getCell();
919  cellId2location[curCell->getCellId()].X = cellX;
920  cellId2location[curCell->getCellId()].Y = cellY;
921 
922  getGridXY(cellX, cellY, binIdX, binIdY);
923 
924  float num_cellOccupationBELs = getActualOccupation(curCell);
925  assert(num_cellOccupationBELs >= 0);
926 
927  bool nonOverflow = false;
928  for (int SharedBELID : getPotentialBELTypeIDs(curCell))
929  {
930  assert(binIdY >= 0);
931  assert(binIdX >= 0);
932  assert((unsigned int)binIdY < getBinGrid(SharedBELID).size());
933  assert((unsigned int)binIdX < getBinGrid(SharedBELID)[binIdY].size());
934  if (!getBinGrid(SharedBELID)[binIdY][binIdX]->inRange(cellX, cellY))
935  {
936  std::cout << "cellX=" << cellX << "\n";
937  std::cout << "cellY=" << cellY << "\n";
938  std::cout << "left=" << getBinGrid(SharedBELID)[binIdY][binIdX]->left() << "\n";
939  std::cout << "right=" << getBinGrid(SharedBELID)[binIdY][binIdX]->right() << "\n";
940  std::cout << "top=" << getBinGrid(SharedBELID)[binIdY][binIdX]->top() << "\n";
941  std::cout << "bottom=" << getBinGrid(SharedBELID)[binIdY][binIdX]->bottom() << "\n";
942  std::cout.flush();
943  }
944  assert(getBinGrid(SharedBELID)[binIdY][binIdX]->inRange(cellX, cellY));
945  if (getBinGrid(SharedBELID)[binIdY][binIdX]->canAddMore(num_cellOccupationBELs))
946  {
947  getBinGrid(SharedBELID)[binIdY][binIdX]->addCell(curCell, num_cellOccupationBELs);
948  setCellBinInfo(curCell->getCellId(), SharedBELID, binIdX, binIdY, num_cellOccupationBELs);
949  nonOverflow = true;
950  break;
951  }
952  }
953  if (!nonOverflow)
954  {
955  getBinGrid(getPotentialBELTypeIDs(curCell)[0])[binIdY][binIdX]->addCell(curCell,
956  num_cellOccupationBELs);
957  setCellBinInfo(curCell->getCellId(), getPotentialBELTypeIDs(curCell)[0], binIdX, binIdY,
958  num_cellOccupationBELs);
959  }
960  }
961  else if (auto curMacro = dynamic_cast<PlacementMacro *>(curPU))
962  {
963  for (int vId = 0; vId < curMacro->getNumOfCells(); vId++)
964  {
965  float offsetX_InMacro, offsetY_InMacro;
967  curMacro->getVirtualCellInfo(vId, offsetX_InMacro, offsetY_InMacro, cellType);
968  DesignInfo::DesignCell *curCell = curMacro->getCell(vId);
969 
970  int binIdX, binIdY;
971  float cellX = curMacro->X() + offsetX_InMacro;
972  float cellY = curMacro->Y() + offsetY_InMacro;
973 
974  getGridXY(cellX, cellY, binIdX, binIdY);
975 
976  float num_cellOccupationBELs = getActualOccupation(curCell);
977  assert(num_cellOccupationBELs >= 0);
978  bool nonOverflow = false;
979 
980  cellId2location[curCell->getCellId()].X = cellX;
981  cellId2location[curCell->getCellId()].Y = cellY;
982 
983  for (int SharedBELID : getPotentialBELTypeIDs(curCell))
984  {
985  assert(binIdY >= 0);
986  assert(binIdX >= 0);
987  assert((unsigned int)binIdY < getBinGrid(SharedBELID).size());
988  assert((unsigned int)binIdX < getBinGrid(SharedBELID)[binIdY].size());
989  assert(getBinGrid(SharedBELID)[binIdY][binIdX]->inRange(cellX, cellY));
990  if (getBinGrid(SharedBELID)[binIdY][binIdX]->canAddMore(num_cellOccupationBELs))
991  {
992 
993  getBinGrid(SharedBELID)[binIdY][binIdX]->addCell(curCell, num_cellOccupationBELs);
994  setCellBinInfo(curCell->getCellId(), SharedBELID, binIdX, binIdY, num_cellOccupationBELs);
995  nonOverflow = true;
996  break;
997  }
998  }
999 
1000  if (!nonOverflow)
1001  {
1002  getBinGrid(getPotentialBELTypeIDs(curCell)[0])[binIdY][binIdX]->addCell(curCell,
1003  num_cellOccupationBELs);
1004  setCellBinInfo(curCell->getCellId(), getPotentialBELTypeIDs(curCell)[0], binIdX, binIdY,
1005  num_cellOccupationBELs);
1006  }
1007  }
1008  }
1009  }
1010 
1011  if (guiEnable)
1012  {
1014  }
1015 
1016  for (auto &tmpRow : globalBinGrid)
1017  {
1018  for (auto &curBin : tmpRow)
1019  {
1020  assert(curBin);
1021  curBin->reset();
1022  }
1023  }
1024 
1025  for (auto curPU : placementUnits)
1026  {
1027  if (auto curUnpackedCell = dynamic_cast<PlacementUnpackedCell *>(curPU))
1028  {
1029  int binIdX, binIdY;
1030  float cellX = curUnpackedCell->X();
1031  float cellY = curUnpackedCell->Y();
1032  DesignInfo::DesignCell *curCell = curUnpackedCell->getCell();
1033 
1034  if (curCell->isLUT() || curCell->isFF()) // currently we only resize LUT/FF
1035  {
1036  getGridXY(cellX, cellY, binIdX, binIdY);
1037  assert(globalBinGrid[binIdY][binIdX]->inRange(cellX, cellY));
1038  assert(binIdY >= 0);
1039  assert(binIdX >= 0);
1040  assert((unsigned int)binIdY < globalBinGrid.size());
1041  assert((unsigned int)binIdX < globalBinGrid[binIdY].size());
1042  globalBinGrid[binIdY][binIdX]->addCell(curCell, 0);
1043  }
1044  }
1045  else if (auto curMacro = dynamic_cast<PlacementMacro *>(curPU))
1046  {
1047  for (int vId = 0; vId < curMacro->getNumOfCells(); vId++)
1048  {
1049  float offsetX_InMacro, offsetY_InMacro;
1050  DesignInfo::DesignCellType cellType;
1051  curMacro->getVirtualCellInfo(vId, offsetX_InMacro, offsetY_InMacro, cellType);
1052  DesignInfo::DesignCell *curCell = curMacro->getCell(vId);
1053  if (curCell->isLUT() || curCell->isFF()) // currently we only resize LUT/FF
1054  {
1055  int binIdX, binIdY;
1056  float cellX = curMacro->X() + offsetX_InMacro;
1057  float cellY = curMacro->Y() + offsetY_InMacro;
1058 
1059  getGridXY(cellX, cellY, binIdX, binIdY);
1060  assert(globalBinGrid[binIdY][binIdX]->inRange(cellX, cellY));
1061 
1062  assert(binIdY >= 0);
1063  assert(binIdX >= 0);
1064  assert((unsigned int)binIdY < globalBinGrid.size());
1065  assert((unsigned int)binIdX < globalBinGrid[binIdY].size());
1066  globalBinGrid[binIdY][binIdX]->addCell(curCell, 0);
1067  }
1068  }
1069  }
1070  }
1071 }
1072 
1073 void PlacementInfo::adjustLUTFFUtilization_Packablity(float neighborDisplacementUpperbound, bool enfore)
1074 {
1075  assert(getProgress() > 0.3);
1076  // based on progress, set the frequency of adjustment
1077  bool doUpdate = false;
1078 
1079  if (getProgress() > 0.8)
1080  doUpdate = std::fabs(getProgress() - lastProgressWhenLUTFFUtilAdjust) > 0.03;
1081  else
1082  doUpdate = std::fabs(getProgress() - lastProgressWhenLUTFFUtilAdjust) > 0.05;
1083 
1084  if (LUTFFUtilizationAdjusted && !doUpdate && !enfore)
1085  {
1086  // we don't need to update LUT/FF utilization so frequently
1087  return;
1088  }
1090 
1091  print_status("PlacementInfo: adjusting LUT/FF utilization based on Packablity");
1092  for (auto &curRow : LUTFFBinGrid)
1093  for (auto curBin : curRow)
1094  curBin->reset();
1095  // assign LUT/FF to bin grid to find their neighbors easily
1096  for (auto curPU : placementUnits)
1097  {
1098  if (auto curUnpackedCell = dynamic_cast<PlacementUnpackedCell *>(curPU))
1099  {
1100  int binIdX, binIdY;
1101  float cellX = curUnpackedCell->X();
1102  float cellY = curUnpackedCell->Y();
1103  DesignInfo::DesignCell *curCell = curUnpackedCell->getCell();
1104 
1105  if (curCell->isLUT() || curCell->isFF())
1106  {
1107  getGridXY(cellX, cellY, binIdX, binIdY);
1108  assert(LUTFFBinGrid[binIdY][binIdX]->inRange(cellX, cellY));
1109  assert(binIdY >= 0);
1110  assert(binIdX >= 0);
1111  assert((unsigned int)binIdY < LUTFFBinGrid.size());
1112  assert((unsigned int)binIdX < LUTFFBinGrid[binIdY].size());
1113  LUTFFBinGrid[binIdY][binIdX]->addCell(curCell,
1114  0); // we just use the bininfo to record LUTFF location
1115  cellId2location[curCell->getCellId()].X = cellX;
1116  cellId2location[curCell->getCellId()].Y = cellY;
1117  }
1118  }
1119  else if (auto curMacro = dynamic_cast<PlacementMacro *>(curPU))
1120  {
1121  for (int vId = 0; vId < curMacro->getNumOfCells(); vId++)
1122  {
1123  float offsetX_InMacro, offsetY_InMacro;
1124  DesignInfo::DesignCellType cellType;
1125  curMacro->getVirtualCellInfo(vId, offsetX_InMacro, offsetY_InMacro, cellType);
1126  DesignInfo::DesignCell *curCell = curMacro->getCell(vId);
1127  if (curCell->isLUT() || curCell->isFF())
1128  {
1129  int binIdX, binIdY;
1130  float cellX = curMacro->X() + offsetX_InMacro;
1131  float cellY = curMacro->Y() + offsetY_InMacro;
1132 
1133  getGridXY(cellX, cellY, binIdX, binIdY);
1134  assert(LUTFFBinGrid[binIdY][binIdX]->inRange(cellX, cellY));
1135 
1136  assert(binIdY >= 0);
1137  assert(binIdX >= 0);
1138  assert((unsigned int)binIdY < LUTFFBinGrid.size());
1139  assert((unsigned int)binIdX < LUTFFBinGrid[binIdY].size());
1140  LUTFFBinGrid[binIdY][binIdX]->addCell(curCell,
1141  0); // we just use the bininfo to record LUTFF location
1142  cellId2location[curCell->getCellId()].X = cellX;
1143  cellId2location[curCell->getCellId()].Y = cellY;
1144  }
1145  }
1146  }
1147  }
1148 
1149  unsigned int cellNum = getCells().size();
1150  std::vector<float> &compatiblePlacementTable_cellId2Occupation = compatiblePlacementTable->getcellId2Occupation();
1151 #pragma omp parallel for schedule(dynamic)
1152  for (unsigned int cellId = 0; cellId < cellNum; cellId++)
1153  {
1154  auto curCell = getCells()[cellId];
1155  int cellRealId = curCell->getCellId();
1156 
1157  if (curCell->isLUT())
1158  {
1159  std::vector<DesignInfo::DesignCell *> *neighborCells =
1160  findNeiborLUTFFsFromBinGrid(curCell, neighborDisplacementUpperbound);
1161  assert(neighborCells->size()); // at least it should find itself
1162  int pairableCnt = 0;
1163  float tmpRatio = -1;
1164  int deteminted = getDeterminedOccupation(curCell->getCellId());
1165  if (deteminted >= 0)
1166  {
1167  compatiblePlacementTable_cellId2Occupation[curCell->getCellId()] = deteminted;
1168  }
1169  else
1170  {
1171  if (curCell->getInputPins().size() <= 5 && !curCell->isLUT6())
1172  {
1173  int totalNumNeighborCells = neighborCells->size();
1174  for (auto neighborLUT : *neighborCells)
1175  {
1176  if (getDeterminedOccupation(neighborLUT->getCellId()) >= 0) // paired LUT
1177  {
1178  totalNumNeighborCells--;
1179  continue;
1180  }
1181  if (neighborLUT->getInputPins().size() <= 5 && !neighborLUT->isLUT6() && curCell != neighborLUT)
1182  {
1183  if (getPairPinNum(curCell, neighborLUT) <= 5)
1184  {
1185  pairableCnt++;
1186  }
1187  }
1188  }
1189  assert(totalNumNeighborCells > 0);
1190  if (totalNumNeighborCells == 1 || pairableCnt == 0)
1191  tmpRatio = 0;
1192  else
1193  tmpRatio = std::pow((float)pairableCnt / (float)(totalNumNeighborCells - 1), 0.3);
1194  assert(tmpRatio <= 1 && tmpRatio >= 0);
1195  // compatiblePlacementTable_cellId2Occupation[cellRealId] =
1196  // (compatiblePlacementTable_cellId2Occupation[cellRealId] +
1197  // (float)(1 * tmpRatio + 2 * (1 - tmpRatio))) /
1198  // 2;
1199 
1200  float areaDemand = (float)(1 * tmpRatio + 2 * (1 - tmpRatio));
1201  compatiblePlacementTable_cellId2Occupation[cellRealId] = areaDemand * 1.15;
1202  }
1203  else
1204  {
1205  compatiblePlacementTable_cellId2Occupation[cellRealId] = 2.2;
1206  }
1207  }
1208  assert(compatiblePlacementTable_cellId2Occupation[cellRealId] >= 0);
1209  delete neighborCells;
1210  }
1211  else if (curCell->isFF())
1212  {
1213  if (!curCell->getControlSetInfo())
1214  {
1215  assert(curCell->isVirtualCell());
1216  compatiblePlacementTable_cellId2Occupation[cellRealId] = 1;
1217  continue;
1218  }
1219  assert(!curCell->isVirtualCell());
1220  std::vector<DesignInfo::DesignCell *> *neighborCells =
1221  findNeiborLUTFFsFromBinGrid(curCell, neighborDisplacementUpperbound);
1222  assert(neighborCells->size()); // at least it should find itself
1223  std::map<int, int> CSId2Cnt;
1224  int targetControlSetId = curCell->getControlSetInfo()->getId();
1225  for (auto neighborFF : *neighborCells)
1226  {
1227  if (neighborFF->isVirtualCell())
1228  continue;
1229  if (neighborFF->getControlSetInfo()->getCLK() == curCell->getControlSetInfo()->getCLK() &&
1230  neighborFF->getControlSetInfo()->getSR() == curCell->getControlSetInfo()->getSR())
1231  CSId2Cnt[neighborFF->getControlSetInfo()->getId()] = 0;
1232  }
1233  for (auto neighborFF : *neighborCells)
1234  {
1235  if (neighborFF->isVirtualCell())
1236  {
1237  // CSId2Cnt[targetControlSetId]++; // it can pack with the target cell
1238  continue;
1239  }
1240  if (neighborFF->getControlSetInfo()->getCLK() == curCell->getControlSetInfo()->getCLK() &&
1241  neighborFF->getControlSetInfo()->getSR() == curCell->getControlSetInfo()->getSR())
1242  CSId2Cnt[neighborFF->getControlSetInfo()->getId()]++;
1243  }
1244  int totalDemand = 0;
1245  int targetFFNum = CSId2Cnt[targetControlSetId]; // n0
1246  int targetDemand = (1 + ((targetFFNum - 1) / 4)); // ceil(n0/4)
1247  for (auto CSIdCntpair : CSId2Cnt)
1248  {
1249  totalDemand += (1 + ((CSIdCntpair.second - 1) / 4)); // sum(ceil(ni/4))
1250  }
1251  int factor = (1 + ((totalDemand - 1) / 2)); // ceil(sum/2)
1252  const float alpha = 1.3;
1253  assert(totalDemand > 0);
1254  assert(targetFFNum > 0);
1255 
1256  float areaDemand =
1257  alpha * 8.0 * ((float)targetDemand) / ((float)totalDemand) * (float)factor / (float)(targetFFNum);
1258  if (areaDemand > 1.5)
1259  areaDemand *= 1.1;
1260  // else if (areaDemand > 1.2)
1261  // areaDemand *= 1.15;
1262  // compatiblePlacementTable_cellId2Occupation[cellRealId] =
1263  // alpha * 4.0 * ((float)targetDemand) / (float)(targetFFNum);
1264  compatiblePlacementTable_cellId2Occupation[cellRealId] = areaDemand;
1265  assert(compatiblePlacementTable_cellId2Occupation[cellRealId] >= 0);
1266  delete neighborCells;
1267  }
1268  }
1269  print_status("PlacementInfo: adjusted LUT/FF utilization based on Packablity");
1270 }
1271 
1272 // refer to RippleFPGA's implementation
1274 {
1275  print_status("PlacementInfo: adjusting LUT/FF utilization based on Routability");
1276 
1277  // calculate the congestion ratio for the bin grid
1278  for (auto tmpNet : placementNets)
1279  {
1280  if (tmpNet->getHPWL(y2xRatio) < eps)
1281  continue;
1282  int leftBinX, rightBinX, topBinY, bottomBinY;
1283  getGridXY(tmpNet->getLeftPinX(), tmpNet->getBottomPinY(), leftBinX, bottomBinY);
1284  getGridXY(tmpNet->getRightPinX(), tmpNet->getTopPinY(), rightBinX, topBinY);
1285 
1286  assert(bottomBinY >= 0);
1287  assert(leftBinX >= 0);
1288  assert((unsigned int)bottomBinY < globalBinGrid.size());
1289  assert((unsigned int)leftBinX < globalBinGrid[bottomBinY].size());
1290  assert(topBinY >= 0);
1291  assert(rightBinX >= 0);
1292  assert((unsigned int)topBinY < globalBinGrid.size());
1293  assert((unsigned int)rightBinX < globalBinGrid[topBinY].size());
1294 
1295  float totW = tmpNet->getHPWL(y2xRatio) + 0.5;
1296  unsigned int nPins = tmpNet->getPinOffsetsInUnit().size();
1297  if (nPins < 10)
1298  totW *= 1.06;
1299  else if (nPins < 20)
1300  totW *= 1.2;
1301  else if (nPins < 30)
1302  totW *= 1.4;
1303  else if (nPins < 50)
1304  totW *= 1.6;
1305  else if (nPins < 100)
1306  totW *= 1.8;
1307  else if (nPins < 200)
1308  totW *= 2.1;
1309  else
1310  totW *= 3.0;
1311 
1312  int numGCell = (rightBinX - leftBinX + 1) * (topBinY - bottomBinY + 1) * binHeight * binWidth;
1313  float indW = totW / numGCell;
1314  for (int x = leftBinX; x <= rightBinX; ++x)
1315  for (int y = bottomBinY; y <= topBinY; ++y)
1316  globalBinGrid[y][x]->increaseSWDemandBy(indW);
1317  }
1318 
1319  std::vector<float> &compatiblePlacementTable_cellId2InfationRatio =
1321  auto LUTTypeBELIds = getPotentialBELTypeIDs(DesignInfo::CellType_LUT6);
1322  std::vector<std::vector<PlacementInfo::PlacementBinInfo *>> &LUTBinGrid = getBinGrid(LUTTypeBELIds[0]);
1324  std::vector<std::vector<PlacementInfo::PlacementBinInfo *>> &FFBinGrid = getBinGrid(FFTypeBELIds[0]);
1325 
1326  for (unsigned int i = 0; i < getCells().size(); i++)
1327  {
1328  compatiblePlacementTable_cellId2InfationRatio[i] = std::sqrt(compatiblePlacementTable_cellId2InfationRatio[i]);
1329  }
1330 
1331  std::vector<PlacementInfo::PlacementBinInfo *> bins;
1332  for (auto &tmpRow : globalBinGrid)
1333  {
1334  for (auto &curBin : tmpRow)
1335  {
1336  assert(curBin);
1337  bins.push_back(curBin);
1338  }
1339  }
1340  std::sort(bins.begin(), bins.end(),
1341  [](const PlacementInfo::PlacementBinInfo *a, const PlacementInfo::PlacementBinInfo *b) -> bool {
1342  return a->getSwitchDemandForNets() > b->getSwitchDemandForNets();
1343  });
1344 
1345  int binOrderId = 0;
1346  for (auto &curBin : bins)
1347  {
1348  binOrderId++;
1349  assert(curBin);
1350  if (curBin->getSwitchDemandForNets() > 80 && binOrderId < bins.size() * 0.3)
1351  {
1352  float infateRatio = 2 * (curBin->getSwitchDemandForNets() / 80);
1353  if (infateRatio > 4)
1354  infateRatio = 4;
1355  for (auto tmpCell : curBin->getCells())
1356  {
1357  assert(tmpCell->isLUT() || tmpCell->isFF());
1358  compatiblePlacementTable_cellId2InfationRatio[tmpCell->getCellId()] = infateRatio;
1359  }
1360  float LUTSupplyRatio = LUTBinGrid[curBin->Y()][curBin->X()]->getRequiredBinShrinkRatio() * 0.9;
1361  float FFSupplyRatio = FFBinGrid[curBin->Y()][curBin->X()]->getRequiredBinShrinkRatio() * 0.9;
1362  if (LUTSupplyRatio > 0.7)
1363  LUTBinGrid[curBin->Y()][curBin->X()]->setRequiredBinShrinkRatio(LUTSupplyRatio);
1364  if (FFSupplyRatio > 0.7)
1365  FFBinGrid[curBin->Y()][curBin->X()]->setRequiredBinShrinkRatio(FFSupplyRatio);
1366  }
1367  // we don't recover the suppy until next creation of bin grid (i.e., createBinGrid), otherwise, you can
1368  // uncomment contents below which might slightly increase the congestion but improve HPWL a bit.
1369  else if (curBin->getSwitchDemandForNets() < 50 || binOrderId > bins.size() * 0.5)
1370  {
1371  if (LUTBinGrid[curBin->Y()][curBin->X()]->getRequiredBinShrinkRatio() < 0.999)
1372  {
1373  LUTBinGrid[curBin->Y()][curBin->X()]->setRequiredBinShrinkRatio(1);
1374  FFBinGrid[curBin->Y()][curBin->X()]->setRequiredBinShrinkRatio(1);
1375  }
1376  }
1377  else if (curBin->getSwitchDemandForNets() < 55)
1378  {
1379  if (LUTBinGrid[curBin->Y()][curBin->X()]->getRequiredBinShrinkRatio() < 0.999)
1380  {
1381  float LUTSupplyRatio = LUTBinGrid[curBin->Y()][curBin->X()]->getRequiredBinShrinkRatio() * 1.05;
1382  if (LUTSupplyRatio > 1)
1383  LUTSupplyRatio = 1;
1384  float FFSupplyRatio = FFBinGrid[curBin->Y()][curBin->X()]->getRequiredBinShrinkRatio() * 1.05;
1385  if (FFSupplyRatio > 1)
1386  FFSupplyRatio = 1;
1387  LUTBinGrid[curBin->Y()][curBin->X()]->setRequiredBinShrinkRatio(LUTSupplyRatio);
1388  FFBinGrid[curBin->Y()][curBin->X()]->setRequiredBinShrinkRatio(FFSupplyRatio);
1389  }
1390  }
1391  else if (curBin->getSwitchDemandForNets() < 70)
1392  {
1393  if (LUTBinGrid[curBin->Y()][curBin->X()]->getRequiredBinShrinkRatio() < 0.999)
1394  {
1395  float LUTSupplyRatio = LUTBinGrid[curBin->Y()][curBin->X()]->getRequiredBinShrinkRatio() * 1.025;
1396  if (LUTSupplyRatio > 1)
1397  LUTSupplyRatio = 1;
1398  float FFSupplyRatio = FFBinGrid[curBin->Y()][curBin->X()]->getRequiredBinShrinkRatio() * 1.025;
1399  if (FFSupplyRatio > 1)
1400  FFSupplyRatio = 1;
1401  LUTBinGrid[curBin->Y()][curBin->X()]->setRequiredBinShrinkRatio(LUTSupplyRatio);
1402  FFBinGrid[curBin->Y()][curBin->X()]->setRequiredBinShrinkRatio(FFSupplyRatio);
1403  }
1404  }
1405  }
1406  print_status("PlacementInfo: adjusted LUT/FF utilization based on Routability");
1407 }
1408 
1410 {
1411  print_status("PlacementInfo: adjusting FF utilization based on Clock Utilization");
1412 
1413  float infateRatio = 1.5;
1414  std::vector<float> &compatiblePlacementTable_cellId2InfationRatio =
1416 
1417  auto &clockRegions = deviceInfo->getClockRegions();
1418 
1419  std::set<int> addedCells;
1420  addedCells.clear();
1421  auto &cells = getCells();
1422 
1424  std::vector<std::vector<PlacementInfo::PlacementBinInfo *>> &FFBinGrid = getBinGrid(FFTypeBELIds[0]);
1425  auto LUTTypeBELIds = getPotentialBELTypeIDs(DesignInfo::CellType_LUT6);
1426  std::vector<std::vector<PlacementInfo::PlacementBinInfo *>> &LUTBinGrid = getBinGrid(LUTTypeBELIds[0]);
1427 
1428  std::set<std::pair<int, int>> clockRegion2Inflat;
1429  clockRegion2Inflat.clear();
1430 
1431  for (int i = deviceInfo->getClockRegionNumY() - 1; i >= 0; i--)
1432  {
1433  for (int j = 0; j < deviceInfo->getClockRegionNumX(); j++)
1434  {
1435  for (auto &row : clockRegions[i][j]->getClockColumns())
1436  {
1437  for (auto clockColumn : row)
1438  {
1439  if ((clockRegionUtilization[i][j] > 12 && clockColumn->getClockNum() > 10))
1440  {
1441  clockLegalizationRisky = true;
1442  for (auto &pair : clockColumn->getClockNetId2CellIds())
1443  {
1444  for (auto cellId : pair.second)
1445  {
1446  assert(cellId < (int)cells.size());
1447  if (cells[cellId]->isFF())
1448  {
1449  if (addedCells.find(cellId) == addedCells.end())
1450  {
1451  if (compatiblePlacementTable_cellId2InfationRatio[cellId] < 4)
1452  compatiblePlacementTable_cellId2InfationRatio[cellId] *= infateRatio;
1453  addedCells.insert(cellId);
1454  std::pair<int, int> rloc(i, j);
1455  clockRegion2Inflat.insert(rloc);
1456  }
1457  }
1458  }
1459  }
1460  }
1461  }
1462  }
1463  }
1464  }
1465 
1466  if (!isDensePlacement())
1467  {
1468  int cnt = 0;
1469  for (auto &tmpRow : FFBinGrid)
1470  {
1471  for (auto curBin : tmpRow)
1472  {
1473  int clockRegionX, clockRegionY;
1474  deviceInfo->getClockRegionByLocation((curBin->left() + curBin->right()) / 2,
1475  (curBin->top() + curBin->bottom()) / 2, clockRegionX,
1476  clockRegionY);
1477  std::pair<int, int> rloc(clockRegionY, clockRegionX);
1478  if (clockRegion2Inflat.find(rloc) != clockRegion2Inflat.end())
1479  {
1480  cnt++;
1481  if (curBin->getRequiredBinShrinkRatio() > 0.75)
1482  {
1483  curBin->setRequiredBinShrinkRatio(curBin->getRequiredBinShrinkRatio() * 0.75);
1484  }
1485  }
1486  }
1487  }
1488  for (auto &tmpRow : LUTBinGrid)
1489  {
1490  for (auto curBin : tmpRow)
1491  {
1492  int clockRegionX, clockRegionY;
1493  deviceInfo->getClockRegionByLocation((curBin->left() + curBin->right()) / 2,
1494  (curBin->top() + curBin->bottom()) / 2, clockRegionX,
1495  clockRegionY);
1496  std::pair<int, int> rloc(clockRegionY, clockRegionX);
1497  if (clockRegion2Inflat.find(rloc) != clockRegion2Inflat.end())
1498  {
1499  if (curBin->getRequiredBinShrinkRatio() > 0.75)
1500  {
1501  curBin->setRequiredBinShrinkRatio(curBin->getRequiredBinShrinkRatio() * 0.85);
1502  }
1503  }
1504  }
1505  }
1506  print_status("PlacementInfo: adjusted FF utilization based on Clock Utilization. " + std::to_string(cnt) +
1507  " bins have been shrinked.");
1508  }
1509 }
1510 
1512 {
1513  // sometime, the HPWL increase too much, we need to reset the adjustion
1514  std::vector<float> &compatiblePlacementTable_cellId2InfationRatio =
1516  auto LUTTypeBELIds = getPotentialBELTypeIDs(DesignInfo::CellType_LUT6);
1517  std::vector<std::vector<PlacementInfo::PlacementBinInfo *>> &LUTBinGrid = getBinGrid(LUTTypeBELIds[0]);
1519  std::vector<std::vector<PlacementInfo::PlacementBinInfo *>> &FFBinGrid = getBinGrid(FFTypeBELIds[0]);
1520 
1521  for (unsigned int i = 0; i < getCells().size(); i++)
1522  {
1523  compatiblePlacementTable_cellId2InfationRatio[i] = 1.0;
1524  }
1525  for (auto &tmpRow : LUTBinGrid)
1526  {
1527  for (auto &curBin : tmpRow)
1528  {
1529  assert(curBin);
1530  curBin->setRequiredBinShrinkRatio(1);
1531  }
1532  }
1533  for (auto &tmpRow : FFBinGrid)
1534  {
1535  for (auto &curBin : tmpRow)
1536  {
1537  assert(curBin);
1538  curBin->setRequiredBinShrinkRatio(1);
1539  }
1540  }
1541  print_status("PlacementInfo: Routability-oriented area adjustion is reset.");
1542 }
1543 
1544 void PlacementInfo::adjustLUTFFUtilization(float neighborDisplacementUpperbound, bool enfore)
1545 {
1546  if (neighborDisplacementUpperbound > 0)
1547  {
1548  print_status("PlacementInfo: adjusting LUT/FF Utilization");
1549  adjustLUTFFUtilization_Packablity(neighborDisplacementUpperbound, enfore);
1550  print_status("PlacementInfo: adjusted LUT/FF Utilization");
1551  }
1552  else
1553  {
1555  }
1557  if (getProgress() > 0.8)
1559  LUTFFUtilizationAdjusted = true;
1560 }
1561 
1562 void PlacementInfo::dumpCongestion(std::string dumpFileName)
1563 {
1564  dumpFileName = dumpFileName;
1565  print_status("PlacementInfo: dumping congestion rate to: " + dumpFileName);
1566  std::vector<std::vector<PlacementInfo::PlacementBinInfo *>> &curBinGrid = globalBinGrid;
1567 
1568  std::ofstream outfile0(dumpFileName.c_str());
1569  assert(outfile0.is_open() && outfile0.good() &&
1570  "The path for congestion dumping does not exist and please check your path settings");
1571  for (auto &row : curBinGrid)
1572  {
1573  for (auto curBin : row)
1574  {
1575  outfile0 << curBin->getSwitchDemandForNets() << " ";
1576  }
1577  outfile0 << "\n";
1578  }
1579  outfile0.close();
1580 }
1581 
1583 {
1584  // std::vector<std::string> checkSiteNameList{"SLICEL", "SLICEM", "DSP48E2", "RAMBFIFO18"};
1585  std::vector<std::string> checkSiteNameList{"SLICEL", "SLICEM"};
1586  siteGridForMacros.clear();
1587 
1588  int i = 0, j = 0;
1589  float curBottomY, curLeftX;
1590 
1591  for (curBottomY = startX, i = 0; curBottomY < endY - eps; curBottomY += binHeight, i++)
1592  {
1593  std::vector<PlacementSiteBinInfo *> tmpBELGridRow;
1594  tmpBELGridRow.clear();
1595  for (curLeftX = startX, j = 0; curLeftX < endX - eps; curLeftX += binWidth, j++)
1596  {
1597  PlacementSiteBinInfo *newBin =
1598  new PlacementSiteBinInfo(curLeftX, curLeftX + binWidth, curBottomY, curBottomY + binHeight, i, j);
1599  tmpBELGridRow.push_back(newBin);
1600  }
1601  siteGridForMacros.push_back(tmpBELGridRow);
1602  }
1603 
1604  for (std::string targetSiteType : checkSiteNameList)
1605  {
1606  std::vector<DeviceInfo::DeviceSite *> &sitesInType = deviceInfo->getSitesInType(targetSiteType);
1607 
1608  unsigned int siteIndex = 0;
1609  for (curBottomY = startY, i = 0; curBottomY < endY - eps; curBottomY += binHeight, i++)
1610  {
1611  while (siteGridForMacros[i][0]->inRangeY(sitesInType[siteIndex]->Y()))
1612  {
1613  for (curLeftX = startX, j = 0; curLeftX < endX - eps; curLeftX += binWidth, j++)
1614  {
1615  while (siteGridForMacros[i][j]->inRange(sitesInType[siteIndex]->X(), sitesInType[siteIndex]->Y()))
1616  {
1617  siteGridForMacros[i][j]->addSiteIntoBin(sitesInType[siteIndex]);
1618  siteIndex++;
1619  if (siteIndex >= sitesInType.size())
1620  break;
1621  }
1622  if (siteIndex >= sitesInType.size())
1623  break;
1624  }
1625  if (siteIndex >= sitesInType.size())
1626  break;
1627  }
1628  if (siteIndex >= sitesInType.size())
1629  break;
1630  }
1631  }
1632 }
1633 
1635 {
1636  if (inRange(curSite->X(), curSite->Y()))
1637  {
1638  correspondingSites.push_back(curSite);
1639  capacity += 1;
1640  }
1641  else
1642  {
1643  print_error("leftX: " + std::to_string(leftX) + "rightX: " + std::to_string(rightX) +
1644  "topY: " + std::to_string(topY) + "bottomY: " + std::to_string(bottomY));
1645  print_error("curSite: " + curSite->getName());
1646  assert(false && "some sites are out of the scope");
1647  }
1648 }
1649 
1651 {
1652  for (auto curRow : siteGridForMacros)
1653  for (auto curBin : curRow)
1654  curBin->reset();
1655 }
1656 
1658 {
1659  assert(false && "unimplemented");
1660  // resetSiteBinGrid();
1661  // for (auto curMacro : placementMacros)
1662  // {
1663  // for (auto offset_occupation_pair : curMacro->getOccupiedSiteInfo())
1664  // {
1665  // float offsetX_InMacro = 0, offsetY_InMacro = offset_occupation_pair.first;
1666 
1667  // int binIdX, binIdY;
1668  // float siteX = curMacro->X() + offsetX_InMacro;
1669  // float siteY = curMacro->Y() + offsetY_InMacro;
1670 
1671  // getGridXY(siteX, siteY, binIdX, binIdY);
1672  // float siteOccupation = offset_occupation_pair.second;
1673 
1674  // assert(binIdY >= 0);
1675  // assert((unsigned int)binIdY < siteGridForMacros.size());
1676  // assert(binIdX >= 0);
1677  // assert((unsigned int)binIdX < siteGridForMacros[binIdY].size());
1678  // siteGridForMacros[binIdY][binIdX]->addMacroSite(curMacro, siteOccupation);
1679  // }
1680  // }
1681 }
1682 
1684 {
1687  for (int i = 0; i < designInfo->getNumCells(); i++)
1688  {
1689  assert(cellId2PlacementUnit[i]);
1691  }
1692 
1693  macroRatio = (float)(cellInMacros.size()) / (float)designInfo->getNumCells();
1694 }
1695 
1697 {
1698  print_status("PlacementInfo: dumping placment Tcl commands archieve to: " + dumpFile);
1700  if (dumpFile != "")
1701  {
1702  // std::stringstream outfile0;
1703  // outfile0 << "GlobalPlacerPseudoNetWeight: " << getPseudoNetWeight() << "\n";
1704  // outfile0 << "GlobalPlacerMacroPseudoNetEnhanceCnt: " << getMacroPseudoNetEnhanceCnt() << "\n";
1705  // outfile0 << "GlobalPlacerMacroLegalizationWeight: " << getMacroLegalizationWeight() << "\n";
1706  // for (auto curPU : getPlacementUnits())
1707  // {
1708  // outfile0 << curPU;
1709  // }
1710  // for (auto PUSitePair : PU2LegalSites)
1711  // {
1712  // outfile0 << "PULegalization: " << PUSitePair.first->getId() << " ";
1713  // std::vector<DeviceInfo::DeviceSite *> tmpSites = PUSitePair.second;
1714  // for (unsigned int tmpId = 0; tmpId < tmpSites.size() - 1; tmpId++)
1715  // outfile0 << tmpSites[tmpId]->getName() << ",";
1716  // outfile0 << tmpSites[tmpSites.size() - 1]->getName() << "\n";
1717  // }
1718  // writeStrToGZip(dumpFile, outfile0);
1719  // print_status("PlacementInfo: dumped placment Tcl commands archieve to " + dumpFile);
1720  }
1721 }
1722 
1724 {
1725  dumpFile += ".gz";
1726  print_status("PlacementInfo: dumping PU information archieve to: " + dumpFile);
1728  if (dumpFile != "")
1729  {
1730  std::stringstream outfile0;
1731  outfile0 << "GlobalPlacerPseudoNetWeight: " << getPseudoNetWeight() << "\n";
1732  outfile0 << "GlobalPlacerMacroPseudoNetEnhanceCnt: " << getMacroPseudoNetEnhanceCnt() << "\n";
1733  outfile0 << "GlobalPlacerMacroLegalizationWeight: " << getMacroLegalizationWeight() << "\n";
1734  for (auto curPU : getPlacementUnits())
1735  {
1736  outfile0 << curPU;
1737  }
1738  for (auto PUSitePair : PU2LegalSites)
1739  {
1740  outfile0 << "PULegalization: " << PUSitePair.first->getId() << " ";
1741  std::vector<DeviceInfo::DeviceSite *> tmpSites = PUSitePair.second;
1742  for (unsigned int tmpId = 0; tmpId < tmpSites.size() - 1; tmpId++)
1743  outfile0 << tmpSites[tmpId]->getName() << ",";
1744  outfile0 << tmpSites[tmpSites.size() - 1]->getName() << "\n";
1745  }
1746  writeStrToGZip(dumpFile, outfile0);
1747  print_status("PlacementInfo: dumped PU information archieve to: " + dumpFile);
1748  }
1749 }
1750 
1751 // TODO: implement a checkpoint mechanism here
1753 {
1754  print_status("loading PU coordinate archieve from: " + locFile);
1755  print_warning("Please note that the loaded PU location information should be compatible with the other"
1756  "information in the placer! Otherwise, there could be potential errors");
1757  print_warning(
1758  "E.g., the initial packing which creates virtual cells should be done. The bin grid for all cell types "
1759  "should be created.");
1760 
1761  PULegalXY.first.clear();
1762  PULegalXY.second.clear();
1763 
1764  std::string unzipCmnd = "gzip -c -d " + locFile;
1765 
1766  struct stat checkbuf;
1767  assert(stat(locFile.c_str(), &checkbuf) != -1);
1768 
1769  FILEbuf sbuf(popen(unzipCmnd.c_str(), "r"));
1770  std::istream infile(&sbuf);
1771  // std::ifstream infile(designTextFileName.c_str());
1772 
1773  std::string line, PUName, macroTypeStr, cellName, siteName, BELName;
1774  bool booleanValue;
1775  std::string fill0, fill1, fill2, fill3, fill4, fill5, fill6;
1776  unsigned int PUId, numCells, cellId;
1777  float X, Y;
1778 
1779  for (auto tmpPU : placementUnits)
1780  {
1781  delete tmpPU;
1782  }
1783 
1784  placementUnits.clear();
1785  fixedPlacementUnits.clear();
1786  placementMacros.clear();
1787  cellInMacros.clear();
1788  placementUnpackedCells.clear();
1789  cellId2PlacementUnitVec.clear();
1790  cellId2PlacementUnitVec.resize(getCells().size(), nullptr);
1791  cellId2PlacementUnit.clear();
1792  PU2LegalSites.clear();
1793  LUTFFUtilizationAdjusted = false;
1794 
1795  // outfile0 << "GlobalPlacerPseudoNetWeight: " << getPseudoNetWeight() << "\n";
1796  std::getline(infile, line);
1797  std::istringstream iss(line);
1798  iss >> fill0 >> oriPseudoNetWeight;
1799  assert(fill0 == "GlobalPlacerPseudoNetWeight:");
1800  std::getline(infile, line);
1801  iss = std::istringstream(line);
1802  iss >> fill0 >> macroPseudoNetEnhanceCnt;
1803  assert(fill0 == "GlobalPlacerMacroPseudoNetEnhanceCnt:");
1804  std::getline(infile, line);
1805  iss = std::istringstream(line);
1806  iss >> fill0 >> macroLegalizationWeight;
1807  assert(fill0 == "GlobalPlacerMacroLegalizationWeight:");
1808 
1809  while (std::getline(infile, line))
1810  {
1811  std::istringstream iss(line);
1812  iss >> fill0 >> PUId >> PUName;
1813  if (fill0.find("Macro") != std::string::npos)
1814  {
1815  // Macro: 8700 design_1_i/xilinx_dma_pcie_ep_0/inst/xdma_0_....
1816  // macroType: PlacementMacroType_BRAM
1817  // placedAt: 76.75 50.925
1818  // isPlaced: 1
1819  // isFixed: 1
1820  // isLocked: 1
1821  // left, right, top, bottom: 0 0 2.5 0
1822  // numCell: 2
1823  // CellId: 645276 name: design_1_i/xilinx_dma_pcie_ep_0/inst/xdma_0_.... 0 0
1824  // CellId: 691036 name: design_1_i/xilinx_dma_pcie_ep_0/inst/xdma_0_....(691036) 0 2.5
1825  // numFixedCell: 2
1826  // CellId: 645276 siteName: RAMB18_X16Y20 BELName: RAMB180.RAMB18E2_L
1827  // CellId: 691036 siteName: RAMB18_X16Y21 BELName: RAMB181.RAMB18E2_U
1828  assert(placementUnits.size() == PUId && "PlacementUnit should be dumped according to the PU id order.");
1829  std::getline(infile, line);
1830  iss = std::istringstream(line);
1831  iss >> fill0 >> macroTypeStr;
1833  if (macroTypeStr == "PlacementMacroType_LUTFFPair")
1835  else if (macroTypeStr == "PlacementMacroType_FFFFPair")
1837  else if (macroTypeStr == "PlacementMacroType_HALFCLB")
1839  else if (macroTypeStr == "PlacementMacroType_LCLB")
1841  else if (macroTypeStr == "PlacementMacroType_MCLB")
1843  else if (macroTypeStr == "PlacementMacroType_CARRY")
1845  else if (macroTypeStr == "PlacementMacroType_DSP")
1847  else if (macroTypeStr == "PlacementMacroType_BRAM")
1849  else if (macroTypeStr == "PlacementMacroType_MUX7")
1851  else if (macroTypeStr == "PlacementMacroType_MUX8")
1853  if (macroTypeStr == "PlacementMacroType_LUTLUTSeires")
1855  else
1856  assert(false && "undefined macro type.");
1857 
1858  PlacementMacro *tmpPU = new PlacementMacro(PUName, PUId, macroType);
1859  placementUnits.push_back(tmpPU);
1860  placementMacros.push_back(tmpPU);
1861 
1862  std::getline(infile, line);
1863  iss = std::istringstream(line);
1864  iss >> fill0 >> X >> Y;
1866 
1867  std::getline(infile, line);
1868  iss = std::istringstream(line);
1869  iss >> fill0 >> booleanValue;
1870  if (booleanValue)
1871  tmpPU->setPlaced();
1872 
1873  std::getline(infile, line);
1874  iss = std::istringstream(line);
1875  iss >> fill0 >> booleanValue;
1876  if (booleanValue)
1877  {
1878  tmpPU->setFixed();
1879  fixedPlacementUnits.push_back(tmpPU);
1880  }
1881 
1882  std::getline(infile, line);
1883  iss = std::istringstream(line);
1884  iss >> fill0 >> booleanValue;
1885  if (booleanValue)
1886  tmpPU->setLocked();
1887 
1888  std::getline(infile, line);
1889  std::getline(infile, line);
1890  iss = std::istringstream(line);
1891  iss >> fill0 >> numCells;
1892 
1893  int totalWeight = 0;
1894  while (numCells--)
1895  {
1896  std::getline(infile, line);
1897  iss = std::istringstream(line);
1898  int virtualCellTypeId;
1899  iss >> fill0 >> cellId >> fill1 >> virtualCellTypeId >> fill2 >> cellName >> X >> Y;
1900  assert(cellId < getCells().size());
1901  assert(getCells()[cellId]->getName() == cellName);
1902  tmpPU->addCell(getCells()[cellId], static_cast<DesignInfo::DesignCellType>(virtualCellTypeId), X, Y);
1903  totalWeight +=
1905  ->cellType2sharedBELTypeOccupation[static_cast<DesignInfo::DesignCellType>(virtualCellTypeId)];
1906  cellId2PlacementUnit[cellId] = tmpPU;
1907  assert(cellId < cellId2PlacementUnitVec.size());
1908  cellId2PlacementUnitVec[cellId] = tmpPU;
1909  cellInMacros.insert(getCells()[cellId]);
1910  }
1911  tmpPU->setWeight(totalWeight);
1912 
1913  std::getline(infile, line);
1914  iss = std::istringstream(line);
1915  iss >> fill0 >> numCells;
1916 
1917  while (numCells--)
1918  {
1919  std::getline(infile, line);
1920  iss = std::istringstream(line);
1921  // CellId: 691036 siteName: RAMB18_X16Y21 BELName: RAMB181.RAMB18E2_U
1922  iss >> fill0 >> cellId >> fill1 >> siteName >> fill2 >> BELName;
1923  assert(cellId < getCells().size());
1924  tmpPU->addFixedCellInfo(getCells()[cellId], siteName, BELName);
1925  }
1926  }
1927  else if (fill0.find("UnpackedCell") != std::string::npos)
1928  {
1929  // UnpackedCell: 321808 design_1_i/xilinx_dma_pcie_ep_0/inst/sys_reset_n_ibuf
1930  // cellId: 644125 name: design_1_i/xilinx_dma_pcie_ep_0/inst/sys_reset_n_ibuf
1931  // placedAt: 52.75 117.857
1932  // isPlaced: 1
1933  // isFixed: 1
1934  // isLocked: 1
1935  // fixedAt: siteName: IOB_X1Y103 BELName: HPIOB.INBUF
1936 
1937  assert(placementUnits.size() == PUId && "PlacementUnit should be dumped according to the PU id order.");
1938  std::getline(infile, line);
1939  iss = std::istringstream(line);
1940  iss >> fill0 >> cellId >> fill1 >> cellName;
1941  assert(cellId < cellId2PlacementUnitVec.size());
1942  assert(getCells()[cellId]->getName() == cellName);
1943  PlacementUnpackedCell *tmpPU = new PlacementUnpackedCell(PUName, PUId, getCells()[cellId]);
1944  tmpPU->setWeight(
1945  getCompatiblePlacementTable()->cellType2sharedBELTypeOccupation[getCells()[cellId]->getCellType()]);
1946  placementUnits.push_back(tmpPU);
1947  placementUnpackedCells.push_back(tmpPU);
1948  cellId2PlacementUnitVec[cellId] = tmpPU;
1949  cellId2PlacementUnit[cellId] = tmpPU;
1950 
1951  std::getline(infile, line);
1952  iss = std::istringstream(line);
1953  iss >> fill0 >> X >> Y;
1955 
1956  std::getline(infile, line);
1957  iss = std::istringstream(line);
1958  iss >> fill0 >> booleanValue;
1959  if (booleanValue)
1960  tmpPU->setPlaced();
1961 
1962  std::getline(infile, line);
1963  iss = std::istringstream(line);
1964  iss >> fill0 >> booleanValue;
1965  if (booleanValue)
1966  {
1967  tmpPU->setFixed();
1968  fixedPlacementUnits.push_back(tmpPU);
1969  }
1970 
1971  bool shouldLock = false;
1972  std::getline(infile, line);
1973  iss = std::istringstream(line);
1974  iss >> fill0 >> booleanValue;
1975  if (booleanValue)
1976  {
1977  shouldLock = true;
1978  }
1979 
1980  if (tmpPU->isFixed())
1981  {
1982  std::getline(infile, line);
1983  iss = std::istringstream(line);
1984  iss >> fill0 >> fill1 >> siteName >> fill2 >> BELName;
1985  tmpPU->setLockedAt(siteName, BELName, deviceInfo);
1986  }
1987 
1988  if (shouldLock) // cannot set locked before other information is loaded
1989  tmpPU->setLocked();
1990  }
1991  else if (fill0.find("PULegalization:") != std::string::npos)
1992  {
1993  std::vector<std::string> tmpSiteNames;
1994  tmpSiteNames.clear();
1995  strSplit(PUName, tmpSiteNames, ",");
1996  assert(PUId < placementUnits.size());
1997  PU2LegalSites[placementUnits[PUId]] = std::vector<DeviceInfo::DeviceSite *>();
1998  for (auto siteName : tmpSiteNames)
1999  {
2000  DeviceInfo::DeviceSite *tmpSite = deviceInfo->getSiteWithName(siteName);
2001  tmpSite->setMapped(); // so later packing or legalization will bypass this site
2002  PU2LegalSites[placementUnits[PUId]].push_back(tmpSite);
2003  }
2004  PULegalXY.first[placementUnits[PUId]] = PU2LegalSites[placementUnits[PUId]][0]->X();
2005  PULegalXY.second[placementUnits[PUId]] = PU2LegalSites[placementUnits[PUId]][0]->Y();
2006  }
2007  else
2008  {
2009  std::cout << "This line : (" << std::string(line) << ") cannot be parsed.\n";
2010  assert(false);
2011  }
2012  }
2013 
2014  setProgress(0.8);
2016  reloadNets();
2017 }
2018 
2020 {
2021  for (auto curPNet : placementNets)
2022  {
2023  if (auto curNet = curPNet->getDesignNet())
2024  {
2025  if (!curNet->checkIsGlobalClock() && !curNet->checkIsGlobalClock() && curNet->getPins().size() < 10000 &&
2026  curNet->getPins().size() >= highFanOutThr)
2027  {
2028  curNet->enhanceOverallTimingNetEnhancement(1.2);
2029  }
2030  }
2031  }
2032 }
2033 
2035 {
2036  for (auto curClockNet : clockNets)
2037  {
2038  int leftId, rightId, topId, bottomId;
2039  deviceInfo->getClockRegionByLocation(curClockNet->getLeftPinX(), curClockNet->getBottomPinY(), leftId,
2040  bottomId);
2041  deviceInfo->getClockRegionByLocation(curClockNet->getRightPinX(), curClockNet->getTopPinY(), rightId, topId);
2042  assert(leftId >= 0 && leftId < deviceInfo->getClockRegionNumX());
2043  assert(rightId >= 0 && rightId < deviceInfo->getClockRegionNumX());
2044  assert(topId >= 0 && topId < deviceInfo->getClockRegionNumY());
2045  assert(bottomId >= 0 && bottomId < deviceInfo->getClockRegionNumY());
2046 
2047  bool enhanced = false;
2048  for (int i = bottomId; i <= topId && !enhanced; i++)
2049  {
2050  for (int j = leftId; j <= rightId && !enhanced; j++)
2051  {
2052  if (clockRegionUtilization[i][j] >= 18)
2053  {
2054  if ((rightId - leftId + 1) * (topId - bottomId + 1) < 15)
2055  {
2056  if (curClockNet->getPinOffsetsInUnit().size() < 5000)
2057  {
2058  curClockNet->getDesignNet()->setOverallTimingNetEnhancement(1.2);
2059  enhanced = true;
2060  }
2061  }
2062  }
2063  }
2064  }
2065 
2066  if (curClockNet->getDesignNet()->getName().find("_ddr") != std::string::npos)
2067  {
2068  curClockNet->getDesignNet()->setOverallTimingNetEnhancement(1.1);
2069  }
2070  }
2071 }
2072 
2074 {
2075  for (auto curPNet : placementNets)
2076  {
2077  if (auto curNet = curPNet->getDesignNet())
2078  {
2079  if (curNet->getName().find("_ddr") != std::string::npos)
2080  {
2081  curNet->setOverallTimingNetEnhancement(1.2);
2082  }
2083  }
2084  }
2085 }
2086 
2088 {
2089  clockNetCoverages.clear();
2090  clockRegionUtilization.clear();
2092  std::vector<int>(deviceInfo->getClockRegionNumX(), 0));
2093  auto &clockRegions = deviceInfo->getClockRegions();
2094 
2095  for (int i = deviceInfo->getClockRegionNumY() - 1; i >= 0; i--)
2096  {
2097  for (int j = 0; j < deviceInfo->getClockRegionNumX(); j++)
2098  {
2099  clockRegions[i][j]->resetClockUtilizationInfo();
2100  }
2101  }
2102 
2103  for (auto curClockNet : clockNets)
2104  {
2105  int leftId, rightId, topId, bottomId;
2106  deviceInfo->getClockRegionByLocation(curClockNet->getLeftPinX(), curClockNet->getBottomPinY(), leftId,
2107  bottomId);
2108  deviceInfo->getClockRegionByLocation(curClockNet->getRightPinX(), curClockNet->getTopPinY(), rightId, topId);
2109  assert(leftId >= 0 && leftId < deviceInfo->getClockRegionNumX());
2110  assert(rightId >= 0 && rightId < deviceInfo->getClockRegionNumX());
2111  assert(topId >= 0 && topId < deviceInfo->getClockRegionNumY());
2112  assert(bottomId >= 0 && bottomId < deviceInfo->getClockRegionNumY());
2113  for (int i = bottomId; i <= topId; i++)
2114  {
2115  for (int j = leftId; j <= rightId; j++)
2116  {
2117  clockRegionUtilization[i][j] += 1;
2118  }
2119  }
2120  }
2121 
2122  for (auto curClockNet : clockNets)
2123  {
2124  auto designNet = curClockNet->getDesignNet();
2125  for (auto curPin : designNet->getPins())
2126  {
2127  auto curCell = curPin->getCell();
2128  auto loc = cellId2location[curCell->getCellId()];
2129  int regionX, regionY;
2130  deviceInfo->getClockRegionByLocation(loc.X, loc.Y, regionX, regionY);
2131  deviceInfo->recordClockRelatedCell(loc.X, loc.Y, regionX, regionY, curCell->getCellId(),
2132  designNet->getElementIdInType());
2133  }
2134  }
2135 
2136  bool isLegal = true;
2137  print_info("Clock region untilization:");
2138  for (int i = deviceInfo->getClockRegionNumY() - 1; i >= 0; i--)
2139  {
2140  for (int j = 0; j < deviceInfo->getClockRegionNumX(); j++)
2141  {
2142  std::cout << std::left << std::setw(4) << clockRegionUtilization[i][j];
2143  isLegal &= ((clockRegionUtilization[i][j]) <= 24);
2144  }
2145  std::cout << "\n";
2146  }
2147 
2148  print_info("Clock column rough max untilization in each clock region:");
2149  for (int i = deviceInfo->getClockRegionNumY() - 1; i >= 0; i--)
2150  {
2151  for (int j = 0; j < deviceInfo->getClockRegionNumX(); j++)
2152  {
2154  std::cout << std::left << std::setw(4) << halfColumnUtil;
2155  isLegal &= (halfColumnUtil <= 12);
2156  }
2157  std::cout << "\n";
2158  }
2159 
2160  return isLegal;
2161 }
2162 
2164 {
2165 
2166  for (int i = deviceInfo->getClockRegionNumY() - 1; i >= 0; i--)
2167  {
2168  for (int j = 0; j < deviceInfo->getClockRegionNumX(); j++)
2169  {
2170  std::cout << "clock region " << i << " " << j
2171  << " ===================================================================\n";
2172  auto curClockRegion = deviceInfo->getClockRegions()[i][j];
2173  if (curClockRegion->getMaxUtilizationOfClockColumns() > 12)
2174  {
2175  auto curColumn = curClockRegion->getMaxUtilizationClockColumnsPtr();
2176 
2177  for (auto curClockNet : clockNets)
2178  {
2179  auto designNet = curClockNet->getDesignNet();
2180  std::vector<DesignInfo::DesignCell *> cellsInColumn;
2181  cellsInColumn.clear();
2182  for (auto curPin : designNet->getPins())
2183  {
2184  auto curCell = curPin->getCell();
2185  auto loc = cellId2location[curCell->getCellId()];
2186  if (loc.X <= curColumn->getRight() && loc.X >= curColumn->getLeft() &&
2187  loc.Y <= curColumn->getTop() && loc.Y >= curColumn->getBottom())
2188  {
2189  cellsInColumn.push_back(curCell);
2190  }
2191  }
2192 
2193  if (cellsInColumn.size())
2194  {
2195  std::cout << "clockSrcPin: " << curClockNet->getDesignNet()->getName() << " has "
2196  << cellsInColumn.size() << " cell in the targetColumn:\n";
2197  for (auto tmpCell : cellsInColumn)
2198  {
2199  std::cout << " " << tmpCell->getName() << "\n";
2200  }
2201  std::cout << "packing record:=========================================================\n";
2202  if (clockCol2ClockNets[curColumn].find(designNet) != clockCol2ClockNets[curColumn].end())
2203  {
2204  std::cout << "design net is found in packing record.";
2205  }
2206  else
2207  {
2208  std::cout << "design net is not found in packing record.";
2209  }
2210  std::cout << "===================================================================\n";
2211  std::cout << "===================================================================\n";
2212  }
2213  }
2214  }
2215  }
2216  }
2217 }
2218 
2220 {
2221  auto &cells = designInfo->getCells();
2222  PaintXs.resize(cells.size());
2223  PaintYs.resize(cells.size());
2224  PaintTypes.resize(cells.size());
2225 
2226  std::vector<std::string> cellNames;
2227  // writeElementInfo(std::vector<float> &_Xs, std::vector<float> &_Ys, std::vector<int> &_elementTypes)
2228  for (int i = 0; i < cells.size(); i++)
2229  {
2230  PaintXs[i] = cellId2location[i].X;
2231  PaintYs[i] = cellId2location[i].Y;
2232  // LUT,FF,MUX,CARRY,DSP,BRAM,LUTRAM
2233  if (cells[i]->isLUT())
2234  PaintTypes[i] = 0;
2235  else if (cells[i]->isFF())
2236  PaintTypes[i] = 1;
2237  else if (cells[i]->isMux())
2238  PaintTypes[i] = 2;
2239  else if (cells[i]->isCarry())
2240  PaintTypes[i] = 3;
2241  else if (cells[i]->isDSP())
2242  PaintTypes[i] = 4;
2243  else if (cells[i]->isBRAM())
2244  PaintTypes[i] = 5;
2245  else
2246  PaintTypes[i] = 6;
2247  cellNames.push_back(cells[i]->getName());
2248  }
2249  assert(paintData);
2250 
2251  auto timingInfo = simplePlacementTimingInfo;
2252  auto timingGraph = timingInfo->getSimplePlacementTimingGraph();
2253  timingGraph->sortedEndpointByDelay();
2254  std::vector<int> isCovered(timingGraph->getNodes().size(), 0);
2255  std::vector<std::vector<int>> resPaths;
2256 
2257  int pathNumThr;
2258 
2259  paintData->getPaintDemand(pathNumThr);
2260  pathNumThr = 1000;
2261  // print_status("painting " + std::to_string(pathNumThr) + " critical paths");
2262 
2263  for (auto curEndpoint : timingGraph->getSortedTimingEndpoints())
2264  {
2265  if (isCovered[curEndpoint->getId()])
2266  continue;
2267  std::vector<int> resPath;
2268  bool findSuccessfully =
2269  timingGraph->backTraceDelayLongestPathFromNode(curEndpoint->getId(), isCovered, resPath, 10);
2270  if (findSuccessfully)
2271  {
2272  // std::cout << "find endpoint [" << curEndpoint->getDesignNode()
2273  // << "] delay=" << curEndpoint->getLatestInputArrival() << " with " << resPath.size()
2274  // << " nodes in path.\n";
2275 
2276  bool containNegativeIndex = false;
2277  for (auto cellId : resPath)
2278  {
2279  if (cellId < 0)
2280  {
2281  containNegativeIndex = true;
2282  break;
2283  }
2284  auto PU = getPlacementUnitByCellId(cellId);
2285  if (auto unpackedCell = dynamic_cast<PlacementInfo::PlacementUnpackedCell *>(PU))
2286  {
2287  isCovered[unpackedCell->getCell()->getCellId()]++;
2288  }
2289  else if (auto macro = dynamic_cast<PlacementInfo::PlacementMacro *>(PU))
2290  {
2291  for (auto cell : macro->getCells())
2292  {
2293  isCovered[cell->getCellId()]++;
2294  }
2295  }
2296  }
2297  if (!containNegativeIndex)
2298  resPaths.push_back(resPath);
2299  }
2300 
2301  if (resPaths.size() > pathNumThr)
2302  break;
2303  }
2304 
2305  paintData->writeElementInfo(PaintXs, PaintYs, PaintTypes, resPaths, cellNames);
2306 }
readZip.h
PlacementInfo::JSONCfg
std::map< std::string, std::string > & JSONCfg
Definition: PlacementInfo.h:4585
PlacementInfo::CompatiblePlacementTable::deviceInfo
DeviceInfo * deviceInfo
Definition: PlacementInfo.h:312
PlacementInfo::CompatiblePlacementTable::cellType2sharedBELTypeOccupation
std::map< DesignInfo::DesignCellType, int > cellType2sharedBELTypeOccupation
the resource demand of specific types. (cost how many slot/BELs)
Definition: PlacementInfo.h:144
PlacementInfo::PlacementNet
Placement net, compared to design net, includes information related to placement.
Definition: PlacementInfo.h:1877
PlacementInfo::loadCompatiblePlacementTable
CompatiblePlacementTable * loadCompatiblePlacementTable(std::string cellType2fixedAmoFileName, std::string cellType2sharedCellTypeFileName, std::string sharedCellType2BELtypeFileName)
describes the type mapping from design to device, where a cell can be placed (which BEL in which site...
Definition: PlacementInfo.h:2732
DesignInfo::getNumCells
int getNumCells()
Definition: DesignInfo.h:1600
PlacementInfo::getProgress
float getProgress()
Get the Progress ratio of the placement.
Definition: PlacementInfo.h:3969
paintPlacement.cnt
int cnt
Definition: paintPlacement.py:155
PlacementInfo::PlacementMacro::getVirtualCellType
DesignInfo::DesignCellType getVirtualCellType(int vId)
Definition: PlacementInfo.h:1786
PlacementInfo::setProgress
void setProgress(float p)
Set the progress ratio, indicating the progress of the placement convergence,.
Definition: PlacementInfo.h:3959
PlacementInfo::PlacementUnit::hasLogic
bool hasLogic()
Definition: PlacementInfo.h:1332
exportDeviceLocation.sites
list sites
Definition: exportDeviceLocation.py:216
PlacementInfo::PlacementMacro::getBottomOffset
float getBottomOffset()
Definition: PlacementInfo.h:1806
PlacementInfo::getPlacementUnits
std::vector< PlacementUnit * > & getPlacementUnits()
Definition: PlacementInfo.h:2810
PlacementInfo::getCells
std::vector< DesignInfo::DesignCell * > & getCells()
Definition: PlacementInfo.h:3898
PlacementInfo::PlacementBinInfo
BEL bin for global placement for a specific shared BEL type.
Definition: PlacementInfo.h:372
PlacementInfo::oriPseudoNetWeight
float oriPseudoNetWeight
Definition: PlacementInfo.h:4615
PlacementInfo::placementUnits
std::vector< PlacementUnit * > placementUnits
Definition: PlacementInfo.h:4433
DeviceInfo::DeviceSite::setMapped
void setMapped()
Definition: DeviceInfo.h:331
PlacementInfo::optimizeLongPaths
void optimizeLongPaths()
make the PlacementUnits in the long path closer to each other
Definition: PlacementInfo.cc:723
PlacementInfo::longPaths
std::vector< std::vector< PlacementUnit * > > longPaths
Definition: PlacementInfo.h:4533
PlacementInfo::PULegalXY
std::pair< std::map< PlacementInfo::PlacementUnit *, float >, std::map< PlacementInfo::PlacementUnit *, float > > PULegalXY
a mapping from PlaceuementUnit objects to legalized locations
Definition: PlacementInfo.h:4451
PlacementTimingInfo::TimingGraph::getNodes
std::vector< TimingNode * > & getNodes()
Definition: PlacementTimingInfo.h:537
PlacementInfo::getCompatiblePlacementTable
CompatiblePlacementTable * getCompatiblePlacementTable()
Definition: PlacementInfo.h:2740
PlacementInfo::adjustLUTFFUtilization_Clocking
void adjustLUTFFUtilization_Clocking()
adjust the utlization of clock-related elements to mitigate the overflow of clock utilization
Definition: PlacementInfo.cc:1409
DesignInfo::getNets
std::vector< DesignNet * > & getNets()
Definition: DesignInfo.h:1613
DeviceInfo::DeviceElement::getName
std::string & getName()
Definition: DeviceInfo.h:79
PlacementInfo::PlacementMacro
a fixed group of multiple standard cells with constraints of their relative locations
Definition: PlacementInfo.h:1525
PlacementInfo::PlacementUnit::setWeight
void setWeight(int numCell)
Definition: PlacementInfo.h:1196
PlacementInfo::PlacementUnpackedCell::getFixedBELName
std::string getFixedBELName()
Definition: PlacementInfo.h:1502
DesignInfo::DesignCell
a DesignCell in design netlist, DesignPin objects of which might connect to DesignNet objects
Definition: DesignInfo.h:782
PlacementTimingInfo
PlacementTimingInfo is the container which record the timing information related to placement.
Definition: PlacementTimingInfo.h:49
DeviceInfo::getSiteWithName
DeviceSite * getSiteWithName(std::string &siteName)
Get a site based on a given name.
Definition: DeviceInfo.h:1031
removeFailurePartFromTcl.line
line
Definition: removeFailurePartFromTcl.py:32
PlacementInfo::endY
float endY
bottom boundary of the bin grid
Definition: PlacementInfo.h:4504
PlacementInfo::placementUnpackedCells
std::vector< PlacementUnpackedCell * > placementUnpackedCells
Definition: PlacementInfo.h:4434
DesignInfo::DesignNet
a design net (hyperedge) defined in the design, connecting to pins of cells
Definition: DesignInfo.h:525
paintPlacement.y
list y
Definition: paintPlacement.py:153
PlacementInfo::CompatiblePlacementTable::cellType2sharedBELTypeIDs
std::map< DesignInfo::DesignCellType, std::vector< int > > cellType2sharedBELTypeIDs
the mapping from design cell type to device resource type ID
Definition: PlacementInfo.h:161
PlacementInfo::dumpCongestion
void dumpCongestion(std::string dumpFileName)
dump the congestion mesh grid for evaluation
Definition: PlacementInfo.cc:1562
DeviceInfo::getSitesInType
std::vector< DeviceSite * > & getSitesInType(std::string &siteType)
Get sites of a specfic type.
Definition: DeviceInfo.h:1043
PlacementInfo::PlacementMacro::getCellOffsetYInMacro
float getCellOffsetYInMacro(DesignInfo::DesignCell *cell)
Definition: PlacementInfo.h:1762
PlacementInfo::compatiblePlacementTable
CompatiblePlacementTable * compatiblePlacementTable
Definition: PlacementInfo.h:4432
PlacementInfo::placementUnitId2Nets
std::vector< std::vector< PlacementNet * > > placementUnitId2Nets
Definition: PlacementInfo.h:4525
PlacementInfo::PlacementMacro::PlacementMacroType_LCLB
@ PlacementMacroType_LCLB
Definition: PlacementInfo.h:1533
DesignInfo::getType2Cells
std::map< DesignCellType, std::vector< DesignCell * > > & getType2Cells()
Definition: DesignInfo.h:1664
PlacementInfo::getGridXY
void getGridXY(float cellX, float cellY, int &binIdX, int &binIdY)
Get the Grid row/column based on given location X,Y.
Definition: PlacementInfo.h:3344
PlacementInfo::PlacementUnit::getNetsSetPtr
std::vector< PlacementNet * > * getNetsSetPtr()
Get the Nets Set Ptr object which records the nets connecting to the PlacementUnit.
Definition: PlacementInfo.h:1231
PlacementInfo::PaintYs
std::vector< float > PaintYs
Definition: PlacementInfo.h:4541
PlacementInfo::PlacementMacro::PlacementMacroType_CARRY
@ PlacementMacroType_CARRY
Definition: PlacementInfo.h:1537
PlacementInfo::cellId2location
std::vector< Location > cellId2location
Definition: PlacementInfo.h:4441
PlacementInfo::dumpVivadoPlacementTclWithPULegalizationInfo
void dumpVivadoPlacementTclWithPULegalizationInfo(std::string dumpFile)
dump the placement commands to place cells in Vivado (do not use this temporarily)
Definition: PlacementInfo.cc:1696
PlacementInfo::adjustLUTFFUtilization_Routability
void adjustLUTFFUtilization_Routability(bool enfore)
adjust the resource demand of LUTs/FFs according to routing congestion refer to RippleFPGA's implemen...
Definition: PlacementInfo.cc:1273
PlacementInfo::PlacementUnit::Y
float Y()
Definition: PlacementInfo.h:1029
DesignInfo::DesignCellType
DesignCellType
design cell types
Definition: DesignInfo.h:73
DeviceInfo::getClockRegionByLocation
void getClockRegionByLocation(float locX, float locY, int &clockRegionX, int &clockRegionY)
Get the clock region ID (X/Y) by a given location (X/Y)
Definition: DeviceInfo.h:1183
PlacementInfo::cellId2PlacementUnit
std::map< int, PlacementUnit * > cellId2PlacementUnit
Definition: PlacementInfo.h:4438
PlacementInfo::getMinYFromSites
float getMinYFromSites(std::vector< DeviceInfo::DeviceSite * > &sites)
Get the Min Y of sites to identify the boundary of the device.
Definition: PlacementInfo.cc:261
operator<<
std::ostream & operator<<(std::ostream &os, PlacementInfo::PlacementMacro *curMacro)
Definition: PlacementInfo.cc:802
paintPlacement.x
list x
Definition: paintPlacement.py:152
PlacementInfo::PlacementMacro::PlacementMacroType_MUX8
@ PlacementMacroType_MUX8
Definition: PlacementInfo.h:1541
PlacementInfo::loadPlacementUnitInformation
void loadPlacementUnitInformation(std::string locationFile)
load the data of the PlacementUnit objects and some placement parameters from a checkpoint file
Definition: PlacementInfo.cc:1752
PlacementInfo::PlacementUnit::setFixed
void setFixed()
Definition: PlacementInfo.h:1144
PlacementInfo::PlacementMacro::PlacementMacroType_MCLB
@ PlacementMacroType_MCLB
Definition: PlacementInfo.h:1535
PlacementInfo::resetSiteBinGrid
void resetSiteBinGrid()
Definition: PlacementInfo.cc:1650
FILEbuf
Definition: readZip.h:34
PlacementInfo::macroRatio
float macroRatio
Definition: PlacementInfo.h:4626
DeviceInfo::getClockRegionNumY
int getClockRegionNumY()
Get the number of rows of the clock region array.
Definition: DeviceInfo.h:1227
PlacementInfo::designInfo
DesignInfo * designInfo
Definition: PlacementInfo.h:4443
PlacementInfo::printStat
void printStat(bool verbose=false)
Definition: PlacementInfo.cc:294
PlacementInfo::updateCells2PlacementUnits
void updateCells2PlacementUnits()
update the mapping from Cells to PlacementUnits, since sometime, PlacementUnits might change
Definition: PlacementInfo.cc:1683
PlacementInfo::clockNets
std::vector< PlacementNet * > clockNets
Definition: PlacementInfo.h:4528
PlacementInfo::PlacementMacro::PlacementMacroType_FFFFPair
@ PlacementMacroType_FFFFPair
Definition: PlacementInfo.h:1531
PlacementInfo::startY
float startY
bottom boundary of the bin grid
Definition: PlacementInfo.h:4490
PlacementInfo::PlacementUnit::X
float X()
Definition: PlacementInfo.h:1024
PlacementInfo::LUTFFUtilizationAdjusted
bool LUTFFUtilizationAdjusted
Definition: PlacementInfo.h:4622
PlacementInfo::cellId2PlacementUnitVec
std::vector< PlacementUnit * > cellId2PlacementUnitVec
Definition: PlacementInfo.h:4439
PlacementInfo::getMaxYFromSites
float getMaxYFromSites(std::vector< DeviceInfo::DeviceSite * > &sites)
Get the Max Y of sites to identify the boundary of the device.
Definition: PlacementInfo.cc:283
PlacementInfo::adjustLUTFFUtilization_Routability_Reset
void adjustLUTFFUtilization_Routability_Reset()
reset the inflate ratio of all the cells to be 1, for re-evaluation
Definition: PlacementInfo.cc:1511
PlacementInfo::getPairPinNum
unsigned int getPairPinNum(DesignInfo::DesignCell *LUTA, DesignInfo::DesignCell *LUTB)
Get the Pair Pin Num of two LUTs.
Definition: PlacementInfo.h:4127
PlacementInfo::enhanceDDRNet
void enhanceDDRNet()
Definition: PlacementInfo.cc:2073
PlacementInfo::getBELType2FalseBELType
std::string getBELType2FalseBELType(std::string curBELType)
get the remapped BEL type of a specific BEL type since some cell can be placed in sites of different ...
Definition: PlacementInfo.h:3331
PlacementInfo::placementMacros
std::vector< PlacementMacro * > placementMacros
Definition: PlacementInfo.h:4435
PlacementInfo::CompatiblePlacementTable::resetCellOccupationToDefault
void resetCellOccupationToDefault()
forget the occupation adjustment by packing feasibility and routing congestion
Definition: PlacementInfo.cc:241
PlacementInfo::PlacementMacro::getRightOffset
float getRightOffset()
Definition: PlacementInfo.h:1814
PlacementInfo::PlacementMacro::PlacementMacroType_MUX7
@ PlacementMacroType_MUX7
Definition: PlacementInfo.h:1540
PlacementInfo::getMacroLegalizationWeight
float getMacroLegalizationWeight()
Get the Macro Legalization Weight.
Definition: PlacementInfo.h:4060
DeviceInfo::getMaxUtilizationOfClockColumns_InClockRegion
int getMaxUtilizationOfClockColumns_InClockRegion(int regionX, int regionY)
Get the maximum utilization among the clock columns in clock region.
Definition: DeviceInfo.h:1251
PlacementInfo::resetElementBinGrid
void resetElementBinGrid()
clean the information in bin grid
Definition: PlacementInfo.cc:898
PlacementInfo::cellType2fixedAmoFileName
std::string cellType2fixedAmoFileName
Definition: PlacementInfo.h:4586
PlacementInfo::PlacementUnit::getName
std::string & getName()
Definition: PlacementInfo.h:1186
delayVisualization.X
X
Definition: delayVisualization.py:80
PlacementInfo::PlacementMacro::PlacementMacroType_LUTLUTSeires
@ PlacementMacroType_LUTLUTSeires
Definition: PlacementInfo.h:1530
PlacementInfo::PlacementMacro::PlacementMacroType_DSP
@ PlacementMacroType_DSP
Definition: PlacementInfo.h:1538
DSE.end
end
Definition: DSE.py:18
DeviceInfo::getBELTypes
std::set< std::string > & getBELTypes()
get BEL types in the device
Definition: DeviceInfo.h:986
PlacementInfo::highFanOutThr
int highFanOutThr
Definition: PlacementInfo.h:4624
PlacementInfo::CompatiblePlacementTable::sharedCellBELTypes
std::vector< std::string > sharedCellBELTypes
some BEL types (design cells should be mapped to the BEL slot on FPGA device)
Definition: PlacementInfo.h:135
PlacementInfo::reloadNets
void reloadNets()
update PlacementNet objects when there are some updates of PlacementUnit objects (e....
Definition: PlacementInfo.cc:507
DeviceInfo::recordClockRelatedCell
void recordClockRelatedCell(float locX, float locY, int regionX, int regionY, int cellId, int netId)
record the information of cell in a specific clock region
Definition: DeviceInfo.cc:388
stringCheck.h
PlacementInfo::transferPaintData
void transferPaintData()
Definition: PlacementInfo.cc:2219
PlacementInfo::netDistribution
int netDistribution[8]
Definition: PlacementInfo.h:4590
PlacementInfo::updateElementBinGrid
void updateElementBinGrid()
map design cells to the bins in the bin grid.
Definition: PlacementInfo.cc:906
DeviceInfo::DeviceSite
Site class for site on device.
Definition: DeviceInfo.h:163
DeviceInfo::DeviceSite::getClockRegionX
int getClockRegionX()
Definition: DeviceInfo.h:352
PlacementInfo::getBinGrid
std::vector< std::vector< std::vector< PlacementBinInfo * > > > & getBinGrid()
Get the Bin Grid object for all types of BEL.
Definition: PlacementInfo.h:3110
PlacementInfo::CompatiblePlacementTable::CompatiblePlacementTable
CompatiblePlacementTable(std::string cellType2fixedAmoFileName, std::string cellType2sharedCellTypeFileName, std::string sharedCellType2BELtypeFileName, DesignInfo *designInfo, DeviceInfo *deviceInfo)
Construct a new Compatible Placement Table object.
Definition: PlacementInfo.cc:90
DeviceInfo::getSites
std::vector< DeviceSite * > & getSites()
Definition: DeviceInfo.h:1097
strPrint.h
PlacementInfo::PUSetContainingFF
std::set< PlacementUnit * > PUSetContainingFF
Definition: PlacementInfo.h:4531
DesignInfo::DesignCell::isFF
bool isFF()
Definition: DesignInfo.h:933
PlacementInfo::clockRegionUtilization
std::vector< std::vector< int > > clockRegionUtilization
Definition: PlacementInfo.h:4529
print_status
void print_status(std::string tmp_string)
Definition: strPrint.cc:44
PlacementInfo::findNeiborLUTFFsFromBinGrid
std::vector< DesignInfo::DesignCell * > * findNeiborLUTFFsFromBinGrid(DesignInfo::DesignCell *curCell, float displacementUpperbound, int minNumNeighbor=10)
find neibor LUTs/FFs from bin grid
Definition: PlacementInfo.h:3009
PlacementInfo::PlacementBinInfo::addSiteIntoBin
void addSiteIntoBin(DeviceInfo::DeviceSite *curSite)
add a resource site into the bin
Definition: PlacementInfo.cc:308
PlacementInfo::PaintXs
std::vector< float > PaintXs
Definition: PlacementInfo.h:4540
PlacementInfo::createSiteBinGrid
void createSiteBinGrid()
Definition: PlacementInfo.cc:1582
PlacementInfo::verifyDeviceForDesign
void verifyDeviceForDesign()
verify that each cells in the design can be mapped on the resource elements on the device.
Definition: PlacementInfo.cc:790
PlacementInfo::designNetId2PlacementNet
std::vector< PlacementNet * > designNetId2PlacementNet
Definition: PlacementInfo.h:4526
PlacementInfo::PlacementMacro::PlacementMacroType_LUTFFPair
@ PlacementMacroType_LUTFFPair
Definition: PlacementInfo.h:1529
PlacementInfo::PU2LegalSites
std::map< PlacementInfo::PlacementUnit *, std::vector< DeviceInfo::DeviceSite * > > PU2LegalSites
a mapping from PlaceuementUnit objects to device sites
Definition: PlacementInfo.h:4456
PlacementInfo::CompatiblePlacementTable::cellType2sharedBELTypes
std::map< DesignInfo::DesignCellType, std::vector< std::string > > cellType2sharedBELTypes
the mapping from design cell type to device resource type
Definition: PlacementInfo.h:153
PlacementInfo::sharedCellType2BELtypeFileName
std::string sharedCellType2BELtypeFileName
Definition: PlacementInfo.h:4588
PlacementInfo::adjustLUTFFUtilization_Packablity
void adjustLUTFFUtilization_Packablity(float neighborDisplacementUpperbound, bool enfore)
adjust the resource demand of LUTs/FFs according to packing feasibility
Definition: PlacementInfo.cc:1073
DeviceInfo::getBoundaryTolerance
float getBoundaryTolerance()
Definition: DeviceInfo.h:1170
delayVisualization.alpha
alpha
Definition: delayVisualization.py:98
DesignInfo::DesignElement::getName
const std::string & getName() const
Definition: DesignInfo.h:243
print_error
void print_error(std::string tmp_string)
Definition: strPrint.cc:52
PlacementInfo::PlacementMacro::getCellOffsetXInMacro
float getCellOffsetXInMacro(DesignInfo::DesignCell *cell)
Definition: PlacementInfo.h:1756
print_warning
void print_warning(std::string tmp_string)
Definition: strPrint.cc:57
PlacementInfo::enhanceHighFanoutNet
void enhanceHighFanoutNet()
Definition: PlacementInfo.cc:2019
PlacementInfo::isDensePlacement
bool isDensePlacement()
Definition: PlacementInfo.h:4388
PlacementInfo::getPlacementUnitByCellId
PlacementUnit * getPlacementUnitByCellId(int cellId)
Definition: PlacementInfo.h:3127
PlacementInfo::getPseudoNetWeight
float getPseudoNetWeight()
Get the Pseudo Net Weight object.
Definition: PlacementInfo.h:4026
PlacementInfo::dumpPlacementUnitLocationCnt
int dumpPlacementUnitLocationCnt
Definition: PlacementInfo.h:4610
PlacementInfo::updateSiteBinGrid
void updateSiteBinGrid()
Definition: PlacementInfo.cc:1657
PlacementInfo::PlacementMacro::getLeftOffset
float getLeftOffset()
Definition: PlacementInfo.h:1810
PlacementInfo::CompatiblePlacementTable::sharedCellBELTypeName2ID
std::map< std::string, int > sharedCellBELTypeName2ID
Definition: PlacementInfo.h:306
PlacementInfo::PlacementUnit
a movement unit in placement with information of location and resource demand
Definition: PlacementInfo.h:1010
DesignInfo::DesignCell::getCellId
int getCellId()
Get the Cell Id in the cell list.
Definition: DesignInfo.h:1037
PlacementInfo::PlacementUnit::getId
unsigned int getId()
Definition: PlacementInfo.h:1206
PlacementInfo::PlacementUnpackedCell::getCell
DesignInfo::DesignCell * getCell()
Definition: PlacementInfo.h:1497
PlacementInfo::CompatiblePlacementTable::setBELTypeForCells
void setBELTypeForCells(DesignInfo *designInfo)
set the mapping from cells in design netlist to BEL type ID for later processing.
Definition: PlacementInfo.cc:217
PlacementInfo::PlacementUnit::isPlaced
bool isPlaced()
Definition: PlacementInfo.h:1181
PlacementInfo::fixedPlacementUnits
std::vector< PlacementUnit * > fixedPlacementUnits
Definition: PlacementInfo.h:4436
DesignInfo::DesignCell::isLUT
bool isLUT()
Definition: DesignInfo.h:927
PlacementInfo::PlacementUnpackedCell::setLockedAt
void setLockedAt(std::string _siteName, std::string _BELName, DeviceInfo *deviceInfo, bool lock=true)
Definition: PlacementInfo.h:1479
writeStrToGZip
void writeStrToGZip(std::string fileName, std::stringstream &data)
Definition: dumpZip.cc:29
PlacementInfo::deviceInfo
DeviceInfo * deviceInfo
Definition: PlacementInfo.h:4444
PlacementInfo::globalBinGrid
std::vector< std::vector< PlacementBinInfo * > > globalBinGrid
Bin Grid includes all types of sites, mainly for congestion evalution.
Definition: PlacementInfo.h:4519
PlacementInfo::PaintTypes
std::vector< int > PaintTypes
Definition: PlacementInfo.h:4542
PlacementInfo::macroPseudoNetEnhanceCnt
int macroPseudoNetEnhanceCnt
Definition: PlacementInfo.h:4616
PlacementInfo::PlacementNet::drawNet
void drawNet(float generalWeight=1.0)
Definition: PlacementInfo.cc:760
PlacementInfo::PlacementSiteBinInfo
Site bin for global placement for some specific Site types.
Definition: PlacementInfo.h:2575
PlacementInfo::PlacementUnit::isFixed
bool isFixed()
Definition: PlacementInfo.h:1177
PlacementInfo::siteGridForMacros
std::vector< std::vector< PlacementSiteBinInfo * > > siteGridForMacros
Definition: PlacementInfo.h:4520
PlacementInfo::dumpOverflowClockUtilization
void dumpOverflowClockUtilization()
Definition: PlacementInfo.cc:2163
PlacementInfo::PlacementUnpackedCell::getFixedSiteName
std::string getFixedSiteName()
Definition: PlacementInfo.h:1507
PlacementInfo::getMinXFromSites
float getMinXFromSites(std::vector< DeviceInfo::DeviceSite * > &sites)
Get the Min X of sites to identify the boundary of the device.
Definition: PlacementInfo.cc:250
PlacementInfo::globalMinX
float globalMinX
left boundary of the device
Definition: PlacementInfo.h:4461
PlacementInfo::PUsContainingFF
std::vector< PlacementUnit * > PUsContainingFF
Definition: PlacementInfo.h:4532
PlacementInfo::PlacementMacro::PlacementMacroType
PlacementMacroType
Definition: PlacementInfo.h:1528
PlacementInfo::enhanceRiskyClockNet
void enhanceRiskyClockNet()
Definition: PlacementInfo.cc:2034
PlacementInfo::setCellBinInfo
void setCellBinInfo(int cellId, int sharedTypeId, int X, int Y, float occupation)
Set the cell bin Information of a design cell.
Definition: PlacementInfo.h:3733
PlacementInfo::PlacementUnit::setLocked
void setLocked()
Definition: PlacementInfo.h:1156
strSplit
void strSplit(const std::string &s, std::vector< std::string > &sv, const char *delim)
Definition: stringCheck.cc:35
PlacementInfo::eps
float eps
Definition: PlacementInfo.h:4506
PlacementInfo::endX
float endX
right boundary of the bin grid
Definition: PlacementInfo.h:4497
DesignInfo::getCells
std::vector< DesignCell * > & getCells()
Definition: DesignInfo.h:1609
PlacementInfo::getMaxXFromSites
float getMaxXFromSites(std::vector< DeviceInfo::DeviceSite * > &sites)
Get the Max X of sites to identify the boundary of the device.
Definition: PlacementInfo.cc:272
PlacementInfo::y2xRatio
float y2xRatio
a factor to tune the weights of the net spanning in Y-coordinate relative to the net spanning in X-co...
Definition: PlacementInfo.h:4596
PlacementInfo::checkClockUtilization
bool checkClockUtilization(bool dump)
check the utlization of the clock regions on the device
Definition: PlacementInfo.cc:2087
DeviceInfo::getBELType2FalseBELType
std::string getBELType2FalseBELType(std::string curBELType)
Definition: DeviceInfo.h:1122
PlacementInfo::clockLegalizationRisky
bool clockLegalizationRisky
Definition: PlacementInfo.h:4613
DeviceInfo::getClockRegionNumX
int getClockRegionNumX()
Get the number of columns of the clock region array.
Definition: DeviceInfo.h:1217
PlacementInfo::PlacementUnit::setPlaced
void setPlaced()
Definition: PlacementInfo.h:1171
PlacementInfo::globalMaxY
float globalMaxY
top boundary of the device
Definition: PlacementInfo.h:4476
PlacementInfo::paintData
PaintDataBase * paintData
Definition: PlacementInfo.h:4538
DeviceInfo
Information class related to FPGA device, including the details of BEL/Site/Tile/ClockRegion.
Definition: DeviceInfo.h:43
PlacementInfo::dumpPlacementUnitInformation
void dumpPlacementUnitInformation(std::string dumpFile)
dump the PlacementUnit objects and some placement parameters as a checkpoint
Definition: PlacementInfo.cc:1723
DeviceInfo::DeviceSite::X
float X()
Definition: DeviceInfo.h:288
PlacementInfo::enforceLegalizeXYInArea
void enforceLegalizeXYInArea(PlacementUnit *curPU)
move the PlacementUnit to ensure the cells in it are within the device area.
Definition: PlacementInfo.h:3402
DesignInfo::CellType_LUT6
@ CellType_LUT6
Definition: DesignInfo.h:79
PlacementInfo::PlacementMacro::PlacementMacroType_HALFCLB
@ PlacementMacroType_HALFCLB
Definition: PlacementInfo.h:1532
delayVisualization.Y
Y
Definition: delayVisualization.py:80
PlacementInfo::PlacementInfo
PlacementInfo(DesignInfo *designInfo, DeviceInfo *deviceInfo, std::map< std::string, std::string > &JSONCfg)
Construct a new Placement Info object based on the information of design and device.
Definition: PlacementInfo.cc:36
PlacementInfo::getActualOccupation
float getActualOccupation(DesignInfo::DesignCell *cell)
Get the actual occupation of a specific cell.
Definition: PlacementInfo.h:2957
PlacementInfo::PlacementMacro::addCell
void addCell(DesignInfo::DesignCell *curCell, DesignInfo::DesignCellType cellType, float x, float y)
add a real cell into the macro with its offsets in the macro
Definition: PlacementInfo.h:1576
PlacementInfo::PlacementUnit::setAnchorLocationAndForgetTheOriginalOne
void setAnchorLocationAndForgetTheOriginalOne(float x, float y)
Definition: PlacementInfo.h:1128
PlacementInfo::PlacementUnpackedCell
the smallest, indivisible, representable component. It will include only one standard cell
Definition: PlacementInfo.h:1447
PlacementInfo::getDeterminedOccupation
int getDeterminedOccupation(int cellId)
Definition: PlacementInfo.h:4099
PlacementInfo::PlacementNet::getUnits
std::vector< PlacementUnit * > & getUnits()
Get the reference of the vector of PlacementUnits connected to the net The placement units in the vec...
Definition: PlacementInfo.h:1943
DesignInfo::CellType_FDCE
@ CellType_FDCE
Definition: DesignInfo.h:82
PlacementInfo::CompatiblePlacementTable::getcellId2Occupation
std::vector< float > & getcellId2Occupation()
get the reference of cellId2Occupation for convenience
Definition: PlacementInfo.h:274
PlacementInfo::cellInMacros
std::set< DesignInfo::DesignCell * > cellInMacros
Definition: PlacementInfo.h:4437
PlacementInfo::getMacroPseudoNetEnhanceCnt
int getMacroPseudoNetEnhanceCnt()
Get the Macro Pseudo Net Enhance Counter.
Definition: PlacementInfo.h:4040
PlacementInfo::binWidth
float binWidth
Definition: PlacementInfo.h:4521
print_info
void print_info(std::string tmp_string)
Definition: strPrint.cc:39
PlacementInfo::CompatiblePlacementTable::getSharedBELTypeId
int getSharedBELTypeId(std::string tmpStr)
get the ID of SharedBELType from a string
Definition: PlacementInfo.h:215
PlacementInfo::PlacementMacro::getCells
std::vector< DesignInfo::DesignCell * > & getCells()
Definition: PlacementInfo.h:1724
PlacementInfo::CompatiblePlacementTable::sharedCellType2SiteType
std::map< std::string, std::string > sharedCellType2SiteType
The mapping from shared cell types to device site types.
Definition: PlacementInfo.h:169
PlacementInfo::netPinNumDistribution
int netPinNumDistribution[8]
Definition: PlacementInfo.h:4589
PlacementInfo::lastProgressWhenLUTFFUtilAdjust
float lastProgressWhenLUTFFUtilAdjust
Definition: PlacementInfo.h:4619
checkHalfColumn.i
int i
Definition: checkHalfColumn.py:5
PlacementInfo::updateLongPaths
void updateLongPaths()
update the long path in the design and enhance their net weights
Definition: PlacementInfo.cc:635
PlacementInfo::CompatiblePlacementTable::sharedCellType2BELNames
std::map< std::string, std::vector< std::string > > sharedCellType2BELNames
The mapping from shared cell types to device BEL types.
Definition: PlacementInfo.h:179
PlacementInfo::globalMinY
float globalMinY
bottom boundary of the device
Definition: PlacementInfo.h:4466
PlacementInfo::startX
float startX
left boundary of the bin grid
Definition: PlacementInfo.h:4483
PlacementInfo::CompatiblePlacementTable::getcellId2InfationRatio
std::vector< float > & getcellId2InfationRatio()
get the reference of cellId2InfationRatio for convenience
Definition: PlacementInfo.h:284
DesignInfo::fromStringToCellType
DesignCellType fromStringToCellType(std::string &cellName, std::string &typeName)
translate a string into a DesignCellType for a cell
Definition: DesignInfo.cc:606
PlacementInfo::SharedBELTypeBinGrid
std::vector< std::vector< std::vector< PlacementBinInfo * > > > SharedBELTypeBinGrid
Definition: PlacementInfo.h:4507
PlacementInfo::clockCol2ClockNets
std::map< DeviceInfo::ClockColumn *, std::set< DesignInfo::DesignNet * > > clockCol2ClockNets
Definition: PlacementInfo.h:4537
PlacementInfo::cellType2sharedCellTypeFileName
std::string cellType2sharedCellTypeFileName
Definition: PlacementInfo.h:4587
PlacementInfo::PlacementNet::isGlobalClock
bool isGlobalClock()
Definition: PlacementInfo.h:2457
PlacementInfo::PlacementSiteBinInfo::addSiteIntoBin
void addSiteIntoBin(DeviceInfo::DeviceSite *curSite)
Definition: PlacementInfo.cc:1634
PlacementInfo::adjustLUTFFUtilization
void adjustLUTFFUtilization(float neighborDisplacementUpperbound, bool enfore=false)
adjust the resource demand of LUTs/FFs according to packing feasibility and routing congestion
Definition: PlacementInfo.cc:1544
PlacementInfo.h
This header file mainly contains the definition of class PlacementInfo, including information related...
PlacementInfo::PlacementUnit::isLocked
bool isLocked()
Definition: PlacementInfo.h:1166
PlacementInfo::CompatiblePlacementTable::designInfo
DesignInfo * designInfo
Definition: PlacementInfo.h:311
PlacementInfo::guiEnable
bool guiEnable
Definition: PlacementInfo.h:4628
PlacementInfo::PlacementMacro::addFixedCellInfo
void addFixedCellInfo(DesignInfo::DesignCell *cell, std::string siteName, std::string BELName)
add information of a fixed cell
Definition: PlacementInfo.h:1751
PlacementInfo::placementNets
std::vector< PlacementNet * > placementNets
Definition: PlacementInfo.h:4524
PlacementInfo::simplePlacementTimingInfo
PlacementTimingInfo * simplePlacementTimingInfo
Definition: PlacementInfo.h:4445
PlacementInfo::PlacementMacro::PlacementMacroType_BRAM
@ PlacementMacroType_BRAM
Definition: PlacementInfo.h:1539
PlacementInfo::PlacementMacro::getMacroType
PlacementMacroType getMacroType()
Definition: PlacementInfo.h:1841
PlacementInfo::PlacementMacro::getFixedCellInfoVec
std::vector< fixedPlacementInfo_inMacro > & getFixedCellInfoVec()
Definition: PlacementInfo.h:1846
PlacementInfo::binHeight
float binHeight
Definition: PlacementInfo.h:4522
PlacementInfo::CompatiblePlacementTable::realBELTypeName2ID
std::map< std::string, int > realBELTypeName2ID
each actual BEL type gets an integer ID for checking
Definition: PlacementInfo.h:125
DesignInfo
Information related to FPGA designs, including design cells and their interconnections.
Definition: DesignInfo.h:51
PlacementInfo::cellId2CellBinInfo
std::vector< CellBinInfo > cellId2CellBinInfo
Definition: PlacementInfo.h:4440
delayVisualization.lines
lines
Definition: delayVisualization.py:26
PlacementInfo::createGridBins
void createGridBins(float binWidth, float binHeight)
Create a grid of bins on the device.
Definition: PlacementInfo.cc:325
PlacementInfo::CompatiblePlacementTable::realBELTypes
std::vector< std::string > realBELTypes
the actual BEL types according to the definition file
Definition: PlacementInfo.h:119
DeviceInfo::getClockRegions
std::vector< std::vector< ClockRegion * > > & getClockRegions()
Get the Clock Regions in an 2D array clockregion[Y][X].
Definition: DeviceInfo.h:1261
PlacementInfo::PlacementUnit::hasRegister
bool hasRegister()
Definition: PlacementInfo.h:1328
PlacementInfo::globalMaxX
float globalMaxX
right boundary of the device
Definition: PlacementInfo.h:4471
PlacementInfo::clockNetCoverages
std::vector< ClockNetCoverage > clockNetCoverages
Definition: PlacementInfo.h:4576
PlacementTimingInfo::TimingGraph::sortedEndpointByDelay
void sortedEndpointByDelay()
Definition: PlacementTimingInfo.h:684
PlacementInfo::getPotentialBELTypeIDs
std::vector< int > & getPotentialBELTypeIDs(DesignInfo::DesignCell *cell)
Definition: PlacementInfo.h:2932
PlacementInfo::LUTFFBinGrid
std::vector< std::vector< PlacementBinInfo * > > LUTFFBinGrid
Bin Grid for LUTs and FFs, mainly for searching neighbor elements during packing.
Definition: PlacementInfo.h:4513
PlacementInfo::macroLegalizationWeight
float macroLegalizationWeight
Definition: PlacementInfo.h:4617
DeviceInfo::DeviceSite::Y
float Y()
Definition: DeviceInfo.h:292
PlacementTimingInfo::getSimplePlacementTimingGraph
TimingGraph< DesignInfo::DesignCell > * getSimplePlacementTimingGraph()
Get the Simple Placement Timing Graph object.
Definition: PlacementTimingInfo.h:850
PlacementInfo::PlacementMacro::getTopOffset
float getTopOffset()
Definition: PlacementInfo.h:1802