File size: 7,754 Bytes
d1be154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
#include <ot/shell/shell.hpp>

namespace ot {

// Procedure: update_timing
void Shell::_update_timing() {
  _timer.update_timing();
}

// ------------------------------------------------------------------------------------------------

// Procedure: report_at
void Shell::_report_at() {

  std::string token;
  std::string pin;
  auto el = MIN;
  auto rf = RISE;

  while(_is >> token) {
    if(token == "-pin") _is >> pin;
    else if(token == "-min" || token == "-early") el = MIN;
    else if(token == "-max" || token == "-late" ) el = MAX;
    else if(token == "-rise" ) rf = RISE;
    else if(token == "-fall" ) rf = FALL;
    else {
      _es << "failed to parse " << std::quoted(token) << '\n';
    }
  }

  if(pin.empty()) {
    _es << "-pin <name> not given\n";
    return;
  }

  auto at = _timer.report_at(std::move(pin), el, rf);
  _os << (at ? *at : std::numeric_limits<float>::quiet_NaN()) << '\n';
}

// ------------------------------------------------------------------------------------------------

// Procedure: report_rat
void Shell::_report_rat() {

  std::string token;
  std::string pin;
  auto el = MIN;
  auto rf = RISE;

  while(_is >> token) {
    if(token == "-pin") _is >> pin;
    else if(token == "-min" || token == "-early") el = MIN;
    else if(token == "-max" || token == "-late" ) el = MAX;
    else if(token == "-rise" ) rf = RISE;
    else if(token == "-fall" ) rf = FALL;
    else {
      _es << "failed to parse " << std::quoted(token) << '\n';
    }
  }

  if(pin.empty()) {
    _es << "-pin <name> not given\n";
    return;
  }

  auto rat = _timer.report_rat(std::move(pin), el, rf);
  _os << (rat ? *rat : std::numeric_limits<float>::quiet_NaN()) << '\n';
}

// ------------------------------------------------------------------------------------------------

// Procedure: report_slack
void Shell::_report_slack() {

  std::string token;
  std::string pin;
  auto el = MIN;
  auto rf = RISE;

  while(_is >> token) {
    if(token == "-pin") _is >> pin;
    else if(token == "-min" || token == "-early") el = MIN;
    else if(token == "-max" || token == "-late" ) el = MAX;
    else if(token == "-rise" ) rf = RISE;
    else if(token == "-fall" ) rf = FALL;
    else {
      _es << "failed to parse " << std::quoted(token) << '\n';
    }
  }

  if(pin.empty()) {
    _es << "-pin <name> not given\n";
    return;
  }

  auto slack = _timer.report_slack(std::move(pin), el, rf);
  _os << (slack ? *slack : std::numeric_limits<float>::quiet_NaN()) << '\n';
}

// ------------------------------------------------------------------------------------------------

// Procedure: report_slew
void Shell::_report_slew() {

  std::string token;
  std::string pin;
  auto el = MIN;
  auto rf = RISE;

  while(_is >> token) {
    if(token == "-pin") _is >> pin;
    else if(token == "-min" || token == "-early") el = MIN;
    else if(token == "-max" || token == "-late" ) el = MAX;
    else if(token == "-rise" ) rf = RISE;
    else if(token == "-fall" ) rf = FALL;
    else {
      _es << "failed to parse " << std::quoted(token) << '\n';
    }
  }

  if(pin.empty()) {
    _es << "-pin <name> not given\n";
    return;
  }

  auto slew = _timer.report_slew(std::move(pin), el, rf);
  _os << (slew ? *slew : std::numeric_limits<float>::quiet_NaN()) << '\n';
}

// ------------------------------------------------------------------------------------------------

// Procedure: report_tns
void Shell::_report_tns() {
  
  std::string token;
  
  std::optional<Split> el;
  std::optional<Tran> rf;

  while(_is >> token) {
    if(token == "-min" || token == "-early") el = MIN;
    else if(token == "-max" || token == "-late" ) el = MAX;
    else if(token == "-rise" ) rf = RISE;
    else if(token == "-fall" ) rf = FALL;
    else {
      _es << "failed to parse " << std::quoted(token) << '\n';
    }
  }

  if(auto tns = _timer.report_tns(el, rf); tns) {
    _os << *tns << '\n';
  }
  else {
    _os << std::numeric_limits<float>::quiet_NaN() << '\n';
  }
}

// ------------------------------------------------------------------------------------------------

// Procedure: report_wns
void Shell::_report_wns() {
  
  std::string token;
  
  std::optional<Split> el;
  std::optional<Tran> rf;

  while(_is >> token) {
    if(token == "-min" || token == "-early") el = MIN;
    else if(token == "-max" || token == "-late" ) el = MAX;
    else if(token == "-rise" ) rf = RISE;
    else if(token == "-fall" ) rf = FALL;
    else {
      _es << "failed to parse " << std::quoted(token) << '\n';
    }
  }

  if(auto wns = _timer.report_wns(el, rf); wns) {
    _os << *wns << '\n';
  }
  else {
    _os << std::numeric_limits<float>::quiet_NaN() << '\n';
  }
}

// ------------------------------------------------------------------------------------------------

// Procedure: report_fep
void Shell::_report_fep() {
  
  std::string token;
  
  std::optional<Split> el;
  std::optional<Tran> rf;

  while(_is >> token) {
    if(token == "-min" || token == "-early") el = MIN;
    else if(token == "-max" || token == "-late" ) el = MAX;
    else if(token == "-rise" ) rf = RISE;
    else if(token == "-fall" ) rf = FALL;
    else {
      _es << "failed to parse " << std::quoted(token) << '\n';
    }
  }

  if(auto fep = _timer.report_fep(el, rf); fep) {
    _os << *fep << '\n';
  }
  else {
    _os << "no failing endpoint found\n";
  }
}

// ------------------------------------------------------------------------------------------------

// Procedure: report_timing
void Shell::_report_timing() {
  
  std::string token;
  size_t K {1};

  std::optional<Split> split;
  std::optional<Tran> tran;
  
  // TODO: make the following format extensible
  bool tau18 {false};

  while(_is >> token) {
    if(token == "-num_paths") {
      _is >> K;
    }
    else if(token == "-min" || token == "-early") {
      split = MIN;
    }
    else if(token == "-max" || token == "-late") {
      split = MAX;
    }
    else if(token == "-rise") {
      tran = RISE;
    }
    else if(token == "-fall") {
      tran = FALL;
    }
    else if(token == "-format") {
      _is >> token;
      if(token == "tau18") {
        tau18 = true;
      }
    }
    else {
      _es << "failed to parse " << std::quoted(token) << '\n';
    }
  }

  std::vector<Path> paths;
  
  if(split && tran) {
    paths = _timer.report_timing(K, *split, *tran);
  }
  else if(split && !tran) {
    paths = _timer.report_timing(K, *split);
  }
  else if(!split && tran) {
    paths = _timer.report_timing(K, *tran);
  }
  else {
    paths = _timer.report_timing(K);
  }

  if(paths.empty()) {
    _os << "no critical path found\n";
  }
  else {
    for(size_t i=0; i<paths.size(); ++i) {
      if(i) _os << '\n';

      if(tau18) {
        paths[i].dump_tau18(_os);
      }
      else {
        _os << paths[i];
      }
    }
  }
}

// ------------------------------------------------------------------------------------------------

// Procedure: report_path
void Shell::_report_path() {
  _report_timing();
}

// ------------------------------------------------------------------------------------------------

// Procedure: report_area
void Shell::_report_area() {
  if(auto area = _timer.report_area(); area) {
    _os << *area << '\n';
  }
  else {
    _os << std::numeric_limits<float>::quiet_NaN() << '\n';
  }
}

// ------------------------------------------------------------------------------------------------

// Procedure: report_leakage_power
void Shell::_report_leakage_power() {
  if(auto lp = _timer.report_leakage_power(); lp) {
    _os << *lp << '\n';
  }
  else {
    _os << std::numeric_limits<float>::quiet_NaN() << '\n';
  }
}

};  // end of namespace ot. -----------------------------------------------------------------------