forked from The-OpenROAD-Project/OpenSTA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReportAnnotation.cc
574 lines (535 loc) · 16.3 KB
/
ReportAnnotation.cc
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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
// OpenSTA, Static Timing Analyzer
// Copyright (c) 2023, Parallax Software, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "sdf/ReportAnnotation.hh"
#include "StringUtil.hh"
#include "Report.hh"
#include "TimingRole.hh"
#include "TimingArc.hh"
#include "Liberty.hh"
#include "Network.hh"
#include "Graph.hh"
#include "GraphCmp.hh"
#include "Sdc.hh"
#include "DcalcAnalysisPt.hh"
namespace sta {
class ReportAnnotated : public StaState
{
public:
ReportAnnotated(bool report_cells,
bool report_nets,
bool report_in_ports,
bool report_out_ports,
int max_lines,
bool list_annotated,
bool list_unannotated,
bool constant_arcs,
StaState *sta);
ReportAnnotated(bool report_setup,
bool report_hold,
bool report_recovery,
bool report_removal,
bool report_nochange,
bool report_width,
bool report_period,
bool report_max_skew,
int max_lines,
bool list_annotated,
bool list_unannotated,
bool constant_arcs,
StaState *sta);
void reportDelayAnnotation();
void reportCheckAnnotation();
protected:
enum CountIndex {
count_internal_net = TimingRole::index_max,
count_input_net,
count_output_net,
count_index_max
};
static int count_delay;
void init();
void findCounts();
void findWidthPeriodCount(Pin *pin);
void reportDelayCounts();
void reportCheckCounts();
void reportArcs();
void reportArcs(const char *header,
bool report_annotated,
PinSet &pins);
void reportArcs(Vertex *vertex,
bool report_annotated,
int &i);
void reportWidthPeriodArcs(const Pin *pin,
bool report_annotated,
int &i);
void reportCount(const char *title,
int index,
int &total,
int &annotated_total);
void reportCheckCount(TimingRole *role,
int &total,
int &annotated_total);
int roleIndex(const TimingRole *role,
const Pin *from_pin,
const Pin *to_pin);
int max_lines_;
bool list_annotated_;
bool list_unannotated_;
bool report_constant_arcs_;
int edge_count_[count_index_max];
int edge_annotated_count_[count_index_max];
int edge_constant_count_[count_index_max];
int edge_constant_annotated_count_[count_index_max];
bool report_role_[count_index_max];
PinSet unannotated_pins_;
PinSet annotated_pins_;
};
int ReportAnnotated::count_delay;
void
reportAnnotatedDelay(bool report_cells,
bool report_nets,
bool from_in_ports,
bool to_out_ports,
int max_lines,
bool list_annotated,
bool list_unannotated,
bool report_constant_arcs,
StaState *sta)
{
ReportAnnotated report_annotated(report_cells, report_nets,
from_in_ports, to_out_ports,
max_lines, list_annotated, list_unannotated,
report_constant_arcs, sta);
report_annotated.reportDelayAnnotation();
}
ReportAnnotated::ReportAnnotated(bool report_cells,
bool report_nets,
bool report_in_ports,
bool report_out_ports,
int max_lines,
bool list_annotated,
bool list_unannotated,
bool report_constant_arcs,
StaState *sta) :
StaState(sta),
max_lines_(max_lines),
list_annotated_(list_annotated),
list_unannotated_(list_unannotated),
report_constant_arcs_(report_constant_arcs),
unannotated_pins_(sta->network()),
annotated_pins_(sta->network())
{
init();
report_role_[TimingRole::sdfIopath()->index()] = report_cells;
report_role_[count_internal_net] = report_nets;
report_role_[count_input_net] = report_in_ports;
report_role_[count_output_net] = report_out_ports;
}
void
ReportAnnotated::reportDelayAnnotation()
{
findCounts();
reportDelayCounts();
reportArcs();
}
void
ReportAnnotated::reportDelayCounts()
{
report_->reportLine(" Not ");
report_->reportLine("Delay type Total Annotated Annotated");
report_->reportLine("----------------------------------------------------------------");
int total = 0;
int annotated_total = 0;
reportCount("cell arcs", count_delay, total, annotated_total);
reportCount("internal net arcs", count_internal_net, total, annotated_total);
reportCount("net arcs from primary inputs", count_input_net,
total, annotated_total);
reportCount("net arcs to primary outputs", count_output_net,
total, annotated_total);
report_->reportLine("----------------------------------------------------------------");
report_->reportLine("%-28s %10u %10u %10u",
" ",
total,
annotated_total,
total - annotated_total);
}
////////////////////////////////////////////////////////////////
void
reportAnnotatedCheck(bool report_setup,
bool report_hold,
bool report_recovery,
bool report_removal,
bool report_nochange,
bool report_width,
bool report_period,
bool report_max_skew,
int max_lines,
bool list_annotated,
bool list_unannotated,
bool report_constant_arcs,
StaState *sta)
{
ReportAnnotated report_annotated(report_setup, report_hold,
report_recovery, report_removal,
report_nochange, report_width,
report_period, report_max_skew,
max_lines, list_annotated, list_unannotated,
report_constant_arcs, sta);
report_annotated.reportCheckAnnotation();
}
ReportAnnotated::ReportAnnotated(bool report_setup,
bool report_hold,
bool report_recovery,
bool report_removal,
bool report_nochange,
bool report_width,
bool report_period,
bool report_max_skew,
int max_lines,
bool list_annotated,
bool list_unannotated,
bool report_constant_arcs,
StaState *sta) :
StaState(sta),
max_lines_(max_lines),
list_annotated_(list_annotated),
list_unannotated_(list_unannotated),
report_constant_arcs_(report_constant_arcs),
unannotated_pins_(sta->network()),
annotated_pins_(sta->network())
{
init();
report_role_[TimingRole::setup()->index()] = report_setup;
report_role_[TimingRole::hold()->index()] = report_hold;
report_role_[TimingRole::recovery()->index()] = report_recovery;
report_role_[TimingRole::removal()->index()] = report_removal;
report_role_[TimingRole::nochange()->index()] = report_nochange;
report_role_[TimingRole::width()->index()] = report_width;
report_role_[TimingRole::period()->index()] = report_period;
report_role_[TimingRole::skew()->index()] = report_max_skew;
}
void
ReportAnnotated::reportCheckAnnotation()
{
findCounts();
reportCheckCounts();
reportArcs();
}
void
ReportAnnotated::reportCheckCounts()
{
report_->reportLine(" Not ");
report_->reportLine("Check type Total Annotated Annotated");
report_->reportLine("----------------------------------------------------------------");
int total = 0;
int annotated_total = 0;
reportCheckCount(TimingRole::setup(), total, annotated_total);
reportCheckCount(TimingRole::hold(), total, annotated_total);
reportCheckCount(TimingRole::recovery(), total, annotated_total);
reportCheckCount(TimingRole::removal(), total, annotated_total);
reportCheckCount(TimingRole::nochange(), total, annotated_total);
reportCheckCount(TimingRole::width(), total, annotated_total);
reportCheckCount(TimingRole::period(), total, annotated_total);
reportCheckCount(TimingRole::skew(), total, annotated_total);
report_->reportLine("----------------------------------------------------------------");
report_->reportLine("%-28s %10u %10u %10u",
" ",
total,
annotated_total,
total - annotated_total);
}
void
ReportAnnotated::reportCheckCount(TimingRole *role,
int &total,
int &annotated_total)
{
int index = role->index();
if (edge_count_[index] > 0) {
const char *role_name = role->asString();
string title;
stringPrint(title, "cell %s arcs", role_name);
reportCount(title.c_str(), index, total, annotated_total);
}
}
////////////////////////////////////////////////////////////////
void
ReportAnnotated::init()
{
count_delay = TimingRole::sdfIopath()->index();
for (int i = 0; i < count_index_max; i++) {
edge_count_[i] = 0;
edge_annotated_count_[i] = 0;
edge_constant_count_[i] = 0;
edge_constant_annotated_count_[i] = 0;
report_role_[i] = false;
}
}
void
ReportAnnotated::findCounts()
{
VertexIterator vertex_iter(graph_);
while (vertex_iter.hasNext()) {
Vertex *from_vertex = vertex_iter.next();
Pin *from_pin = from_vertex->pin();
LogicValue from_logic_value;
bool from_logic_value_exists;
sdc_->logicValue(from_pin, from_logic_value,
from_logic_value_exists);
VertexOutEdgeIterator edge_iter(from_vertex, graph_);
while (edge_iter.hasNext()) {
Edge *edge = edge_iter.next();
const TimingRole *role = edge->role();
Vertex *to_vertex = edge->to(graph_);
Pin *to_pin = to_vertex->pin();
int index = roleIndex(role, from_pin, to_pin);
LogicValue to_logic_value;
bool to_logic_value_exists;
sdc_->logicValue(to_pin, to_logic_value,
to_logic_value_exists);
edge_count_[index]++;
if (from_logic_value_exists || to_logic_value_exists)
edge_constant_count_[index]++;
if (report_role_[index]) {
if (graph_->delayAnnotated(edge)) {
edge_annotated_count_[index]++;
if (from_logic_value_exists || to_logic_value_exists)
edge_constant_annotated_count_[index]++;
if (list_annotated_)
annotated_pins_.insert(from_pin);
}
else {
if (list_unannotated_)
unannotated_pins_.insert(from_pin);
}
}
}
findWidthPeriodCount(from_pin);
}
}
int
ReportAnnotated::roleIndex(const TimingRole *role,
const Pin *from_pin,
const Pin *to_pin)
{
if (role == TimingRole::wire()) {
if (network_->isTopLevelPort(from_pin))
return count_input_net;
else if (network_->isTopLevelPort(to_pin))
return count_output_net;
else
return count_internal_net;
}
else if (role->sdfRole() == TimingRole::sdfIopath())
return count_delay;
else {
if (role->isTimingCheck()
&& (role == TimingRole::latchSetup()
|| role == TimingRole::latchHold()))
role = role->genericRole();
return role->index();
}
}
// Width and period checks are not edges in the graph so
// they require special handling.
void
ReportAnnotated::findWidthPeriodCount(Pin *pin)
{
LibertyPort *port = network_->libertyPort(pin);
if (port) {
DcalcAPIndex ap_index = 0;
float value;
bool exists, annotated;
int period_index = TimingRole::period()->index();
if (report_role_[period_index]) {
port->minPeriod(value, exists);
if (exists) {
edge_count_[period_index]++;
graph_->periodCheckAnnotation(pin, ap_index, value, annotated);
if (annotated) {
edge_annotated_count_[period_index]++;
if (list_annotated_)
annotated_pins_.insert(pin);
}
else {
if (list_unannotated_)
unannotated_pins_.insert(pin);
}
}
}
int width_index = TimingRole::width()->index();
if (report_role_[width_index]) {
for (auto hi_low : RiseFall::range()) {
port->minPulseWidth(hi_low, value, exists);
if (exists) {
edge_count_[width_index]++;
graph_->widthCheckAnnotation(pin, hi_low, ap_index,
value, annotated);
if (annotated) {
edge_annotated_count_[width_index]++;
if (list_annotated_)
annotated_pins_.insert(pin);
}
else {
if (list_unannotated_)
unannotated_pins_.insert(pin);
}
}
}
}
}
}
void
ReportAnnotated::reportCount(const char *title,
int index,
int &total,
int &annotated_total)
{
if (report_role_[index]) {
int count = edge_count_[index];
int annotated_count = edge_annotated_count_[index];
report_->reportLine("%-28s %10u %10u %10u",
title,
count,
annotated_count,
count - annotated_count);
if (report_constant_arcs_) {
int const_count = edge_constant_count_[index];
int const_annotated_count = edge_constant_annotated_count_[index];
report_->reportLine("%-28s %10s %10u %10u",
"constant arcs",
"",
const_annotated_count,
const_count - const_annotated_count);
}
total += count;
annotated_total += annotated_count;
}
}
void
ReportAnnotated::reportArcs()
{
if (list_annotated_)
reportArcs("Annotated Arcs", true, annotated_pins_);
if (list_unannotated_)
reportArcs("Unannotated Arcs", false, unannotated_pins_);
}
void
ReportAnnotated::reportArcs(const char *header,
bool report_annotated,
PinSet &pins)
{
report_->reportBlankLine();
report_->reportLineString(header);
PinSeq pins1 = sortByPathName(&pins, network_);
int i = 0;
for (const Pin *pin : pins1) {
Vertex *vertex, *bidirect_drvr_vertex;
graph_->pinVertices(pin, vertex, bidirect_drvr_vertex);
reportArcs(vertex, report_annotated, i);
if (bidirect_drvr_vertex)
reportArcs(bidirect_drvr_vertex, report_annotated, i);
reportWidthPeriodArcs(pin, report_annotated, i);
if (max_lines_ != 0 && i > max_lines_)
break;
}
}
void
ReportAnnotated::reportArcs(Vertex *vertex,
bool report_annotated,
int &i)
{
const Pin *from_pin = vertex->pin();
VertexOutEdgeIterator edge_iter(vertex, graph_);
while (edge_iter.hasNext()
&& (max_lines_ == 0 || i < max_lines_)) {
Edge *edge = edge_iter.next();
TimingRole *role = edge->role();
const Pin *to_pin = edge->to(graph_)->pin();
if (graph_->delayAnnotated(edge) == report_annotated
&& report_role_[roleIndex(role, from_pin, to_pin)]) {
const char *role_name;
if (role->isTimingCheck())
role_name = role->asString();
else if (role->isWire()) {
if (network_->isTopLevelPort(from_pin))
role_name = "primary input net";
else if (network_->isTopLevelPort(to_pin))
role_name = "primary output net";
else
role_name = "internal net";
}
else
role_name = "delay";
const char *cond = edge->timingArcSet()->sdfCond();
report_->reportLine(" %-18s %s -> %s %s",
role_name,
network_->pathName(from_pin),
network_->pathName(to_pin),
cond ? cond : "");
i++;
}
}
}
void
ReportAnnotated::reportWidthPeriodArcs(const Pin *pin,
bool report_annotated,
int &i)
{
LibertyPort *port = network_->libertyPort(pin);
if (port) {
DcalcAPIndex ap_index = 0;
float value;
bool exists, annotated;
int period_index = TimingRole::period()->index();
if (report_role_[period_index]
&& (max_lines_ == 0 || i < max_lines_)) {
float value;
bool exists, annotated;
port->minPeriod(value, exists);
if (exists) {
edge_count_[period_index]++;
graph_->periodCheckAnnotation(pin, ap_index, value, annotated);
if (annotated == report_annotated) {
report_->reportLine(" %-18s %s",
"period",
network_->pathName(pin));
i++;
}
}
}
int width_index = TimingRole::width()->index();
if (report_role_[width_index]
&& (max_lines_ == 0 || i < max_lines_)) {
bool report = false;
for (auto hi_low : RiseFall::range()) {
port->minPulseWidth(hi_low, value, exists);
if (exists) {
edge_count_[width_index]++;
graph_->widthCheckAnnotation(pin, hi_low, ap_index,
value, annotated);
report |= (annotated == report_annotated);
}
}
if (report) {
report_->reportLine(" %-18s %s",
"min width",
network_->pathName(pin));
i++;
}
}
}
}
} // namespace