From d4c13bb7cdfcea212ee45d7051228dd1f5b0cd81 Mon Sep 17 00:00:00 2001 From: James Cherry Date: Fri, 24 Apr 2026 11:54:28 -0700 Subject: [PATCH] delays wrt clks refactor Signed-off-by: James Cherry --- include/sta/Search.hh | 5 +++++ include/sta/SearchClass.hh | 7 +++++++ include/sta/Sta.hh | 14 +++---------- search/Search.cc | 34 ++++++++++++++++++++++++++++++++ search/Sta.cc | 40 ++++++++------------------------------ 5 files changed, 57 insertions(+), 43 deletions(-) diff --git a/include/sta/Search.hh b/include/sta/Search.hh index 47fb6247..58506e1f 100644 --- a/include/sta/Search.hh +++ b/include/sta/Search.hh @@ -409,6 +409,11 @@ public: void saveEnumPath(Path *path); bool isSrchRoot(Vertex *vertex, const Mode *mode) const; + DelaysWrtClks arrivalsWrtClks(Vertex *vertex, + const Scene *scene); + DelaysWrtClks delaysWrtClks(Vertex *vertex, + const Scene *scene, + const PathDelayFunc &get_path_delay); protected: void initVars(); diff --git a/include/sta/SearchClass.hh b/include/sta/SearchClass.hh index 9e3205b9..c47ccf1b 100644 --- a/include/sta/SearchClass.hh +++ b/include/sta/SearchClass.hh @@ -24,14 +24,18 @@ #pragma once +#include #include #include #include #include "Delay.hh" #include "GraphClass.hh" +#include "LibertyClass.hh" #include "MinMaxValues.hh" #include "NetworkClass.hh" +#include "RiseFallMinMaxDelay.hh" +#include "SdcClass.hh" #include "VectorMap.hh" namespace sta { @@ -111,6 +115,9 @@ using SlackSeq = std::vector; using Crpr = Delay; using PathSeq = std::vector; using ConstPathSeq = std::vector; +// Path::slack/arrival/required function. +using PathDelayFunc = std::function; +using DelaysWrtClks = std::map; enum class ReportPathFormat { full, full_clock, diff --git a/include/sta/Sta.hh b/include/sta/Sta.hh index 1b74fb28..7817b1c2 100644 --- a/include/sta/Sta.hh +++ b/include/sta/Sta.hh @@ -24,7 +24,7 @@ #pragma once -#include +#include #include #include #include @@ -82,8 +82,6 @@ using CheckError = StringSeq; using CheckErrorSeq = std::vector; enum class CmdNamespace { sta, sdc }; using ParasiticsNameMap = std::map>; -// Path::slack/arrival/required function. -using PathDelayFunc = std::function; using GraphLoopSeq = std::vector; // Initialize sta functions that are not part of the Sta class. @@ -1524,16 +1522,10 @@ protected: int digits, bool find_required, const PathDelayFunc &get_path_delay); - void reportDelaysWrtClks(Vertex *vertex, - const ClockEdge *clk_edge, - const Scene *scene, + void reportDelaysWrtClks(const ClockEdge *clk_edge, bool report_variance, int digits, - const PathDelayFunc &get_path_delay); - RiseFallMinMaxDelay findDelaysWrtClks(Vertex *vertex, - const ClockEdge *clk_edge, - const Scene *scene, - const PathDelayFunc &get_path_delay); + DelaysWrtClks &clk_delays); std::string formatDelay(const RiseFall *rf, const MinMax *min_max, const RiseFallMinMaxDelay &delays, diff --git a/search/Search.cc b/search/Search.cc index 2fc617fa..d0d6b0ca 100644 --- a/search/Search.cc +++ b/search/Search.cc @@ -57,6 +57,7 @@ #include "PortDelay.hh" #include "PortDirection.hh" #include "Report.hh" +#include "RiseFallMinMaxDelay.hh" #include "Scene.hh" #include "Sdc.hh" #include "SdcClass.hh" @@ -3997,4 +3998,37 @@ Search::wnsSlack(Vertex *vertex, return slacks[path_ap_index]; } +//////////////////////////////////////////////////////////////// + +DelaysWrtClks +Search::arrivalsWrtClks(Vertex *vertex, + const Scene *scene) +{ + return delaysWrtClks(vertex, scene, + [] (const Path *path) { + return path->arrival(); + }); +} + +DelaysWrtClks +Search::delaysWrtClks(Vertex *vertex, + const Scene *scene, + const PathDelayFunc &get_path_delay) +{ + DelaysWrtClks delays_wrt_clks; + VertexPathIterator path_iter(vertex, scene, nullptr, nullptr, this); + while (path_iter.hasNext()) { + Path *path = path_iter.next(); + Delay delay = get_path_delay(path); + if (!delayInf(delay, this)) { + const RiseFall *rf = path->transition(this); + const MinMax *min_max = path->minMax(this); + const ClockEdge *clk_edge = path->clkEdge(this); + RiseFallMinMaxDelay &delays = delays_wrt_clks[clk_edge]; + delays.mergeValue(rf, min_max, delay, this); + } + } + return delays_wrt_clks; +} + } // namespace sta diff --git a/search/Sta.cc b/search/Sta.cc index 2d85c027..dc6bfc04 100644 --- a/search/Sta.cc +++ b/search/Sta.cc @@ -26,6 +26,7 @@ #include #include +#include #include #include "ArcDelayCalc.hh" @@ -3346,29 +3347,25 @@ Sta::reportDelaysWrtClks(Vertex *vertex, else search_->findArrivals(vertex->level()); const Sdc *sdc = scene->sdc(); - reportDelaysWrtClks(vertex, nullptr, scene, report_variance, digits, get_path_delay); + DelaysWrtClks clk_delays = search_->delaysWrtClks(vertex, scene, get_path_delay); + reportDelaysWrtClks(nullptr, report_variance, digits, clk_delays); const ClockEdge *default_clk_edge = sdc->defaultArrivalClock()->edge(RiseFall::rise()); - reportDelaysWrtClks(vertex, default_clk_edge, scene, report_variance, - digits, get_path_delay); + reportDelaysWrtClks(default_clk_edge, report_variance, digits, clk_delays); for (const Clock *clk : sdc->sortedClocks()) { for (const RiseFall *rf : RiseFall::range()) { const ClockEdge *clk_edge = clk->edge(rf); - reportDelaysWrtClks(vertex, clk_edge, scene, report_variance, digits, - get_path_delay); + reportDelaysWrtClks(clk_edge, report_variance, digits, clk_delays); } } } void -Sta::reportDelaysWrtClks(Vertex *vertex, - const ClockEdge *clk_edge, - const Scene *scene, +Sta::reportDelaysWrtClks(const ClockEdge *clk_edge, bool report_variance, int digits, - const PathDelayFunc &get_path_delay) + DelaysWrtClks &clk_delays) { - RiseFallMinMaxDelay delays = - findDelaysWrtClks(vertex, clk_edge, scene, get_path_delay); + const RiseFallMinMaxDelay &delays = clk_delays[clk_edge]; if (!delays.empty()) { std::string clk_name; if (clk_edge) @@ -3385,27 +3382,6 @@ Sta::reportDelaysWrtClks(Vertex *vertex, } } -RiseFallMinMaxDelay -Sta::findDelaysWrtClks(Vertex *vertex, - const ClockEdge *clk_edge, - const Scene *scene, - const PathDelayFunc &get_path_delay) -{ - RiseFallMinMaxDelay delays; - VertexPathIterator path_iter(vertex, scene, nullptr, nullptr, this); - while (path_iter.hasNext()) { - Path *path = path_iter.next(); - Delay delay = get_path_delay(path); - const RiseFall *rf = path->transition(this); - const MinMax *min_max = path->minMax(this); - const ClockEdge *path_clk_edge = path->clkEdge(this); - if (path_clk_edge == clk_edge - && !delayInf(delay, this)) - delays.mergeValue(rf, min_max, delay, this); - } - return delays; -} - std::string Sta::formatDelay(const RiseFall *rf, const MinMax *min_max,