1717#include < string>
1818#include < utility>
1919#include < vector>
20+ #include < fstream>
21+ #include < iostream>
2022
2123#include " db_sta/dbSta.hh"
2224#include " odb/db.h"
@@ -942,18 +944,23 @@ std::vector<TechChar::SolutionData> TechChar::createPatterns(
942944 // can be placed and...
943945 // ...the number of topologies (combinations of buffers, considering only 1
944946 // drive) that can exist.
947+
945948 const unsigned numberOfNodes
946949 = setupWirelength / options_->getWireSegmentUnit ();
947950 const unsigned numberOfTopologies = 1 << numberOfNodes;
948951 std::vector<SolutionData> topologiesVector;
949952 odb::dbNet* net = nullptr ;
950953 // clang-format off
951- debugPrint (logger_, CTS, " tech char" , 1 , " createPatterns WL:{} #nodes: {}"
952- " #topo: {}" , setupWirelength, numberOfNodes, numberOfTopologies);
954+ debugPrint (logger_, CTS, " tech char" , 1 , " * createPatterns for #nodes = {}"
955+ " #topologies = {}" , setupWirelength, numberOfNodes, numberOfTopologies);
953956 // clang-format on
954957 // For each possible topology...
955958 for (unsigned solutionCounterInt = 0 ; solutionCounterInt < numberOfTopologies;
956959 solutionCounterInt++) {
960+ debugPrint (
961+ logger_, CTS, " tech char" , 1 , " **topology {}" , solutionCounterInt + 1 );
962+ std::stringstream tmp;
963+ tmp << " ***IN " ;
957964 // Creates a bitset that represents the buffer locations.
958965 const std::bitset<5 > solutionCounter (solutionCounterInt);
959966 int wireCounter = 0 ;
@@ -983,20 +990,24 @@ std::vector<TechChar::SolutionData> TechChar::createPatterns(
983990 // Not a buffer, only a wire segment.
984991 nodesWithoutBuf++;
985992 // clang-format off
986- debugPrint (logger_, CTS, " tech char" , 1 , " wire at node:{} topo: {}" ,
993+ debugPrint (logger_, CTS, " tech char" , 2 , " *** wire at node : {}" ,
987994 nodeIndex, solutionCounterInt);
988995 // clang-format on
989996 } else {
990997 // Buffer, need to create the instance and a new net.
991998 nodesWithoutBuf++;
999+ for (int i = 0 ; i < nodesWithoutBuf - 1 ; i++) {
1000+ tmp << " -- " ;
1001+ }
1002+ tmp << " -> " ;
9921003 // Creates a new buffer instance.
9931004 const std::string bufName = fmt::format (" buf_{}_{}_{}" ,
9941005 setupWirelength,
9951006 solutionCounter.to_string (),
9961007 wireCounter);
9971008 // clang-format off
998- debugPrint (logger_, CTS, " tech char" , 1 , " buffer {} at node:{} "
999- " topo:{} " , bufName, nodeIndex, solutionCounterInt);
1009+ debugPrint (logger_, CTS, " tech char" , 2 , " *** buffer {} at node : {} "
1010+ , bufName, nodeIndex, solutionCounterInt);
10001011 // clang-format on
10011012 odb::dbInst* bufInstance
10021013 = odb::dbInst::create (charBlock_, charBuf_, bufName.c_str ());
@@ -1020,11 +1031,6 @@ std::vector<TechChar::SolutionData> TechChar::createPatterns(
10201031 // Updates the topology wih the new instance and the current topology
10211032 // (as a vector of strings).
10221033 topology.instVector .push_back (bufInstance);
1023- // clang-format off
1024- debugPrint (logger_, CTS, " tech char" , 1 , " topo instVector size:{} "
1025- " node:{} topo:{}" , topology.instVector .size (), nodeIndex,
1026- solutionCounterInt);
1027- // clang-format on
10281034 topology.topologyDescriptor .push_back (
10291035 std::to_string (nodesWithoutBuf * options_->getWireSegmentUnit ()));
10301036 topology.topologyDescriptor .push_back (charBuf_->getName ());
@@ -1041,6 +1047,11 @@ std::vector<TechChar::SolutionData> TechChar::createPatterns(
10411047 odb::dbBPin* outPortPin = odb::dbBPin::create (outPort);
10421048 // Updates the topology with the output port, old new, possible instances
10431049 // and other attributes.
1050+ for (int i = 0 ; i < nodesWithoutBuf; i++) {
1051+ tmp << " -- " ;
1052+ }
1053+ tmp << " OUT" ;
1054+ debugPrint (logger_, CTS, " tech char" , 1 , tmp.str ());
10441055 topology.outPort = outPortPin;
10451056 topology.isPureWire = isPureWire;
10461057 topology.netVector .push_back (net);
@@ -1191,7 +1202,7 @@ TechChar::ResultData TechChar::computeTopologyResults(
11911202 const float pinArrival = openStaChar_->vertexArrival (
11921203 outPinVert, sta::RiseFall::fall (), charPathAnalysis_);
11931204 results.pinArrival = pinArrival;
1194- // Computations for output slew.
1205+ // Computations for output slew. Avg of rise and fall slew.
11951206 const float pinRise = openStaChar_->vertexSlew (
11961207 outPinVert, sta::RiseFall::rise (), sta::MinMax::max ());
11971208 const float pinFall = openStaChar_->vertexSlew (
@@ -1330,7 +1341,7 @@ void TechChar::updateBufferTopologies(TechChar::SolutionData& solution)
13301341 odb::dbInst* inst = solution.instVector [nodeIndex];
13311342 inst->swapMaster (newMaster);
13321343 // clang-format off
1333- debugPrint (logger_, CTS, " tech char" , 1 , " **updateBufferTopologies swap "
1344+ debugPrint (logger_, CTS, " tech char" , 1 , " *** updateBufferTopologies swap "
13341345 " from {} to {}, index:{}" , oldMaster->getName (),
13351346 newMaster->getName (), nodeIndex);
13361347 // clang-format on
@@ -1341,6 +1352,10 @@ void TechChar::updateBufferTopologies(TechChar::SolutionData& solution)
13411352
13421353std::vector<size_t > TechChar::getCurrConfig (const SolutionData& solution)
13431354{
1355+ if (solution.isPureWire ) {
1356+ debugPrint (logger_, CTS, " tech char" , 1 , " **currConfig is a pure wire" );
1357+ return {};
1358+ }
13441359 std::vector<size_t > config;
13451360 for (auto inst : solution.instVector ) {
13461361 size_t masterID = cellNameToID (inst->getMaster ()->getName ());
@@ -1349,11 +1364,11 @@ std::vector<size_t> TechChar::getCurrConfig(const SolutionData& solution)
13491364
13501365 if (logger_->debugCheck (CTS, " tech char" , 1 )) {
13511366 std::stringstream tmp;
1352- tmp << " currConfig: " ;
1367+ tmp << " ** currConfig: " ;
13531368 for (unsigned i : config) {
13541369 tmp << i << " " ;
13551370 }
1356- logger_-> report ( tmp.str ());
1371+ debugPrint (logger_, CTS, " tech char " , 1 , tmp.str ());
13571372 }
13581373 return config;
13591374}
@@ -1365,7 +1380,7 @@ size_t TechChar::cellNameToID(const std::string& masterName)
13651380 return std::distance (masterNames_.begin (), masterIter);
13661381}
13671382
1368- // Find a buffer config that is monotonic from current buffer config
1383+ // Find a buffer config that is monotonic from current buffer config.
13691384std::vector<size_t > TechChar::getNextConfig (
13701385 const std::vector<size_t >& currConfig)
13711386{
@@ -1389,11 +1404,11 @@ std::vector<size_t> TechChar::getNextConfig(
13891404
13901405 if (logger_->debugCheck (CTS, " tech char" , 1 )) {
13911406 std::stringstream tmp;
1392- tmp << " nextConfig: " ;
1407+ tmp << " ** nextConfig: " ;
13931408 for (unsigned i : nextConfig) {
13941409 tmp << i << " " ;
13951410 }
1396- logger_-> report ( tmp.str ());
1411+ debugPrint (logger_, CTS, " tech char " , 1 , tmp.str ());
13971412 }
13981413
13991414 return nextConfig;
@@ -1423,15 +1438,15 @@ void TechChar::swapTopologyBuffer(SolutionData& solution,
14231438 topologyIndex++) {
14241439 const std::string topologyS = solution.topologyDescriptor [topologyIndex];
14251440 // clang-format off
1426- debugPrint (logger_, CTS, " tech char" , 1 , " **topo:{} topoIdx:{}" ,
1441+ debugPrint (logger_, CTS, " tech char" , 1 , " *** topo:{} topoIdx:{}" ,
14271442 topologyS, topologyIndex);
14281443 // clang-format on
14291444 if (!(std::find (masterNames_.begin (), masterNames_.end (), topologyS)
14301445 == masterNames_.end ())) {
14311446 if (topologyCounter == nodeIndex) {
14321447 solution.topologyDescriptor [topologyIndex] = newMasterName;
14331448 // clang-format off
1434- debugPrint (logger_, CTS, " tech char" , 1 , " **soln topo descript at "
1449+ debugPrint (logger_, CTS, " tech char" , 1 , " *** soln topo descript at "
14351450 " {} set to {}" , topologyIndex, newMasterName);
14361451 // clang-format on
14371452 break ;
@@ -1454,14 +1469,20 @@ std::vector<TechChar::ResultData> TechChar::characterizationPostProcess()
14541469 selectedSolutions.push_back (selectedResults);
14551470 }
14561471 }
1472+ std::ofstream arquivo (" test_insetion_delay_techChar_tbl.csv" );
14571473
1474+ if (!arquivo.is_open ()) {
1475+ logger_->error (CTS, 2 , " Erro ao criar o arquivo CSV" );
1476+ }
14581477 // Creates variables to set the max and min values. These are normalized.
14591478 unsigned minResultWirelength = std::numeric_limits<unsigned >::max ();
14601479 unsigned maxResultWirelength = 0 ;
14611480 unsigned minResultCapacitance = std::numeric_limits<unsigned >::max ();
14621481 unsigned maxResultCapacitance = 0 ;
14631482 unsigned minResultSlew = std::numeric_limits<unsigned >::max ();
14641483 unsigned maxResultSlew = 0 ;
1484+ // Cabeçalho
1485+ arquivo << " Wl,pinSlew,inSlew,totalcap,load,pinArrival,totalPower\n " ;
14651486 std::vector<ResultData> convertedSolutions;
14661487 for (ResultData solution : selectedSolutions) {
14671488 if (solution.pinSlew <= options_->getMaxCharSlew ()) {
@@ -1494,6 +1515,7 @@ std::vector<TechChar::ResultData> TechChar::characterizationPostProcess()
14941515 // Add missing information.
14951516 convertedResult.totalPower = solution.totalPower ;
14961517 convertedResult.isPureWire = solution.isPureWire ;
1518+ arquivo << convertedResult.wirelength << " ," << convertedResult.pinSlew << " ," << convertedResult.inSlew << " ," << convertedResult.totalcap << " ," << convertedResult.load << " ," << convertedResult.pinArrival << " ," << convertedResult.totalPower << " \n " ;
14971519 std::vector<std::string> topologyResult;
14981520 for (int topologyIndex = 0 ; topologyIndex < solution.topology .size ();
14991521 topologyIndex++) {
@@ -1514,6 +1536,7 @@ std::vector<TechChar::ResultData> TechChar::characterizationPostProcess()
15141536 convertedSolutions.push_back (convertedResult);
15151537 }
15161538 }
1539+ arquivo.close ();
15171540 // Sets the min and max values and returns the result vector.
15181541 minSlew_ = minResultSlew;
15191542 maxSlew_ = maxResultSlew;
@@ -1558,6 +1581,8 @@ void TechChar::create()
15581581 int64_t topologiesCreated = 0 ;
15591582 for (unsigned setupWirelength : wirelengthsToTest_) {
15601583 // Creates the topologies for the current wirelength.
1584+ debugPrint (
1585+ logger_, CTS, " tech char" , 1 , " Wirelength = {}" , setupWirelength);
15611586 std::vector<SolutionData> topologiesVector
15621587 = createPatterns (setupWirelength);
15631588 // Creates an OpenSTA instance.
@@ -1569,9 +1594,8 @@ void TechChar::create()
15691594 int topoIndex = 0 ;
15701595 for (SolutionData solution : topologiesVector) {
15711596 // clang-format off
1572- debugPrint (logger_, CTS, " tech char" , 1 , " create WL:{} of {}, "
1573- " topo:{} of {}" , setupWirelength, wirelengthsToTest_.size (),
1574- topoIndex, topologiesVector.size ());
1597+ debugPrint (logger_, CTS, " tech char" , 1 , " *genrate combinations for "
1598+ " topology: {} of {}" , topoIndex + 1 , topologiesVector.size ());
15751599 // clang-format on
15761600 topoIndex++;
15771601 // Gets the input and output port (as terms, pins and vertices).
@@ -1607,15 +1631,15 @@ void TechChar::create()
16071631 r1,
16081632 c1,
16091633 piExists);
1634+
1635+ // clang-format off
1636+ debugPrint (logger_, CTS, " tech char" , 1 , " *# bufs = {}; "
1637+ " # nodes with buf = {}" ,
1638+ masterNames_.size (), solution.instVector .size ());
1639+ // clang-format on
16101640 // For each possible buffer combination (different sizes).
16111641 unsigned buffersCombinations
16121642 = getBufferingCombo (masterNames_.size (), solution.instVector .size ());
1613- // clang-format off
1614- debugPrint (logger_, CTS, " tech char" , 1 , " create #bufs={} "
1615- " #soln.instVector.size={}, #bufUpdate={}, #topo={}" ,
1616- masterNames_.size (), solution.instVector .size (),
1617- buffersCombinations, topologiesCreated);
1618- // clang-format on
16191643
16201644 if (buffersCombinations == 0 ) {
16211645 continue ;
@@ -1734,14 +1758,15 @@ void TechChar::create()
17341758unsigned TechChar::getBufferingCombo (size_t numBuffers, size_t numNodes)
17351759{
17361760 // check if this has been computed already
1737- std::stringstream tmp;
17381761 std::pair iPair (numBuffers, numNodes);
17391762 auto iter = bufferingComboTable_.find (iPair);
17401763 if (iter != bufferingComboTable_.end ()) {
1741- if (logger_->debugCheck (CTS, " tech char" , 1 )) {
1742- tmp << " Monotonic entries (hashed): " << iter->second << ' \n ' ;
1743- logger_->report (tmp.str ());
1744- }
1764+ debugPrint (logger_,
1765+ CTS,
1766+ " tech char" ,
1767+ 1 ,
1768+ " **Monotonic entries are already hashed: {}" ,
1769+ iter->second );
17451770 return iter->second ;
17461771 }
17471772
@@ -1759,6 +1784,8 @@ unsigned TechChar::getBufferingCombo(size_t numBuffers, size_t numNodes)
17591784
17601785 unsigned numMonotonic = 0 ;
17611786 for (const auto & row : matrix) {
1787+ std::stringstream tmp;
1788+ tmp << " **" ;
17621789 for (size_t val : row) {
17631790 if (logger_->debugCheck (CTS, " tech char" , 1 )) {
17641791 tmp << val << " " ;
@@ -1770,15 +1797,10 @@ unsigned TechChar::getBufferingCombo(size_t numBuffers, size_t numNodes)
17701797 }
17711798 numMonotonic++;
17721799 }
1773- if (logger_->debugCheck (CTS, " tech char" , 1 )) {
1774- logger_->report (tmp.str ());
1775- }
1776- }
1777- if (logger_->debugCheck (CTS, " tech char" , 1 )) {
1778- tmp << " Monotonic entries: " << numMonotonic;
1779- logger_->report (tmp.str ());
1800+ debugPrint (logger_, CTS, " tech char" , 1 , tmp.str ());
17801801 }
1781-
1802+ debugPrint (
1803+ logger_, CTS, " tech char" , 1 , " **Monotonic entries: {}" , numMonotonic);
17821804 // insert new result into hash table
17831805 bufferingComboTable_[iPair] = numMonotonic;
17841806 return numMonotonic;
0 commit comments