Skip to content

Commit 748fb9b

Browse files
committed
code review changes per Deepashree
Signed-off-by: Cho Moon <cmoon@precisioninno.com>
1 parent 211aea7 commit 748fb9b

8 files changed

Lines changed: 4651 additions & 4 deletions

File tree

graph/Graph.i

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "Graph.hh"
2929
#include "FuncExpr.hh"
3030
#include "TimingRole.hh"
31+
#include "search/Levelize.hh"
3132
#include "Liberty.hh"
3233
#include "Network.hh"
3334
#include "Clock.hh"
@@ -118,6 +119,32 @@ remove_delay_slew_annotations()
118119
Sta::sta()->removeDelaySlewAnnotations();
119120
}
120121

122+
void
123+
report_levelized_drvr_vertices(int max_count)
124+
{
125+
Sta *sta = Sta::sta();
126+
sta->ensureGraph();
127+
const VertexSeq &drvrs = sta->levelizedDrvrVertices();
128+
Report *report = sta->report();
129+
const Network *network = sta->network();
130+
report->report("driver vertex count {}", drvrs.size());
131+
Level prev_level = -1;
132+
int n = 0;
133+
for (Vertex *vertex : drvrs) {
134+
Level level = vertex->level();
135+
if (level < prev_level)
136+
report->report("level order violated {} {} < {}",
137+
network->pathName(vertex->pin()),
138+
level, prev_level);
139+
if (n < max_count)
140+
report->report("{} level={}",
141+
network->pathName(vertex->pin()),
142+
level);
143+
prev_level = level;
144+
n++;
145+
}
146+
}
147+
121148
%} // inline
122149

123150
////////////////////////////////////////////////////////////////

include/sta/Sta.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,7 @@ public:
13251325
// Ensure that the timing graph has been built.
13261326
Graph *ensureGraph();
13271327
void ensureClkArrivals();
1328-
Levelize* levelize() const { return levelize_; }
1328+
const VertexSeq& levelizedDrvrVertices();
13291329

13301330
// Find all arc delays and vertex slews with delay calculator.
13311331
virtual void findDelays();

search/Levelize.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Levelize::clear()
9292
loop_edges_.clear();
9393
max_level_ = 0;
9494
drvr_vertices_level_valid_ = false;
95+
levelized_drvr_vertices_.clear();
9596
}
9697

9798
void
@@ -548,11 +549,11 @@ Levelize::setLevel(Vertex *vertex,
548549
void
549550
Levelize::invalid()
550551
{
552+
drvr_vertices_level_valid_ = false;
551553
if (levelized_) {
552554
debugPrint(debug_, "levelize", 1, "levels invalid");
553555
levelized_ = false;
554556
levels_valid_ = false;
555-
drvr_vertices_level_valid_ = false;
556557
}
557558
}
558559

@@ -563,6 +564,7 @@ Levelize::deleteVertexBefore(Vertex *vertex)
563564
roots_.erase(vertex);
564565
relevelize_from_.erase(vertex);
565566
drvr_vertices_level_valid_ = false;
567+
levelized_drvr_vertices_.clear();
566568
}
567569
}
568570

@@ -720,15 +722,19 @@ void
720722
Levelize::levelizeDrvrVertices()
721723
{
722724
levelized_drvr_vertices_.clear();
725+
// Rough estimate: ~half of vertices are drivers
726+
levelized_drvr_vertices_.reserve(graph_->vertexCount() / 2);
723727
VertexIterator vertex_iter(graph_);
724728
while (vertex_iter.hasNext()) {
725729
Vertex *vertex = vertex_iter.next();
726730
if (vertex->isDriver(network_))
727731
levelized_drvr_vertices_.emplace_back(vertex);
728732
}
729733
sort(levelized_drvr_vertices_,
730-
[](const Vertex *a, const Vertex *b) {
731-
return a->level() < b->level();
734+
[this](const Vertex *a, const Vertex *b) {
735+
if (a->level() != b->level())
736+
return a->level() < b->level();
737+
return VertexNameLess(network_)(a, b);
732738
});
733739
drvr_vertices_level_valid_ = true;
734740
}

search/Sta.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2900,6 +2900,12 @@ Sta::ensureClkArrivals()
29002900
search_->findClkArrivals();
29012901
}
29022902

2903+
const VertexSeq&
2904+
Sta::levelizedDrvrVertices()
2905+
{
2906+
return levelize_->levelizedDrvrVertices();
2907+
}
2908+
29032909
////////////////////////////////////////////////////////////////
29042910

29052911
VertexSet &

0 commit comments

Comments
 (0)