delays wrt clks refactor

Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
James Cherry 2026-04-24 11:54:28 -07:00
parent a1c3077139
commit d4c13bb7cd
5 changed files with 57 additions and 43 deletions

View File

@ -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();

View File

@ -24,14 +24,18 @@
#pragma once
#include <functional>
#include <limits>
#include <map>
#include <vector>
#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<Slack>;
using Crpr = Delay;
using PathSeq = std::vector<Path*>;
using ConstPathSeq = std::vector<const Path*>;
// Path::slack/arrival/required function.
using PathDelayFunc = std::function<Delay (const Path *path)>;
using DelaysWrtClks = std::map<const ClockEdge*, RiseFallMinMaxDelay>;
enum class ReportPathFormat { full,
full_clock,

View File

@ -24,7 +24,7 @@
#pragma once
#include <functional>
#include <map>
#include <string>
#include <string_view>
#include <vector>
@ -82,8 +82,6 @@ using CheckError = StringSeq;
using CheckErrorSeq = std::vector<CheckError*>;
enum class CmdNamespace { sta, sdc };
using ParasiticsNameMap = std::map<std::string, Parasitics*, std::less<>>;
// Path::slack/arrival/required function.
using PathDelayFunc = std::function<Delay (const Path *path)>;
using GraphLoopSeq = std::vector<GraphLoop*>;
// 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,

View File

@ -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

View File

@ -26,6 +26,7 @@
#include <algorithm>
#include <cstddef>
#include <map>
#include <string>
#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,