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 "ClockInsertion.hh"
18 
19 namespace sta {
20 
ClockInsertion(const Clock * clk,const Pin * pin)21 ClockInsertion::ClockInsertion(const Clock *clk,
22 			       const Pin *pin) :
23   clk_(clk),
24   pin_(pin)
25 {
26 }
27 
28 void
setDelay(const RiseFallBoth * rf,const MinMaxAll * min_max,const EarlyLateAll * early_late,float delay)29 ClockInsertion::setDelay(const RiseFallBoth *rf,
30 			 const MinMaxAll *min_max,
31 			 const EarlyLateAll *early_late,
32 			 float delay)
33 {
34   for (auto el_index : early_late->rangeIndex())
35     delays_[el_index].setValue(rf, min_max, delay);
36 }
37 
38 float
delay(const RiseFall * rf,const MinMax * min_max,const EarlyLate * early_late)39 ClockInsertion::delay(const RiseFall *rf,
40 		      const MinMax *min_max,
41 		      const EarlyLate *early_late)
42 {
43   float insertion;
44   bool exists;
45   delays_[early_late->index()].value(rf, min_max, insertion, exists);
46   if (exists)
47     return insertion;
48   else
49     return 0.0;
50 }
51 
52 void
delay(const RiseFall * rf,const MinMax * min_max,const EarlyLate * early_late,float & insertion,bool & exists)53 ClockInsertion::delay(const RiseFall *rf,
54 		      const MinMax *min_max,
55 		      const EarlyLate *early_late,
56 		      // Return values.
57 		      float &insertion,
58 		      bool &exists)
59 
60 {
61   delays_[early_late->index()].value(rf, min_max, insertion, exists);
62   if (!exists)
63     insertion = 0.0;
64 }
65 
66 void
setDelay(const RiseFall * rf,const MinMax * min_max,const EarlyLate * early_late,float delay)67 ClockInsertion::setDelay(const RiseFall *rf,
68 			 const MinMax *min_max,
69 			 const EarlyLate *early_late,
70 			 float delay)
71 {
72   delays_[early_late->index()].setValue(rf, min_max, delay);
73 }
74 
75 void
setDelays(RiseFallMinMax * delays)76 ClockInsertion::setDelays(RiseFallMinMax *delays)
77 {
78   for (auto el_index : EarlyLate::rangeIndex())
79     delays_[el_index].setValues(delays);
80 }
81 
82 RiseFallMinMax *
delays(const EarlyLate * early_late)83 ClockInsertion::delays(const EarlyLate *early_late)
84 {
85   return &delays_[early_late->index()];
86 }
87 
88 } // namespace
89