From 8cf84facee11a9e410fda6d7d48fe0500d9f27d4 Mon Sep 17 00:00:00 2001 From: James Cherry Date: Sat, 8 May 2021 16:55:38 -0700 Subject: [PATCH] sta::endpoint_count --- include/sta/Sta.hh | 1 + search/Sta.cc | 20 ++++++++++++++++++++ tcl/StaTcl.i | 6 ++++++ 3 files changed, 27 insertions(+) diff --git a/include/sta/Sta.hh b/include/sta/Sta.hh index 148f99d3..21d5da4c 100644 --- a/include/sta/Sta.hh +++ b/include/sta/Sta.hh @@ -903,6 +903,7 @@ public: void arrivalsInvalid(); void visitStartpoints(VertexVisitor *visitor); void visitEndpoints(VertexVisitor *visitor); + int endpointCount(); // Find the fanin vertices for a group path. // Vertices in the clock network are NOT included. // Return value is owned by the caller. diff --git a/search/Sta.cc b/search/Sta.cc index ff9c3c11..751f19ef 100644 --- a/search/Sta.cc +++ b/search/Sta.cc @@ -2617,6 +2617,26 @@ Sta::visitEndpoints(VertexVisitor *visitor) search_->visitEndpoints(visitor); } +class EndpointCounter : public VertexVisitor +{ +public: + EndpointCounter() : count_(0) {} + virtual void visit(Vertex *) { count_++; } + int count() const { return count_; } + virtual EndpointCounter *copy() { return new EndpointCounter; } +protected: + int count_; +}; + +int +Sta::endpointCount() +{ + ensureGraph(); + EndpointCounter counter; + search_->visitEndpoints(&counter); + return counter.count(); +} + PinSet * Sta::findGroupPathPins(const char *group_path_name) { diff --git a/tcl/StaTcl.i b/tcl/StaTcl.i index 32b76f9a..8258d33d 100644 --- a/tcl/StaTcl.i +++ b/tcl/StaTcl.i @@ -5388,6 +5388,12 @@ pin_location(Pin *pin) return ""; } +int +endpoint_count() +{ + return Sta::sta()->endpointCount(); +} + %} // inline ////////////////////////////////////////////////////////////////