1 // OpenSTA, Static Timing Analyzer
2 // Copyright (c) 2021, Parallax Software, Inc.
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program.  If not, see <https://www.gnu.org/licenses/>.
16 
17 #include "DelayCalc.hh"
18 
19 #include "Map.hh"
20 #include "StringUtil.hh"
21 #include "UnitDelayCalc.hh"
22 #include "LumpedCapDelayCalc.hh"
23 #include "SimpleRCDelayCalc.hh"
24 #include "DmpDelayCalc.hh"
25 #include "ArnoldiDelayCalc.hh"
26 
27 namespace sta {
28 
29 typedef Map<const char*, MakeArcDelayCalc, CharPtrLess> DelayCalcMap;
30 
31 static DelayCalcMap *delay_calcs = nullptr;
32 
33 void
registerDelayCalcs()34 registerDelayCalcs()
35 {
36   registerDelayCalc("unit", makeUnitDelayCalc);
37   registerDelayCalc("lumped_cap", makeLumpedCapDelayCalc);
38   registerDelayCalc("simple_rc", makeSimpleRCDelayCalc);
39   registerDelayCalc("dmp_ceff_elmore", makeDmpCeffElmoreDelayCalc);
40   registerDelayCalc("dmp_ceff_two_pole", makeDmpCeffTwoPoleDelayCalc);
41   registerDelayCalc("arnoldi", makeArnoldiDelayCalc);
42 }
43 
44 void
registerDelayCalc(const char * name,MakeArcDelayCalc maker)45 registerDelayCalc(const char *name,
46 		  MakeArcDelayCalc maker)
47 {
48   if (delay_calcs == nullptr)
49     delay_calcs = new DelayCalcMap;
50   (*delay_calcs)[name] = maker;
51 }
52 
53 void
deleteDelayCalcs()54 deleteDelayCalcs()
55 {
56   delete delay_calcs;
57   delay_calcs = nullptr;
58 }
59 
60 ArcDelayCalc *
makeDelayCalc(const char * name,StaState * sta)61 makeDelayCalc(const char *name,
62 	      StaState *sta)
63 {
64   MakeArcDelayCalc maker = delay_calcs->findKey(name);
65   if (maker)
66     return maker(sta);
67   else
68     return nullptr;
69 }
70 
71 bool
isDelayCalcName(const char * name)72 isDelayCalcName(const char *name)
73 {
74   return delay_calcs->hasKey(name);
75 }
76 
77 StringSeq *
delayCalcNames()78 delayCalcNames()
79 {
80   StringSeq *names = new StringSeq;
81   DelayCalcMap::Iterator dcalc_iter(delay_calcs);
82   while (dcalc_iter.hasNext()) {
83     MakeArcDelayCalc maker;
84     const char *name;
85     dcalc_iter.next(name, maker);
86     names->push_back(name);
87   }
88   return names;
89 }
90 
91 } // namespace
92