AMF-Placer  2.0
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
DesignInfo.cc
Go to the documentation of this file.
1 
24 #include "DesignInfo.h"
25 #include "dumpZip.h"
26 #include "readZip.h"
27 #include "strPrint.h"
28 #include "stringCheck.h"
29 #include <assert.h>
30 #include <queue>
31 #include <regex>
32 
34 {
35  DesignInfo::DesignCell *parentCell = getCell();
36  parentCell->addNetForPin(this, netPtr);
37 }
38 
39 DesignInfo::DesignPinType DesignInfo::DesignPin::checkPinType(DesignCell *cell, std::string &_refpinName, bool isInput)
40 {
41  if (cell->isLUT())
42  {
43  if (isInput)
44  return PinType_LUTInput;
45  else
46  return PinType_LUTOutput;
47  }
48  else if (cell->isFF())
49  {
50  if (isInput)
51  {
52  if (_refpinName == "R" || _refpinName == "S" || _refpinName == "SRI" || _refpinName == "CLR" ||
53  _refpinName == "PRE")
54  return PinType_SR;
55  if (_refpinName == "C" || _refpinName == "G")
56  return PinType_CLK;
57  if (_refpinName == "D" || _refpinName == "DI")
58  return PinType_D;
59  if (_refpinName == "CE" || _refpinName == "GE")
60  return PinType_E;
61  print_error("no such pin type:" + _refpinName);
62  assert(false && "no such pin type");
63  return PinType_SR; // no meaning
64  }
65  else
66  {
67  if (_refpinName == "Q" || _refpinName == "O")
68  return PinType_Q;
69  std::cout << "cell: " << cell << "\n";
70  print_error("no such pin type:" + _refpinName);
71  assert(false && "no such pin type");
72  return PinType_SR; // no meaning
73  }
74  }
75  else
76  {
77  return PinType_Others;
78  }
79 }
80 
81 void DesignInfo::DesignNet::connectToPinName(const std::string &_pinName)
82 {
83  pinNames.push_back(_pinName);
84 }
85 
87 {
88  pinPtrs.push_back(_pinPtr);
89  if (_pinPtr->isOutputPort())
90  driverPinPtrs.push_back(_pinPtr);
91  else
92  BeDrivenPinPtrs.push_back(_pinPtr);
93 }
94 
96 {
97  netPtrs.push_back(_netPtr);
98  if (_netPtr)
99  {
100  netNames.push_back(_netPtr->getName());
101  if (_pinPtr->isOutputPort())
102  {
103  outputNetPtrs.push_back(_netPtr);
104  }
105  else
106  {
107  inputNetPtrs.push_back(_netPtr);
108  }
109  }
110  else
111  {
112  netNames.push_back(std::string(""));
113  }
114 }
115 
117 {
118  pinPtrs.push_back(_pinPtr);
119  pinNames.push_back(_pinPtr->getName());
120  if (_pinPtr->isOutputPort())
121  {
122  outputPinPtrs.push_back(_pinPtr);
123  }
124  else
125  {
126  inputPinPtrs.push_back(_pinPtr);
127  }
128 }
129 
131 {
132  if (name2Net.find(curPin->getNetName()) == name2Net.end())
133  {
134  DesignNet *curNet = new DesignNet(curPin->getNetName(), getNumNets());
135  netlist.push_back(curNet);
136  name2Net[curPin->getNetName()] = curNet;
137  }
138 
139  DesignNet *curNet = name2Net[curPin->getNetName()];
140  curNet->connectToPinName(curPin->getName());
141  curNet->connectToPinVariable(curPin);
142 }
143 
144 DesignInfo::DesignInfo(std::map<std::string, std::string> &JSONCfg, DeviceInfo *deviceInfo) : JSONCfg(JSONCfg)
145 {
146 
147  // curCell=>
148  // design_1_i/axis_clock_converter_0/inst/gen_async_conv.axisc_async_clock_converter_0/xpm_fifo_async_inst/gnuram_async_fifo.xpm_fifo_base_inst/FSM_sequential_gen_fwft.curr_fwft_state[0]_i_1
149  // type=> LUT4
150  // pin=>
151  // design_1_i/axis_clock_converter_0/inst/gen_async_conv.axisc_async_clock_converter_0/xpm_fifo_async_inst/gnuram_async_fifo.xpm_fifo_base_inst/FSM_sequential_gen_fwft.curr_fwft_state[0]_i_1/O
152  // dir=> OUT net=>
153  // design_1_i/axis_clock_converter_0/inst/gen_async_conv.axisc_async_clock_converter_0/xpm_fifo_async_inst/gnuram_async_fifo.xpm_fifo_base_inst/next_fwft_state__0[0]
154  // drivepin=>
155  // design_1_i/axis_clock_converter_0/inst/gen_async_conv.axisc_async_clock_converter_0/xpm_fifo_async_inst/gnuram_async_fifo.xpm_fifo_base_inst/FSM_sequential_gen_fwft.curr_fwft_state[0]_i_1/O
156  // pin=>
157  // design_1_i/axis_clock_converter_0/inst/gen_async_conv.axisc_async_clock_converter_0/xpm_fifo_async_inst/gnuram_async_fifo.xpm_fifo_base_inst/FSM_sequential_gen_fwft.curr_fwft_state[0]_i_1/I0
158  // dir=> IN net=>
159  // design_1_i/axis_clock_converter_0/inst/gen_async_conv.axisc_async_clock_converter_0/xpm_fifo_async_inst/gnuram_async_fifo.xpm_fifo_base_inst/rd_en
160  // drivepin=> design_1_i/face_detect_0/inst/regslice_both_input_r_U/ibuf_inst/input_r_TREADY_INST_0/O
161 
162  designArchievedTextFileName = std::string(JSONCfg["vivado extracted design information file"]);
163  netlist.clear();
164  cells.clear();
165  pins.clear();
166  name2Net.clear();
167  name2Cell.clear();
168  type2Cells.clear();
171  controlSets.clear();
172  clock2Cells.clear();
173  clocks.clear();
174  clockSet.clear();
175  aliasNet2AliasNetId.clear();
176 
177  print_status("Design Information Loading.");
178 
179  std::string unzipCmnd = "unzip -p " + designArchievedTextFileName;
180  FILEbuf sbuf(popen(unzipCmnd.c_str(), "r"));
181  std::istream infile(&sbuf);
182  // std::ifstream infile(designTextFileName.c_str());
183 
184  std::string line;
185  std::getline(infile, line);
186  std::string cellType, cellName, targetName, dir, refpinname, netName, drivepinName, fill0, fill1, fill2, fill3,
187  aliasNetName;
188  std::istringstream iss(line);
189  iss >> fill0 >> cellName >> fill1 >> cellType;
190 
191  DesignCell *curCell = new DesignCell(cellName, fromStringToCellType(cellName, cellType), getNumCells());
192  curCell = addCell(curCell);
193 
194  while (std::getline(infile, line))
195  {
196  std::istringstream iss(line);
197  iss >> fill0 >> targetName;
198  if (strContains(fill0, "pin=>"))
199  {
200  iss >> fill3 >> refpinname >> fill0 >> dir >> fill1 >> netName >> fill2 >> drivepinName;
201  DesignPin *curPin = new DesignPin(targetName, refpinname,
202  DesignPin::checkPinType(curCell, refpinname, dir == std::string("IN")),
203  dir == std::string("IN"), curCell, pins.size());
204  pins.push_back(curPin);
205  curCell->addPin(curPin);
206  aliasNetName = netName;
207 
208  if (aliasNet2AliasNetId.find(aliasNetName) == aliasNet2AliasNetId.end())
209  {
210  int numAliasNet = aliasNet2AliasNetId.size();
211  aliasNet2AliasNetId[aliasNetName] = numAliasNet;
212  }
213  if (netName == "drivepin=>")
214  {
215  curPin->updateParentCellNetInfo();
216  curPin->setUnconnected();
217  continue; // not connected
218  }
219  assert(drivepinName != "");
220 
221  assert(fill1 == "net=>");
222  std::regex GNDpattern(".*/<const0>");
223  if (std::regex_match(netName, GNDpattern))
224  {
225  netName = drivepinName = "<const0>";
226  }
227  std::regex VCCpattern(".*/<const1>");
228  if (std::regex_match(netName, VCCpattern))
229  {
230  netName = drivepinName = "<const1>";
231  }
232  netName = drivepinName; // don't use the net name, which has aliases in Vivado, otherwise will fail to map
233  curPin->setDriverPinName(drivepinName); // bind to a net name first
234  curPin->connectToNetName(netName);
235  addPinToNet(curPin); // update net in netlist
236  curPin->connectToNetVariable(name2Net[netName]); // bind to a net pointer
237  curPin->updateParentCellNetInfo();
238  curPin->setAliasNetId(aliasNet2AliasNetId[aliasNetName]);
239  }
240  else if (strContains(fill0, "curCell=>"))
241  {
242  iss >> fill1 >> cellType;
243  curCell = new DesignCell(targetName, fromStringToCellType(targetName, cellType), getNumCells());
244  curCell = addCell(curCell);
245  }
246  else
247  assert(false && "Parser Error");
248  }
249 
250  for (DesignNet *curNet : netlist)
251  {
252  for (DesignPin *driverPin : curNet->getDriverPins())
253  for (DesignPin *pinBeDriven : curNet->getPinsBeDriven())
254  {
255  pinBeDriven->setDriverPin(driverPin);
256  }
257  }
258 
259  for (DesignNet *curNet : netlist)
260  {
261  if (curNet->getPins().size() < 32)
262  {
263  for (DesignPin *tmpDrivePin : curNet->getPins())
264  for (DesignPin *tmpPinBeDriven : curNet->getPins())
265  {
266  if (tmpDrivePin != tmpPinBeDriven)
267  {
269  std::pair<DesignPin *, DesignPin *>(tmpDrivePin, tmpPinBeDriven));
270  }
271  }
272  }
273  }
274 
275  print_info("#Connected Cell Pairs in Small Nets = " + std::to_string(connectedPinsWithSmallNet.size()));
276 
277  std::string STR_PCIE_3_1 = "PCIE_3_1";
278 
279  assert(deviceInfo->getSitesInType(STR_PCIE_3_1).size() > 0 && "info for PCIE should be included in deviceInfo.");
281  deviceInfo->getSitesInType(STR_PCIE_3_1)[0]->getSitePinInfos();
282  assert(PCIESitePinInfo);
283  for (DesignCell *PCIECell : type2Cells[CellType_PCIE_3_1])
284  {
285  for (DesignPin *curPin : PCIECell->getPins())
286  {
287  assert(PCIESitePinInfo->name2offsetX.find(curPin->getRefPinName()) != PCIESitePinInfo->name2offsetX.end());
288  curPin->setOffsetInCell(PCIESitePinInfo->name2offsetX[curPin->getRefPinName()],
289  PCIESitePinInfo->name2offsetY[curPin->getRefPinName()]);
290  }
291  }
292 
294 
295  if (JSONCfg.find("clock file") != JSONCfg.end())
296  {
297  std::string clockFileName = std::string(JSONCfg["clock file"]);
298  loadClocks(clockFileName);
299  }
300  else
301  {
302  print_warning("No clock file to specify clock signals in design! It might lead to clock partitioning error in "
303  "final placement in vendor tools!");
304  }
305 
307 
308  // int DSPInLoopsCnt = 0;
309  // int coverCnt = 0;
310  // int lenThr = 10;
311  // for (auto startCell : cells)
312  // {
313  // if (startCell->isDSP())
314  // {
315  // std::queue<DesignCell *> nodeQ;
316  // std::map<DesignCell *, int> cell2Len;
317  // std::set<DesignCell *> nodeSet;
318  // nodeSet.clear();
319  // nodeSet.insert(startCell);
320  // nodeQ.push(startCell);
321  // cell2Len[startCell] = 1;
322  // bool loopFound = false;
323  // int maxLen = 1;
324  // while (nodeQ.size() && !loopFound)
325  // {
326  // DesignCell *curCell = nodeQ.front();
327  // int curLen = cell2Len[curCell];
328  // nodeQ.pop();
329  // nodeSet.erase(curCell);
330 
331  // for (auto outputNet : curCell->getOutputNets())
332  // {
333  // for (auto succPin : outputNet->getPinsBeDriven())
334  // {
335  // auto succCell = succPin->getCell();
336  // if (succCell && curCell != succCell)
337  // {
338  // if (succCell == startCell)
339  // {
340  // loopFound = true;
341  // break;
342  // }
343  // if (!succCell->isFF() && !succCell->isBRAM())
344  // {
345  // if (nodeSet.find(succCell) == nodeSet.end())
346  // {
347  // nodeSet.insert(succCell);
348  // nodeQ.push(succCell);
349  // }
350  // if (cell2Len.find(succCell) == cell2Len.end())
351  // cell2Len[succCell] = curLen + 1;
352  // else if (curLen + 1 > cell2Len[succCell])
353  // cell2Len[succCell] = curLen + 1;
354  // if (cell2Len[succCell] > maxLen)
355  // maxLen = cell2Len[succCell];
356  // }
357  // }
358  // }
359  // }
360  // }
361  // coverCnt += nodeSet.size();
362  // if (maxLen > 10)
363  // DSPInLoopsCnt++;
364  // }
365  // }
366 
367  // print_warning("DSP in loops cnt=" + std::to_string(DSPInLoopsCnt));
368 
369  print_status("New Design Info Created.");
370 }
371 
372 void DesignInfo::loadClocks(std::string clockFileName)
373 {
374  std::ifstream clockFile(clockFileName);
375  assert(clockFile.good() && "The clock file does not exist and please check your path settings");
376 
377  while (clockFile.peek() != EOF)
378  {
379  std::string clockDriverPinName;
380  clockFile >> clockDriverPinName;
381  if (clockDriverPinName == "")
382  continue;
383  if (name2Net.find(clockDriverPinName) == name2Net.end())
384  {
385  print_warning("global clock: [" + clockDriverPinName +
386  "] is not found in design info. It might not be a problem as long as it is an external pin "
387  "or only connected to one instance.");
388  continue;
389  }
390  assert(name2Net.find(clockDriverPinName) != name2Net.end());
391  assert(clockSet.find(name2Net[clockDriverPinName]) == clockSet.end());
392  clockSet.insert(name2Net[clockDriverPinName]);
393  clocks.push_back(name2Net[clockDriverPinName]);
394  clock2Cells[name2Net[clockDriverPinName]] = std::set<DesignCell *>();
395  name2Net[clockDriverPinName]->setGlobalClock();
396  // if (name2Net[clockDriverPinName]->getPins().size() < 4000)
397  // name2Net[clockDriverPinName]->setOverallNetEnhancement(1.1);
398  }
399 
400  for (auto tmpCell : cells)
401  {
402  for (auto tmpPin : tmpCell->getPins())
403  {
404  if (!tmpPin->isUnconnected())
405  {
406  if (tmpPin->getNet())
407  {
408  if (isDesignClock(tmpPin->getNet()))
409  {
410  clock2Cells[tmpPin->getNet()].insert(tmpCell);
411  tmpCell->addClockNet(tmpPin->getNet());
412  }
413  }
414  }
415  }
416  }
417 
418  print_info("#global clock=" + std::to_string(clockSet.size()));
419  // for (auto pair : clock2Cells)
420  // {
421  // std::cout << "clock: [" << pair.first->getName() << "] drives " << pair.second.size() << " loads\n";
422  // }
423 }
424 
426 {
427  if (controlSets.size())
428  {
429  for (auto CS : controlSets)
430  delete CS;
431  }
432 
433  controlSets.clear();
434  FFId2ControlSetId.clear();
436  FFId2ControlSetId.resize(cells.size(), -1);
437  for (auto curCell : cells)
438  {
439  if (curCell->isFF())
440  {
441  if (curCell->isVirtualCell())
442  continue;
443  int CLKId, SRId, CEId;
444  getCLKSRCENetId(curCell, CLKId, SRId, CEId);
445  std::tuple<int, int, int, int> CS(CLKId, SRId, CEId, getFFSRType(curCell->getOriCellType()));
446  ControlSetInfo *curCS = nullptr;
448  {
450  curCell->setControlSetInfo(curCS);
451  }
452  else
453  {
454  curCS = new ControlSetInfo(curCell, controlSets.size());
456  controlSets.push_back(curCS);
457  curCell->setControlSetInfo(curCS);
458  }
459  curCS->addFF(curCell);
460  }
461  }
462 }
463 
465 {
466  if (controlSets.size())
467  {
468  for (auto CS : controlSets)
469  {
470  if (CS->getCE())
471  {
472  if (CS->getCE()->getPins().size() < 5000 && CS->getCE()->getPins().size() > 25)
473  CS->getCE()->enhanceOverallClusterNetEnhancement(1.2);
474  }
475  if (CS->getSR())
476  {
477  if (CS->getSR()->getPins().size() < 5000 && CS->getSR()->getPins().size() > 25)
478  CS->getSR()->enhanceOverallClusterNetEnhancement(1.2);
479  }
480  }
481  }
482 }
483 
485 {
486  if (JSONCfg.find("designCluster") != JSONCfg.end())
487  {
488  std::string clusterFile = std::string(JSONCfg["designCluster"]);
489  assert(fileExists(clusterFile) && "designCluster file does not exist and please check your path settings");
490  print_status("Design User-Defined Cluster Information Loading.");
491  std::string unzipCmnd = "unzip -p " + clusterFile;
492  FILEbuf sbuf(popen(unzipCmnd.c_str(), "r"));
493  std::istream infile(&sbuf);
494  std::string line;
495  std::vector<std::string> strV;
496  std::set<DesignCell *> userDefinedClusterCells;
497  std::vector<DesignCell *> userDefinedClusterCellsVec;
498  std::set<DesignCell *> allCellsInClusters;
499  std::set<DesignNet *> enhancedNets;
500  enhancedNets.clear();
501  allCellsInClusters.clear();
502 
503  while (std::getline(infile, line))
504  {
505  strV.clear();
506  userDefinedClusterCells.clear();
507  userDefinedClusterCellsVec.clear();
508  strSplit(line, strV, " ");
509  for (auto tmpName : strV)
510  {
511  assert(name2Cell.find(tmpName) != name2Cell.end());
512  auto curCell = name2Cell[tmpName];
513  // if (!curCell->isTimingEndPoint() && curCell->getTimingLength() < 7)
514  // continue;
515  if (userDefinedClusterCells.find(curCell) == userDefinedClusterCells.end())
516  {
517  userDefinedClusterCellsVec.push_back(curCell);
518  userDefinedClusterCells.insert(curCell);
519  allCellsInClusters.insert(curCell);
520  }
521  }
522  if ((float)userDefinedClusterCellsVec.size() / (float)strV.size() < 0.8)
523  continue;
524  predefinedClusters.push_back(userDefinedClusterCellsVec);
525 
526  bool hasDSP = false;
527  bool hasBRAM = false;
528  for (auto cellA : userDefinedClusterCells)
529  {
530  hasBRAM |= cellA->isBRAM();
531  hasDSP |= cellA->isDSP();
532  }
533  if (hasBRAM || hasDSP)
534  continue;
535 
536  if (userDefinedClusterCells.size() > 200 || userDefinedClusterCells.size() < 16)
537  continue;
538 
539  // float enhanceRatio = userDefinedClusterCells.size() / 100.0 * 0.5;
540  // if (enhanceRatio > 0.5)
541  // enhanceRatio = 0.5;
542  float enhanceRatio = 1.5 - (0.5 * userDefinedClusterCells.size() / 200.0);
543  if (enhanceRatio < 1)
544  continue;
545  for (auto cellA : userDefinedClusterCells)
546  {
547  int pinAIdInNet = 0;
548  for (DesignPin *curPinA : cellA->getPins())
549  {
550  if (curPinA->getNet())
551  {
552  if (curPinA->getNet()->getPins().size() > 64)
553  continue;
554  int pinBIdInNet = 0;
555  for (DesignPin *pinInNet : curPinA->getNet()->getPins())
556  {
557  if (userDefinedClusterCells.find(pinInNet->getCell()) != userDefinedClusterCells.end())
558  {
559  if (pinInNet->getCell() != cellA)
560  {
561  if (connectedPinsWithSmallNet.find(std::pair<DesignPin *, DesignPin *>(
562  curPinA, pinInNet)) != connectedPinsWithSmallNet.end())
563  {
564  // if (cellA->isDSP() || pinInNet->getCell()->isDSP() || cellA->isBRAM() ||
565  // pinInNet->getCell()->isBRAM())
566  // {
567  // curPinA->getNet()->enhance(pinAIdInNet, pinBIdInNet, 1.2);
568  // curPinA->getNet()->enhance(pinBIdInNet, pinAIdInNet, 1.2);
569  // }
570  // else
571  // {
572  // curPinA->getNet()->enhance(pinAIdInNet, pinBIdInNet, 1.1);
573  // curPinA->getNet()->enhance(pinBIdInNet, pinAIdInNet, 1.1);
574  // }
575  curPinA->getNet()->enhance(pinAIdInNet, pinBIdInNet, enhanceRatio);
576  curPinA->getNet()->enhance(pinBIdInNet, pinAIdInNet, enhanceRatio);
577  enhancedNets.insert(curPinA->getNet());
578  }
579  }
580  }
581  pinBIdInNet++;
582  }
583  }
584  pinAIdInNet++;
585  }
586  }
587  }
588 
589  int numClusters = predefinedClusters.size();
590  for (int i = 0; i < numClusters; i++)
591  {
592  for (int j = i + 1; j < numClusters; j++)
593  if (predefinedClusters[i].size() < predefinedClusters[j].size())
594  {
595  std::vector<DesignCell *> tmpSet = predefinedClusters[i];
597  predefinedClusters[j] = tmpSet;
598  }
599  }
600 
601  print_info("#Nets Enhanced for userDefinedClusters = " + std::to_string(enhancedNets.size()));
602  print_info("#Cells in userDefinedClusters = " + std::to_string(allCellsInClusters.size()));
603  }
604 }
605 
606 DesignInfo::DesignCellType DesignInfo::fromStringToCellType(std::string &cellName, std::string &typeName)
607 {
608  for (std::size_t i = 0; i < DesignCellTypeStr.size(); ++i)
609  {
610  if (DesignCellTypeStr[i] == typeName)
611  return static_cast<DesignCellType>(i);
612  }
613  print_error("no such type: " + typeName + " for cell: " + cellName);
614  assert(false && "no such type. Please check your DesignCellType enum definition and CELLTYPESTRS macro.");
615 }
616 
618 {
619  if (name2Cell.find(curCell->getName()) != name2Cell.end())
620  {
621  auto existingCell = name2Cell[curCell->getName()];
622  print_warning("get duplicated cells from the design archieve. Maybe bug in Vivado Tcl Libs.");
623  std::cout << "duplicated cell: " << existingCell << "\n";
624  delete curCell;
625  return existingCell;
626  }
627  cells.push_back(curCell);
628  name2Cell[curCell->getName()] = curCell;
629  if (type2Cells.find(curCell->getCellType()) == type2Cells.end())
630  type2Cells[curCell->getCellType()] = std::vector<DesignCell *>();
631  type2Cells[curCell->getCellType()].push_back(curCell);
632  return curCell;
633 }
634 
635 void DesignInfo::printStat(bool verbose)
636 {
637  print_info("#Cell= " + std::to_string(cells.size()));
638  print_info("#Net= " + std::to_string(netlist.size()));
639 
640  std::string existTypes = "";
641 
642  for (std::map<DesignCellType, std::vector<DesignCell *>>::iterator it = type2Cells.begin(); it != type2Cells.end();
643  ++it)
644  {
645  existTypes += DesignCellTypeStr[it->first] + " ";
646  }
647 
648  print_info("CellTypes(" + std::to_string(type2Cells.size()) + " types): " + existTypes);
649 
650  int LUTCnt = 0;
651  int FFCnt = 0;
652  int CarryCnt = 0;
653  int MuxCnt = 0;
654  int LUTRAMCnt = 0;
655  int DSPCnt = 0;
656  int BRAMCnt = 0;
657  for (std::map<DesignCellType, std::vector<DesignCell *>>::iterator it = type2Cells.begin(); it != type2Cells.end();
658  ++it)
659  {
660  if (verbose)
661  print_info("#" + DesignCellTypeStr[it->first] + ": " + std::to_string(it->second.size()));
662  if (isLUT(it->first))
663  LUTCnt += it->second.size();
664  if (isFF(it->first))
665  FFCnt += it->second.size();
666  if (isDSP(it->first))
667  DSPCnt += it->second.size();
668  if (isBRAM(it->first))
669  BRAMCnt += it->second.size();
670  if (isMux(it->first))
671  MuxCnt += it->second.size();
672  if (isLUTRAM(it->first))
673  LUTRAMCnt += it->second.size();
674  if (isCarry(it->first))
675  CarryCnt += it->second.size();
676  }
677  print_info("#LUTCnt: " + std::to_string(LUTCnt));
678  print_info("#FFCnt: " + std::to_string(FFCnt));
679  print_info("#CarryCnt: " + std::to_string(CarryCnt));
680  print_info("#MuxCnt: " + std::to_string(MuxCnt));
681  print_info("#LUTRAMCnt: " + std::to_string(LUTRAMCnt));
682  print_info("#DSPCnt: " + std::to_string(DSPCnt));
683  print_info("#BRAMCnt: " + std::to_string(BRAMCnt));
684 }
685 
686 std::ostream &operator<<(std::ostream &os, DesignInfo::DesignCell *cell)
687 {
688  static const char *DesignCellTypeStr_const[] = {CELLTYPESTRS};
689  os << "DesignCell: (" << DesignCellTypeStr_const[cell->getCellType()] << ") " << cell->getName();
690  return os;
691 }
692 
693 std::ostream &operator<<(std::ostream &os, DesignInfo::DesignPin *pin)
694 {
695  auto cell = pin->getCell();
696  static const char *DesignCellTypeStr_const[] = {CELLTYPESTRS};
697  os << "DesignPin: " << pin->getName() << " = refPin: (" << pin->getRefPinName() << ") of "
698  << " (" << DesignCellTypeStr_const[cell->getCellType()] << ") " << cell->getName();
699  return os;
700 }
DesignInfo::name2Net
std::map< std::string, DesignNet * > name2Net
Definition: DesignInfo.h:1744
DesignInfo::isBRAM
static bool isBRAM(DesignCellType cellType)
Definition: DesignInfo.h:1341
readZip.h
DesignInfo::printStat
void printStat(bool verbose=false)
Definition: DesignInfo.cc:635
DesignInfo::getNumCells
int getNumCells()
Definition: DesignInfo.h:1600
DesignInfo::PinType_Others
@ PinType_Others
Definition: DesignInfo.h:205
DesignInfo::DesignPin::connectToNetName
void connectToNetName(std::string &_netName)
bind the pin to the net by the net name
Definition: DesignInfo.h:337
DesignInfo::clockSet
std::set< DesignNet * > clockSet
Definition: DesignInfo.h:1781
DesignInfo::aliasNet2AliasNetId
std::map< std::string, int > aliasNet2AliasNetId
Definition: DesignInfo.h:1745
DesignInfo::pins
std::vector< DesignPin * > pins
Definition: DesignInfo.h:1743
DesignInfo::DesignCell::addNetForPin
void addNetForPin(DesignPin *_pinPtr, DesignNet *_netPtr)
add a net and assign it into output/input net list
Definition: DesignInfo.cc:95
DesignInfo::DesignNet::connectToPinVariable
void connectToPinVariable(DesignPin *_pinPtr)
bind the net to a pin's pointer
Definition: DesignInfo.cc:86
DesignInfo::clock2Cells
std::map< DesignNet *, std::set< DesignCell * > > clock2Cells
the mapping from clocks to their corresponding cells driven by the clock net
Definition: DesignInfo.h:1787
DesignInfo::addPinToNet
void addPinToNet(DesignPin *curPin)
bind a pin to an existing net. If the net does not exist, new one.
Definition: DesignInfo.cc:130
DesignInfo::DesignCell
a DesignCell in design netlist, DesignPin objects of which might connect to DesignNet objects
Definition: DesignInfo.h:782
removeFailurePartFromTcl.line
line
Definition: removeFailurePartFromTcl.py:32
DesignInfo::DesignNet
a design net (hyperedge) defined in the design, connecting to pins of cells
Definition: DesignInfo.h:525
DeviceInfo::DeviceSite::DeviceSitePinInfos::name2offsetY
std::map< std::string, float > name2offsetY
Definition: DeviceInfo.h:231
DeviceInfo::getSitesInType
std::vector< DeviceSite * > & getSitesInType(std::string &siteType)
Get sites of a specfic type.
Definition: DeviceInfo.h:1043
DesignInfo::loadUserDefinedClusterNets
void loadUserDefinedClusterNets()
for user-defined-cluster-based optimization, load the nets in a user-defined cluster for later proces...
Definition: DesignInfo.cc:484
DesignInfo::controlSets
std::vector< ControlSetInfo * > controlSets
Definition: DesignInfo.h:1779
DesignInfo::netlist
std::vector< DesignNet * > netlist
Definition: DesignInfo.h:1741
DesignInfo::DesignNet::getPins
std::vector< DesignPin * > & getPins()
Get the vector reference of the pins.
Definition: DesignInfo.h:591
DesignInfo::isDesignClock
bool isDesignClock(DesignNet *tmpNet)
check if a net is a global clock indicated by input design files
Definition: DesignInfo.h:1713
DesignInfo::DesignCellType
DesignCellType
design cell types
Definition: DesignInfo.h:73
DesignInfo::DesignPin
A design pin on a design cell connected to a net.
Definition: DesignInfo.h:277
DesignInfo::PinType_LUTOutput
@ PinType_LUTOutput
Definition: DesignInfo.h:199
DesignInfo::isCarry
static bool isCarry(DesignCellType cellType)
Definition: DesignInfo.h:1331
DesignInfo::DesignPin::getNet
DesignNet * getNet()
Definition: DesignInfo.h:408
fileExists
bool fileExists(const std::string &filename)
Definition: dumpZip.cc:45
DesignInfo::ControlSetInfo::addFF
void addFF(DesignInfo::DesignCell *curFF)
add a FF into the set of FFs which are compatible to this control set
Definition: DesignInfo.h:1288
FILEbuf
Definition: readZip.h:34
DesignInfo::DesignCell::getCellType
DesignCellType getCellType()
Definition: DesignInfo.h:881
DesignInfo::PinType_CLK
@ PinType_CLK
Definition: DesignInfo.h:200
DesignInfo::isLUTRAM
static bool isLUTRAM(DesignCellType cellType)
Definition: DesignInfo.h:1352
DesignInfo::DesignPin::getRefPinName
std::string & getRefPinName()
Get the reference pin name of the pin.
Definition: DesignInfo.h:431
DesignInfo::isDSP
static bool isDSP(DesignCellType cellType)
Definition: DesignInfo.h:1336
DesignInfo.h
This header file contains the classes of data for a standalone design netlist.
DesignInfo::updateFFControlSets
void updateFFControlSets()
go through the FF cells to extract control sets for later processing
Definition: DesignInfo.cc:425
DesignInfo::cells
std::vector< DesignCell * > cells
Definition: DesignInfo.h:1742
dumpZip.h
strContains
bool strContains(std::string target, std::string substring)
Definition: stringCheck.cc:30
DesignInfo::getCLKSRCENetId
void getCLKSRCENetId(DesignInfo::DesignCell *curFF, int &CLKId, int &SRId, int &CEId)
extract the ids of CLK, SR, and CE for a given FF
Definition: DesignInfo.h:1475
DesignInfo::DesignInfo
DesignInfo(std::map< std::string, std::string > &JSONCfg, DeviceInfo *deviceInfo)
Construct a new Design Info object based on user-defined settings and device information.
Definition: DesignInfo.cc:144
DesignInfo::enhanceFFControlSetNets
void enhanceFFControlSetNets()
intend to enhance the nets between FFs in a control set to make later packing easier
Definition: DesignInfo.cc:464
stringCheck.h
DesignInfo::ControlSetInfo
A control set is a combination of CLK, CE and SR signal. It could be nullptr (not related to control ...
Definition: DesignInfo.h:1152
CELLTYPESTRS
#define CELLTYPESTRS
Definition: DesignInfo.h:37
strPrint.h
DesignInfo::isFF
static bool isFF(DesignCellType cellType)
Definition: DesignInfo.h:1360
DesignInfo::DesignCell::isFF
bool isFF()
Definition: DesignInfo.h:933
print_status
void print_status(std::string tmp_string)
Definition: strPrint.cc:44
DesignInfo::FFId2ControlSetId
std::vector< int > FFId2ControlSetId
the mapping from FF IDs to a unique defined control set id
Definition: DesignInfo.h:1777
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
DesignInfo::JSONCfg
std::map< std::string, std::string > & JSONCfg
Definition: DesignInfo.h:1789
DesignInfo::DesignPin::connectToNetVariable
void connectToNetVariable(DesignNet *_netPtr)
bind the pin to the net's pointer for later processing
Definition: DesignInfo.h:357
print_warning
void print_warning(std::string tmp_string)
Definition: strPrint.cc:57
DesignInfo::CLKSRCEFFType2ControlSetInfoId
std::map< std::tuple< int, int, int, int >, int > CLKSRCEFFType2ControlSetInfoId
the mapping from the tuple of CLK/SR/CE ids and FF type to a unique defined control set id
Definition: DesignInfo.h:1771
DeviceInfo::DeviceSite::DeviceSitePinInfos
a class record the pin on the site boundary
Definition: DeviceInfo.h:218
DesignInfo::PinType_LUTInput
@ PinType_LUTInput
Definition: DesignInfo.h:198
DesignInfo::DesignPin::netPtr
DesignNet * netPtr
Definition: DesignInfo.h:509
DesignInfo::DesignCellTypeStr
std::vector< std::string > DesignCellTypeStr
Definition: DesignInfo.h:194
DesignInfo::DesignCell::isLUT
bool isLUT()
Definition: DesignInfo.h:927
DesignInfo::DesignPin::setDriverPinName
void setDriverPinName(std::string &_driverPinName)
Set the driver Pin Name of the pin.
Definition: DesignInfo.h:377
DesignInfo::connectedPinsWithSmallNet
std::set< std::pair< DesignPin *, DesignPin * > > connectedPinsWithSmallNet
connected pin pairs by nets with a small number of pins
Definition: DesignInfo.h:1759
DesignInfo::DesignPin::setUnconnected
void setUnconnected()
Set the attribute unconnected to be true, indicating the pin connect to no net.
Definition: DesignInfo.h:440
strSplit
void strSplit(const std::string &s, std::vector< std::string > &sv, const char *delim)
Definition: stringCheck.cc:35
DesignInfo::PinType_Q
@ PinType_Q
Definition: DesignInfo.h:201
DesignInfo::DesignNet::connectToPinName
void connectToPinName(const std::string &_pinName)
bind the net to a pin by name
Definition: DesignInfo.cc:81
DesignInfo::CellType_PCIE_3_1
@ CellType_PCIE_3_1
Definition: DesignInfo.h:133
DesignInfo::getNumNets
int getNumNets()
Definition: DesignInfo.h:1604
DeviceInfo::DeviceSite::DeviceSitePinInfos::name2offsetX
std::map< std::string, float > name2offsetX
Definition: DeviceInfo.h:230
DesignInfo::name2Cell
std::map< std::string, DesignCell * > name2Cell
Definition: DesignInfo.h:1746
DeviceInfo
Information class related to FPGA device, including the details of BEL/Site/Tile/ClockRegion.
Definition: DeviceInfo.h:43
operator<<
std::ostream & operator<<(std::ostream &os, DesignInfo::DesignCell *cell)
Definition: DesignInfo.cc:686
DesignInfo::DesignPin::isOutputPort
bool isOutputPort()
Definition: DesignInfo.h:362
print_info
void print_info(std::string tmp_string)
Definition: strPrint.cc:39
checkHalfColumn.i
int i
Definition: checkHalfColumn.py:5
DesignInfo::DesignPin::getNetName
std::string & getNetName()
Get the name of the net which the pin connects to.
Definition: DesignInfo.h:327
DesignInfo::addCell
DesignCell * addCell(DesignCell *curCell)
add a cell into the design information
Definition: DesignInfo.cc:617
DesignInfo::PinType_D
@ PinType_D
Definition: DesignInfo.h:202
DesignInfo::fromStringToCellType
DesignCellType fromStringToCellType(std::string &cellName, std::string &typeName)
translate a string into a DesignCellType for a cell
Definition: DesignInfo.cc:606
DesignInfo::isLUT
static bool isLUT(DesignCellType cellType)
Definition: DesignInfo.h:1324
DesignInfo::PinType_E
@ PinType_E
Definition: DesignInfo.h:203
DesignInfo::DesignPin::updateParentCellNetInfo
void updateParentCellNetInfo()
let the parent cell know that one of its pin connects to a specific net
Definition: DesignInfo.cc:33
DesignInfo::designArchievedTextFileName
std::string designArchievedTextFileName
Definition: DesignInfo.h:1790
DesignInfo::DesignPin::getCell
DesignCell * getCell()
Get the Cell object of the pin.
Definition: DesignInfo.h:418
DesignInfo::clocks
std::vector< DesignNet * > clocks
Definition: DesignInfo.h:1780
DesignInfo::loadClocks
void loadClocks(std::string clockFileName)
load the global clock signals from a design information file
Definition: DesignInfo.cc:372
DesignInfo::predefinedClusters
std::vector< std::vector< DesignCell * > > predefinedClusters
the predefined clusters which are defined in design configuration files
Definition: DesignInfo.h:1752
DesignInfo::DesignPinType
DesignPinType
Definition: DesignInfo.h:197
DesignInfo::type2Cells
std::map< DesignCellType, std::vector< DesignCell * > > type2Cells
Definition: DesignInfo.h:1753
DesignInfo::isMux
static bool isMux(DesignCellType cellType)
Definition: DesignInfo.h:1347
DesignInfo::DesignCell::addPin
void addPin(DesignPin *_pinPtr)
bind a pin to the cell
Definition: DesignInfo.cc:116
DesignInfo::DesignPin::checkPinType
static DesignPinType checkPinType(DesignCell *cell, std::string &refpinname, bool isInput)
get the pin type based on its reference name
Definition: DesignInfo.cc:39
DesignInfo::PinType_SR
@ PinType_SR
Definition: DesignInfo.h:204
DesignInfo::DesignPin::setAliasNetId
void setAliasNetId(int _aliasNetId)
Definition: DesignInfo.h:347
DesignInfo::getFFSRType
static bool getFFSRType(DesignCellType typeA)
Definition: DesignInfo.h:179