00001
00002
00003
00004
00005
00006
00007
00008
00009 #if !defined(oagTimerUtil_P)
00010 #define oagTimerUtil_P
00011
00012 #include <string>
00013 #include <vector>
00014 #include <iostream>
00015 #include <iomanip>
00016 #include <map>
00017 #include "oaDesignDB.h"
00018 #include "oagTimerModel.h"
00019 #include "oagTimerTimer.h"
00020 #include "oagTimerTPointMaster.h"
00021 #include "oagTimerLibParserInt.h"
00022
00023 namespace oagTimer{
00024
00025
00026 using namespace oa;
00027 using namespace std;
00028
00029 typedef enum {
00030 INPUT,
00031 OUTPUT
00032 } io_Type;
00033
00034 typedef vector<oaModInst*> instVector;
00035
00036
00037 class Util{
00038 private:
00039 oaDesign *topDesign;
00040 Timer *timer;
00041 public:
00042 Util();
00043 ~Util();
00044
00045
00046 void add(oaDesign *d, Timer* t){
00047 topDesign = d;
00048 timer = t;
00049 };
00050 double getCellArea(oaInst *inst);
00051 static void getCellFootprint(oaString cellName, oaString & footprint);
00052 static double getCellLeakagePower(oaModInst *modInst);
00053 static double getCellLeakagePower(oaOccInst *occInst);
00054 static double getCellLeakagePower(oaInst *inst);
00055 static double getCellLeakagePower(oaModule *m);
00056 static double getCellLeakagePower(const char *s);
00057 static double getCellLeakagePower(oaString cellName);
00058 static double getTotalLeakPower(const oaDesign *design);
00059
00060 static double getPowerSensitivity(const char *curr, const char *other);
00061
00062 static double getCellInputCap(oaOccInstTerm *i, oaString s, Timer *timer);
00063 oaString getCellName(oaModInst *i);
00064 oaString getCellName(oaOccInst *i);
00065
00066 oaOccInstTerm* findOccInTerms(oaDesign *design, oaModScalarInst *m);
00067 oaOccInstTerm* findOccOutTerm(oaDesign *design, oaModScalarInst *m);
00068
00069 oaModInstTerm* getOutInstTerm(oaModNet *net);
00070
00071
00072
00073
00074 TimeType getIOArr(oaModInst* i, oaDesign* design, Timer* timing, io_Type io);
00075 TimeType getIOArr(oaOccInst* i, oaDesign* design, Timer* timing, io_Type io);
00076
00077 DelayType getIOSlack(oaModInst* i, oaDesign* design, Timer* timing, io_Type io);
00078 void updateFanIOTiming(oaDesign* design,Timer* t,oaModInst *m);
00079 void invalidateFanIOTiming(oaDesign* design,Timer* t,oaModInst *m);
00080
00081 vector<oaModInst*> getOtherFanin(oaModInst* currFanin, oaModInst* currCell);
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 void getMatchCells(vector<oaString> &list, int sizes);
00092 bool isGreaterThan(oaString current, oaString other);
00093 bool isLessThan(oaString current, oaString other);
00094
00095 int swapCell(oaString cellName,oaModInst* currModInst);
00096
00098
00108 static double getCellDelayEstimate(oaOccInstTerm *inpTerm,
00109 oaString otherSize,
00110 double load,
00111 Timer* timer);
00112
00119
00120 static DelayType getCellRiseDelay(oaOccInstTerm *inPin);
00121 static DelayType getCellFallDelay(oaOccInstTerm *inPin);
00122 static DelayType getCellDelay(oaOccInstTerm *inPin);
00123
00124
00125
00133
00134
00135
00136
00137
00147 static DelayType getDeltaDelay(oaDesign* design, Timer* timing,
00148 CellData *c, oaString newSize);
00149
00158 static DelayType getDeltaDelay(oaOccObject *block,
00159 TPointMaster *otherTM, Timer* timer);
00160
00169 static double getUpSizeDeltaDelay(oaDesign* design, Timer* timing, CellData *c);
00170
00177 static DelayType getWorstInputSlack(Timer* t, oaOccInst* inst);
00178
00187 static double getDownSizeDeltaDelay(oaDesign* design, Timer* timing, CellData *c);
00188
00193 static bool hasValidArrTime(Timer* timer, CellData *cell);
00198 static double getMaxNetDelay(oaOccInstTerm* t);
00199
00200 static oaString getInstName(oaModInst *i){
00201 oaNativeNS NS;
00202 oaString name;
00203 i->getName(NS,name);
00204 return name;
00205 }
00206 static oaString getInstName(oaOccInst *i){
00207 oaNativeNS NS;
00208 oaString name;
00209 i->getName(NS,name);
00210 return name;
00211 }
00212
00213 static void parseLibCellName(oaString &name, oaString &basename, double &size){
00214 if(libParseData.libType.compare("footprint") == 0){
00215 Util::parseFootprintLibCellName(name,basename,size);
00216 }else if(libParseData.libType.compare("nangate") == 0
00217 || libParseData.libType.compare("eyechart") == 0){
00218 Util::parseNangateLibCellName(name,basename,size);
00219 }else if(libParseData.libType.compare("st") == 0){
00220 Util::parseSTLibCellName(name,basename,size);
00221 }else if(libParseData.libType.compare("st_vt") == 0){
00222 Util::parseVtSTLibCellName(name,basename,size);
00223 }
00224 }
00225
00226 static void parseVtSTLibCellName(oaString name, oaString &basename, double &size){
00227 size_t index1, index2;
00228 string curr = static_cast<string>(name);
00229 index1 = curr.find_first_of("_");
00230 index2 = curr.find_last_of("_");
00231
00232
00233 string currBase = curr.substr(index2+1);
00234 string currVt = curr.substr(index1+1,2);
00235 basename = currBase.c_str();
00236 if(currVt == "LH") size = 1;
00237 else if(currVt == "LS") size = 2;
00238 else if(currVt == "LL") size = 3;
00239
00240
00241 }
00242
00243 static void parseSTLibCellName(oaString name, oaString &basename, double &size){
00244 size_t name_index, size_index;
00245 string curr = static_cast<string>(name);
00246 name_index = curr.find_last_of("X");
00247
00248
00249
00250 string currBase = curr.substr(0,name_index);
00251 string currSize = curr.substr(name_index+1);
00252 basename = currBase.c_str();
00253 size = atoi(currSize.c_str());
00254
00255
00256 }
00257
00258
00259 static void parseNangateLibCellName(oaString name, oaString &basename, double &size){
00260 size_t name_index, size_index;
00261 string curr = static_cast<string>(name);
00262 std::cout<<"String Name "<<curr<<'\t';
00263 name_index = curr.find_first_of("_");
00264 size_index = curr.find_last_of("_");
00265 if((name_index && size_index) == string::npos){
00266 name_index = curr.find_first_of("X");
00267 size_index = curr.find_last_of("X");
00268
00269
00270 }
00271
00272
00273 string currBase = curr.substr(0,name_index);
00274 string currSize = curr.substr(size_index+2);
00275 basename = currBase.c_str();
00276 size = atoi(currSize.c_str());
00277
00278
00279
00280 }
00281
00282 static void parseFootprintLibCellName(oaString name, oaString &basename, double &size){
00283 size_t name_index, size_index;
00284 string curr = static_cast<string>(name);
00285
00286
00287
00288 getCellFootprint(name, basename);
00289 size = 0;
00290
00291 size = getCellLeakagePower(name);
00292
00293
00294
00295
00296 }
00297
00298
00299
00300
00301
00302
00303 static vector<instVector>
00304 getCombinations(instVector insts, int k){
00305 vector<instVector> temp_vec;
00306 if(insts.size() <= k){
00307 temp_vec.push_back(insts);
00308 return temp_vec;
00309 }
00310 if(!temp_vec.empty()) temp_vec.empty();
00311 instVector c;
00312 genComb(insts,k,temp_vec,c);
00313 return temp_vec;
00314 }
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324 static void genComb(instVector L, int k, vector<instVector> &T, instVector &C){
00325 if(k == 1){
00326 for(instVector::iterator it=L.begin(); it!=L.end(); ++it){
00327 C.push_back(*it);
00328 T.push_back(C);
00329 C.pop_back();
00330 }
00331 return;
00332 }
00333 instVector::iterator iter = L.begin();
00334 instVector temp_list = L;
00335 for(int i=0; i<=(L.size()-k); ++i){
00336 C.push_back(*iter);
00337 temp_list.erase(temp_list.begin());
00338 genComb(temp_list,k-1,T,C);
00339 C.pop_back();
00340 ++iter;
00341 }
00342 }
00343
00344 static void Util::downSizeAll(oaDesign *design, Timer *timer);
00345 static void Util::changeToMinCellSize(oaDesign *design, Timer *timer);
00346
00347
00348
00349
00350
00351 static void reportSlacks(oaDesign* design,Timer *timer);
00352 static void reportGates(oaDesign* design);
00353
00354
00355
00356 static void reportTimingInfo(oaDesign* design, Timer *t);
00357 static void reportCellTiming(CellData *cell, Timer *t);
00358 static void reportAllCellTiming(oaDesign *design, Timer *t);
00359 static void reportTimingFlag(oaDesign *des);
00365 static void printAllNetData(oaDesign *design);
00366
00372 static std::string getBlockName(oaOccObject *oPtr);
00373
00374
00383 static void linear_fit(double &a,double &b, double *x, double *y, int N);
00384
00385 };
00386
00387 }
00388 #endif