diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 00000000..c095fa1b --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,80 @@ +Checks: > + clang-diagnostic-*, + clang-analyzer-*, + -clang-analyzer-core.NonNullParamChecker, + -clang-analyzer-core.CallAndMessage, + -clang-analyzer-core.uninitialized.UndefReturn, + -clang-analyzer-cplusplus.NewDeleteLeaks, + -clang-analyzer-optin.performance.Padding, + readability-*, + -readability-identifier-naming, + -readability-braces-around-statements, + -readability-convert-member-functions-to-static, + -readability-else-after-return, + -readability-function-cognitive-complexity, + -readability-inconsistent-ifelse-braces, + -readability-identifier-length, + -readability-implicit-bool-conversion, + -readability-isolate-declaration, + -readability-magic-numbers, + -readability-make-member-function-const, + -readability-math-missing-parentheses, + -readability-named-parameter, + -readability-qualified-auto, + -readability-redundant-access-specifiers, + -readability-simplify-boolean-expr, + -readability-static-definition-in-anonymous-namespace, + -readability-suspicious-call-argument, + -readability-uppercase-literal-suffix, + -readability-use-anyofallof, + google-*, + -google-readability-avoid-underscore-in-googletest-name, + -google-readability-braces-around-statements, + -google-readability-casting, + -google-readability-todo, + -google-runtime-references, + -google-explicit-constructor, + performance-*, + -performance-enum-size, + bugprone-*, + -bugprone-branch-clone, + -bugprone-easily-swappable-parameters, + -bugprone-exception-escape, + -bugprone-macro-parentheses, + -bugprone-move-forwarding-reference, + -bugprone-narrowing-conversions, + -bugprone-suspicious-missing-comma, + -bugprone-throwing-static-initialization, + modernize-*, + -modernize-avoid-bind, + -modernize-avoid-c-arrays, + -modernize-concat-nested-namespaces, + -modernize-macro-to-enum, + -modernize-pass-by-value, + -modernize-raw-string-literal, + -modernize-return-braced-init-list, + -modernize-use-auto, + -modernize-use-nodiscard, + -modernize-use-trailing-return-type, + -modernize-use-transparent-functors, + misc-*, + -misc-const-correctness, + -misc-multiple-inheritance, + -misc-no-recursion, + -misc-non-private-member-variables-in-classes, + -misc-redundant-expression, + -misc-unused-parameters, + -misc-use-anonymous-namespace, + -misc-use-internal-linkage, + -misc-include-cleaner + +# Only report diagnostics in headers under this tree (app/, include/sta/, build-generated +# headers, etc.). +# Excludes system and third-party paths such as /opt/local/include. +HeaderFilterRegex: '.*/(app|cmake|dcalc|graph|liberty|network|parasitics|power|sdc|sdf|search|spice|tcl|util|verilog|include/sta|build/include/sta)/.*' + +# util/gzstream.hh +# util/FlexDisableRegister.hh +# Bison-generated parser headers (build/{Liberty,Verilog,...}Parse.hh) +ExcludeHeaderFilterRegex: '(.*/)?(gzstream\.hh|FlexDisableRegister\.hh|(Liberty|Verilog|Sdf|Spef|Saif|LibExpr)Parse\.hh)$' +FormatStyle: none diff --git a/.cursor/rules/cpp-coding-standards.mdc b/.cursor/rules/cpp-coding-standards.mdc index 34c6cfe6..538991fb 100644 --- a/.cursor/rules/cpp-coding-standards.mdc +++ b/.cursor/rules/cpp-coding-standards.mdc @@ -31,3 +31,29 @@ alwaysApply: false - C++ source: `.cc` - C++ headers: `.hh` + +## Include order + +Sort `#include` lines **lexicographically by the path inside** `<>` +or `""` (case-sensitive). Separate **groups** with a single blank line. + +### Translation units (`*.cc`) + +1. **Primary header(s)** for this file only: + - `#include "Stem.hh"` where `Stem` matches the basename of the `.cc` file (e.g. `Foo.cc` → `Foo.hh`). + - If the file uses a paired private header, include `#include "StemPvt.hh"` **immediately after** `Stem.hh` (e.g. `MakeTimingModel.cc` → `MakeTimingModel.hh` then `MakeTimingModelPvt.hh`). + - Do **not** pull in other headers just because their names share a prefix with `Stem` (e.g. `SearchClass.hh` is not a “primary” include for `Search.cc`; it belongs in the project group below). + +2. **System / standard library** headers: `#include <...>` lines, sorted alphabetically. + +3. **All other project** headers: `#include "..."` lines, sorted alphabetically (including `search/Crpr.hh`-style paths and includes from `liberty/`, etc.). + +If a **comment or special block** intentionally splits the include list (e.g. a third-party note before `#include "cudd.h"`), keep that structure; sort only within each contiguous run of `#include` lines unless merging groups is clearly safe. + +### Headers (`*.hh`) + +After `#pragma once` (and the file’s license block, if present): + +1. **System** `#include <...>` lines, sorted alphabetically. + +2. **Project** `#include "..."` lines, sorted alphabetically. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5fb13fd9..62c82e2b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,6 +54,7 @@ jobs: name: artifact path: | build/install/* + retention-days: 1 - name: Upload Test Result uses: actions/upload-artifact@v7 diff --git a/CMakeLists.txt b/CMakeLists.txt index e322b3e4..a6eaddaf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # OpenSTA, Static Timing Analyzer -# Copyright (c) 2025, Parallax Software, Inc. +# Copyright (c) 2026, 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 @@ -222,7 +222,6 @@ set(STA_SOURCE util/Error.cc util/Fuzzy.cc util/Hash.cc - util/Machine.cc util/MinMax.cc util/PatternMatch.cc util/Report.cc @@ -239,6 +238,16 @@ set(STA_SOURCE verilog/VerilogWriter.cc ) +if(APPLE) + list(APPEND STA_SOURCE util/MachineApple.cc) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + list(APPEND STA_SOURCE util/MachineLinux.cc) +elseif(WIN32) + list(APPEND STA_SOURCE util/MachineWin32.cc) +else() + list(APPEND STA_SOURCE util/MachineUnknown.cc) +endif() + # Source files. set(STA_TCL_FILES tcl/Init.tcl diff --git a/app/StaMain.cc b/app/StaMain.cc index f2eda7ae..84b0540f 100644 --- a/app/StaMain.cc +++ b/app/StaMain.cc @@ -148,4 +148,4 @@ unencode(const char *inits[]) return unencoded; } -} // namespace +} // namespace sta diff --git a/dcalc/ArcDcalcWaveforms.cc b/dcalc/ArcDcalcWaveforms.cc index 00f1e3bb..184607e6 100644 --- a/dcalc/ArcDcalcWaveforms.cc +++ b/dcalc/ArcDcalcWaveforms.cc @@ -22,16 +22,16 @@ // // This notice may not be removed or altered from any source distribution. -#include - #include "ArcDcalcWaveforms.hh" -#include "Report.hh" +#include + +#include "ArcDelayCalc.hh" +#include "Graph.hh" +#include "GraphDelayCalc.hh" #include "Liberty.hh" #include "Network.hh" -#include "Graph.hh" -#include "ArcDelayCalc.hh" -#include "GraphDelayCalc.hh" +#include "Report.hh" namespace sta { @@ -83,4 +83,4 @@ ArcDcalcWaveforms::inputWaveform(ArcDcalcArg &dcalc_arg, return Waveform(); } -} // namespace +} // namespace sta diff --git a/dcalc/ArcDcalcWaveforms.hh b/dcalc/ArcDcalcWaveforms.hh index 8c9964b9..8b84f72f 100644 --- a/dcalc/ArcDcalcWaveforms.hh +++ b/dcalc/ArcDcalcWaveforms.hh @@ -51,5 +51,5 @@ protected: const StaState *sta); }; -} // namespace +} // namespace sta diff --git a/dcalc/ArcDelayCalc.cc b/dcalc/ArcDelayCalc.cc index a2a1ad0e..b615ca47 100644 --- a/dcalc/ArcDelayCalc.cc +++ b/dcalc/ArcDelayCalc.cc @@ -27,12 +27,12 @@ #include #include -#include "StringUtil.hh" -#include "Units.hh" -#include "Liberty.hh" -#include "TimingArc.hh" -#include "Network.hh" #include "Graph.hh" +#include "Liberty.hh" +#include "Network.hh" +#include "StringUtil.hh" +#include "TimingArc.hh" +#include "Units.hh" namespace sta { @@ -135,7 +135,7 @@ ArcDcalcArg::ArcDcalcArg(const Pin *in_pin, const Pin *drvr_pin, Edge *edge, const TimingArc *arc, - const Slew in_slew, + Slew in_slew, float load_cap, const Parasitic *parasitic) : in_pin_(in_pin), @@ -165,17 +165,7 @@ ArcDcalcArg::ArcDcalcArg(const Pin *in_pin, { } -ArcDcalcArg::ArcDcalcArg(const ArcDcalcArg &arg) : - in_pin_(arg.in_pin_), - drvr_pin_(arg.drvr_pin_), - edge_(arg.edge_), - arc_(arg.arc_), - in_slew_(arg.in_slew_), - load_cap_(arg.load_cap_), - parasitic_(arg.parasitic_), - input_delay_(arg.input_delay_) -{ -} +ArcDcalcArg::ArcDcalcArg(const ArcDcalcArg &arg) = default; const RiseFall * ArcDcalcArg::inEdge() const @@ -305,4 +295,4 @@ ArcDcalcResult::setLoadSlew(size_t load_idx, load_slews_[load_idx] = load_slew; } -} // namespace +} // namespace sta diff --git a/dcalc/Arnoldi.hh b/dcalc/Arnoldi.hh index 51453bd6..ccfbb002 100644 --- a/dcalc/Arnoldi.hh +++ b/dcalc/Arnoldi.hh @@ -45,7 +45,7 @@ class arnoldi1 public: arnoldi1() { order=0; n=0; d=nullptr; e=nullptr; U=nullptr; ctot=0.0; sqc=0.0; } ~arnoldi1(); - double elmore(int term_index); + double elmore(int k); // // calculate poles/residues for given rdrive @@ -70,12 +70,12 @@ class rcmodel : public ConcreteParasitic, { public: rcmodel(); - virtual ~rcmodel(); - virtual float capacitance() const; - virtual PinSet unannotatedLoads(const Pin *drvr_pin, - const Parasitics *parasitics) const; + ~rcmodel() override; + float capacitance() const override; + PinSet unannotatedLoads(const Pin *drvr_pin, + const Parasitics *parasitics) const override; - const Pin **pinV; // [n] + const Pin **pinV{nullptr}; // [n] }; struct timing_table @@ -86,4 +86,4 @@ struct timing_table float in_slew; }; -} // namespace +} // namespace sta diff --git a/dcalc/ArnoldiDelayCalc.cc b/dcalc/ArnoldiDelayCalc.cc index 2523686e..502a73eb 100644 --- a/dcalc/ArnoldiDelayCalc.cc +++ b/dcalc/ArnoldiDelayCalc.cc @@ -28,30 +28,34 @@ #include "ArnoldiDelayCalc.hh" -#include +#include #include // abs +#include +#include +#include -#include "Report.hh" -#include "Debug.hh" -#include "Units.hh" -#include "Liberty.hh" -#include "TimingModel.hh" -#include "TimingArc.hh" -#include "TableModel.hh" -#include "PortDirection.hh" -#include "Network.hh" -#include "Graph.hh" -#include "Parasitics.hh" -#include "Sdc.hh" -#include "DelayCalc.hh" #include "ArcDelayCalc.hh" -#include "LumpedCapDelayCalc.hh" -#include "GraphDelayCalc.hh" -#include "Variables.hh" #include "Arnoldi.hh" #include "ArnoldiReduce.hh" +#include "Debug.hh" +#include "DelayCalc.hh" +#include "Graph.hh" +#include "GraphDelayCalc.hh" +#include "Liberty.hh" +#include "LumpedCapDelayCalc.hh" +#include "Network.hh" +#include "Parasitics.hh" +#include "PortDirection.hh" +#include "Report.hh" +#include "Sdc.hh" +#include "TableModel.hh" +#include "TimingArc.hh" +#include "TimingModel.hh" +#include "Units.hh" +#include "Variables.hh" namespace sta { +// NOLINTBEGIN(modernize-avoid-c-style-cast) // wireload8 is n^2 // do not delete arnoldi parasitics @@ -76,7 +80,11 @@ delay_work_get_residues(delay_work *D, int term_index); static bool -tridiagEV(int n,double *d,double *e,double *p,double **v); +tridiagEV(int n, + const double *din, + const double *ein, + double *d, + double **v); ////////////////////////////////////////////////////////////// @@ -229,7 +237,7 @@ private: double *c_x1, double *c_y1); - rcmodel *rcmodel_; + rcmodel *rcmodel_{nullptr}; int _pinNmax; double *_delayV; double *_slewV; @@ -246,7 +254,6 @@ makeArnoldiDelayCalc(StaState *sta) ArnoldiDelayCalc::ArnoldiDelayCalc(StaState *sta) : LumpedCapDelayCalc(sta), - rcmodel_(nullptr), reduce_(new ArnoldiReduce(sta)), delay_work_(delay_work_create()) { @@ -362,7 +369,7 @@ ArnoldiDelayCalc::inputPortDelay(const Pin *, for (int j=1;jelmore(j); - double wire_delay = 0.6931472*elmore; + double wire_delay = std::numbers::ln2 * elmore; double load_slew = in_slew + c_log*elmore/slew_derate; _delayV[j] = wire_delay; _slewV[j] = load_slew; @@ -487,7 +494,7 @@ ArnoldiDelayCalc::reportGateDelay(const Pin *drvr_pin, arnoldi1::~arnoldi1() { free(d); - free(U); + free(reinterpret_cast(U)); } double @@ -506,13 +513,16 @@ delay_work_create() int j; delay_work *D = (delay_work*)malloc(sizeof(delay_work)); D->nmax = 256; - D->resi = (double**)malloc(D->nmax*sizeof(double*)); - D->resi[0] = (double*)malloc(D->nmax*32*sizeof(double)); - for (j=1;jnmax;j++) D->resi[j] = D->resi[0] + j*32; - D->v[0] = (double*)malloc(32*32*sizeof(double)); - for (j=1;j<32;j++) D->v[j] = D->v[0] + j*32; - D->w[0] = (double*)malloc(32*D->nmax*sizeof(double)); - for (j=1;j<32;j++) D->w[j] = D->w[0] + j*D->nmax; + D->resi = (double**)malloc(static_cast(D->nmax) * sizeof(double *)); + D->resi[0] = (double*)malloc(static_cast(D->nmax) * 32u * sizeof(double)); + for (j=1;jnmax;j++) + D->resi[j] = D->resi[0] + static_cast(j) * 32; + D->v[0] = (double*)malloc(static_cast(32) * 32u * sizeof(double)); + for (j=1;j<32;j++) + D->v[j] = D->v[0] + static_cast(j) * 32; + D->w[0] = (double*)malloc(32u * static_cast(D->nmax) * sizeof(double)); + for (j=1;j<32;j++) + D->w[j] = D->w[0] + static_cast(j) * D->nmax; D->lo_thresh = 0.0; D->hi_thresh = 0.0; D->slew_derate = 0.0; @@ -535,7 +545,7 @@ static void delay_work_destroy(delay_work *D) { free(D->resi[0]); - free(D->resi); + free(reinterpret_cast(D->resi)); free(D->v[0]); free(D->w[0]); free(D); @@ -547,15 +557,17 @@ delay_work_alloc(delay_work *D,int n) if (n<=D->nmax) return; free(D->w[0]); free(D->resi[0]); - free(D->resi); + free(reinterpret_cast(D->resi)); D->nmax *= 2; - if (n > D->nmax) D->nmax = n; + D->nmax = std::max(n, D->nmax); int j; - D->resi = (double**)malloc(D->nmax*sizeof(double*)); - D->resi[0] = (double*)malloc(D->nmax*32*sizeof(double)); - for (j=1;jnmax;j++) D->resi[j] = D->resi[0] + j*32; - D->w[0] = (double*)malloc(32*D->nmax*sizeof(double)); - for (j=1;j<32;j++) D->w[j] = D->w[0] + j*D->nmax; + D->resi = (double**)malloc(static_cast(D->nmax) * sizeof(double *)); + D->resi[0] = (double*)malloc(static_cast(D->nmax) * 32u * sizeof(double)); + for (j=1;jnmax;j++) + D->resi[j] = D->resi[0] + static_cast(j) * 32; + D->w[0] = (double*)malloc(32u * static_cast(D->nmax) * sizeof(double)); + for (j=1;j<32;j++) + D->w[j] = D->w[0] + static_cast(j) * D->nmax; } void @@ -622,8 +634,7 @@ void arnoldi1::calculate_poles_res(delay_work *D, d[0] = dsave; for (h=0;h= 0.0) + if ((((rts-xh)*df-f)*((rts-x_lo)*df-f) >= 0.0) || (std::abs(2.0*f) > std::abs(dxold*df))) { dxold = dx; - dx = 0.5*(xh-xl); + dx = 0.5*(xh-x_lo); if (flast*f >0.0) { // 2 successive bisections in same direction, // accelerate - if (f<0.0) dx = 0.9348*(xh-xl); - else dx = 0.0625*(xh-xl); + if (f<0.0) dx = 0.9348*(xh-x_lo); + else dx = 0.0625*(xh-x_lo); } flast = f; - rts = xl+dx; - if (xl == rts) { + rts = x_lo+dx; + if (x_lo == rts) { return rts; } } else { @@ -849,13 +881,13 @@ solve_t_bracketed(double s,int order,double *p,double *rr, } get_dv(rts,s,order,p,rr,&f,&df); f -= val; if (f<0.0) - xl = rts; + x_lo = rts; else xh = rts; } if (std::abs(f)<1e-6) // 1uV return rts; - return 0.5*(xl+xh); + return 0.5*(x_lo+xh); } void @@ -949,8 +981,7 @@ ArnoldiDelayCalc::pr_solve3(double s, for (h=1;h0.3 && rr[h]>rr[0]) { h0 = h; break; } } double p0 = p[h0]; - if (p0>10e+9) // 1/10ns - p0=10e+9; + p0 = std::min(p0, 10e+9); // 1/10ns cap double ps,vs,ta,va; vs = 0.0; for (h=0;hvmid) { - tmin5 = tmin8 = ta; vmin5 = tmin8 = va; + tmin5 = ta; + tmin8 = ta; + vmin5 = va; ta += 0.7/p0; pr_get_v(ta,s,order,p,rr,&va); } @@ -1064,18 +1097,14 @@ ArnoldiDelayCalc::pr_solve3(double s, pr_get_v(ta,s,order,p,rr,&va); } tmax2 = ta; vmax2 = va; - if (va < vmid) { - tmax5 = ta; vmax5 = va; - } else while (va > vmid) { + while (va > vmid) { tmin5 = tmin8 = ta; vmin5 = vmin8 = va; ta += 1.0/p0; pr_get_v(ta,s,order,p,rr,&va); } tmax5 = ta; vmax5 = va; - if (va < vlo) { - tmax8 = ta; vmax8 = va; - } else while (va > vlo) { + while (va > vlo) { tmin8 = ta; vmin8 = va; ta += 1.0/p0; @@ -1248,11 +1277,12 @@ ArnoldiDelayCalc::ra_solve_for_s(delay_work *D, if (x <= x1) { y = y1 - 0.5*(x-x1); - if (y>1.0) y=1.0; + y = std::min(y, 1.0); } else { y = y1 - (x-x1)*(0.5 + 8*(x-x1)); - if (y0.0 && r<100e+3)) // 100khom @@ -1436,9 +1465,6 @@ ArnoldiDelayCalc::ar1_ceff_delay(delay_work *D, units_->timeUnit()->asString(tlox-thix)); } ceff = ctot; - tab->table->gateDelay(tab->pvt, tab->in_slew, ceff, df, sf); - t50_sy = delayAsFloat(df); - t50_sr = ra_solve_for_t(1.0/(r*ceff),s,0.5); // calculate s,r,mod -> t50_srmod, // then t50_srmod+t50_sy-t50_sr @@ -1488,4 +1514,5 @@ ArnoldiDelayCalc::ar1_ceff_delay(delay_work *D, } } -} // namespace +// NOLINTEND(modernize-avoid-c-style-cast) +} // namespace sta diff --git a/dcalc/ArnoldiDelayCalc.hh b/dcalc/ArnoldiDelayCalc.hh index de16171e..03441eeb 100644 --- a/dcalc/ArnoldiDelayCalc.hh +++ b/dcalc/ArnoldiDelayCalc.hh @@ -32,4 +32,4 @@ class StaState; ArcDelayCalc * makeArnoldiDelayCalc(StaState *sta); -} // namespace +} // namespace sta diff --git a/dcalc/ArnoldiReduce.cc b/dcalc/ArnoldiReduce.cc index 046e8e8d..236c01a6 100644 --- a/dcalc/ArnoldiReduce.cc +++ b/dcalc/ArnoldiReduce.cc @@ -28,19 +28,22 @@ #include "ArnoldiReduce.hh" -#include "Debug.hh" -#include "MinMax.hh" -#include "Sdc.hh" -#include "Network.hh" -#include "Units.hh" +#include + #include "Arnoldi.hh" +#include "Debug.hh" #include "Format.hh" +#include "MinMax.hh" +#include "Network.hh" +#include "Sdc.hh" +#include "Units.hh" #include "parasitics/ConcreteParasiticsPvt.hh" namespace sta { +// This is legacy C-style code. +// NOLINTBEGIN(modernize-avoid-c-style-cast, bugprone-multi-level-implicit-pointer-conversion, bugprone-implicit-widening-of-multiplication-result) -rcmodel::rcmodel() : - pinV(nullptr) +rcmodel::rcmodel() { } @@ -87,11 +90,7 @@ const int ArnoldiReduce::ts_point_count_incr_ = 1024; const int ArnoldiReduce::ts_edge_count_incr_ = 1024; ArnoldiReduce::ArnoldiReduce(StaState *sta) : - StaState(sta), - ts_pointNmax(1024), - ts_edgeNmax(1024), - termNmax(256), - dNmax(8) + StaState(sta) { ts_pointV = (ts_point *)malloc(ts_pointNmax * sizeof(ts_point)); ts_ordV = (int *)malloc(ts_pointNmax * sizeof(int)); @@ -351,14 +350,14 @@ ArnoldiReduce::makeRcmodelDfs(ts_point *pdrv) ts_point *p0 = ts_pointV; ts_point *pend = p0 + ts_pointN; for (p = p0; p != pend; p++) - p->visited = 0; + p->visited = false; ts_edge *e; ts_edge **stackV = ts_stackV; int stackN = 1; stackV[0] = e = pdrv->eV[0]; ts_orient(pdrv, e); - pdrv->visited = 1; + pdrv->visited = true; pdrv->in_edge = nullptr; pdrv->ts = 0; ts_ordV[0] = pdrv - p0; @@ -376,7 +375,7 @@ ArnoldiReduce::makeRcmodelDfs(ts_point *pdrv) } else { // try to descend - q->visited = 1; + q->visited = true; q->ts = ts_ordN++; ts_pordV[q->ts] = q; ts_ordV[q->ts] = q - p0; @@ -531,9 +530,7 @@ ArnoldiReduce::makeRcmodelFromTs() u0 = _u0; u1 = _u1; double sum, e1; - order = max_order; - if (n < order) - order = n; + order = std::min(n, max_order); par[0] = -1; r[0] = 0.0; @@ -682,4 +679,5 @@ ArnoldiReduce::makeRcmodelFromW() return mod; } +// NOLINTEND(modernize-avoid-c-style-cast, bugprone-multi-level-implicit-pointer-conversion, bugprone-implicit-widening-of-multiplication-result) } // namespace sta diff --git a/dcalc/ArnoldiReduce.hh b/dcalc/ArnoldiReduce.hh index aed95e52..16232d5c 100644 --- a/dcalc/ArnoldiReduce.hh +++ b/dcalc/ArnoldiReduce.hh @@ -52,7 +52,7 @@ class ArnoldiReduce : public StaState { public: ArnoldiReduce(StaState *sta); - ~ArnoldiReduce(); + ~ArnoldiReduce() override; rcmodel *reduceToArnoldi(Parasitic *parasitic, const Pin *drvr_pin, float coupling_cap_factor, @@ -86,11 +86,11 @@ protected: // rcWork ts_point *ts_pointV; int ts_pointN; - int ts_pointNmax; + int ts_pointNmax{1024}; static const int ts_point_count_incr_; ts_edge *ts_edgeV; int ts_edgeN; - int ts_edgeNmax; + int ts_edgeNmax{1024}; static const int ts_edge_count_incr_; ts_edge **ts_eV; ts_edge **ts_stackV; @@ -98,14 +98,14 @@ protected: ts_point **ts_pordV; int ts_ordN; - int termNmax; + int termNmax{256}; int termN; ts_point *pterm0; const Pin **pinV; // fixed order, offset from pterm0 int *termV; // from drv-ordered to fixed order int *outV; // from drv-ordered to ts_pordV - int dNmax; + int dNmax{8}; double *d; double *e; double *U0; @@ -120,4 +120,4 @@ protected: int order; }; -} // namespace +} // namespace sta diff --git a/dcalc/CcsCeffDelayCalc.cc b/dcalc/CcsCeffDelayCalc.cc index fec6f032..848ac227 100644 --- a/dcalc/CcsCeffDelayCalc.cc +++ b/dcalc/CcsCeffDelayCalc.cc @@ -24,19 +24,20 @@ #include "CcsCeffDelayCalc.hh" +#include #include #include "Debug.hh" -#include "Units.hh" -#include "Liberty.hh" -#include "TimingArc.hh" -#include "Network.hh" -#include "Graph.hh" -#include "Scene.hh" -#include "Parasitics.hh" -#include "GraphDelayCalc.hh" #include "DmpDelayCalc.hh" #include "FindRoot.hh" +#include "Graph.hh" +#include "GraphDelayCalc.hh" +#include "Liberty.hh" +#include "Network.hh" +#include "Parasitics.hh" +#include "Scene.hh" +#include "TimingArc.hh" +#include "Units.hh" namespace sta { @@ -53,10 +54,6 @@ makeCcsCeffDelayCalc(StaState *sta) CcsCeffDelayCalc::CcsCeffDelayCalc(StaState *sta) : LumpedCapDelayCalc(sta), - output_waveforms_(nullptr), - // Includes the Vh:Vdd region. - region_count_(0), - vl_fail_(false), watch_pin_values_(network_), capacitance_unit_(units_->capacitanceUnit()), table_dcalc_(makeDmpCeffElmoreDelayCalc(sta)) @@ -176,8 +173,8 @@ CcsCeffDelayCalc::gateDelaySlew(const LibertyLibrary *drvr_library, } for (size_t i = 0; i < region_count_; i++) { - double v1 = region_volts_[i]; - double v2 = region_volts_[i + 1]; + double seg_v1 = region_volts_[i]; + double seg_v2 = region_volts_[i + 1]; double t1 = region_times_[i]; double t2 = region_times_[i + 1]; @@ -186,11 +183,11 @@ CcsCeffDelayCalc::gateDelaySlew(const LibertyLibrary *drvr_library, // for the charge on c1 from previous segments so it does not // work well. double c1_v1, c1_v2, ignore; - vl(t1, rpi_ * c1_, c1_v1, ignore); - vl(t2, rpi_ * c1_, c1_v2, ignore); - double q1 = v1 * c2_ + c1_v1 * c1_; - double q2 = v2 * c2_ + c1_v2 * c1_; - double ceff = (q2 - q1) / (v2 - v1); + vLoad(t1, rpi_ * c1_, c1_v1, ignore); + vLoad(t2, rpi_ * c1_, c1_v2, ignore); + double q1 = seg_v1 * c2_ + c1_v1 * c1_; + double q2 = seg_v2 * c2_ + c1_v2 * c1_; + double ceff = (q2 - q1) / (seg_v2 - seg_v1); debugPrint(debug_, "ccs_dcalc", 2, "ceff {}", capacitance_unit_->asString(ceff)); @@ -297,7 +294,7 @@ CcsCeffDelayCalc::initRegions(const LibertyLibrary *drvr_library, report_->error(1701, "unsupported ccs region count."); break; } - fill(region_ceff_.begin(), region_ceff_.end(), c2_ + c1_); + std::ranges::fill(region_ceff_, c2_ + c1_); } void @@ -402,11 +399,11 @@ rampElmoreV(double t, // Elmore (one pole) response to 2 segment ramps [0, vth] slew1, [vth, vdd] slew2. void -CcsCeffDelayCalc::vl(double t, - double elmore, - // Return values. - double &vl, - double &dvl_dt) +CcsCeffDelayCalc::vLoad(double t, + double elmore, + // Return values. + double &vl, + double &dvl_dt) { vl = 0.0; dvl_dt = 0.0; @@ -431,11 +428,11 @@ CcsCeffDelayCalc::vl(double t, // for debugging double -CcsCeffDelayCalc::vl(double t, - double elmore) +CcsCeffDelayCalc::vLoad(double t, + double elmore) { double vl1, dvl_dt; - vl(t, elmore, vl1, dvl_dt); + vLoad(t, elmore, vl1, dvl_dt); return vl1; } @@ -447,7 +444,7 @@ CcsCeffDelayCalc::findVlTime(double v, double t_final = region_ramp_times_[region_count_]; auto [time, failed] = findRoot([&](double t, double &y, double &dy) { - vl(t, elmore, y, dy); + vLoad(t, elmore, y, dy); y -= v; }, t_init, t_final + elmore * 3.0, .001, 20); @@ -539,7 +536,7 @@ CcsCeffDelayCalc::loadWaveform(const Pin *load_pin) load_times->push_back(t); double ignore; - vl(t, elmore, v, ignore); + vLoad(t, elmore, v, ignore); double v1 = (drvr_rf_ == RiseFall::rise()) ? v : vdd_ - v; load_volts->push_back(v1); } diff --git a/dcalc/CcsCeffDelayCalc.hh b/dcalc/CcsCeffDelayCalc.hh index 665588f8..07a659b9 100644 --- a/dcalc/CcsCeffDelayCalc.hh +++ b/dcalc/CcsCeffDelayCalc.hh @@ -24,8 +24,8 @@ #pragma once -#include "LumpedCapDelayCalc.hh" #include "ArcDcalcWaveforms.hh" +#include "LumpedCapDelayCalc.hh" namespace sta { @@ -39,7 +39,7 @@ class CcsCeffDelayCalc : public LumpedCapDelayCalc, { public: CcsCeffDelayCalc(StaState *sta); - virtual ~CcsCeffDelayCalc(); + ~CcsCeffDelayCalc() override; ArcDelayCalc *copy() override; std::string_view name() const override { return "ccs_ceff"; } bool reduceSupported() const override { return true; } @@ -68,7 +68,7 @@ public: Waveform watchWaveform(const Pin *pin) override; protected: - typedef std::vector Region; + using Region = std::vector; void gateDelaySlew(const LibertyLibrary *drvr_library, // Return values. @@ -106,13 +106,13 @@ protected: const Pin *load_pin, const Scene *scene, const MinMax *min_max); - void vl(double t, - double elmore, - // Return values. - double &vl, - double &dvl_dt); - double vl(double t, - double elmore); + void vLoad(double t, + double elmore, + // Return values. + double &vl, + double &dvl_dt); + double vLoad(double t, + double elmore); void fail(std::string_view reason); const Pin *drvr_pin_; @@ -122,7 +122,7 @@ protected: Parasitics *parasitics_; const Parasitic *parasitic_; - OutputWaveforms *output_waveforms_; + OutputWaveforms *output_waveforms_{nullptr}; double ref_time_; float vdd_; float vth_; @@ -133,7 +133,7 @@ protected: float rpi_; float c1_; - size_t region_count_; + size_t region_count_{0}; size_t region_vl_idx_; size_t region_vth_idx_; size_t region_vh_idx_; @@ -146,7 +146,7 @@ protected: Region region_time_offsets_; Region region_ramp_times_; Region region_ramp_slopes_; - bool vl_fail_; + bool vl_fail_{false}; // Waveform recording. WatchPinValuesMap watch_pin_values_; @@ -155,4 +155,4 @@ protected: ArcDelayCalc *table_dcalc_; }; -} // namespace +} // namespace sta diff --git a/dcalc/Delay.cc b/dcalc/Delay.cc index 48c867a3..295cd453 100644 --- a/dcalc/Delay.cc +++ b/dcalc/Delay.cc @@ -1,5 +1,5 @@ // OpenSTA, Static Timing Analyzer -// Copyright (c) 2025, Parallax Software, Inc. +// Copyright (c) 2026, 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 @@ -26,10 +26,10 @@ #include -#include "StaConfig.hh" #include "Fuzzy.hh" -#include "Units.hh" +#include "StaConfig.hh" #include "StaState.hh" +#include "Units.hh" #include "Variables.hh" namespace sta { @@ -43,18 +43,18 @@ initDelayConstants() delay_init_values[MinMax::maxIndex()] = MinMax::max()->initValue(); } -Delay::Delay() : +Delay::Delay() noexcept : values_{0.0, 0.0, 0.0, 0.0} { } -Delay::Delay(float mean) : +Delay::Delay(float mean) noexcept : values_{mean, 0.0, 0.0, 0.0} { } Delay::Delay(float mean, - float std_dev2) : + float std_dev2) noexcept : values_{mean, 0.0, std_dev2, 0.0} { } @@ -62,18 +62,19 @@ Delay::Delay(float mean, Delay::Delay(float mean, float mean_shift, float std_dev2, - float skewness) : + float skewness) noexcept : values_{mean, mean_shift, std_dev2, skewness} { } -void +Delay & Delay::operator=(float delay) { values_[0] = delay; values_[1] = 0.0; values_[2] = 0.0; values_[3] = 0.0; + return *this; } void @@ -126,12 +127,12 @@ Delay::setSkewness(float skewness) //////////////////////////////////////////////////////////////// -DelayDbl::DelayDbl() : +DelayDbl::DelayDbl() noexcept : values_{0.0, 0.0, 0.0, 0.0} { } -DelayDbl::DelayDbl(double mean) : +DelayDbl::DelayDbl(double mean) noexcept : values_{mean, 0.0, 0.0, 0.0} { } @@ -166,13 +167,14 @@ DelayDbl::setValues(double mean, values_[3] = skewnes; } -void +DelayDbl & DelayDbl::operator=(double delay) { values_[0] = delay; values_[1] = 0.0; values_[2] = 0.0; values_[3] = 0.0; + return *this; } //////////////////////////////////////////////////////////////// @@ -520,4 +522,4 @@ delayStdDev2(const Delay &delay, return sta->delayOps()->stdDev2(delay, early_late); } -} // namespace +} // namespace sta diff --git a/dcalc/DelayCalc.cc b/dcalc/DelayCalc.cc index 614ff610..2b8fc826 100644 --- a/dcalc/DelayCalc.cc +++ b/dcalc/DelayCalc.cc @@ -27,18 +27,18 @@ #include #include -#include "ContainerHelpers.hh" -#include "StringUtil.hh" -#include "UnitDelayCalc.hh" -#include "LumpedCapDelayCalc.hh" -#include "DmpDelayCalc.hh" #include "ArnoldiDelayCalc.hh" #include "CcsCeffDelayCalc.hh" +#include "ContainerHelpers.hh" +#include "DmpDelayCalc.hh" +#include "LumpedCapDelayCalc.hh" #include "PrimaDelayCalc.hh" +#include "StringUtil.hh" +#include "UnitDelayCalc.hh" namespace sta { -typedef std::map> DelayCalcMap; +using DelayCalcMap = std::map>; static DelayCalcMap delay_calcs; @@ -93,4 +93,4 @@ delayCalcNames() return names; } -} // namespace +} // namespace sta diff --git a/dcalc/DelayCalc.i b/dcalc/DelayCalc.i index 992ecade..9aaa3f3f 100644 --- a/dcalc/DelayCalc.i +++ b/dcalc/DelayCalc.i @@ -28,11 +28,11 @@ %{ -#include "DelayCalc.hh" #include "ArcDelayCalc.hh" +#include "DelayCalc.hh" +#include "Sta.hh" #include "dcalc/ArcDcalcWaveforms.hh" #include "dcalc/PrimaDelayCalc.hh" -#include "Sta.hh" %} diff --git a/dcalc/DelayCalcBase.cc b/dcalc/DelayCalcBase.cc index 71e2f116..214aec7d 100644 --- a/dcalc/DelayCalcBase.cc +++ b/dcalc/DelayCalcBase.cc @@ -24,16 +24,16 @@ #include "DelayCalcBase.hh" +#include "Graph.hh" +#include "GraphDelayCalc.hh" #include "Liberty.hh" -#include "TimingArc.hh" -#include "TimingModel.hh" -#include "TableModel.hh" #include "Network.hh" #include "Parasitics.hh" -#include "Graph.hh" -#include "Sdc.hh" #include "Scene.hh" -#include "GraphDelayCalc.hh" +#include "Sdc.hh" +#include "TableModel.hh" +#include "TimingArc.hh" +#include "TimingModel.hh" #include "Variables.hh" namespace sta { @@ -239,4 +239,4 @@ DelayCalcBase::setDcalcArgParasiticSlew(ArcDcalcArgSeq &gates, setDcalcArgParasiticSlew(gate, scene, min_max); } -} // namespace +} // namespace sta diff --git a/dcalc/DelayCalcBase.hh b/dcalc/DelayCalcBase.hh index da69ed1b..a2d4666b 100644 --- a/dcalc/DelayCalcBase.hh +++ b/dcalc/DelayCalcBase.hh @@ -72,7 +72,7 @@ protected: void thresholdAdjust(const Pin *load_pin, const LibertyLibrary *drvr_library, const RiseFall *rf, - double &load_delay, + double &wire_delay, double &load_slew); // Helper function for input ports driving dspf parasitic. void dspfWireDelaySlew(const Pin *load_pin, @@ -89,4 +89,4 @@ protected: using ArcDelayCalc::reduceParasitic; }; -} // namespace +} // namespace sta diff --git a/dcalc/DelayNormal.cc b/dcalc/DelayNormal.cc index 2c3cb059..c73de069 100644 --- a/dcalc/DelayNormal.cc +++ b/dcalc/DelayNormal.cc @@ -1,5 +1,5 @@ // OpenSTA, Static Timing Analyzer -// Copyright (c) 2025, Parallax Software, Inc. +// Copyright (c) 2026, 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 @@ -27,10 +27,10 @@ #include // sqrt #include "Error.hh" -#include "Fuzzy.hh" -#include "Units.hh" #include "Format.hh" +#include "Fuzzy.hh" #include "StaState.hh" +#include "Units.hh" #include "Variables.hh" namespace sta { @@ -229,4 +229,4 @@ DelayOpsNormal::asStringVariance(const Delay &delay, unit->asString(delay.stdDev(), digits)); } -} // namespace +} // namespace sta diff --git a/dcalc/DelayScalar.cc b/dcalc/DelayScalar.cc index 6ad49178..0ec8543e 100644 --- a/dcalc/DelayScalar.cc +++ b/dcalc/DelayScalar.cc @@ -1,5 +1,5 @@ // OpenSTA, Static Timing Analyzer -// Copyright (c) 2025, Parallax Software, Inc. +// Copyright (c) 2026, 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 @@ -27,8 +27,8 @@ #include "DelayScalar.hh" #include "Fuzzy.hh" -#include "Units.hh" #include "StaState.hh" +#include "Units.hh" namespace sta { @@ -202,5 +202,5 @@ DelayOpsScalar::asStringVariance(const Delay &delay, return unit->asString(delay.mean(), digits); } -} // namespace +} // namespace sta diff --git a/dcalc/DelaySkewNormal.cc b/dcalc/DelaySkewNormal.cc index 306634ba..7e492a03 100644 --- a/dcalc/DelaySkewNormal.cc +++ b/dcalc/DelaySkewNormal.cc @@ -1,5 +1,5 @@ // OpenSTA, Static Timing Analyzer -// Copyright (c) 2025, Parallax Software, Inc. +// Copyright (c) 2026, 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 @@ -27,10 +27,10 @@ #include // sqrt #include "Error.hh" -#include "Fuzzy.hh" -#include "Units.hh" #include "Format.hh" +#include "Fuzzy.hh" #include "StaState.hh" +#include "Units.hh" #include "Variables.hh" namespace sta { @@ -290,4 +290,4 @@ DelayOpsSkewNormal::asStringVariance(const Delay &delay, sta->units()->scalarUnit()->asString(delay.skewness(), digits)); } -} // namespace +} // namespace sta diff --git a/dcalc/DmpCeff.cc b/dcalc/DmpCeff.cc index 108bf798..7ce3e903 100644 --- a/dcalc/DmpCeff.cc +++ b/dcalc/DmpCeff.cc @@ -40,17 +40,17 @@ #include #include -#include "Format.hh" -#include "Report.hh" -#include "Debug.hh" -#include "Units.hh" -#include "TimingArc.hh" -#include "TableModel.hh" -#include "Liberty.hh" -#include "Sdc.hh" -#include "Parasitics.hh" #include "ArcDelayCalc.hh" +#include "Debug.hh" #include "FindRoot.hh" +#include "Format.hh" +#include "Liberty.hh" +#include "Parasitics.hh" +#include "Report.hh" +#include "Sdc.hh" +#include "TableModel.hh" +#include "TimingArc.hh" +#include "Units.hh" #include "Variables.hh" namespace sta { @@ -72,7 +72,7 @@ class DmpError : public Exception { public: DmpError(std::string_view what); - virtual const char *what() const noexcept { return what_.c_str(); } + const char *what() const noexcept override { return what_.c_str(); } private: std::string what_; @@ -127,7 +127,7 @@ protected: void newtonRaphson(); // Find driver parameters t0, delta_t, Ceff. void findDriverParams(double ceff); - std::pair gateCapDelaySlew(double cl); + std::pair gateCapDelaySlew(double ceff); std::tuple gateDelays(double ceff); // Partial derivatives of y(t) jacobian (dydt0, dyddt, dydcl). std::tuple dy(double t, @@ -143,12 +143,12 @@ protected: void showJacobian(); std::pair findDriverDelaySlew(); double findVoCrossing(double vth, - double lower_bound, - double upper_bound); + double t_lower, + double t_upper); void showVo(); double findVlCrossing(double vth, - double lower_bound, - double upper_bound); + double t_lower, + double t_upper); void showVl(); void fail(std::string_view reason); @@ -177,9 +177,9 @@ protected: const Pvt *pvt_; const GateTableModel *gate_model_; double in_slew_; - double c2_; - double rpi_; - double c1_; + double c2_{0.0}; + double rpi_{0.0}; + double c1_{0.0}; double rd_; // Logic threshold (percentage of supply voltage). @@ -232,9 +232,6 @@ protected: DmpAlg::DmpAlg(int nr_order, StaState *sta) : StaState(sta), - c2_(0.0), - rpi_(0.0), - c1_(0.0), nr_order_(nr_order) { } @@ -465,8 +462,13 @@ DmpAlg::showVo() { report_->report(" t vo(t)"); double ub = voCrossingUpperBound(); - for (double t = t0_; t < t0_ + ub; t += dt_ / 10.0) + const double step = dt_ / 10.0; + for (int i = 0;; ++i) { + double t = t0_ + step * i; + if (!(t < t0_ + ub)) + break; report_->report(" {:g} {:g}", t, Vo(t).first); + } } std::pair @@ -567,8 +569,14 @@ DmpAlg::showVl() { report_->report(" t vl(t)"); double ub = vlCrossingUpperBound(); - for (double t = t0_; t < t0_ + ub * 2.0; t += ub / 10.0) + const double step = ub / 10.0; + const double t_end = t0_ + ub * 2.0; + for (int i = 0;; ++i) { + double t = t0_ + step * i; + if (!(t < t_end)) + break; report_->report(" {:g} {:g}", t, Vl(t).first); + } } void @@ -605,9 +613,9 @@ public: std::pair loadDelaySlew(const Pin *, double elmore) override; void evalDmpEqns() override; - double voCrossingUpperBound() override; -private: +protected: + double voCrossingUpperBound() override; std::pair V0(double t) override; std::pair Vl0(double t) override; }; @@ -702,7 +710,11 @@ public: double c1) override; std::pair gateDelaySlew() override; void evalDmpEqns() override; + +protected: double voCrossingUpperBound() override; + std::pair V0(double t) override; + std::pair Vl0(double t) override; private: void findDriverParamsPi(); @@ -710,39 +722,26 @@ private: double dt, double ceff_time, double ceff); - std::pair V0(double t) override; - std::pair Vl0(double t) override; // Poles/zero. - double p1_; - double p2_; - double z1_; + double p1_{0.0}; + double p2_{0.0}; + double z1_{0.0}; // Residues. - double k0_; - double k1_; - double k2_; - double k3_; - double k4_; + double k0_{0.0}; + double k1_{0.0}; + double k2_{0.0}; + double k3_{0.0}; + double k4_{0.0}; // Ipi coefficients. - double A_; - double B_; - double D_; + double A_{0.0}; + double B_{0.0}; + double D_{0.0}; }; DmpPi::DmpPi(StaState *sta) : DmpAlg(3, - sta), - p1_(0.0), - p2_(0.0), - z1_(0.0), - k0_(0.0), - k1_(0.0), - k2_(0.0), - k3_(0.0), - k4_(0.0), - A_(0.0), - B_(0.0), - D_(0.0) + sta) { } @@ -846,8 +845,7 @@ DmpPi::evalDmpEqns() throw DmpError("eqn eval failed: slew = 0"); double ceff_time = slew / (vh_ - vl_); - if (ceff_time > 1.4 * dt) - ceff_time = 1.4 * dt; + ceff_time = std::min(ceff_time, 1.4 * dt); if (dt <= 0.0) throw DmpError("eqn eval failed: dt < 0"); @@ -949,6 +947,8 @@ class DmpOnePole : public DmpAlg public: DmpOnePole(StaState *sta); void evalDmpEqns() override; + +protected: double voCrossingUpperBound() override; }; @@ -1018,29 +1018,24 @@ public: double c1) override; std::pair gateDelaySlew() override; -private: +protected: std::pair V0(double t) override; std::pair Vl0(double t) override; double voCrossingUpperBound() override; +private: // Pole/zero. - double p1_; - double z1_; + double p1_{0.0}; + double z1_{0.0}; // Residues. - double k0_; - double k1_; - double k2_; - double k3_; + double k0_{0.0}; + double k1_{0.0}; + double k2_{0.0}; + double k3_{0.0}; }; DmpZeroC2::DmpZeroC2(StaState *sta) : - DmpOnePole(sta), - p1_(0.0), - z1_(0.0), - k0_(0.0), - k1_(0.0), - k2_(0.0), - k3_(0.0) + DmpOnePole(sta) { } @@ -1172,8 +1167,7 @@ DmpAlg::luDecomp() double big = 0.0; for (int j = 0; j < size; j++) { double temp = std::abs(fjac_[i][j]); - if (temp > big) - big = temp; + big = std::max(temp, big); } if (big == 0.0) throw DmpError("LU decomposition: no non-zero row element"); @@ -1268,8 +1262,7 @@ DmpCeffDelayCalc::DmpCeffDelayCalc(StaState *sta) : LumpedCapDelayCalc(sta), dmp_cap_(new DmpCap(sta)), dmp_pi_(new DmpPi(sta)), - dmp_zero_c2_(new DmpZeroC2(sta)), - dmp_alg_(nullptr) + dmp_zero_c2_(new DmpZeroC2(sta)) { } diff --git a/dcalc/DmpCeff.hh b/dcalc/DmpCeff.hh index 065a0026..1ca6209e 100644 --- a/dcalc/DmpCeff.hh +++ b/dcalc/DmpCeff.hh @@ -44,7 +44,7 @@ class DmpCeffDelayCalc : public LumpedCapDelayCalc { public: DmpCeffDelayCalc(StaState *sta); - virtual ~DmpCeffDelayCalc(); + ~DmpCeffDelayCalc() override; bool reduceSupported() const override { return true; } ArcDcalcResult gateDelay(const Pin *drvr_pin, const TimingArc *arc, @@ -98,7 +98,7 @@ private: DmpCap *dmp_cap_; DmpPi *dmp_pi_; DmpZeroC2 *dmp_zero_c2_; - DmpAlg *dmp_alg_; + DmpAlg *dmp_alg_{nullptr}; }; -} // namespace +} // namespace sta diff --git a/dcalc/DmpDelayCalc.cc b/dcalc/DmpDelayCalc.cc index d89b319d..f94d2086 100644 --- a/dcalc/DmpDelayCalc.cc +++ b/dcalc/DmpDelayCalc.cc @@ -24,15 +24,15 @@ #include "DmpDelayCalc.hh" +#include "DmpCeff.hh" +#include "GraphDelayCalc.hh" +#include "Liberty.hh" +#include "Network.hh" +#include "Parasitics.hh" +#include "PortDirection.hh" +#include "Sdc.hh" #include "TableModel.hh" #include "TimingArc.hh" -#include "Liberty.hh" -#include "PortDirection.hh" -#include "Network.hh" -#include "Sdc.hh" -#include "Parasitics.hh" -#include "GraphDelayCalc.hh" -#include "DmpCeff.hh" namespace sta { @@ -164,7 +164,7 @@ public: const Scene *scene, const MinMax *min_max) override; -private: +protected: void loadDelaySlew(const Pin *load_pin, double drvr_slew, const RiseFall *rf, @@ -173,6 +173,8 @@ private: // Return values. double &wire_delay, double &load_slew) override; + +private: void loadDelay(double drvr_slew, Parasitic *pole_residue, double p1, @@ -190,11 +192,11 @@ private: double tt, double y_tt); - bool parasitic_is_pole_residue_; - float vth_; - float vl_; - float vh_; - float slew_derate_; + bool parasitic_is_pole_residue_{false}; + float vth_{0.0F}; + float vl_{0.0F}; + float vh_{0.0F}; + float slew_derate_{0.0F}; }; ArcDelayCalc * @@ -204,12 +206,7 @@ makeDmpCeffTwoPoleDelayCalc(StaState *sta) } DmpCeffTwoPoleDelayCalc::DmpCeffTwoPoleDelayCalc(StaState *sta) : - DmpCeffDelayCalc(sta), - parasitic_is_pole_residue_(false), - vth_(0.0), - vl_(0.0), - vh_(0.0), - slew_derate_(0.0) + DmpCeffDelayCalc(sta) { } @@ -334,7 +331,7 @@ DmpCeffTwoPoleDelayCalc::loadDelaySlew(const Pin *load_pin, // Should handle PiElmore parasitic. wire_delay = 0.0; load_slew = drvr_slew; - Parasitic *pole_residue = 0; + Parasitic *pole_residue = nullptr; if (parasitic_is_pole_residue_) pole_residue = parasitics_->findPoleResidue(parasitic, load_pin); if (pole_residue) { @@ -436,4 +433,4 @@ DmpCeffTwoPoleDelayCalc::loadDelay(double vth, } } -} // namespace +} // namespace sta diff --git a/dcalc/DmpDelayCalc.hh b/dcalc/DmpDelayCalc.hh index 34ecbd7b..518d7818 100644 --- a/dcalc/DmpDelayCalc.hh +++ b/dcalc/DmpDelayCalc.hh @@ -34,4 +34,4 @@ makeDmpCeffElmoreDelayCalc(StaState *sta); ArcDelayCalc * makeDmpCeffTwoPoleDelayCalc(StaState *sta); -} // namespace +} // namespace sta diff --git a/dcalc/FindRoot.cc b/dcalc/FindRoot.cc index 5ca987df..58e8dde8 100644 --- a/dcalc/FindRoot.cc +++ b/dcalc/FindRoot.cc @@ -29,7 +29,7 @@ namespace sta { std::pair -findRoot(FindRootFunc func, +findRoot(const FindRootFunc &func, double x1, double x2, double x_tol, @@ -42,7 +42,7 @@ findRoot(FindRootFunc func, } std::pair -findRoot(FindRootFunc func, +findRoot(const FindRootFunc &func, double x1, double y1, double x2, @@ -98,4 +98,4 @@ findRoot(FindRootFunc func, return {root, true}; } -} // namespace +} // namespace sta diff --git a/dcalc/FindRoot.hh b/dcalc/FindRoot.hh index ab35ab4e..61daac86 100644 --- a/dcalc/FindRoot.hh +++ b/dcalc/FindRoot.hh @@ -36,7 +36,7 @@ using FindRootFunc = const std::function -findRoot(FindRootFunc func, +findRoot(const FindRootFunc &func, double x1, double x2, double x_tol, @@ -44,7 +44,7 @@ findRoot(FindRootFunc func, // first: root estimate; second: true if the search failed. std::pair -findRoot(FindRootFunc func, +findRoot(const FindRootFunc &func, double x1, double y1, double x2, @@ -52,4 +52,4 @@ findRoot(FindRootFunc func, double x_tol, int max_iter); -} // namespace +} // namespace sta diff --git a/dcalc/GraphDelayCalc.cc b/dcalc/GraphDelayCalc.cc index 67536ef0..741353bf 100644 --- a/dcalc/GraphDelayCalc.cc +++ b/dcalc/GraphDelayCalc.cc @@ -24,35 +24,35 @@ #include "GraphDelayCalc.hh" -#include #include +#include #include #include +#include "ArcDelayCalc.hh" +#include "Bfs.hh" +#include "ClkNetwork.hh" #include "ContainerHelpers.hh" #include "Debug.hh" -#include "Stats.hh" -#include "MinMax.hh" -#include "Mutex.hh" -#include "TimingRole.hh" -#include "TimingArc.hh" -#include "Liberty.hh" -#include "PortDirection.hh" -#include "Network.hh" -#include "InputDrive.hh" -#include "Sdc.hh" -#include "Mode.hh" #include "Graph.hh" +#include "InputDrive.hh" +#include "Liberty.hh" +#include "MinMax.hh" +#include "Mode.hh" +#include "Mutex.hh" +#include "NetCaps.hh" +#include "Network.hh" #include "Parasitics.hh" -#include "search/Levelize.hh" +#include "PortDirection.hh" +#include "Sdc.hh" #include "Scene.hh" #include "SearchPred.hh" -#include "Bfs.hh" -#include "ArcDelayCalc.hh" -#include "NetCaps.hh" -#include "ClkNetwork.hh" +#include "Stats.hh" +#include "TimingArc.hh" +#include "TimingRole.hh" #include "Variables.hh" #include "search/Latches.hh" +#include "search/Levelize.hh" namespace sta { @@ -143,15 +143,10 @@ DcalcNonLatchPred::searchThru(Edge *edge, GraphDelayCalc::GraphDelayCalc(StaState *sta) : StaState(sta), - observer_(nullptr), - delays_seeded_(false), - incremental_(false), - delays_exist_(false), invalid_delays_(makeVertexSet(this)), search_pred_(new DcalcPred(sta)), search_non_latch_pred_(new DcalcNonLatchPred(sta)), - iter_(new BfsFwdIterator(BfsIndex::dcalc, search_non_latch_pred_, sta)), - incremental_delay_tolerance_(0.0) + iter_(new BfsFwdIterator(BfsIndex::dcalc, search_non_latch_pred_, sta)) { } @@ -297,9 +292,9 @@ class FindVertexDelays : public VertexVisitor { public: FindVertexDelays(GraphDelayCalc *graph_delay_calc1); - virtual ~FindVertexDelays(); - virtual void visit(Vertex *vertex); - virtual VertexVisitor *copy() const; + ~FindVertexDelays() override; + void visit(Vertex *vertex) override; + VertexVisitor *copy() const override; protected: GraphDelayCalc *graph_delay_calc_; @@ -419,7 +414,7 @@ GraphDelayCalc::seedDrvrSlew(Vertex *drvr_vertex, if (drive) { const LibertyCell *drvr_cell; const LibertyPort *from_port, *to_port; - float *from_slews; + const DriveCellSlews *from_slews; drive->driveCell(rf, min_max, drvr_cell, from_port, from_slews, to_port); if (drvr_cell) { @@ -562,7 +557,7 @@ LibertyPort * GraphDelayCalc::driveCellDefaultFromPort(const LibertyCell *cell, const LibertyPort *to_port) { - LibertyPort *from_port = 0; + LibertyPort *from_port = nullptr; int from_port_index = 0; for (TimingArcSet *arc_set : cell->timingArcSetsTo(to_port)) { LibertyPort *set_from_port = arc_set->from(); @@ -599,7 +594,7 @@ GraphDelayCalc::findInputDriverDelay(const LibertyCell *drvr_cell, Vertex *drvr_vertex, const RiseFall *rf, const LibertyPort *from_port, - float *from_slews, + const DriveCellSlews *from_slews, const LibertyPort *to_port, const Scene *scene, const MinMax *min_max, @@ -611,7 +606,7 @@ GraphDelayCalc::findInputDriverDelay(const LibertyCell *drvr_cell, for (TimingArcSet *arc_set : drvr_cell->timingArcSets(from_port, to_port)) { for (TimingArc *arc : arc_set->arcs()) { if (arc->toEdge()->asRiseFall() == rf) { - float from_slew = from_slews[arc->fromEdge()->index()]; + float from_slew = (*from_slews)[arc->fromEdge()->index()]; findInputArcDelay(drvr_pin, drvr_vertex, arc, from_slew, scene, min_max, arc_delay_calc); } @@ -1270,19 +1265,19 @@ GraphDelayCalc::annotateLoadDelays(Vertex *drvr_vertex, bool load_changed = false; if (!load_vertex->slewAnnotated(drvr_rf, min_max)) { if (drvr_vertex->slewAnnotated(drvr_rf, min_max)) { - // Copy the driver slew to the load if it is annotated. - const Slew drvr_slew = graph_->slew(drvr_vertex,drvr_rf,ap_index); - graph_->setSlew(load_vertex, drvr_rf, ap_index, drvr_slew); + // Copy the driver slew to the load if it is annotated. + const Slew drvr_slew = graph_->slew(drvr_vertex, drvr_rf, ap_index); + graph_->setSlew(load_vertex, drvr_rf, ap_index, drvr_slew); load_changed = true; - } - else { - const Slew slew = graph_->slew(load_vertex, drvr_rf, ap_index); - if (!merge + } + else { + const Slew slew = graph_->slew(load_vertex, drvr_rf, ap_index); + if (!merge || delayGreater(load_slew, slew, min_max, this)) { - graph_->setSlew(load_vertex, drvr_rf, ap_index, load_slew); + graph_->setSlew(load_vertex, drvr_rf, ap_index, load_slew); load_changed = true; } - } + } } if (!graph_->wireDelayAnnotated(wire_edge, drvr_rf, ap_index)) { // Multiple timing arcs with the same output transition @@ -1594,9 +1589,9 @@ GraphDelayCalc::findCheckEdgeDelays(Edge *edge, const RiseFall *to_rf = arc->toEdge()->asRiseFall(); if (from_rf && to_rf) { const LibertyPort *related_out_port = arc_set->relatedOut(); - const Pin *related_out_pin = 0; + const Pin *related_out_pin = nullptr; if (related_out_port) - related_out_pin = network_->findPin(inst, related_out_port); + related_out_pin = network_->findPin(inst, related_out_port); for (Scene *scene : scenes_) { for (const MinMax *min_max : MinMax::range()) { @@ -1677,7 +1672,7 @@ GraphDelayCalc::reportDelayCalc(const Edge *edge, const RiseFall *to_rf = arc->toEdge()->asRiseFall(); if (from_rf && to_rf) { const LibertyPort *related_out_port = arc_set->relatedOut(); - const Pin *related_out_pin = 0; + const Pin *related_out_pin = nullptr; if (related_out_port) related_out_pin = network_->findPin(inst, related_out_port); float related_out_cap = 0.0; @@ -1767,11 +1762,6 @@ GraphDelayCalc::minPeriod(const Pin *pin, //////////////////////////////////////////////////////////////// -MultiDrvrNet::MultiDrvrNet() : - dcalc_drvr_(nullptr) -{ -} - void MultiDrvrNet::netCaps(const RiseFall *drvr_rf, const Scene *scene, @@ -1828,4 +1818,4 @@ MultiDrvrNet::parallelGates(const Network *network) const return network->direction(dcalc_drvr_->pin())->isOutput(); } -} // namespace +} // namespace sta diff --git a/dcalc/LumpedCapDelayCalc.cc b/dcalc/LumpedCapDelayCalc.cc index 692c01f0..b245c1d6 100644 --- a/dcalc/LumpedCapDelayCalc.cc +++ b/dcalc/LumpedCapDelayCalc.cc @@ -27,15 +27,15 @@ #include // isnan #include "Debug.hh" -#include "Units.hh" +#include "GraphDelayCalc.hh" +#include "Liberty.hh" +#include "Network.hh" +#include "Parasitics.hh" +#include "PortDirection.hh" +#include "Sdc.hh" #include "TimingArc.hh" #include "TimingModel.hh" -#include "Liberty.hh" -#include "PortDirection.hh" -#include "Network.hh" -#include "Sdc.hh" -#include "Parasitics.hh" -#include "GraphDelayCalc.hh" +#include "Units.hh" #include "Variables.hh" namespace sta { @@ -203,4 +203,4 @@ LumpedCapDelayCalc::reportGateDelay(const Pin *check_pin, return ""; } -} // namespace +} // namespace sta diff --git a/dcalc/LumpedCapDelayCalc.hh b/dcalc/LumpedCapDelayCalc.hh index eb2bf4f0..d9b24d74 100644 --- a/dcalc/LumpedCapDelayCalc.hh +++ b/dcalc/LumpedCapDelayCalc.hh @@ -61,7 +61,7 @@ public: const LoadPinIndexMap &load_pin_index_map, const Scene *scene, const MinMax *min_max) override; - std::string reportGateDelay(const Pin *drvr_pin, + std::string reportGateDelay(const Pin *check_pin, const TimingArc *arc, const Slew &in_slew, float load_cap, @@ -84,4 +84,4 @@ protected: ArcDelayCalc * makeLumpedCapDelayCalc(StaState *sta); -} // namespace +} // namespace sta diff --git a/dcalc/NetCaps.cc b/dcalc/NetCaps.cc index 3ca8cd6a..d1eaa45b 100644 --- a/dcalc/NetCaps.cc +++ b/dcalc/NetCaps.cc @@ -26,10 +26,6 @@ namespace sta { -NetCaps::NetCaps() -{ -} - NetCaps::NetCaps(float pin_cap, float wire_cap, float fanout, @@ -53,4 +49,4 @@ NetCaps::init(float pin_cap, has_net_load_ = has_net_load; } -} // namespace +} // namespace sta diff --git a/dcalc/NetCaps.hh b/dcalc/NetCaps.hh index cb0db7ea..a968ddda 100644 --- a/dcalc/NetCaps.hh +++ b/dcalc/NetCaps.hh @@ -30,7 +30,7 @@ namespace sta { class NetCaps { public: - NetCaps(); + NetCaps() = default; NetCaps(float pin_cap, float wire_cap, float fanout, @@ -51,4 +51,4 @@ private: bool has_net_load_; }; -} // namespace +} // namespace sta diff --git a/dcalc/ParallelDelayCalc.cc b/dcalc/ParallelDelayCalc.cc index 38b71c32..8a47956c 100644 --- a/dcalc/ParallelDelayCalc.cc +++ b/dcalc/ParallelDelayCalc.cc @@ -24,13 +24,13 @@ #include "ParallelDelayCalc.hh" -#include "TimingArc.hh" -#include "Scene.hh" -#include "Network.hh" #include "Graph.hh" -#include "Sdc.hh" -#include "Liberty.hh" #include "GraphDelayCalc.hh" +#include "Liberty.hh" +#include "Network.hh" +#include "Scene.hh" +#include "Sdc.hh" +#include "TimingArc.hh" namespace sta { @@ -118,4 +118,4 @@ ParallelDelayCalc::gateDelaysParallel(ArcDcalcArgSeq &dcalc_args, return dcalc_results; } -} // namespace +} // namespace sta diff --git a/dcalc/ParallelDelayCalc.hh b/dcalc/ParallelDelayCalc.hh index c7d3c921..f20f4b74 100644 --- a/dcalc/ParallelDelayCalc.hh +++ b/dcalc/ParallelDelayCalc.hh @@ -24,8 +24,8 @@ #pragma once -#include #include +#include #include "DelayCalcBase.hh" @@ -47,4 +47,4 @@ protected: const MinMax *min_max); }; -} // namespace +} // namespace sta diff --git a/dcalc/PrimaDelayCalc.cc b/dcalc/PrimaDelayCalc.cc index f3c7ec5d..15d6a662 100644 --- a/dcalc/PrimaDelayCalc.cc +++ b/dcalc/PrimaDelayCalc.cc @@ -24,32 +24,27 @@ #include "PrimaDelayCalc.hh" +#include +#include #include // abs #include #include "Debug.hh" -#include "Units.hh" -#include "TimingArc.hh" -#include "Liberty.hh" -#include "PortDirection.hh" -#include "Network.hh" -#include "Sdc.hh" -#include "Scene.hh" -#include "Graph.hh" -#include "Parasitics.hh" -#include "GraphDelayCalc.hh" #include "DmpDelayCalc.hh" #include "Format.hh" - -#include -#include +#include "Graph.hh" +#include "GraphDelayCalc.hh" +#include "Liberty.hh" +#include "Network.hh" +#include "Parasitics.hh" +#include "PortDirection.hh" +#include "Scene.hh" +#include "Sdc.hh" +#include "TimingArc.hh" +#include "Units.hh" namespace sta { -using Eigen::ColPivHouseholderQR; -using Eigen::HouseholderQR; -using Eigen::SparseLU; - // Lawrence Pillage - “Electronic Circuit & System Simulation Methods” 1998 // McGraw-Hill, Inc. New York, NY. @@ -61,17 +56,7 @@ makePrimaDelayCalc(StaState *sta) PrimaDelayCalc::PrimaDelayCalc(StaState *sta) : DelayCalcBase(sta), - dcalc_args_(nullptr), - scene_(nullptr), - min_max_(nullptr), - parasitics_(nullptr), - parasitic_network_(nullptr), - load_pin_index_map_(nullptr), pin_node_map_(network_), - prima_order_(3), - make_waveforms_(false), - waveform_drvr_pin_(nullptr), - waveform_load_pin_(nullptr), watch_pin_values_(network_), table_dcalc_(makeDmpCeffElmoreDelayCalc(sta)) { @@ -79,20 +64,18 @@ PrimaDelayCalc::PrimaDelayCalc(StaState *sta) : PrimaDelayCalc::PrimaDelayCalc(const PrimaDelayCalc &dcalc) : DelayCalcBase(dcalc), - dcalc_args_(nullptr), - load_pin_index_map_(nullptr), pin_node_map_(network_), node_index_map_(dcalc.node_index_map_), prima_order_(dcalc.prima_order_), - make_waveforms_(false), - waveform_drvr_pin_(nullptr), - waveform_load_pin_(nullptr), watch_pin_values_(network_), table_dcalc_(makeDmpCeffElmoreDelayCalc(this)) { } -PrimaDelayCalc::~PrimaDelayCalc() { delete table_dcalc_; } +PrimaDelayCalc::~PrimaDelayCalc() +{ + delete table_dcalc_; +} ArcDelayCalc * PrimaDelayCalc::copy() @@ -359,7 +342,7 @@ PrimaDelayCalc::simulate1(const MatrixSd &G, const Eigen::MatrixXd &B, const Eigen::VectorXd &x_init, const Eigen::MatrixXd &x_to_v, - const size_t order) + size_t order) { Eigen::VectorXd x(order); Eigen::VectorXd x_prev(order); @@ -379,7 +362,7 @@ PrimaDelayCalc::simulate1(const MatrixSd &G, MatrixSd A(order, order); A = G + (2.0 / time_step_) * C; A.makeCompressed(); - SparseLU A_solver; + Eigen::SparseLU A_solver; A_solver.compute(A); // Initial time depends on ceff which impact delay, so use a sim step @@ -403,7 +386,10 @@ PrimaDelayCalc::simulate1(const MatrixSd &G, if (make_waveforms_) recordWaveformStep(time_begin); - for (double time = time_begin; time <= time_end; time += time_step_) { + for (size_t step = 0;; ++step) { + const double time = time_begin + step * time_step_; + if (time > time_end) + break; setPortCurrents(); rhs = B * u_ + (1.0 / time_step_) * C * (3.0 * x_prev - x_prev2); x = A_solver.solve(rhs); @@ -850,7 +836,7 @@ PrimaDelayCalc::primaReduce() { G_.makeCompressed(); // Step 3: solve G*R = B for R - SparseLU G_solver(G_); + Eigen::SparseLU G_solver(G_); if (G_solver.info() != Eigen::Success) report_->error(1752, "G matrix is singular."); Eigen::MatrixXd R(order_, port_count_); @@ -1042,7 +1028,7 @@ PinSeq PrimaDelayCalc::watchPins() const { PinSeq pins; - for (auto pin_values : watch_pin_values_) { + for (const auto &pin_values : watch_pin_values_) { const Pin *pin = pin_values.first; pins.push_back(pin); } @@ -1121,10 +1107,8 @@ void PrimaDelayCalc::reportMatrix(Eigen::VectorXd &matrix) { std::string line = "| "; - for (Eigen::Index i = 0; i < matrix.rows(); i++) { - std::string entry = + for (Eigen::Index i = 0; i < matrix.rows(); i++) line += sta::format("{:10.3e}", matrix.coeff(i)) + " "; - } line += "|"; report_->reportLine(line); } @@ -1133,8 +1117,8 @@ void PrimaDelayCalc::reportVector(std::vector &matrix) { std::string line = "| "; - for (size_t i = 0; i < matrix.size(); i++) - line += sta::format("{:10.3e}", matrix[i]) + " "; + for (const double &entry : matrix) + line += sta::format("{:10.3e}", entry) + " "; line += "|"; report_->reportLine(line); } diff --git a/dcalc/PrimaDelayCalc.hh b/dcalc/PrimaDelayCalc.hh index 086e29ce..4d5b1346 100644 --- a/dcalc/PrimaDelayCalc.hh +++ b/dcalc/PrimaDelayCalc.hh @@ -24,13 +24,14 @@ #pragma once -#include -#include #include #include +#include +#include +#include -#include "LumpedCapDelayCalc.hh" #include "ArcDcalcWaveforms.hh" +#include "LumpedCapDelayCalc.hh" #include "Parasitics.hh" namespace sta { @@ -57,7 +58,7 @@ class PrimaDelayCalc : public DelayCalcBase, public: PrimaDelayCalc(StaState *sta); PrimaDelayCalc(const PrimaDelayCalc &dcalc); - ~PrimaDelayCalc(); + ~PrimaDelayCalc() override; ArcDelayCalc *copy() override; void copyState(const StaState *sta) override; std::string_view name() const override { return "prima"; } @@ -123,7 +124,7 @@ protected: const Eigen::MatrixXd &B, const Eigen::VectorXd &x_init, const Eigen::MatrixXd &x_to_v, - const size_t order); + size_t order); double maxTime(); double timeStep(); float driverResistance(); @@ -178,15 +179,15 @@ protected: void reportMatrix(Eigen::VectorXd &matrix); void reportVector(std::vector &matrix); - ArcDcalcArgSeq *dcalc_args_; + ArcDcalcArgSeq *dcalc_args_{nullptr}; size_t drvr_count_; float load_cap_; - const Scene *scene_; - const MinMax *min_max_; - Parasitics *parasitics_; - const Parasitic *parasitic_network_; + const Scene *scene_{nullptr}; + const MinMax *min_max_{nullptr}; + Parasitics *parasitics_{nullptr}; + const Parasitic *parasitic_network_{nullptr}; const RiseFall *drvr_rf_; - const LoadPinIndexMap *load_pin_index_map_; + const LoadPinIndexMap *load_pin_index_map_{nullptr}; PinNodeMap pin_node_map_; // Parasitic pin -> array index NodeIndexMap node_index_map_; // Parasitic node -> array index @@ -210,7 +211,7 @@ protected: Eigen::VectorXd u_; // Prima reduced MNA eqns - size_t prima_order_; + size_t prima_order_{3}; Eigen::MatrixXd Vq_; MatrixSd Gq_; MatrixSd Cq_; @@ -231,9 +232,9 @@ protected: double time_step_prev_; // Waveform recording. - bool make_waveforms_; - const Pin *waveform_drvr_pin_; - const Pin *waveform_load_pin_; + bool make_waveforms_{false}; + const Pin *waveform_drvr_pin_{nullptr}; + const Pin *waveform_load_pin_{nullptr}; FloatSeq drvr_voltages_; FloatSeq load_voltages_; WatchPinValuesMap watch_pin_values_; @@ -248,7 +249,7 @@ protected: static constexpr size_t threshold_vth = 1; static constexpr size_t threshold_vh = 2; static constexpr size_t measure_threshold_count_ = 3; - typedef std::array ThresholdTimes; + using ThresholdTimes = std::array; // Vl Vth Vh ThresholdTimes measure_thresholds_; // Indexed by node number. @@ -263,4 +264,4 @@ protected: using ArcDelayCalc::reduceParasitic; }; -} // namespace +} // namespace sta diff --git a/dcalc/UnitDelayCalc.cc b/dcalc/UnitDelayCalc.cc index afda4922..f376ec7b 100644 --- a/dcalc/UnitDelayCalc.cc +++ b/dcalc/UnitDelayCalc.cc @@ -187,4 +187,4 @@ UnitDelayCalc::finishDrvrPin() { } -} // namespace +} // namespace sta diff --git a/dcalc/UnitDelayCalc.hh b/dcalc/UnitDelayCalc.hh index 5e2a3079..3eaca081 100644 --- a/dcalc/UnitDelayCalc.hh +++ b/dcalc/UnitDelayCalc.hh @@ -109,4 +109,4 @@ protected: ArcDelayCalc * makeUnitDelayCalc(StaState *sta); -} // namespace +} // namespace sta diff --git a/doc/StaApi.txt b/doc/StaApi.txt index ecf7d35a..e48eff98 100644 --- a/doc/StaApi.txt +++ b/doc/StaApi.txt @@ -108,9 +108,6 @@ in a class derived from Sta. Because the components refer to each other, Sta::updateComponentsState() must be called to notify the components if any of them are changed after creation. -The file liberty/LibertyExt.cc contains an example that shows how the -liberty reader is replaced with a custom one on the Sta object. - Units ----- @@ -291,7 +288,7 @@ in this arc set: S r -> Z f The liberty file reader can be customized to read attributes that are -not used by the STA. See liberty/LibertyExt.cc for an example. +not used by the STA. Graph ----- diff --git a/graph/Graph.cc b/graph/Graph.cc index ca65fe01..74996842 100644 --- a/graph/Graph.cc +++ b/graph/Graph.cc @@ -26,16 +26,16 @@ #include "ContainerHelpers.hh" #include "Debug.hh" -#include "Stats.hh" +#include "FuncExpr.hh" +#include "Liberty.hh" #include "MinMax.hh" #include "Mutex.hh" -#include "Transition.hh" -#include "TimingRole.hh" -#include "TimingArc.hh" -#include "Liberty.hh" -#include "PortDirection.hh" #include "Network.hh" -#include "FuncExpr.hh" +#include "PortDirection.hh" +#include "Stats.hh" +#include "TimingArc.hh" +#include "TimingRole.hh" +#include "Transition.hh" #include "Variables.hh" namespace sta { @@ -49,8 +49,6 @@ namespace sta { Graph::Graph(StaState *sta, DcalcAPIndex ap_count) : StaState(sta), - vertices_(nullptr), - edges_(nullptr), ap_count_(ap_count), period_check_annotations_(network_), reg_clk_vertices_(makeVertexSet(this)) @@ -342,11 +340,10 @@ class MakeEdgesThruHierPin : public HierPinThruVisitor { public: MakeEdgesThruHierPin(Graph *graph); - -private: void visit(const Pin *drvr, const Pin *load) override; +private: Graph *graph_; }; @@ -585,7 +582,7 @@ Graph::slew(const Vertex *vertex, size_t slew_index = ap_index * RiseFall::index_count + rf->index(); const float *slews_flt = vertex->slewsFloat(); if (variables_->pocvEnabled()) { - const Slew *slews = std::bit_cast(slews_flt); + const Slew *slews = reinterpret_cast(slews_flt); return slews[slew_index]; } else @@ -598,7 +595,7 @@ Graph::slew(const Vertex *vertex, { const float *slews_flt = vertex->slewsFloat(); if (variables_->pocvEnabled()) { - const Slew *slews = std::bit_cast(slews_flt); + const Slew *slews = reinterpret_cast(slews_flt); return slews[index]; } else @@ -678,7 +675,7 @@ Graph::arcDelay(const Edge *edge, { size_t index = arc->index() * ap_count_ + ap_index; if (variables_->pocvEnabled()) { - ArcDelay *delays = std::bit_cast(edge->arcDelays()); + const ArcDelay *delays = reinterpret_cast(edge->arcDelays()); return delays[index]; } else { @@ -695,7 +692,7 @@ Graph::setArcDelay(Edge *edge, { size_t index = arc->index() * ap_count_ + ap_index; if (variables_->pocvEnabled()) { - ArcDelay *delays = std::bit_cast(edge->arcDelays()); + ArcDelay *delays = reinterpret_cast(edge->arcDelays()); delays[index] = delay; } else { @@ -711,7 +708,7 @@ Graph::wireArcDelay(const Edge *edge, { size_t index = rf->index() * ap_count_ + ap_index; if (variables_->pocvEnabled()) { - ArcDelay *delays = std::bit_cast(edge->arcDelays()); + const ArcDelay *delays = reinterpret_cast(edge->arcDelays()); return delays[index]; } else { @@ -728,7 +725,7 @@ Graph::setWireArcDelay(Edge *edge, { size_t index = rf->index() * ap_count_ + ap_index; if (variables_->pocvEnabled()) { - ArcDelay *delays = std::bit_cast(edge->arcDelays()); + ArcDelay *delays = reinterpret_cast(edge->arcDelays()); delays[index] = delay; } else { @@ -753,7 +750,7 @@ Graph::setArcDelayAnnotated(Edge *edge, DcalcAPIndex ap_index, bool annotated) { - return edge->setArcDelayAnnotated(arc, ap_index, ap_count_, annotated); + edge->setArcDelayAnnotated(arc, ap_index, ap_count_, annotated); } bool @@ -774,7 +771,7 @@ Graph::setWireDelayAnnotated(Edge *edge, { int arc_index = TimingArcSet::wireArcIndex(rf); TimingArc *arc = TimingArcSet::wireTimingArcSet()->findTimingArc(arc_index); - return edge->setArcDelayAnnotated(arc, ap_index, ap_count_, annotated); + edge->setArcDelayAnnotated(arc, ap_index, ap_count_, annotated); } void @@ -819,7 +816,7 @@ Graph::initSlews(Vertex *vertex) { size_t slew_count = slewCount(); if (variables_->pocvEnabled()) { - float *slews = std::bit_cast(new Slew[slew_count]{}); + float *slews = reinterpret_cast(new Slew[slew_count]{}); vertex->setSlews(slews); } else { @@ -840,7 +837,7 @@ Graph::initArcDelays(Edge *edge) size_t arc_count = edge->timingArcSet()->arcCount(); size_t delay_count = arc_count * ap_count_; if (variables_->pocvEnabled()) { - float *delays = std::bit_cast(new ArcDelay[delay_count]{}); + float *delays = reinterpret_cast(new ArcDelay[delay_count]{}); edge->setArcDelays(delays); } else { @@ -1187,7 +1184,7 @@ Vertex::setHasDownstreamClkPin(bool has_clk_pin) bool Vertex::bfsInQueue(BfsIndex index) const { - return (bfs_in_queue_ >> unsigned(index)) & 1; + return (bfs_in_queue_ >> static_cast(index)) & 1; } void @@ -1195,9 +1192,9 @@ Vertex::setBfsInQueue(BfsIndex index, bool value) { if (value) - bfs_in_queue_ |= 1 << int(index); + bfs_in_queue_ |= 1 << static_cast(index); else - bfs_in_queue_ &= ~(1 << int(index)); + bfs_in_queue_ &= ~(1 << static_cast(index)); } //////////////////////////////////////////////////////////////// @@ -1400,10 +1397,7 @@ VertexIterator::VertexIterator(Graph *graph) : graph_(graph), network_(graph->network()), top_inst_(network_->topInstance()), - inst_iter_(network_->leafInstanceIterator()), - pin_iter_(nullptr), - vertex_(nullptr), - bidir_vertex_(nullptr) + inst_iter_(network_->leafInstanceIterator()) { if (inst_iter_) findNext(); @@ -1580,4 +1574,4 @@ VertexIdLess::operator()(const Vertex *vertex1, } -} // namespace +} // namespace sta diff --git a/graph/Graph.i b/graph/Graph.i index e0cf76d7..63ef9937 100644 --- a/graph/Graph.i +++ b/graph/Graph.i @@ -25,17 +25,17 @@ %module graph %{ -#include "Graph.hh" +#include "Clock.hh" #include "FuncExpr.hh" -#include "TimingRole.hh" +#include "Graph.hh" #include "search/Levelize.hh" #include "Liberty.hh" #include "Network.hh" -#include "Clock.hh" #include "Scene.hh" #include "Search.hh" #include "Sdc.hh" #include "Sta.hh" +#include "TimingRole.hh" using namespace sta; diff --git a/graph/GraphCmp.cc b/graph/GraphCmp.cc index 3c3a5dfc..8ad693df 100644 --- a/graph/GraphCmp.cc +++ b/graph/GraphCmp.cc @@ -22,12 +22,13 @@ // // This notice may not be removed or altered from any source distribution. +#include "GraphCmp.hh" + #include "ContainerHelpers.hh" -#include "StringUtil.hh" +#include "Graph.hh" #include "Network.hh" #include "NetworkCmp.hh" -#include "Graph.hh" -#include "GraphCmp.hh" +#include "StringUtil.hh" namespace sta { @@ -73,4 +74,4 @@ sortEdges(EdgeSeq *edges, sort(edges, EdgeLess(network, graph)); } -} +} // namespace sta diff --git a/include/sta/ArcDelayCalc.hh b/include/sta/ArcDelayCalc.hh index 85e656d1..eacad445 100644 --- a/include/sta/ArcDelayCalc.hh +++ b/include/sta/ArcDelayCalc.hh @@ -24,20 +24,20 @@ #pragma once +#include #include #include #include -#include -#include "MinMax.hh" -#include "LibertyClass.hh" -#include "TimingArc.hh" -#include "TableModel.hh" -#include "NetworkClass.hh" -#include "GraphClass.hh" #include "Delay.hh" +#include "GraphClass.hh" +#include "LibertyClass.hh" +#include "MinMax.hh" +#include "NetworkClass.hh" #include "ParasiticsClass.hh" #include "StaState.hh" +#include "TableModel.hh" +#include "TimingArc.hh" namespace sta { @@ -63,14 +63,14 @@ public: const Pin *drvr_pin, Edge *edge, const TimingArc *arc, - const Slew in_slew, + Slew in_slew, float load_cap, const Parasitic *parasitic); ArcDcalcArg(const Pin *in_pin, const Pin *drvr_pin, Edge *edge, const TimingArc *arc, - float in_delay); + float input_delay); const Pin *inPin() const { return in_pin_; } const RiseFall *inEdge() const; const Pin *drvrPin() const { return drvr_pin_; } @@ -160,7 +160,6 @@ class ArcDelayCalc : public StaState { public: ArcDelayCalc(StaState *sta); - virtual ~ArcDelayCalc() {} virtual ArcDelayCalc *copy() = 0; virtual std::string_view name() const = 0; @@ -262,4 +261,4 @@ public: virtual void finishDrvrPin() = 0; }; -} // namespace +} // namespace sta diff --git a/include/sta/Bdd.hh b/include/sta/Bdd.hh index df565a5a..834696fc 100644 --- a/include/sta/Bdd.hh +++ b/include/sta/Bdd.hh @@ -26,8 +26,8 @@ #include -#include "StaState.hh" #include "LibertyClass.hh" +#include "StaState.hh" struct DdNode; struct DdManager; @@ -41,7 +41,7 @@ class Bdd : public StaState { public: Bdd(const StaState *sta); - ~Bdd(); + ~Bdd() override; DdNode *funcBdd(const FuncExpr *expr); DdNode *findNode(const LibertyPort *port); const LibertyPort *nodePort(DdNode *node); @@ -58,4 +58,4 @@ private: BddVarIdxPortMap bdd_var_idx_port_map_; }; -} // namespace +} // namespace sta diff --git a/include/sta/Bfs.hh b/include/sta/Bfs.hh index 162bd9a8..5c11ab1c 100644 --- a/include/sta/Bfs.hh +++ b/include/sta/Bfs.hh @@ -27,10 +27,10 @@ #include #include -#include "Iterator.hh" #include "GraphClass.hh" -#include "VertexVisitor.hh" +#include "Iterator.hh" #include "StaState.hh" +#include "VertexVisitor.hh" namespace sta { @@ -50,10 +50,10 @@ using LevelQueue = std::vector; // Vertices are marked as being in the queue by using a flag on // the vertex indexed by bfs_index. A unique flag is only needed // if the BFS in in use when other BFS's are simultaneously in use. -class BfsIterator : public StaState, Iterator +class BfsIterator : public StaState, + public Iterator { public: - virtual ~BfsIterator(); // Make sure that the BFS queue is deep enough for the max logic level. void ensureSize(); // Reset to virgin state. @@ -130,7 +130,7 @@ public: BfsFwdIterator(BfsIndex bfs_index, SearchPred *search_pred, StaState *sta); - virtual ~BfsFwdIterator(); + ~BfsFwdIterator() override; void enqueueAdjacentVertices(Vertex *vertex, SearchPred *search_pred) override; void enqueueAdjacentVertices(Vertex *vertex, @@ -152,7 +152,7 @@ public: BfsBkwdIterator(BfsIndex bfs_index, SearchPred *search_pred, StaState *sta); - virtual ~BfsBkwdIterator(); + ~BfsBkwdIterator() override; void enqueueAdjacentVertices(Vertex *vertex, SearchPred *search_pred) override; void enqueueAdjacentVertices(Vertex *vertex, @@ -168,4 +168,4 @@ protected: void incrLevel(Level &level) const override; }; -} // namespace +} // namespace sta diff --git a/include/sta/BoundedHeap.hh b/include/sta/BoundedHeap.hh index ff0ee39d..6ae23ce0 100644 --- a/include/sta/BoundedHeap.hh +++ b/include/sta/BoundedHeap.hh @@ -24,10 +24,10 @@ #pragma once -#include #include #include #include +#include namespace sta { diff --git a/include/sta/CircuitSim.hh b/include/sta/CircuitSim.hh index 3e5756e4..8e366d09 100644 --- a/include/sta/CircuitSim.hh +++ b/include/sta/CircuitSim.hh @@ -28,4 +28,4 @@ namespace sta { enum class CircuitSim { hspice, ngspice, xyce }; -} // namespace +} // namespace sta diff --git a/include/sta/ClkNetwork.hh b/include/sta/ClkNetwork.hh index 4bbfacfa..493446c8 100644 --- a/include/sta/ClkNetwork.hh +++ b/include/sta/ClkNetwork.hh @@ -26,10 +26,10 @@ #include -#include "StaState.hh" -#include "NetworkClass.hh" #include "GraphClass.hh" +#include "NetworkClass.hh" #include "SdcClass.hh" +#include "StaState.hh" namespace sta { @@ -44,7 +44,7 @@ class ClkNetwork : public StaState public: ClkNetwork(Mode *mode, StaState *sta); - ~ClkNetwork(); + ~ClkNetwork() override; void ensureClkNetwork(); void clear(); bool isClock(const Pin *pin) const; @@ -73,9 +73,9 @@ private: void findClkPins(); void findClkPins(bool ideal_only, - PinClksMap &clk_pin_map); + PinClksMap &pin_clks_map); - bool clk_pins_valid_; + bool clk_pins_valid_{false}; // pin -> clks PinClksMap pin_clks_map_; // pin -> ideal clks @@ -84,4 +84,4 @@ private: ClkPinsMap clk_pins_map_; }; -} // namespace +} // namespace sta diff --git a/include/sta/Clock.hh b/include/sta/Clock.hh index 4422212d..48cfb88d 100644 --- a/include/sta/Clock.hh +++ b/include/sta/Clock.hh @@ -27,11 +27,11 @@ #include #include +#include "GraphClass.hh" #include "MinMax.hh" #include "RiseFallMinMax.hh" #include "SdcClass.hh" #include "SdcCmdComment.hh" -#include "GraphClass.hh" namespace sta { @@ -82,11 +82,11 @@ public: void removeSlew(); const RiseFallMinMax &slews() const { return slews_; } void setSlewLimit(const RiseFallBoth *rf, - const PathClkOrData clk_data, + PathClkOrData clk_data, const MinMax *min_max, float slew); void slewLimit(const RiseFall *rf, - const PathClkOrData clk_data, + PathClkOrData clk_data, const MinMax *min_max, // Return values. float &slew, @@ -170,31 +170,31 @@ protected: std::string name_; PinSet pins_; - bool add_to_pins_; + bool add_to_pins_{false}; // Hierarchical pins in pins_ become driver pins through the pin. PinSet leaf_pins_; - float period_; - FloatSeq *waveform_; - bool waveform_valid_; + float period_{0.0}; + FloatSeq *waveform_{nullptr}; + bool waveform_valid_{false}; const int index_; - ClockEdge **clk_edges_; - bool is_propagated_; + ClockEdge **clk_edges_{nullptr}; + bool is_propagated_{false}; RiseFallMinMax slews_; RiseFallMinMax slew_limits_[path_clk_or_data_count]; - ClockUncertainties *uncertainties_; - bool is_generated_; + ClockUncertainties *uncertainties_{nullptr}; + bool is_generated_{false}; // Generated clock variables. - Pin *src_pin_; - Clock *master_clk_; + Pin *src_pin_{nullptr}; + Clock *master_clk_{nullptr}; // True if the master clock is infered rather than specified by command. - bool master_clk_infered_; - int divide_by_; - int multiply_by_; - float duty_cycle_; - bool invert_; - bool combinational_; - IntSeq *edges_; - FloatSeq *edge_shifts_; + bool master_clk_infered_{false}; + int divide_by_{0}; + int multiply_by_{0}; + float duty_cycle_{0}; + bool invert_{false}; + bool combinational_{false}; + IntSeq *edges_{nullptr}; + FloatSeq *edge_shifts_{nullptr}; private: friend class Sdc; @@ -205,7 +205,6 @@ class ClockEdge { public: Clock *clock() const { return clock_; } - ~ClockEdge(); const RiseFall *transition() const { return rf_; } float time() const { return time_; } const std::string &name() const { return name_; } @@ -223,7 +222,7 @@ private: Clock *clock_; const RiseFall *rf_; std::string name_; - float time_; + float time_{0.0}; int index_; }; @@ -291,4 +290,4 @@ int compare(const ClockSet *set1, const ClockSet *set2); -} // namespace +} // namespace sta diff --git a/include/sta/ClockGatingCheck.hh b/include/sta/ClockGatingCheck.hh index 41417384..f460472f 100644 --- a/include/sta/ClockGatingCheck.hh +++ b/include/sta/ClockGatingCheck.hh @@ -24,22 +24,21 @@ #pragma once -#include "SdcClass.hh" #include "RiseFallMinMax.hh" +#include "SdcClass.hh" namespace sta { class ClockGatingCheck { public: - ClockGatingCheck(); RiseFallMinMax *margins() { return &margins_; } void setActiveValue(LogicValue value); LogicValue activeValue() const { return active_value_; } private: RiseFallMinMax margins_; - LogicValue active_value_; + LogicValue active_value_{LogicValue::unknown}; }; -} // namespace +} // namespace sta diff --git a/include/sta/ClockGroups.hh b/include/sta/ClockGroups.hh index 63765088..7a3540b1 100644 --- a/include/sta/ClockGroups.hh +++ b/include/sta/ClockGroups.hh @@ -26,20 +26,20 @@ #include -#include "SdcCmdComment.hh" #include "SdcClass.hh" +#include "SdcCmdComment.hh" namespace sta { class ClockGroups : public SdcCmdComment { public: - ClockGroups(const std::string &name, + ClockGroups(std::string_view name, bool logically_exclusive, bool physically_exclusive, bool asynchronous, bool allow_paths, - std::string comment); + std::string_view comment); ~ClockGroups(); void makeClockGroup(ClockSet *clks); const std::string &name() const { return name_; } @@ -59,4 +59,4 @@ private: ClockGroupSet groups_; }; -} // namespace +} // namespace sta diff --git a/include/sta/ClockInsertion.hh b/include/sta/ClockInsertion.hh index 1a1aef85..a33423b3 100644 --- a/include/sta/ClockInsertion.hh +++ b/include/sta/ClockInsertion.hh @@ -26,8 +26,8 @@ #include "MinMax.hh" #include "NetworkClass.hh" -#include "SdcClass.hh" #include "RiseFallMinMax.hh" +#include "SdcClass.hh" #include "Transition.hh" namespace sta { @@ -57,4 +57,4 @@ private: RiseFallMinMax delays_[EarlyLate::index_count]; }; -} // namespace +} // namespace sta diff --git a/include/sta/ClockLatency.hh b/include/sta/ClockLatency.hh index 33479fd7..54c4dff2 100644 --- a/include/sta/ClockLatency.hh +++ b/include/sta/ClockLatency.hh @@ -26,9 +26,9 @@ #include "MinMax.hh" #include "NetworkClass.hh" -#include "Transition.hh" -#include "SdcClass.hh" #include "RiseFallMinMax.hh" +#include "SdcClass.hh" +#include "Transition.hh" namespace sta { @@ -61,4 +61,4 @@ private: RiseFallMinMax delays_; }; -} // namespace +} // namespace sta diff --git a/include/sta/ConcreteLibrary.hh b/include/sta/ConcreteLibrary.hh index fc831a99..75018056 100644 --- a/include/sta/ConcreteLibrary.hh +++ b/include/sta/ConcreteLibrary.hh @@ -25,12 +25,12 @@ #pragma once #include +#include #include #include -#include -#include "StringUtil.hh" #include "NetworkClass.hh" +#include "StringUtil.hh" // The classes defined in this file are a contrete implementation of // the library API. They can be used by a reader to construct classes @@ -84,8 +84,8 @@ protected: ObjectId id_; std::string filename_; bool is_liberty_; - char bus_brkt_left_; - char bus_brkt_right_; + char bus_brkt_left_{'['}; + char bus_brkt_right_{']'}; ConcreteCellMap cell_map_; private: @@ -127,12 +127,12 @@ public: ConcretePort *makeBundlePort(std::string_view name, ConcretePortSeq *members); // Group previously defined bus bit ports together. - void groupBusPorts(const char bus_brkt_left, - const char bus_brkt_right, - std::function port_msb_first); + void groupBusPorts(char bus_brkt_left, + char bus_brkt_right, + const std::function &port_msb_first); size_t portCount() const; void setName(std::string_view name); - void addPort(ConcretePort *port); + virtual void addPort(ConcretePort *port); void addPortBit(ConcretePort *port); protected: @@ -149,7 +149,7 @@ protected: int from_index, int to_index); // Bus port bit (internal to makeBusPortBits). - ConcretePort *makePort(std::string bit_name, + ConcretePort *makePort(std::string_view bit_name, int bit_index); void makeBusPortBit(ConcretePort *bus_port, std::string_view bus_name, @@ -160,14 +160,14 @@ protected: // Filename is optional. std::string filename_; ConcreteLibrary *library_; - LibertyCell *liberty_cell_; + LibertyCell *liberty_cell_{nullptr}; // External application cell. - void *ext_cell_; + void *ext_cell_{nullptr}; // Non-bus and bus ports (but no expanded bus bit ports). ConcretePortSeq ports_; ConcretePortMap port_map_; // Port bit count (expanded buses). - int port_bit_count_; + int port_bit_count_{0}; bool is_leaf_; AttributeMap attribute_map_; @@ -242,10 +242,10 @@ protected: ObjectId id_; ConcreteCell *cell_; PortDirection *direction_; - LibertyPort *liberty_port_; + LibertyPort *liberty_port_{nullptr}; // External application port. - void *ext_port_; - int pin_index_; + void *ext_port_{nullptr}; + int pin_index_{-1}; bool is_bundle_; bool is_bus_; int from_index_; @@ -253,7 +253,7 @@ protected: // Expanded bus bit ports (ordered by from_index_ to to_index_) // or bundle member ports. ConcretePortSeq *member_ports_; - ConcretePort *bundle_port_; + ConcretePort *bundle_port_{nullptr}; private: friend class ConcreteCell; @@ -271,8 +271,8 @@ private: const ConcretePortSeq &ports_; ConcretePortSeq::const_iterator port_iter_; - ConcretePortMemberIterator *member_iter_; - ConcretePort *next_; + ConcretePortMemberIterator *member_iter_{nullptr}; + ConcretePort *next_{nullptr}; }; -} // Namespace +} // namespace sta diff --git a/include/sta/ConcreteNetwork.hh b/include/sta/ConcreteNetwork.hh index b3a37793..593c444c 100644 --- a/include/sta/ConcreteNetwork.hh +++ b/include/sta/ConcreteNetwork.hh @@ -25,14 +25,14 @@ #pragma once #include -#include -#include #include #include +#include +#include -#include "StringUtil.hh" -#include "Network.hh" #include "LibertyClass.hh" +#include "Network.hh" +#include "StringUtil.hh" namespace sta { @@ -62,7 +62,7 @@ class ConcreteNetwork : public NetworkReader { public: ConcreteNetwork(); - ~ConcreteNetwork(); + ~ConcreteNetwork() override; void clear() override; bool linkNetwork(std::string_view top_cell_name, bool make_black_boxes, @@ -263,6 +263,9 @@ public: using Network::isLeaf; protected: + void clearImpl(); + void deleteCellNetworkViewsImpl(); + void deleteInstanceImpl(Instance *inst); void addLibrary(ConcreteLibrary *library); void setName(std::string_view name); void clearConstantNets(); @@ -280,8 +283,8 @@ protected: // Cell lookup search order sequence. ConcreteLibrarySeq library_seq_; ConcreteLibraryMap library_map_; - Instance *top_instance_; - NetSet constant_nets_[2]; // LogicValue::zero/one + Instance *top_instance_{nullptr}; + NetSet constant_nets_[2]{NetSet(this), NetSet(this)}; // LogicValue::zero/one LinkNetworkFunc link_func_; CellNetworkViewMap cell_network_view_map_; static ObjectId object_id_; @@ -293,7 +296,7 @@ private: class ConcreteInstance { public: - std::string_view name() const { return name_; } + const std::string &name() const { return name_; } ObjectId id() const { return id_; } Cell *cell() const; ConcreteInstance *parent() const { return parent_; } @@ -332,8 +335,8 @@ protected: ConcreteInstance *parent_; // Array of pins indexed by pin->port->index(). ConcretePinSeq pins_; - ConcreteInstanceChildMap *children_; - ConcreteInstanceNetMap *nets_; + ConcreteInstanceChildMap *children_{nullptr}; + ConcreteInstanceNetMap *nets_{nullptr}; AttributeMap attribute_map_; private: @@ -344,7 +347,7 @@ private: class ConcretePin { public: - std::string_view name() const; + const std::string &name() const; ConcreteInstance *instance() const { return instance_; } ConcreteNet *net() const { return net_; } ConcretePort *port() const { return port_; } @@ -354,7 +357,7 @@ public: void setVertexId(VertexId id); protected: - ~ConcretePin() {} + ~ConcretePin() = default; ConcretePin(ConcreteInstance *instance, ConcretePort *port, ConcreteNet *net); @@ -362,12 +365,12 @@ protected: ConcreteInstance *instance_; ConcretePort *port_; ConcreteNet *net_; - ConcreteTerm *term_; + ConcreteTerm *term_{nullptr}; ObjectId id_; // Doubly linked list of net pins. - ConcretePin *net_next_; - ConcretePin *net_prev_; - VertexId vertex_id_; + ConcretePin *net_next_{nullptr}; + ConcretePin *net_prev_{nullptr}; + VertexId vertex_id_{vertex_id_null}; private: friend class ConcreteNetwork; @@ -378,13 +381,13 @@ private: class ConcreteTerm { public: - std::string_view name() const; + const std::string &name() const; ObjectId id() const { return id_; } ConcreteNet *net() const { return net_; } ConcretePin *pin() const { return pin_; } protected: - ~ConcreteTerm() {} + ~ConcreteTerm() = default; ConcreteTerm(ConcretePin *pin, ConcreteNet *net); @@ -392,7 +395,7 @@ protected: ConcreteNet *net_; ObjectId id_; // Linked list of net terms. - ConcreteTerm *net_next_; + ConcreteTerm *net_next_{nullptr}; private: friend class ConcreteNetwork; @@ -403,7 +406,7 @@ private: class ConcreteNet { public: - std::string_view name() const { return name_; } + const std::string &name() const { return name_; } ObjectId id() const { return id_; } ConcreteInstance *instance() const { return instance_; } void addPin(ConcretePin *pin); @@ -420,16 +423,16 @@ protected: ObjectId id_; ConcreteInstance *instance_; // Pointer to head of linked list of pins. - ConcretePin *pins_; + ConcretePin *pins_{nullptr}; // Pointer to head of linked list of terminals. // These terminals correspond to the pins attached to the instance that // contains this net in the hierarchy level above. - ConcreteTerm *terms_; - ConcreteNet *merged_into_; + ConcreteTerm *terms_{nullptr}; + ConcreteNet *merged_into_{nullptr}; friend class ConcreteNetwork; friend class ConcreteNetTermIterator; friend class ConcreteNetPinIterator; }; -} // namespace +} // namespace sta diff --git a/include/sta/ContainerHelpers.hh b/include/sta/ContainerHelpers.hh index 67e6c38d..e7cbe7ce 100644 --- a/include/sta/ContainerHelpers.hh +++ b/include/sta/ContainerHelpers.hh @@ -42,7 +42,8 @@ namespace sta { // 1. Sequence containers (vector, list, deque, …) // ------------------------------------------------------------ template -std::enable_if_t> +requires std::is_pointer_v +void deleteContents(Container& c) { for (auto ptr : c) @@ -51,7 +52,8 @@ deleteContents(Container& c) } template -std::enable_if_t> +requires std::is_pointer_v +void deleteContents(Container *c) { for (auto ptr : *c) @@ -63,8 +65,8 @@ deleteContents(Container *c) // 2. Maps (map, unordered_map) // ------------------------------------------------------------ template -std::enable_if_t -> +requires std::is_pointer_v +void deleteContents(Map& m) { for (auto& kv : m) @@ -73,8 +75,8 @@ deleteContents(Map& m) } template -std::enable_if_t -> +requires std::is_pointer_v +void deleteContents(Map *m) { for (auto& kv : *m) @@ -86,10 +88,10 @@ deleteContents(Map *m) // 3. Sets (set, unordered_set) // ------------------------------------------------------------ template -std::enable_if_t< - std::is_pointer_v && - !std::is_same_v -> +requires (std::is_pointer_v && + requires { typename Set::mapped_type; } && + !std::is_same_v) +void deleteContents(Set& s) { for (auto ptr : s) @@ -119,28 +121,28 @@ struct find_return; template struct find_return { - using type = typename C::mapped_type; + using type = C::mapped_type; }; // pointer to set template struct find_return { - using type = typename C::key_type; + using type = C::key_type; }; // map ref template struct find_return { - using type = typename C::mapped_type; + using type = C::mapped_type; }; // set ref template struct find_return { - using type = typename C::key_type; + using type = C::key_type; }; @@ -149,10 +151,10 @@ struct find_return template auto findKey(const AssocContainer& c, - typename AssocContainer::key_type key) - -> typename find_return::type + const typename AssocContainer::key_type& key) + -> find_return::type { - using ReturnType = typename find_return::type; + using ReturnType = find_return::type; static_assert(std::is_pointer_v, "findKey requires pointer types"); @@ -173,9 +175,9 @@ template auto findStringKey(const AssocContainer& c, std::string_view key) - -> typename find_return::type + -> find_return::type { - using ReturnType = typename find_return::type; + using ReturnType = find_return::type; static_assert(std::is_pointer_v, "findStringKey requires pointer types"); @@ -194,8 +196,8 @@ findStringKey(const AssocContainer& c, template auto findKeyValue(const AssocContainer& c, - typename AssocContainer::key_type key) - -> const typename find_return::type & + const typename AssocContainer::key_type& key) + -> const find_return::type & { auto it = c.find(key); if (it != c.end()) { @@ -213,7 +215,7 @@ findKeyValue(const AssocContainer& c, template void findKeyValue(const AssocContainer& c, - typename AssocContainer::key_type key, + const typename AssocContainer::key_type& key, typename find_return::type &value, bool &exists) { @@ -240,7 +242,7 @@ findKeyValue(const AssocContainer& c, template void findKeyValue(const AssocContainer *c, - typename AssocContainer::key_type key, + const typename AssocContainer::key_type& key, typename find_return::type &value, bool &exists) { @@ -269,8 +271,8 @@ findKeyValue(const AssocContainer *c, template auto findKeyValuePtr(AssocContainer& c, - typename AssocContainer::key_type key) - -> typename find_return::type* + const typename AssocContainer::key_type& key) + -> find_return::type* { auto it = c.find(key); if (it == c.end()) @@ -289,8 +291,8 @@ findKeyValuePtr(AssocContainer& c, template auto findKeyValuePtr(const AssocContainer& c, - typename AssocContainer::key_type key) - -> typename find_return::type const* + const typename AssocContainer::key_type& key) + -> find_return::type const* { auto it = c.find(key); if (it == c.end()) @@ -310,8 +312,8 @@ findKeyValuePtr(const AssocContainer& c, template auto findStringValuePtr(AssocContainer& c, - std::string_view key) - -> typename find_return::type* + std::string_view key) + -> find_return::type* { auto it = c.find(key); if (it == c.end()) @@ -326,8 +328,8 @@ findStringValuePtr(AssocContainer& c, template auto findStringValuePtr(const AssocContainer& c, - std::string_view key) - -> typename find_return::type const* + std::string_view key) + -> find_return::type const* { auto it = c.find(key); if (it == c.end()) @@ -435,7 +437,7 @@ requires std::predicate> void sort(Range& r, - Comp comp = Comp{}) + const Comp &comp = Comp{}) { std::stable_sort(std::ranges::begin(r), std::ranges::end(r), comp); } @@ -450,9 +452,9 @@ requires std::ranges::random_access_range && std::ranges::range_reference_t> void sort(Range* r, - Comp comp = Comp{}) + const Comp &comp = Comp{}) { std::stable_sort(std::ranges::begin(*r), std::ranges::end(*r), comp); } -} // namespace +} // namespace sta diff --git a/include/sta/CycleAccting.hh b/include/sta/CycleAccting.hh index ad18a0cd..8eb36907 100644 --- a/include/sta/CycleAccting.hh +++ b/include/sta/CycleAccting.hh @@ -27,9 +27,9 @@ #include #include "MinMax.hh" -#include "TimingRole.hh" -#include "StaState.hh" #include "SdcClass.hh" +#include "StaState.hh" +#include "TimingRole.hh" namespace sta { @@ -127,7 +127,7 @@ private: int src_cycle_[TimingRole::index_max + 1]; // Target clock cycle offset. int tgt_cycle_[TimingRole::index_max + 1]; - bool max_cycles_exceeded_; + bool max_cycles_exceeded_{false}; }; -} // namespace +} // namespace sta diff --git a/include/sta/DataCheck.hh b/include/sta/DataCheck.hh index a1bb30ee..e14c6331 100644 --- a/include/sta/DataCheck.hh +++ b/include/sta/DataCheck.hh @@ -24,12 +24,12 @@ #pragma once -#include "MinMax.hh" #include "LibertyClass.hh" +#include "MinMax.hh" #include "NetworkClass.hh" #include "NetworkCmp.hh" -#include "SdcClass.hh" #include "RiseFallMinMax.hh" +#include "SdcClass.hh" namespace sta { @@ -79,4 +79,4 @@ private: const Network *network_; }; -} // namespace +} // namespace sta diff --git a/include/sta/Debug.hh b/include/sta/Debug.hh index afbb68e2..876009a4 100644 --- a/include/sta/Debug.hh +++ b/include/sta/Debug.hh @@ -24,10 +24,10 @@ #pragma once -#include -#include #include #include +#include +#include #include "Format.hh" #include "Report.hh" @@ -64,9 +64,9 @@ public: protected: Report *report_; std::mutex buffer_lock_; - bool debug_on_; + bool debug_on_{false}; DebugMap debug_map_; - int stats_level_; + int stats_level_{0}; }; // Inlining a varargs function would eval the args, which can @@ -76,4 +76,4 @@ protected: debug->report(what, fmt __VA_OPT__(,) __VA_ARGS__); \ } -} // namespace +} // namespace sta diff --git a/include/sta/Delay.hh b/include/sta/Delay.hh index e2547557..6a6984bd 100644 --- a/include/sta/Delay.hh +++ b/include/sta/Delay.hh @@ -27,8 +27,8 @@ #include #include -#include "StaConfig.hh" #include "MinMax.hh" +#include "StaConfig.hh" namespace sta { @@ -37,16 +37,16 @@ class StaState; class Delay { public: - Delay(); - Delay(float mean); + Delay() noexcept; + Delay(float mean) noexcept; Delay(float mean, // std_dev^2 - float std_dev2); + float std_dev2) noexcept; Delay(float mean, float mean_shift, // std_dev^2 float std_dev2, - float skewness); + float skewness) noexcept; void setValues(float mean, float mean_shift, float std_dev2, @@ -62,7 +62,7 @@ public: float skewness() const { return values_[3]; } void setSkewness(float skewness); - void operator=(float delay); + Delay &operator=(float delay); // This allows applications that do not support statistical timing // to treat Delays as floats without explicitly converting with // delayAsFloat. @@ -77,8 +77,8 @@ private: class DelayDbl { public: - DelayDbl(); - DelayDbl(double value); + DelayDbl() noexcept; + DelayDbl(double mean) noexcept; double mean() const { return values_[0]; } void setMean(double mean); double meanShift() const { return values_[1]; } @@ -91,7 +91,7 @@ public: double std_dev2, double skewnes); - void operator=(double delay); + DelayDbl &operator=(double delay); private: std::array values_; @@ -108,7 +108,7 @@ const Delay delay_zero(0.0); class DelayOps { public: - virtual ~DelayOps() {} + virtual ~DelayOps() = default; virtual float stdDev2(const Delay &delay, const EarlyLate *early_late) const = 0; virtual float asFloat(const Delay &delay, @@ -356,4 +356,4 @@ Delay delayRemove(const Delay &delay1, const Delay &delay2); -} // namespace +} // namespace sta diff --git a/include/sta/DelayCalc.hh b/include/sta/DelayCalc.hh index 4969b956..05127976 100644 --- a/include/sta/DelayCalc.hh +++ b/include/sta/DelayCalc.hh @@ -55,4 +55,4 @@ ArcDelayCalc * makeDelayCalc(std::string_view name, StaState *sta); -} // namespace +} // namespace sta diff --git a/include/sta/DelayNormal.hh b/include/sta/DelayNormal.hh index 3a25cbf7..8b94725e 100644 --- a/include/sta/DelayNormal.hh +++ b/include/sta/DelayNormal.hh @@ -1,5 +1,5 @@ // OpenSTA, Static Timing Analyzer -// Copyright (c) 2025, Parallax Software, Inc. +// Copyright (c) 2026, 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 @@ -87,4 +87,4 @@ public: const StaState *sta) const override; }; -} // namespace +} // namespace sta diff --git a/include/sta/DelayScalar.hh b/include/sta/DelayScalar.hh index a413c92d..d255be3c 100644 --- a/include/sta/DelayScalar.hh +++ b/include/sta/DelayScalar.hh @@ -1,5 +1,5 @@ // OpenSTA, Static Timing Analyzer -// Copyright (c) 2025, Parallax Software, Inc. +// Copyright (c) 2026, 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 @@ -87,4 +87,4 @@ public: const StaState *sta) const override; }; -} // namespace +} // namespace sta diff --git a/include/sta/DelaySkewNormal.hh b/include/sta/DelaySkewNormal.hh index 5922e03e..dacce47c 100644 --- a/include/sta/DelaySkewNormal.hh +++ b/include/sta/DelaySkewNormal.hh @@ -1,5 +1,5 @@ // OpenSTA, Static Timing Analyzer -// Copyright (c) 2025, Parallax Software, Inc. +// Copyright (c) 2026, 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 @@ -95,4 +95,4 @@ private: double skewness2) const; }; -} // namespace +} // namespace sta diff --git a/include/sta/DeratingFactors.hh b/include/sta/DeratingFactors.hh index 07678695..00531830 100644 --- a/include/sta/DeratingFactors.hh +++ b/include/sta/DeratingFactors.hh @@ -24,10 +24,10 @@ #pragma once -#include "MinMax.hh" #include "LibertyClass.hh" -#include "SdcClass.hh" +#include "MinMax.hh" #include "RiseFallMinMax.hh" +#include "SdcClass.hh" namespace sta { @@ -111,10 +111,4 @@ private: DeratingFactors factors_[timing_derate_cell_type_count]; }; -class DeratingFactorsNet : public DeratingFactors -{ -public: - DeratingFactorsNet(); -}; - -} // namespace +} // namespace sta diff --git a/include/sta/DisabledPorts.hh b/include/sta/DisabledPorts.hh index 20ea6a18..2352b8a3 100644 --- a/include/sta/DisabledPorts.hh +++ b/include/sta/DisabledPorts.hh @@ -27,8 +27,8 @@ #include #include -#include "NetworkClass.hh" #include "LibertyClass.hh" +#include "NetworkClass.hh" #include "SdcClass.hh" namespace sta { @@ -46,7 +46,6 @@ using TimingArcSetSet = std::set; class DisabledPorts { public: - DisabledPorts(); ~DisabledPorts(); void setDisabledAll(); void removeDisabledAll(); @@ -67,10 +66,10 @@ public: [[nodiscard]] bool all() const { return all_; } private: - bool all_; - LibertyPortSet *from_; - LibertyPortSet *to_; - LibertyPortPairSet *from_to_; + bool all_{false}; + LibertyPortSet *from_{nullptr}; + LibertyPortSet *to_{nullptr}; + LibertyPortPairSet *from_to_{nullptr}; }; // set_disable_timing cell [-from] [-to] @@ -89,7 +88,7 @@ public: private: LibertyCell *cell_; - TimingArcSetSet *arc_sets_; + TimingArcSetSet *arc_sets_{nullptr}; }; // set_disable_timing instance [-from] [-to] @@ -111,4 +110,4 @@ sortByPathName(const DisabledInstancePortsMap *inst_map, LibertyPortPairSeq sortByName(const LibertyPortPairSet *set); -} // namespace +} // namespace sta diff --git a/include/sta/DispatchQueue.hh b/include/sta/DispatchQueue.hh index f28d94c5..ceda2e78 100644 --- a/include/sta/DispatchQueue.hh +++ b/include/sta/DispatchQueue.hh @@ -5,23 +5,23 @@ #pragma once -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include namespace sta { class DispatchQueue { - typedef std::function fp_t; + using fp_t = std::function; public: - DispatchQueue(size_t thread_cnt); + DispatchQueue(size_t thread_count); ~DispatchQueue(); void setThreadCount(size_t thread_count); size_t getThreadCount() const; @@ -49,4 +49,4 @@ private: bool quit_ = false; }; -} // namespace +} // namespace sta diff --git a/include/sta/EnumNameMap.hh b/include/sta/EnumNameMap.hh index 9ae20acb..6af151c3 100644 --- a/include/sta/EnumNameMap.hh +++ b/include/sta/EnumNameMap.hh @@ -34,7 +34,8 @@ template class EnumNameMap { public: - EnumNameMap(std::initializer_list> enum_names); + EnumNameMap(std::initializer_list> enum_names) noexcept; const std::string &find(ENUM key) const; ENUM find(std::string_view name, ENUM unknown_key) const; @@ -49,7 +50,7 @@ private: }; template -EnumNameMap::EnumNameMap(std::initializer_list> enum_names) : +EnumNameMap::EnumNameMap(std::initializer_list> enum_names) noexcept : enum_map_(enum_names) { for (const auto& [key, name] : enum_map_) @@ -97,4 +98,4 @@ EnumNameMap::find(std::string_view name, return unknown_key; } -} // namespace +} // namespace sta diff --git a/include/sta/EquivCells.hh b/include/sta/EquivCells.hh index 1227a544..510ee50f 100644 --- a/include/sta/EquivCells.hh +++ b/include/sta/EquivCells.hh @@ -87,4 +87,4 @@ bool equivCellSequentials(const LibertyCell *cell1, const LibertyCell *cell2); -} // namespace +} // namespace sta diff --git a/include/sta/Error.hh b/include/sta/Error.hh index 80fb1b0a..5754a99b 100644 --- a/include/sta/Error.hh +++ b/include/sta/Error.hh @@ -35,8 +35,6 @@ namespace sta { class Exception : public std::exception { public: - Exception(); - virtual ~Exception() {} const char *what() const noexcept override = 0; }; @@ -44,7 +42,7 @@ class ExceptionMsg : public Exception { public: ExceptionMsg(const std::string &msg, - const bool suppressed); + bool suppressed); const char *what() const noexcept override; bool suppressed() const { return suppressed_; } @@ -93,4 +91,4 @@ protected: #define criticalError(id, msg) \ Report::defaultReport()->fileCritical(id, __FILE__, __LINE__, msg) -} // namespace +} // namespace sta diff --git a/include/sta/ExceptionPath.hh b/include/sta/ExceptionPath.hh index bfe9c16d..c67270ae 100644 --- a/include/sta/ExceptionPath.hh +++ b/include/sta/ExceptionPath.hh @@ -29,8 +29,8 @@ #include #include "Error.hh" -#include "SdcCmdComment.hh" #include "SdcClass.hh" +#include "SdcCmdComment.hh" namespace sta { @@ -70,6 +70,7 @@ public: virtual bool isFilter() const { return false; } virtual ExceptionPathType type() const = 0; virtual std::string to_string(const Network *network) const; + virtual std::string_view typeString() const = 0; ExceptionFrom *from() const { return from_; } ExceptionThruSeq *thrus() const { return thrus_; } ExceptionTo *to() const { return to_; } @@ -135,7 +136,6 @@ public: virtual bool breakPath() const { return false; } protected: - virtual const char *typeString() const = 0; std::string fromThruToString(const Network *network) const; void makeStates(); @@ -145,7 +145,7 @@ protected: const MinMaxAll *min_max_; bool own_pts_; int priority_; - size_t id_; // Unique ID assigned by Sdc. + size_t id_{0}; // Unique ID assigned by Sdc. ExceptionState *states_; }; @@ -172,7 +172,7 @@ public: bool own_pts) override; bool isFalse() const override { return true; } ExceptionPathType type() const override { return ExceptionPathType::false_path; } - const char *typeString() const override; + std::string_view typeString() const override; bool mergeable(ExceptionPath *exception) const override; bool overrides(ExceptionPath *exception) const override; int typePriority() const override; @@ -188,7 +188,7 @@ public: bool own_pts); bool isLoop() const override { return true; } ExceptionPathType type() const override { return ExceptionPathType::loop; } - const char *typeString() const override; + std::string_view typeString() const override; bool mergeable(ExceptionPath *exception) const override; }; @@ -212,7 +212,7 @@ public: bool isPathDelay() const override { return true; } ExceptionPathType type() const override { return ExceptionPathType::path_delay; } std::string to_string(const Network *network) const override; - const char *typeString() const override; + std::string_view typeString() const override; bool mergeable(ExceptionPath *exception) const override; bool overrides(ExceptionPath *exception) const override; float delay() const override { return delay_; } @@ -248,7 +248,7 @@ public: bool matches(const MinMax *min_max, bool exactly) const override; std::string to_string(const Network *network) const override; - const char *typeString() const override; + std::string_view typeString() const override; bool mergeable(ExceptionPath *exception) const override; bool overrides(ExceptionPath *exception) const override; bool useEndClk() const override { return use_end_clk_; } @@ -279,7 +279,7 @@ public: bool own_pts) override; bool isFilter() const override { return true; } ExceptionPathType type() const override { return ExceptionPathType::filter; } - const char *typeString() const override; + std::string_view typeString() const override; bool mergeable(ExceptionPath *exception) const override; bool overrides(ExceptionPath *exception) const override; bool resetMatch(ExceptionFrom *from, @@ -301,14 +301,13 @@ public: ExceptionTo *to, bool own_pts, std::string_view comment); - ~GroupPath() override; ExceptionPath *clone(ExceptionFrom *from, ExceptionThruSeq *thrus, ExceptionTo *to, bool own_pts) override; bool isGroupPath() const override { return true; } ExceptionPathType type() const override { return ExceptionPathType::group_path; } - const char *typeString() const override; + std::string_view typeString() const override; bool mergeable(ExceptionPath *exception) const override; bool overrides(ExceptionPath *exception) const override; int typePriority() const override; @@ -327,7 +326,7 @@ class ExceptionPt public: ExceptionPt(const RiseFallBoth *rf, bool own_pts); - virtual ~ExceptionPt() {}; + virtual ~ExceptionPt() = default; virtual bool isFrom() const { return false; } virtual bool isThru() const { return false; } virtual bool isTo() const { return false; } @@ -367,7 +366,7 @@ protected: bool own_pts_; // Hash is cached because there may be many objects to speed up // exception merging. - size_t hash_; + size_t hash_{0}; // Maximum number of objects for to_string() to show. static const int to_string_max_objects_; @@ -386,7 +385,7 @@ public: const RiseFallBoth *rf, bool own_pts, const Network *network); - ~ExceptionFromTo(); + ~ExceptionFromTo() override; PinSet *pins() override { return pins_; } bool hasPins() const; ClockSet *clks() override { return clks_; } @@ -512,7 +511,7 @@ public: const RiseFallBoth *rf, bool own_pts, const Network *network); - ~ExceptionThru(); + ~ExceptionThru() override; ExceptionThru *clone(const Network *network); std::string to_string(const Network *network) const override; bool isThru() const override { return true; } @@ -538,15 +537,6 @@ public: const Network *network) const; int typePriority() const override { return 2; } size_t objectCount() const override; - void connectPinAfter(PinSet *drvrs, - Network *network) override; - void deletePinBefore(const Pin *pin, - Network *network) override; - void deleteInstance(const Instance *inst, - const Network *network); - -protected: - void findHash(const Network *network); void addPin(const Pin *pin, const Network *network) override; void addEdge(const EdgePins &edge, @@ -556,6 +546,15 @@ protected: void addInstance(const Instance *inst, const Network *network) override; void addClock(Clock *) override {} + void connectPinAfter(PinSet *drvrs, + Network *network) override; + void deletePinBefore(const Pin *pin, + Network *network) override; + void deleteInstance(const Instance *inst, + const Network *network); + +protected: + void findHash(const Network *network); void deletePin(const Pin *pin, const Network *network); void deleteEdge(const EdgePins &edge); @@ -583,7 +582,7 @@ protected: // Leaf/port pins. PinSet *pins_; // Graph edges that traverse thru hierarchical pins. - EdgePinsSet *edges_; + EdgePinsSet *edges_{nullptr}; NetSet *nets_; InstanceSet *insts_; }; @@ -602,9 +601,9 @@ public: private: const ExceptionPath *exception_; - bool from_done_; + bool from_done_{false}; ExceptionThruSeq::iterator thru_iter_; - bool to_done_; + bool to_done_{false}; }; // Visitor for exception point sets expanded into single object paths. @@ -620,7 +619,6 @@ class ExpandedExceptionVisitor public: ExpandedExceptionVisitor(ExceptionPath *exception, const Network *network); - virtual ~ExpandedExceptionVisitor() {} void visitExpansions(); // From/thrus/to have a single exception point (pin/instance/net/clock). virtual void visit(ExceptionFrom *from, @@ -666,7 +664,7 @@ public: private: ExceptionPath *exception_; ExceptionThru *next_thru_; - ExceptionState *next_state_; + ExceptionState *next_state_{nullptr}; int index_; }; @@ -678,7 +676,7 @@ exceptionStateCmp(const ExceptionState *state1, class EmptyExpceptionPt : public Exception { public: - virtual const char *what() const noexcept; + const char *what() const noexcept override; }; class ExceptionPathLess @@ -698,4 +696,4 @@ checkFromThrusTo(ExceptionFrom *from, ExceptionThruSeq *thrus, ExceptionTo *to); -} // namespace +} // namespace sta diff --git a/include/sta/FilterObjects.hh b/include/sta/FilterObjects.hh index dbeec3c5..71bea6c0 100644 --- a/include/sta/FilterObjects.hh +++ b/include/sta/FilterObjects.hh @@ -1,5 +1,5 @@ // OpenSTA, Static Timing Analyzer -// Copyright (c) 2025, Parallax Software, Inc. +// Copyright (c) 2026, 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 @@ -28,6 +28,7 @@ #include #include +#include "GraphClass.hh" #include "NetworkClass.hh" #include "SdcClass.hh" #include "SearchClass.hh" @@ -40,52 +41,52 @@ class Report; PortSeq filterPorts(std::string_view filter_expression, - PortSeq *objects, + PortSeq *ports, Sta *sta); InstanceSeq filterInstances(std::string_view filter_expression, - InstanceSeq *objects, + InstanceSeq *insts, Sta *sta); PinSeq filterPins(std::string_view filter_expression, - PinSeq *objects, + PinSeq *pins, Sta *sta); NetSeq filterNets(std::string_view filter_expression, - NetSeq *objects, + NetSeq *nets, Sta *sta); ClockSeq filterClocks(std::string_view filter_expression, - ClockSeq *objects, + ClockSeq *clks, Sta *sta); LibertyCellSeq filterLibCells(std::string_view filter_expression, - LibertyCellSeq *objects, + LibertyCellSeq *cells, Sta *sta); LibertyPortSeq filterLibPins(std::string_view filter_expression, - LibertyPortSeq *objects, + LibertyPortSeq *ports, Sta *sta); LibertyLibrarySeq filterLibertyLibraries(std::string_view filter_expression, - LibertyLibrarySeq *objects, + LibertyLibrarySeq *libs, Sta *sta); EdgeSeq filterTimingArcs(std::string_view filter_expression, - EdgeSeq *objects, + EdgeSeq *edges, Sta *sta); PathEndSeq filterPathEnds(std::string_view filter_expression, - PathEndSeq *objects, + PathEndSeq *ends, Sta *sta); // For FilterExpr unit tests. @@ -93,4 +94,4 @@ StringSeq filterExprToPostfix(std::string_view expr, Report *report); -} // namespace +} // namespace sta diff --git a/include/sta/FuncExpr.hh b/include/sta/FuncExpr.hh index 00ff6dee..72f7bf96 100644 --- a/include/sta/FuncExpr.hh +++ b/include/sta/FuncExpr.hh @@ -26,8 +26,8 @@ #include -#include "NetworkClass.hh" #include "LibertyClass.hh" +#include "NetworkClass.hh" namespace sta { @@ -105,4 +105,4 @@ private: FuncExpr * funcExprNot(FuncExpr *expr); -} // namespace +} // namespace sta diff --git a/include/sta/Fuzzy.hh b/include/sta/Fuzzy.hh index 5517190b..29963b23 100644 --- a/include/sta/Fuzzy.hh +++ b/include/sta/Fuzzy.hh @@ -48,4 +48,4 @@ fuzzyGreaterEqual(float v1, bool fuzzyInf(float value); -} // namespace +} // namespace sta diff --git a/include/sta/Graph.hh b/include/sta/Graph.hh index a7475962..233d363c 100644 --- a/include/sta/Graph.hh +++ b/include/sta/Graph.hh @@ -24,19 +24,19 @@ #pragma once -#include #include #include +#include -#include "Iterator.hh" -#include "ObjectTable.hh" -#include "LibertyClass.hh" -#include "NetworkClass.hh" #include "Delay.hh" #include "GraphClass.hh" -#include "VertexId.hh" +#include "Iterator.hh" +#include "LibertyClass.hh" +#include "NetworkClass.hh" +#include "ObjectTable.hh" #include "Path.hh" #include "StaState.hh" +#include "VertexId.hh" namespace sta { @@ -61,7 +61,7 @@ public: Graph(StaState *sta, DcalcAPIndex ap_count); void makeGraph(); - ~Graph(); + ~Graph() override; // Number of arc delays and slews from sdf or delay calculation. void setDelayCount(DcalcAPIndex ap_count); @@ -102,7 +102,7 @@ public: const Slew &slew); // Edge functions. - Edge *edge(EdgeId edge_index) const; + Edge *edge(EdgeId edge_id) const; EdgeId id(const Edge *edge) const; Edge *makeEdge(Vertex *from, Vertex *to, @@ -211,8 +211,8 @@ protected: void initArcDelays(Edge *edge); void removeDelayAnnotated(Edge *edge); - VertexTable *vertices_; - EdgeTable *edges_; + VertexTable *vertices_{nullptr}; + EdgeTable *edges_{nullptr}; // Bidirect pins are split into two vertices: // load/sink (top level output, instance pin input) vertex in pin_vertex_map // driver/source (top level input, instance pin output) vertex @@ -291,8 +291,8 @@ protected: bool is_bidirect_drvr, bool is_reg_clk); void clear(); - Slew *slews() { return std::bit_cast(slews_); } - const Slew *slews() const { return std::bit_cast(slews_); } + Slew *slews() { return reinterpret_cast(slews_); } + const Slew *slews() const { return reinterpret_cast(slews_); } float *slewsFloat() { return slews_; } const float *slewsFloat() const { return slews_; } void setSlews(float *slews); @@ -436,9 +436,9 @@ private: Network *network_; Instance *top_inst_; LeafInstanceIterator *inst_iter_; - InstancePinIterator *pin_iter_; - Vertex *vertex_; - Vertex *bidir_vertex_; + InstancePinIterator *pin_iter_{nullptr}; + Vertex *vertex_{nullptr}; + Vertex *bidir_vertex_{nullptr}; }; class VertexInEdgeIterator : public VertexEdgeIterator @@ -491,4 +491,4 @@ makeVertexSet(StaState *sta) return VertexSet(VertexIdLess(sta->graphRef())); } -} // namespace +} // namespace sta diff --git a/include/sta/GraphClass.hh b/include/sta/GraphClass.hh index c56cea17..cdf7539b 100644 --- a/include/sta/GraphClass.hh +++ b/include/sta/GraphClass.hh @@ -25,13 +25,13 @@ #pragma once #include -#include #include +#include -#include "ObjectId.hh" -#include "MinMax.hh" -#include "Transition.hh" #include "Delay.hh" +#include "MinMax.hh" +#include "ObjectId.hh" +#include "Transition.hh" namespace sta { @@ -76,4 +76,4 @@ static constexpr int slew_annotated_bits = MinMax::index_count * RiseFall::index // Bit shifts used to mark vertices in a Bfs queue. enum class BfsIndex { dcalc, arrival, required, other, bits }; -} // namespace +} // namespace sta diff --git a/include/sta/GraphCmp.hh b/include/sta/GraphCmp.hh index bf67c963..9c714d9c 100644 --- a/include/sta/GraphCmp.hh +++ b/include/sta/GraphCmp.hh @@ -24,9 +24,9 @@ #pragma once +#include "GraphClass.hh" #include "NetworkClass.hh" #include "NetworkCmp.hh" -#include "GraphClass.hh" namespace sta { @@ -59,4 +59,4 @@ sortEdges(EdgeSeq *edges, Network *network, Graph *graph); -} // namespace +} // namespace sta diff --git a/include/sta/GraphDelayCalc.hh b/include/sta/GraphDelayCalc.hh index 85d198c6..caf309b5 100644 --- a/include/sta/GraphDelayCalc.hh +++ b/include/sta/GraphDelayCalc.hh @@ -25,16 +25,16 @@ #pragma once #include -#include #include #include +#include -#include "NetworkClass.hh" -#include "GraphClass.hh" -#include "SearchClass.hh" -#include "SdcClass.hh" -#include "StaState.hh" #include "ArcDelayCalc.hh" +#include "GraphClass.hh" +#include "NetworkClass.hh" +#include "SdcClass.hh" +#include "SearchClass.hh" +#include "StaState.hh" namespace sta { @@ -53,8 +53,8 @@ class GraphDelayCalc : public StaState { public: GraphDelayCalc(StaState *sta); - virtual ~GraphDelayCalc(); - virtual void copyState(const StaState *sta); + ~GraphDelayCalc() override; + void copyState(const StaState *sta) override; // Set the observer for edge delay changes. virtual void setObserver(DelayCalcObserver *observer); // Invalidate all delays/slews. @@ -104,7 +104,7 @@ public: float &pin_cap, float &wire_cap, float &fanout, - bool &has_set_load) const; + bool &has_net_load) const; void parasiticLoad(const Pin *drvr_pin, const RiseFall *rf, const Scene *scene, @@ -171,7 +171,7 @@ protected: Vertex *drvr_vertex, const RiseFall *rf, const LibertyPort *from_port, - float *from_slews, + const DriveCellSlews *from_slews, const LibertyPort *to_port, const Scene *scene, const MinMax *min_max, @@ -191,7 +191,7 @@ protected: ArcDelayCalc *arc_delay_calc, LoadPinIndexMap &load_pin_index_map); MultiDrvrNet *multiDrvrNet(const Vertex *drvr_vertex) const; - MultiDrvrNet *findMultiDrvrNet(Vertex *drvr_pin); + MultiDrvrNet *findMultiDrvrNet(Vertex *drvr_vertex); MultiDrvrNet *makeMultiDrvrNet(Vertex *drvr_vertex); bool hasMultiDrvrs(Vertex *drvr_vertex); Vertex *firstLoad(Vertex *drvr_vertex); @@ -235,7 +235,7 @@ protected: ArcDelayCalc *arc_delay_calc, bool propagate); DrvrLoadSlews loadSlews(LoadPinIndexMap &load_pin_index_map); - bool loadSlewsChanged(DrvrLoadSlews &prev_load_slews, + bool loadSlewsChanged(DrvrLoadSlews &load_slews_prev, LoadPinIndexMap &load_pin_index_map); void enqueueTimingChecksEdges(Vertex *vertex); bool annotateDelaysSlews(Edge *edge, @@ -294,10 +294,10 @@ protected: bool &has_net_load) const; // Observer for edge delay changes. - DelayCalcObserver *observer_; - bool delays_seeded_; - bool incremental_; - bool delays_exist_; + DelayCalcObserver *observer_{nullptr}; + bool delays_seeded_{false}; + bool incremental_{false}; + bool delays_exist_{false}; // Vertices with invalid -to delays. VertexSet invalid_delays_; // Timing check edges with invalid delays. @@ -313,7 +313,7 @@ protected: std::mutex multi_drvr_lock_; // Percentage (0.0:1.0) change in delay that causes downstream // delays to be recomputed during incremental delay calculation. - float incremental_delay_tolerance_; + float incremental_delay_tolerance_{0.0}; friend class FindVertexDelays; friend class MultiDrvrNet; @@ -323,8 +323,7 @@ protected: class DelayCalcObserver { public: - DelayCalcObserver() {} - virtual ~DelayCalcObserver() {} + virtual ~DelayCalcObserver() = default; virtual void delayChangedFrom(Vertex *vertex) = 0; virtual void delayChangedTo(Vertex *vertex) = 0; virtual void checkDelayChangedTo(Vertex *vertex) = 0; @@ -335,7 +334,6 @@ public: class MultiDrvrNet { public: - MultiDrvrNet(); VertexSeq &drvrs() { return drvrs_; } const VertexSeq &drvrs() const { return drvrs_; } bool parallelGates(const Network *network) const; @@ -353,10 +351,10 @@ public: private: // Driver that triggers delay calculation for all the drivers on the net. - Vertex *dcalc_drvr_; + Vertex *dcalc_drvr_{nullptr}; VertexSeq drvrs_; // [drvr_rf->index][dcalc_ap->index] std::vector net_caps_; }; -} // namespace +} // namespace sta diff --git a/include/sta/Hash.hh b/include/sta/Hash.hh index 6f87d56c..5cfd423d 100644 --- a/include/sta/Hash.hh +++ b/include/sta/Hash.hh @@ -24,8 +24,8 @@ #pragma once -#include #include +#include #include namespace sta { @@ -67,4 +67,4 @@ hashString(std::string_view str); #define hashPtr(ptr) (reinterpret_cast(ptr) >> 2) #endif -} // namespace +} // namespace sta diff --git a/include/sta/HpinDrvrLoad.hh b/include/sta/HpinDrvrLoad.hh index 974156fc..4b68cae8 100644 --- a/include/sta/HpinDrvrLoad.hh +++ b/include/sta/HpinDrvrLoad.hh @@ -47,8 +47,7 @@ public: class HpinDrvrLoadVisitor { public: - HpinDrvrLoadVisitor() {} - virtual ~HpinDrvrLoadVisitor() {} + virtual ~HpinDrvrLoadVisitor() = default; virtual void visit(HpinDrvrLoad *drvr_load) = 0; }; @@ -76,4 +75,4 @@ private: PinSet *hpins_to_load_; }; -} // namespace +} // namespace sta diff --git a/include/sta/InputDrive.hh b/include/sta/InputDrive.hh index 6eacc7e7..30bdd5f3 100644 --- a/include/sta/InputDrive.hh +++ b/include/sta/InputDrive.hh @@ -24,10 +24,11 @@ #pragma once -#include "MinMax.hh" #include "LibertyClass.hh" +#include "MinMax.hh" #include "NetworkClass.hh" #include "RiseFallMinMax.hh" +#include "SdcClass.hh" namespace sta { @@ -58,7 +59,7 @@ public: void setDriveCell(const LibertyLibrary *library, const LibertyCell *cell, const LibertyPort *from_port, - float *from_slews, + const DriveCellSlews &from_slews, const LibertyPort *to_port, const RiseFallBoth *rf, const MinMaxAll *min_max); @@ -67,7 +68,7 @@ public: // Return values. const LibertyCell *&cell, const LibertyPort *&from_port, - float *&from_slews, + const DriveCellSlews *&from_slews, const LibertyPort *&to_port) const; InputDriveCell *driveCell(const RiseFall *rf, const MinMax *min_max) const; @@ -94,7 +95,7 @@ public: InputDriveCell(const LibertyLibrary *library, const LibertyCell *cell, const LibertyPort *from_port, - float *from_slews, + const DriveCellSlews &from_slews, const LibertyPort *to_port); const LibertyLibrary *library() const { return library_; } void setLibrary(const LibertyLibrary *library); @@ -102,8 +103,8 @@ public: void setCell(const LibertyCell *cell); const LibertyPort *fromPort() const { return from_port_; } void setFromPort(const LibertyPort *from_port); - float *fromSlews() { return from_slews_; } - void setFromSlews(float *from_slews); + const DriveCellSlews &fromSlews() const { return from_slews_; } + void setFromSlews(const DriveCellSlews &from_slews); const LibertyPort *toPort() const { return to_port_; } void setToPort(const LibertyPort *to_port); bool equal(const InputDriveCell *drive) const; @@ -112,8 +113,8 @@ private: const LibertyLibrary *library_; const LibertyCell *cell_; const LibertyPort *from_port_; - float from_slews_[RiseFall::index_count]; + DriveCellSlews from_slews_; const LibertyPort *to_port_; }; -} // namespace +} // namespace sta diff --git a/include/sta/InternalPower.hh b/include/sta/InternalPower.hh index 30d20ebb..fb1c2d01 100644 --- a/include/sta/InternalPower.hh +++ b/include/sta/InternalPower.hh @@ -94,4 +94,4 @@ protected: InternalPowerModels models_; }; -} // namespace +} // namespace sta diff --git a/include/sta/Iterator.hh b/include/sta/Iterator.hh index 83e799eb..0c7e9ba3 100644 --- a/include/sta/Iterator.hh +++ b/include/sta/Iterator.hh @@ -35,7 +35,7 @@ template class Iterator { public: - virtual ~Iterator() {} + virtual ~Iterator() = default; virtual bool hasNext() = 0; virtual OBJ next() = 0; }; @@ -116,4 +116,4 @@ protected: SET_TYPE::const_iterator itr_; }; -} // namespace +} // namespace sta diff --git a/include/sta/LeakagePower.hh b/include/sta/LeakagePower.hh index 15f84db2..265e83f2 100644 --- a/include/sta/LeakagePower.hh +++ b/include/sta/LeakagePower.hh @@ -50,4 +50,4 @@ protected: float power_; }; -} // namespace +} // namespace sta diff --git a/include/sta/Liberty.hh b/include/sta/Liberty.hh index a6f8b5b3..20443127 100644 --- a/include/sta/Liberty.hh +++ b/include/sta/Liberty.hh @@ -80,7 +80,7 @@ public: private: std::string value_; - FuncExpr *cond_; + FuncExpr *cond_{nullptr}; std::string sdf_cond_; }; @@ -159,10 +159,10 @@ enum class PwrGndType { none, deepnwell, deeppwell}; enum class ScaleFactorPvt { process, volt, temp, unknown }; -constexpr int scale_factor_pvt_count = int(ScaleFactorPvt::unknown) + 1; +constexpr int scale_factor_pvt_count = static_cast(ScaleFactorPvt::unknown) + 1; enum class TableTemplateType { delay, power, output_current, capacitance, ocv }; -constexpr int table_template_type_count = int(TableTemplateType::ocv) + 1; +constexpr int table_template_type_count = static_cast(TableTemplateType::ocv) + 1; enum class LevelShifterType { HL, LH, HL_LH }; @@ -206,7 +206,7 @@ class LibertyLibrary : public ConcreteLibrary public: LibertyLibrary(std::string_view name, std::string_view filename); - virtual ~LibertyLibrary(); + ~LibertyLibrary() override; LibertyCell *findLibertyCell(std::string_view name) const; LibertyCellSeq findLibertyCellsMatching(PatternMatch *pattern); // Liberty cells that are buffers. @@ -269,7 +269,7 @@ public: void defaultIntrinsic(const RiseFall *rf, // Return values. - float &intrisic, + float &intrinsic, bool &exists) const; void setDefaultIntrinsic(const RiseFall *rf, float value); @@ -360,7 +360,7 @@ public: void setDefaultOcvDerate(OcvDerate *derate); OcvDerate *makeOcvDerate(std::string_view name); OcvDerate *findOcvDerate(std::string_view derate_name); - void addSupplyVoltage(std::string_view suppy_name, + void addSupplyVoltage(std::string_view supply_name, float voltage); bool supplyExists(std::string_view supply_name) const; void supplyVoltage(std::string_view supply_name, @@ -374,19 +374,19 @@ public: static void makeSceneMap(LibertyLibrary *lib, - int ap_index, + size_t lib_ap_index, Network *network, Report *report); static void makeSceneMap(LibertyCell *link_cell, - LibertyCell *map_cell, - int ap_index, + LibertyCell *scene_cell, + size_t lib_ap_index, Report *report); static void makeSceneMap(LibertyCell *cell1, LibertyCell *cell2, bool link, - int ap_index, + size_t lib_ap_index, Report *report); static void checkScenes(LibertyCell *cell, @@ -396,62 +396,66 @@ public: DriverWaveform *findDriverWaveform(std::string_view name); DriverWaveform *driverWaveformDefault() { return findDriverWaveform(""); } DriverWaveform *makeDriverWaveform(std::string_view name, - TablePtr waveforms); + const TablePtr &waveforms); protected: float degradeWireSlew(const TableModel *model, float in_slew, float wire_delay) const; - Units *units_; - DelayModelType delay_model_type_; - BusDclMap bus_dcls_; - TableTemplateMap template_maps_[table_template_type_count]; - float nominal_process_; - float nominal_voltage_; - float nominal_temperature_; - ScaleFactors *scale_factors_; - ScaleFactorsMap scale_factors_map_; - TableModel *wire_slew_degradation_tbls_[RiseFall::index_count]; - float default_input_pin_cap_; - float default_output_pin_cap_; - float default_bidirect_pin_cap_; - RiseFallValues default_intrinsic_; - RiseFallValues default_inout_pin_res_; - RiseFallValues default_output_pin_res_; - float default_fanout_load_; - bool default_fanout_load_exists_; - float default_max_cap_; - bool default_max_cap_exists_; - float default_max_fanout_; - bool default_max_fanout_exists_; - float default_max_slew_; - bool default_max_slew_exists_; - float input_threshold_[RiseFall::index_count]; - float output_threshold_[RiseFall::index_count]; - float slew_lower_threshold_[RiseFall::index_count]; - float slew_upper_threshold_[RiseFall::index_count]; - float slew_derate_from_library_; - WireloadMap wireloads_; - const Wireload *default_wire_load_; - WireloadMode default_wire_load_mode_; - const WireloadSelection *default_wire_load_selection_; - WireloadSelectionMap wire_load_selections_; - OperatingConditionsMap operating_conditions_; - OperatingConditions *default_operating_conditions_; - float ocv_arc_depth_; - OcvDerate *default_ocv_derate_; - OcvDerateMap ocv_derate_map_; - SupplyVoltageMap supply_voltage_map_; - LibertyCellSeq *buffers_; - LibertyCellSeq *inverters_; - DriverWaveformMap driver_waveform_map_; - static constexpr float input_threshold_default_ = .5; static constexpr float output_threshold_default_ = .5; static constexpr float slew_lower_threshold_default_ = .2; static constexpr float slew_upper_threshold_default_ = .8; + Units *units_{nullptr}; + DelayModelType delay_model_type_{DelayModelType::table}; + BusDclMap bus_dcls_; + TableTemplateMap template_maps_[table_template_type_count]; + float nominal_process_{0.0F}; + float nominal_voltage_{0.0F}; + float nominal_temperature_{0.0F}; + ScaleFactors *scale_factors_{nullptr}; + ScaleFactorsMap scale_factors_map_; + TableModel *wire_slew_degradation_tbls_[RiseFall::index_count]{nullptr, nullptr}; + float default_input_pin_cap_{0.0F}; + float default_output_pin_cap_{0.0F}; + float default_bidirect_pin_cap_{0.0F}; + RiseFallValues default_intrinsic_; + RiseFallValues default_inout_pin_res_; + RiseFallValues default_output_pin_res_; + float default_fanout_load_{0.0F}; + bool default_fanout_load_exists_{false}; + float default_max_cap_{0.0F}; + bool default_max_cap_exists_{false}; + float default_max_fanout_{0.0F}; + bool default_max_fanout_exists_{false}; + float default_max_slew_{0.0F}; + bool default_max_slew_exists_{false}; + float input_threshold_[RiseFall::index_count]{input_threshold_default_, + input_threshold_default_}; + float output_threshold_[RiseFall::index_count]{output_threshold_default_, + output_threshold_default_}; + float slew_lower_threshold_[RiseFall::index_count]{slew_lower_threshold_default_, + slew_lower_threshold_default_}; + float slew_upper_threshold_[RiseFall::index_count]{slew_upper_threshold_default_, + slew_upper_threshold_default_}; + float slew_derate_from_library_{1.0F}; + WireloadMap wireloads_; + const Wireload *default_wire_load_{nullptr}; + WireloadMode default_wire_load_mode_{WireloadMode::unknown}; + const WireloadSelection *default_wire_load_selection_{nullptr}; + WireloadSelectionMap wire_load_selections_; + OperatingConditionsMap operating_conditions_; + OperatingConditions *default_operating_conditions_{nullptr}; + float ocv_arc_depth_{0.0F}; + OcvDerate *default_ocv_derate_{nullptr}; + OcvDerateMap ocv_derate_map_; + SupplyVoltageMap supply_voltage_map_; + LibertyCellSeq *buffers_{nullptr}; + LibertyCellSeq *inverters_{nullptr}; + DriverWaveformMap driver_waveform_map_; + private: friend class LibertyCell; friend class LibertyCellIterator; @@ -476,12 +480,11 @@ public: LibertyCell(LibertyLibrary *library, std::string_view name, std::string_view filename); - virtual ~LibertyCell(); + ~LibertyCell() override; LibertyLibrary *libertyLibrary() const { return liberty_library_; } LibertyLibrary *libertyLibrary() { return liberty_library_; } LibertyPort *findLibertyPort(std::string_view name) const; LibertyPortSeq findLibertyPortsMatching(PatternMatch *pattern) const; - bool hasInternalPorts() const { return has_internal_ports_; } ScaleFactors *scaleFactors() const { return scale_factors_; } void setScaleFactors(ScaleFactors *scale_factors); ModeDef *makeModeDef(std::string_view name); @@ -524,7 +527,7 @@ public: const LibertyPort *to) const; size_t timingArcSetCount() const; // Find a timing arc set equivalent to key. - TimingArcSet *findTimingArcSet(TimingArcSet *key) const; + TimingArcSet *findTimingArcSet(TimingArcSet *arc_set) const; TimingArcSet *findTimingArcSet(size_t index) const; bool hasTimingArcs(LibertyPort *port) const; @@ -552,7 +555,7 @@ public: // timing arcs. bool hasInferedRegTimingArcs() const { return has_infered_reg_timing_arcs_; } TestCell *testCell() const { return test_cell_; } - void latchEnable(const TimingArcSet *arc_set, + void latchEnable(const TimingArcSet *d_to_q_set, // Return values. const LibertyPort *&enable_port, const FuncExpr *&enable_func, @@ -560,7 +563,7 @@ public: const RiseFall *latchCheckEnableEdge(TimingArcSet *check_set); LibertyCell *sceneCell(const Scene *scene, const MinMax *min_max); - LibertyCell *sceneCell(int ap_index); + LibertyCell *sceneCell(size_t lib_ap_index); // AOCV float ocvArcDepth() const; @@ -604,7 +607,7 @@ public: void setTestCell(TestCell *test); void setHasInferedRegTimingArcs(bool infered); void setSceneCell(LibertyCell *scene_cell, - int ap_index); + size_t lib_ap_index); // Call after cell is finished being constructed. void finish(bool infer_latches, Report *report, @@ -623,9 +626,9 @@ public: void setFootprint(std::string_view footprint); const std::string &userFunctionClass() const { return user_function_class_; } void setUserFunctionClass(std::string_view user_function_class); + void addPort(ConcretePort *port) override; protected: - void addPort(ConcretePort *port); void setHasInternalPorts(bool has_internal); void setLibertyLibrary(LibertyLibrary *library); void makeLatchEnables(Report *report, @@ -661,35 +664,35 @@ protected: bool checkSceneCell(const Scene *scene, const MinMax *min_max) const; - LibertyLibrary *liberty_library_; - float area_; - bool dont_use_; - bool is_macro_; - bool is_memory_; - bool is_pad_; - bool is_clock_cell_; - bool is_level_shifter_; - LevelShifterType level_shifter_type_; - bool is_isolation_cell_; - bool always_on_; - SwitchCellType switch_cell_type_; - bool interface_timing_; - ClockGateType clock_gate_type_; + LibertyLibrary *liberty_library_{nullptr}; + float area_{0.0F}; + bool dont_use_{false}; + bool is_macro_{false}; + bool is_memory_{false}; + bool is_pad_{false}; + bool is_clock_cell_{false}; + bool is_level_shifter_{false}; + LevelShifterType level_shifter_type_{LevelShifterType::HL_LH}; + bool is_isolation_cell_{false}; + bool always_on_{false}; + SwitchCellType switch_cell_type_{SwitchCellType::fine_grain}; + bool interface_timing_{false}; + ClockGateType clock_gate_type_{ClockGateType::none}; TimingArcSetSeq timing_arc_sets_; TimingArcSetSet timing_arc_set_set_; LibertyPortPairTimingArcMap port_timing_arc_set_map_; - bool has_infered_reg_timing_arcs_; + bool has_infered_reg_timing_arcs_{false}; InternalPowerSeq internal_powers_; PortInternalPowerMap port_internal_powers_; LeakagePowerSeq leakage_powers_; SequentialSeq sequentials_; PortToSequentialMap port_to_seq_map_; - Statetable *statetable_; + Statetable *statetable_{nullptr}; BusDclMap bus_dcls_; ModeDefMap mode_defs_; - ScaleFactors *scale_factors_; + ScaleFactors *scale_factors_{nullptr}; ScaledCellMap scaled_cells_; - TestCell *test_cell_; + TestCell *test_cell_{nullptr}; // Latch D->Q to LatchEnable index. LatchEnableIndexMap latch_d_to_q_map_; // Latch EN->D setup to LatchEnable index. @@ -697,14 +700,14 @@ protected: LatchEnableSeq latch_enables_; // Ports that have latch D->Q timing arc sets from them. LibertyPortSet latch_data_ports_; - float ocv_arc_depth_; - OcvDerate *ocv_derate_; + float ocv_arc_depth_{0.0F}; + OcvDerate *ocv_derate_{nullptr}; OcvDerateMap ocv_derate_map_; std::vector scene_cells_; - float leakage_power_; - bool leakage_power_exists_; - bool has_internal_ports_; - std::atomic have_voltage_waveforms_; + float leakage_power_{0.0F}; + bool leakage_power_exists_{false}; + bool has_internal_ports_{false}; + std::atomic have_voltage_waveforms_{false}; std::mutex waveform_lock_; std::string footprint_; std::string user_function_class_; @@ -731,7 +734,7 @@ class LibertyCellPortBitIterator : public Iterator { public: LibertyCellPortBitIterator(const LibertyCell *cell); - virtual ~LibertyCellPortBitIterator(); + ~LibertyCellPortBitIterator() override; bool hasNext() override; LibertyPort *next() override; @@ -748,9 +751,7 @@ public: LibertyLibrary *libertyLibrary() const { return liberty_cell_->libertyLibrary(); } LibertyPort *findLibertyMember(int index) const; LibertyPort *findLibertyBusBit(int index) const; - LibertyPort *bundlePort() const; BusDcl *busDcl() const { return bus_dcl_; } - void setDirection(PortDirection *dir); //////////////////////////////////////////////////////////////// // pg_pin functions @@ -872,15 +873,15 @@ public: const RiseFall *pulseClkTrigger() const { return pulse_clk_trigger_; } // Rise for high, fall for low. const RiseFall *pulseClkSense() const { return pulse_clk_sense_; } - void setPulseClk(const RiseFall *rfigger, + void setPulseClk(const RiseFall *trigger, const RiseFall *sense); LibertyPort *scenePort(const Scene *scene, const MinMax *min_max); const LibertyPort *scenePort(const Scene *scene, const MinMax *min_max) const; - const LibertyPort *scenePort(int ap_index) const; + const LibertyPort *scenePort(size_t lib_ap_index) const; void setScenePort(LibertyPort *scene_port, - int ap_index); + size_t lib_ap_index); LibertyPort *relatedGroundPort() const { return related_ground_port_; } void setRelatedGroundPort(LibertyPort *related_ground_port); LibertyPort *relatedPowerPort() const { return related_power_port_; } @@ -913,7 +914,7 @@ protected: int to_index, bool is_bundle, ConcretePortSeq *members); - virtual ~LibertyPort(); + ~LibertyPort() override; void setMinPort(LibertyPort *min); void addScaledPort(OperatingConditions *op_cond, LibertyPort *scaled_port); @@ -927,48 +928,48 @@ protected: float, const MinMax *)> &setter); - LibertyPort *scenePort(int ap_index); + LibertyPort *scenePort(size_t lib_ap_index); - LibertyCell *liberty_cell_; - BusDcl *bus_dcl_; - PwrGndType pwr_gnd_type_; + LibertyCell *liberty_cell_{nullptr}; + BusDcl *bus_dcl_{nullptr}; + PwrGndType pwr_gnd_type_{PwrGndType::none}; std::string voltage_name_; - ScanSignalType scan_signal_type_; - FuncExpr *function_; - FuncExpr *tristate_enable_; - ScaledPortMap *scaled_ports_; + ScanSignalType scan_signal_type_{ScanSignalType::none}; + FuncExpr *function_{nullptr}; + FuncExpr *tristate_enable_{nullptr}; + ScaledPortMap *scaled_ports_{nullptr}; RiseFallMinMax capacitance_; MinMaxFloatValues slew_limit_; // inputs and outputs MinMaxFloatValues cap_limit_; // outputs - float fanout_load_; // inputs - bool fanout_load_exists_; + float fanout_load_{0.0F}; // inputs + bool fanout_load_exists_{false}; MinMaxFloatValues fanout_limit_; // outputs - float min_period_; - float min_pulse_width_[RiseFall::index_count]; - const RiseFall *pulse_clk_trigger_; - const RiseFall *pulse_clk_sense_; - LibertyPort *related_ground_port_; - LibertyPort *related_power_port_; + float min_period_{0.0F}; + float min_pulse_width_[RiseFall::index_count]{0.0F, 0.0F}; + const RiseFall *pulse_clk_trigger_{nullptr}; + const RiseFall *pulse_clk_sense_{nullptr}; + LibertyPort *related_ground_port_{nullptr}; + LibertyPort *related_power_port_{nullptr}; std::vector scene_ports_; - ReceiverModelPtr receiver_model_; - DriverWaveform *driver_waveform_[RiseFall::index_count]; + ReceiverModelPtr receiver_model_{nullptr}; + DriverWaveform *driver_waveform_[RiseFall::index_count]{nullptr, nullptr}; - unsigned int min_pulse_width_exists_:RiseFall::index_count; - bool min_period_exists_:1; - bool is_clk_:1; - bool is_reg_clk_:1; - bool is_reg_output_:1; - bool is_latch_data_: 1; - bool is_check_clk_:1; - bool is_clk_gate_clk_:1; - bool is_clk_gate_enable_:1; - bool is_clk_gate_out_:1; - bool is_pll_feedback_:1; - bool isolation_cell_data_:1; - bool isolation_cell_enable_:1; - bool level_shifter_data_:1; - bool is_switch_:1; - bool is_pad_:1; + bool min_pulse_width_exists_:RiseFall::index_count {false}; + bool min_period_exists_:1 {false}; + bool is_clk_:1 {false}; + bool is_reg_clk_:1 {false}; + bool is_reg_output_:1 {false}; + bool is_latch_data_: 1 {false}; + bool is_check_clk_:1 {false}; + bool is_clk_gate_clk_:1 {false}; + bool is_clk_gate_enable_:1 {false}; + bool is_clk_gate_out_:1 {false}; + bool is_pll_feedback_:1 {false}; + bool isolation_cell_data_:1 {false}; + bool isolation_cell_enable_:1 {false}; + bool level_shifter_data_:1 {false}; + bool is_switch_:1 {false}; + bool is_pad_:1 {false}; private: friend class LibertyLibrary; @@ -984,7 +985,7 @@ class LibertyPortMemberIterator : public Iterator { public: LibertyPortMemberIterator(const LibertyPort *port); - virtual ~LibertyPortMemberIterator(); + ~LibertyPortMemberIterator() override; bool hasNext() override; LibertyPort *next() override; @@ -999,7 +1000,7 @@ public: Pvt(float process, float voltage, float temperature); - virtual ~Pvt() {} + virtual ~Pvt() = default; float process() const { return process_; } void setProcess(float process); float voltage() const { return voltage_; } @@ -1023,7 +1024,7 @@ public: protected: std::string name_; - WireloadTree wire_load_tree_; + WireloadTree wire_load_tree_{WireloadTree::unknown}; }; class ScaleFactors @@ -1112,7 +1113,7 @@ public: protected: std::string name_; - TableTemplateType type_; + TableTemplateType type_{TableTemplateType::delay}; TableAxisPtr axis1_; TableAxisPtr axis2_; TableAxisPtr axis3_; @@ -1124,15 +1125,12 @@ public: TestCell(LibertyLibrary *library, std::string_view name, std::string_view filename); - -protected: }; class OcvDerate { public: OcvDerate(std::string_view name); - ~OcvDerate(); const std::string &name() const { return name_; } const Table *derateTable(const RiseFall *rf, const EarlyLate *early_late, @@ -1153,8 +1151,8 @@ portLibertyToSta(std::string_view port_name); const std::string & scanSignalTypeName(ScanSignalType scan_type); const std::string & -pwrGndTypeName(PwrGndType pwr_gnd_type); +pwrGndTypeName(PwrGndType pg_type); PwrGndType findPwrGndType(std::string_view pg_name); -} // namespace +} // namespace sta diff --git a/include/sta/LibertyClass.hh b/include/sta/LibertyClass.hh index af00c3a4..4687cbbb 100644 --- a/include/sta/LibertyClass.hh +++ b/include/sta/LibertyClass.hh @@ -24,10 +24,10 @@ #pragma once -#include -#include #include +#include #include +#include namespace sta { @@ -85,7 +85,7 @@ enum class ScaleFactorType : unsigned { wire_cap, wire_res, min_period, - // Liberty attributes have rise/fall suffix. + // Liberty attributes with rise/fall suffix. cell, hold, setup, @@ -95,13 +95,13 @@ enum class ScaleFactorType : unsigned { skew, leakage_power, internal_power, - // Liberty attributes have rise/fall prefix. + // Liberty attributes with rise/fall prefix. transition, - // Liberty attributes have low/high suffix (indexed as rise/fall). + // Liberty attributes with low/high suffix (indexed as rise/fall). min_pulse_width, unknown, }; -const int scale_factor_type_count = int(ScaleFactorType::unknown) + 1; +const int scale_factor_type_count = static_cast(ScaleFactorType::unknown) + 1; // Enough bits to hold a ScaleFactorType enum. const int scale_factor_bits = 4; @@ -116,7 +116,7 @@ enum class TimingSense { none, unknown }; -const int timing_sense_count = int(TimingSense::unknown) + 1; +const int timing_sense_count = static_cast(TimingSense::unknown) + 1; const int timing_sense_bit_count = 3; enum class TableAxisVariable { @@ -178,4 +178,4 @@ public: } }; -} // namespace +} // namespace sta diff --git a/include/sta/LibertyWriter.hh b/include/sta/LibertyWriter.hh index a58ce44e..0178ad8e 100644 --- a/include/sta/LibertyWriter.hh +++ b/include/sta/LibertyWriter.hh @@ -35,4 +35,4 @@ writeLiberty(LibertyLibrary *lib, const char *filename, StaState *sta); -} // namespace +} // namespace sta diff --git a/include/sta/LinearModel.hh b/include/sta/LinearModel.hh index 0ee16401..d7e0218d 100644 --- a/include/sta/LinearModel.hh +++ b/include/sta/LinearModel.hh @@ -55,10 +55,9 @@ public: PocvMode pocv_mode, int digits) const override; float driveResistance(const Pvt *pvt) const override; - -protected: void setIsScaled(bool is_scaled) override; +protected: float intrinsic_; float resistance_; }; @@ -82,11 +81,10 @@ public: const MinMax *min_max, PocvMode pocv_mode, int digits) const override; - -protected: void setIsScaled(bool is_scaled) override; +protected: float intrinsic_; }; -} // namespace +} // namespace sta diff --git a/include/sta/Machine.hh b/include/sta/Machine.hh index b02e1e5f..1df4d828 100644 --- a/include/sta/Machine.hh +++ b/include/sta/Machine.hh @@ -26,11 +26,6 @@ // This header contains global os/port specific definitions. -// Pragma placeholder for non-gcc compilers. -#ifndef __GNUC__ - #define __attribute__(x) -#endif // __GNUC__ - #ifdef _MSC_VER // Microcruft Visual C++ // Obtuse warning codes enabled by pragma. @@ -48,6 +43,7 @@ // 4611 = setjmp used in C++ function // 4701 = variable used but not initialized #pragma warning( 3 : 4018 4032 4132 4189 4201 4222 4234 4505 4611 4701 ) + // Disable security warnings for posix functions. // _CRT_SECURE_NO_WARNINGS does not seem to work #pragma warning( disable : 4996 ) @@ -65,7 +61,7 @@ // Flex doesn't check for unistd.h. #define YY_NO_UNISTD_H namespace sta { - int vsnprint(char *str, size_t size, const char *fmt, va_list args); + int vsnprint(char *str, size_t size, const char *fmt, const va_list args); int vasprintf(char **str, const char *fmt, va_list args); } #else diff --git a/include/sta/MakeConcreteNetwork.hh b/include/sta/MakeConcreteNetwork.hh index 7f82834a..47dd56b4 100644 --- a/include/sta/MakeConcreteNetwork.hh +++ b/include/sta/MakeConcreteNetwork.hh @@ -31,4 +31,4 @@ class NetworkReader; NetworkReader * makeConcreteNetwork(); -} // namespace +} // namespace sta diff --git a/include/sta/MinMax.hh b/include/sta/MinMax.hh index 24b91155..a23eda8e 100644 --- a/include/sta/MinMax.hh +++ b/include/sta/MinMax.hh @@ -25,8 +25,8 @@ #pragma once #include -#include #include +#include #include "Iterator.hh" @@ -52,12 +52,12 @@ public: static const MinMax *max() { return &max_; } static const EarlyLate *early() { return &min_; } static const EarlyLate *late() { return &max_; } - static int minIndex() { return min_.index_; } - static int earlyIndex() { return min_.index_; } - static int maxIndex() { return max_.index_; } - static int lateIndex() { return max_.index_; } + static size_t minIndex() { return min_.index_; } + static size_t earlyIndex() { return min_.index_; } + static size_t maxIndex() { return max_.index_; } + static size_t lateIndex() { return max_.index_; } const std::string &to_string() const { return name_; } - int index() const { return index_; } + size_t index() const { return index_; } float initValue() const { return init_value_; } int initValueInt() const { return init_value_int_; } // Max value1 > value2, Min value1 < value2. @@ -72,18 +72,18 @@ public: // for (auto min_max : MinMax::range()) {} static const std::array &range() { return range_; } // for (auto mm_index : MinMax::rangeIndex()) {} - static const std::array &rangeIndex() { return range_index_; } + static const std::array &rangeIndex() { return range_index_; } // Find MinMax from name. - static const MinMax *find(const char *min_max); + static const MinMax *find(std::string_view min_max); // Find MinMax from index. - static const MinMax *find(int index); - static const int index_max = 1; - static const int index_count = 2; - static const int index_bit_count = 1; + static const MinMax *find(size_t index); + static const size_t index_max = 1; + static const size_t index_count = 2; + static const size_t index_bit_count = 1; private: - MinMax(const char *name, - int index, + MinMax(std::string_view name, + size_t index, float init_value, int init_value_int, bool (*compare)(float value1, @@ -99,7 +99,7 @@ private: static const MinMax min_; static const MinMax max_; static const std::array range_; - static const std::array range_index_; + static const std::array range_index_; }; // Min/Max/All, where "All" means use both min and max. @@ -114,7 +114,7 @@ public: static const MinMaxAll *all() { return &all_; } static const MinMaxAll *minMax() { return &all_; } const std::string &to_string() const { return name_; } - int index() const { return index_; } + size_t index() const { return index_; } const MinMax *asMinMax() const; bool matches(const MinMax *min_max) const; bool matches(const MinMaxAll *min_max) const; @@ -122,22 +122,22 @@ public: // for (const auto min_max : min_max->range()) {} const std::vector &range() const { return range_; } // for (const auto mm_index : min_max->rangeIndex()) {} - const std::vector &rangeIndex() const { return range_index_; } + const std::vector &rangeIndex() const { return range_index_; } private: - MinMaxAll(const char *name, - int index, - std::vector range, - std::vector range_index); + MinMaxAll(std::string_view name, + size_t index, + const std::vector &range, + const std::vector &range_index); const std::string name_; - int index_; + size_t index_; const std::vector range_; - const std::vector range_index_; + const std::vector range_index_; static const MinMaxAll min_; static const MinMaxAll max_; static const MinMaxAll all_; }; -} // namespace +} // namespace sta diff --git a/include/sta/MinMaxValues.hh b/include/sta/MinMaxValues.hh index 7814c256..8fb8eeea 100644 --- a/include/sta/MinMaxValues.hh +++ b/include/sta/MinMaxValues.hh @@ -24,8 +24,8 @@ #pragma once -#include "MinMax.hh" #include "Error.hh" +#include "MinMax.hh" namespace sta { @@ -200,4 +200,4 @@ private: using MinMaxFloatValues = MinMaxValues; using MinMaxIntValues = MinMaxValues; -} // namespace +} // namespace sta diff --git a/include/sta/Mode.hh b/include/sta/Mode.hh index 11222619..b3a2b9c0 100644 --- a/include/sta/Mode.hh +++ b/include/sta/Mode.hh @@ -39,21 +39,22 @@ class PathGroups; using PathGroupSeq = std::vector; // Sdc and dependent state. -class Mode : public StaState +class Mode { public: Mode(std::string_view name, size_t mode_index, StaState *sta); - virtual ~Mode(); - virtual void copyState(const StaState *sta); + ~Mode(); + void copyState(const StaState *sta); void clear(); const std::string &name() const { return name_; } size_t modeIndex() const { return mode_index_; } const SceneSeq &scenes() const { return scenes_; } - const SceneSet sceneSet() const; + SceneSet sceneSet() const; void addScene(Scene *scene); void removeScene(Scene *scene); + StaState *sta() const { return sta_; } Sdc *sdc() { return sdc_; } Sdc *sdc() const { return sdc_; } Sim *sim() { return sim_; } @@ -69,8 +70,8 @@ public: int endpoint_path_count, bool unique_pins, bool unique_edges, - float min_slack, - float max_slack, + float slack_min, + float slack_max, StringSeq &group_names, bool setup, bool hold, @@ -89,7 +90,8 @@ private: Sim *sim_; ClkNetwork *clk_network_; Genclks *genclks_; - PathGroups *path_groups_; + PathGroups *path_groups_{nullptr}; + StaState *sta_; }; -} // namespace +} // namespace sta diff --git a/include/sta/Mutex.hh b/include/sta/Mutex.hh index a3668582..565e0272 100644 --- a/include/sta/Mutex.hh +++ b/include/sta/Mutex.hh @@ -29,6 +29,6 @@ namespace sta { // Hide a bit of the std verbosity. -using LockGuard = std::lock_guard; +using LockGuard = std::scoped_lock; -} // namespace +} // namespace sta diff --git a/include/sta/Network.hh b/include/sta/Network.hh index 32dd25b3..70580e90 100644 --- a/include/sta/Network.hh +++ b/include/sta/Network.hh @@ -29,11 +29,11 @@ #include #include -#include "StringUtil.hh" #include "LibertyClass.hh" -#include "VertexId.hh" #include "NetworkClass.hh" #include "StaState.hh" +#include "StringUtil.hh" +#include "VertexId.hh" namespace sta { @@ -93,8 +93,8 @@ using NetDrvrPinsMap = std::map; class Network : public StaState { public: - Network(); - virtual ~Network(); + Network() = default; + ~Network() override; virtual void clear(); // Linking the hierarchy creates the instance/pin/net network hierarchy. @@ -446,7 +446,7 @@ protected: void findInstancesMatching1(const Instance *context, size_t context_name_length, const PatternMatch *pattern, - InstanceSeq &insts) const; + InstanceSeq &matches) const; void findInstancesHierMatching1(const Instance *instance, const PatternMatch *pattern, InstanceSeq &matches) const; @@ -475,7 +475,7 @@ protected: const PatternMatch *pattern, // Return value. PinSeq &matches) const; - void findInstPinsHierMatching(const Instance *parent, + void findInstPinsHierMatching(const Instance *instance, const PatternMatch *pattern, // Return value. PinSeq &matches) const; @@ -490,9 +490,9 @@ protected: // nets may be connected across hierarchy levels. void clearNetDrvrPinMap(); - LibertyLibrary *default_liberty_; - char divider_; - char escape_; + LibertyLibrary *default_liberty_{nullptr}; + char divider_{'/'}; + char escape_{'\\'}; NetDrvrPinsMap net_drvr_pin_map_; }; @@ -500,8 +500,8 @@ protected: class NetworkEdit : public Network { public: - NetworkEdit(); - virtual bool isEditable() const { return true; } + NetworkEdit() = default; + bool isEditable() const override { return true; } virtual Instance *makeInstance(LibertyCell *cell, std::string_view name, Instance *parent) = 0; @@ -533,7 +533,6 @@ public: class NetworkReader : public NetworkEdit { public: - NetworkReader() {} // Called before reading a netlist to delete any previously linked network. virtual void readNetlistBefore() = 0; virtual void setLinkFunc(LinkNetworkFunc link) = 0; @@ -599,8 +598,7 @@ linkReaderNetwork(Cell *top_cell, class ConstantPinIterator { public: - ConstantPinIterator() {} - virtual ~ConstantPinIterator() {} + virtual ~ConstantPinIterator() = default; virtual bool hasNext() = 0; virtual void next(const Pin *&pin, LogicValue &value) = 0; @@ -613,16 +611,15 @@ public: NetworkConstantPinIterator(const Network *network, NetSet &zero_nets, NetSet &one_nets); - virtual ~NetworkConstantPinIterator() {} - virtual bool hasNext(); - virtual void next(const Pin *&pin, LogicValue &value); + bool hasNext() override; + void next(const Pin *&pin, LogicValue &value) override; private: void findConstantPins(NetSet &nets, PinSet &pins); const Network *network_; - PinSet constant_pins_[2]; + PinSet constant_pins_[2]{PinSet(network_), PinSet(network_)}; LogicValue value_; PinSet::iterator pin_iter_; }; @@ -631,8 +628,7 @@ private: class HierPinThruVisitor { public: - HierPinThruVisitor() {} - virtual ~HierPinThruVisitor() {} + virtual ~HierPinThruVisitor() = default; virtual void visit(const Pin *drvr, const Pin *load) = 0; }; @@ -640,7 +636,7 @@ public: class PinVisitor { public: - virtual ~PinVisitor() {} + virtual ~PinVisitor() = default; virtual void operator()(const Pin *pin) = 0; }; @@ -652,7 +648,7 @@ public: PinSeq &loads, PinSeq &drvrs, const Network *network); - virtual void operator()(const Pin *pin); + void operator()(const Pin *pin) override; protected: const Pin *drvr_pin_; @@ -675,4 +671,4 @@ visitDrvrLoadsThruNet(const Net *net, char logicValueString(LogicValue value); -} // namespace +} // namespace sta diff --git a/include/sta/NetworkClass.hh b/include/sta/NetworkClass.hh index 23f63a6a..e32ce51a 100644 --- a/include/sta/NetworkClass.hh +++ b/include/sta/NetworkClass.hh @@ -25,11 +25,11 @@ #pragma once #include -#include -#include #include #include +#include #include +#include #include "Iterator.hh" @@ -173,4 +173,4 @@ public: NetSet(const Network *network); }; -} // namespace +} // namespace sta diff --git a/include/sta/NetworkCmp.hh b/include/sta/NetworkCmp.hh index ac5ffc5b..019eb9b7 100644 --- a/include/sta/NetworkCmp.hh +++ b/include/sta/NetworkCmp.hh @@ -91,4 +91,4 @@ NetSeq sortByPathName(NetSet *set, const Network *network); -} // namespace +} // namespace sta diff --git a/include/sta/ObjectId.hh b/include/sta/ObjectId.hh index cd455858..905f7b1b 100644 --- a/include/sta/ObjectId.hh +++ b/include/sta/ObjectId.hh @@ -40,4 +40,4 @@ static constexpr BlockIdx block_idx_null = 0; static constexpr ObjectId object_id_null = 0; static constexpr ObjectIdx object_idx_null = 0; -} // Namespace +} // namespace sta diff --git a/include/sta/ObjectTable.hh b/include/sta/ObjectTable.hh index 4736b5e0..b1568b93 100644 --- a/include/sta/ObjectTable.hh +++ b/include/sta/ObjectTable.hh @@ -50,7 +50,6 @@ template class ObjectTable { public: - ObjectTable(); ~ObjectTable(); TYPE *make(); void destroy(TYPE *object); @@ -70,20 +69,13 @@ private: void freePush(TYPE *object, ObjectId id); - size_t size_; + size_t size_{0}; // Object ID of next free object. - ObjectId free_; + ObjectId free_{object_id_null}; std::vector*> blocks_; static constexpr ObjectId idx_mask_ = block_object_count - 1; }; -template -ObjectTable::ObjectTable() : - size_(0), - free_(object_id_null) -{ -} - template ObjectTable::~ObjectTable() { @@ -213,4 +205,4 @@ TableBlock::TableBlock(BlockIdx block_idx, { } -} // Namespace +} // namespace sta diff --git a/include/sta/Parasitics.hh b/include/sta/Parasitics.hh index 8c010f07..c6706f90 100644 --- a/include/sta/Parasitics.hh +++ b/include/sta/Parasitics.hh @@ -28,11 +28,11 @@ #include #include -#include "StaState.hh" #include "LibertyClass.hh" #include "NetworkClass.hh" -#include "SdcClass.hh" #include "ParasiticsClass.hh" +#include "SdcClass.hh" +#include "StaState.hh" namespace sta { @@ -52,7 +52,6 @@ class Parasitics : public StaState { public: Parasitics(StaState *sta); - virtual ~Parasitics() {} virtual const std::string &name() const = 0; virtual const std::string &filename() const = 0; virtual bool haveParasitics() = 0; @@ -165,12 +164,12 @@ public: // Parasitic network component builders. virtual ParasiticNode *findParasiticNode(Parasitic *parasitic, const Net *net, - int id, + uint32_t id, const Network *network) const = 0; // Make a subnode of the parasitic network net. virtual ParasiticNode *ensureParasiticNode(Parasitic *parasitic, const Net *net, - int id, + uint32_t id, const Network *network) = 0; // Find the parasitic node connected to pin. virtual ParasiticNode *findParasiticNode(const Parasitic *parasitic, @@ -196,11 +195,11 @@ public: // Coupling capacitor between parasitic nodes on a net. virtual void makeCapacitor(Parasitic *parasitic, - size_t id, + uint32_t id, float cap, ParasiticNode *node1, ParasiticNode *node2) = 0; - virtual size_t id(const ParasiticCapacitor *capacitor) const = 0; + virtual uint32_t id(const ParasiticCapacitor *capacitor) const = 0; virtual float value(const ParasiticCapacitor *capacitor) const = 0; virtual ParasiticNode *node1(const ParasiticCapacitor *capacitor) const = 0; virtual ParasiticNode *node2(const ParasiticCapacitor *capacitor) const = 0; @@ -208,15 +207,15 @@ public: ParasiticNode *node) const; virtual void makeResistor(Parasitic *parasitic, - size_t id, + uint32_t id, float res, ParasiticNode *node1, ParasiticNode *node2) = 0; - virtual size_t id(const ParasiticResistor *resistor) const = 0; + virtual uint32_t id(const ParasiticResistor *resistor) const = 0; virtual float value(const ParasiticResistor *resistor) const = 0; virtual ParasiticNode *node1(const ParasiticResistor *resistor) const = 0; virtual ParasiticNode *node2(const ParasiticResistor *resistor) const = 0; - virtual ParasiticNode *otherNode(const ParasiticResistor *capacitor, + virtual ParasiticNode *otherNode(const ParasiticResistor *resistor, ParasiticNode *node) const; // Iteration over resistors connected to a nodes. @@ -288,7 +287,7 @@ protected: const Net *findParasiticNet(const Pin *pin) const; - float coupling_cap_factor_; + float coupling_cap_factor_ {1.0}; }; class ParasiticNodeLess @@ -304,4 +303,4 @@ private: const Network *network_; }; -} // namespace +} // namespace sta diff --git a/include/sta/ParasiticsClass.hh b/include/sta/ParasiticsClass.hh index d75ff05f..590156b1 100644 --- a/include/sta/ParasiticsClass.hh +++ b/include/sta/ParasiticsClass.hh @@ -32,4 +32,4 @@ class ParasiticNode; class ParasiticResistor; class ParasiticCapacitor; -} // namespace +} // namespace sta diff --git a/include/sta/ParseBus.hh b/include/sta/ParseBus.hh index 9b40063a..e6236fa8 100644 --- a/include/sta/ParseBus.hh +++ b/include/sta/ParseBus.hh @@ -32,8 +32,8 @@ namespace sta { // Return true if name is a bus. bool isBusName(std::string_view name, - const char brkt_left, - const char brkt_right, + char brkt_left, + char brkt_right, char escape); // Parse name as a bus. @@ -45,8 +45,8 @@ isBusName(std::string_view name, // Caller must delete returned bus_name string. void parseBusName(std::string_view name, - const char brkt_left, - const char brkt_right, + char brkt_left, + char brkt_right, char escape, // Return values. bool &is_bus, @@ -68,8 +68,8 @@ parseBusName(std::string_view name, // Caller must delete returned bus_name string. void parseBusName(std::string_view name, - const char brkt_left, - const char brkt_right, + char brkt_left, + char brkt_right, char escape, // Return values. bool &is_bus, @@ -85,7 +85,7 @@ void parseBusName(std::string_view name, std::string_view brkts_left, std::string_view brkts_right, - const char escape, + char escape, // Return values. bool &is_bus, bool &is_range, @@ -97,8 +97,8 @@ parseBusName(std::string_view name, // Insert escapes before ch1 and ch2 in token. std::string escapeChars(std::string_view token, - const char ch1, - const char ch2, - const char escape); + char ch1, + char ch2, + char escape); -} // namespace +} // namespace sta diff --git a/include/sta/Path.hh b/include/sta/Path.hh index 7095a269..d04f9827 100644 --- a/include/sta/Path.hh +++ b/include/sta/Path.hh @@ -24,14 +24,14 @@ #pragma once +#include "Delay.hh" +#include "GraphClass.hh" #include "MinMax.hh" #include "NetworkClass.hh" #include "SdcClass.hh" -#include "Transition.hh" -#include "GraphClass.hh" -#include "Delay.hh" -#include "StaState.hh" #include "SearchClass.hh" +#include "StaState.hh" +#include "Transition.hh" namespace sta { @@ -103,7 +103,7 @@ public: const Required &required() const {return required_; } void setRequired(const Required &required); Slack slack(const StaState *sta) const; - const Slew slew(const StaState *sta) const; + Slew slew(const StaState *sta) const; // This takes the same time as prevPath and prevArc combined. Path *prevPath() const; void setPrevPath(Path *prev_path); @@ -201,7 +201,6 @@ public: const RiseFall *rf, const MinMax *min_max, const StaState *sta); - virtual ~VertexPathIterator(); bool hasNext() override; Path *next() override; @@ -219,4 +218,4 @@ private: Path *next_; }; -} // namespace +} // namespace sta diff --git a/include/sta/PathEnd.hh b/include/sta/PathEnd.hh index 1fca8d5a..be54fa73 100644 --- a/include/sta/PathEnd.hh +++ b/include/sta/PathEnd.hh @@ -26,11 +26,11 @@ #include -#include "LibertyClass.hh" #include "GraphClass.hh" +#include "LibertyClass.hh" +#include "Path.hh" #include "SdcClass.hh" #include "SearchClass.hh" -#include "Path.hh" #include "StaState.hh" namespace sta { @@ -69,7 +69,7 @@ public: }; virtual PathEnd *copy() const = 0; - virtual ~PathEnd() {} + virtual ~PathEnd() = default; void deletePath(); Path *path() { return path_; } const Path *path() const { return path_; } @@ -147,9 +147,8 @@ public: virtual TimingArc *checkArc() const { return nullptr; } // PathEndDataCheck data clock path. virtual const Path *dataClkPath() const { return nullptr; } - virtual int setupDefaultCycles() const { return 1; } virtual Delay clkSkew(const StaState *sta); - virtual bool ignoreClkLatency(const StaState * /* sta */) const { return false; } + [[nodiscard]] virtual bool ignoreClkLatency(const StaState *) const { return false; } static bool less(const PathEnd *path_end1, const PathEnd *path_end2, @@ -219,53 +218,55 @@ protected: static bool ignoreClkLatency(const Path *path, PathDelay *path_delay, const StaState *sta); + virtual int setupDefaultCycles() const { return 1; } + Path *path_; - PathGroup *path_group_; + PathGroup *path_group_{nullptr}; }; class PathEndUnconstrained : public PathEnd { public: PathEndUnconstrained(Path *path); - virtual Type type() const; - virtual const char *typeName() const; - virtual PathEnd *copy() const; - virtual void reportShort(const ReportPath *report) const; - virtual void reportFull(const ReportPath *report) const; - virtual bool isUnconstrained() const; - virtual Required requiredTime(const StaState *sta) const; - virtual Required requiredTimeOffset(const StaState *sta) const; - virtual ArcDelay margin(const StaState *sta) const; - virtual Slack slack(const StaState *sta) const; - virtual Slack slackNoCrpr(const StaState *sta) const; - virtual float sourceClkOffset(const StaState *sta) const; + Type type() const override; + const char *typeName() const override; + PathEnd *copy() const override; + void reportShort(const ReportPath *report) const override; + void reportFull(const ReportPath *report) const override; + bool isUnconstrained() const override; + Required requiredTime(const StaState *sta) const override; + Required requiredTimeOffset(const StaState *sta) const override; + ArcDelay margin(const StaState *sta) const override; + Slack slack(const StaState *sta) const override; + Slack slackNoCrpr(const StaState *sta) const override; + float sourceClkOffset(const StaState *sta) const override; }; class PathEndClkConstrained : public PathEnd { public: - virtual float sourceClkOffset(const StaState *sta) const; - virtual Delay sourceClkLatency(const StaState *sta) const; - virtual Delay sourceClkInsertionDelay(const StaState *sta) const; - virtual const Clock *targetClk(const StaState *sta) const; - virtual const ClockEdge *targetClkEdge(const StaState *sta) const; - virtual Path *targetClkPath(); - virtual const Path *targetClkPath() const; - virtual float targetClkTime(const StaState *sta) const; - virtual float targetClkOffset(const StaState *sta) const; - virtual Arrival targetClkArrival(const StaState *sta) const; - virtual Delay targetClkDelay(const StaState *sta) const; - virtual Delay targetClkInsertionDelay(const StaState *sta) const; - virtual float targetNonInterClkUncertainty(const StaState *sta) const; - virtual float interClkUncertainty(const StaState *sta) const; - virtual float targetClkUncertainty(const StaState *sta) const; - virtual Crpr crpr(const StaState *sta) const; - virtual Required requiredTime(const StaState *sta) const; - virtual Slack slack(const StaState *sta) const; - virtual Slack slackNoCrpr(const StaState *sta) const; - virtual int exceptPathCmp(const PathEnd *path_end, - const StaState *sta) const; - virtual void setPath(Path *path); + float sourceClkOffset(const StaState *sta) const override; + Delay sourceClkLatency(const StaState *sta) const override; + Delay sourceClkInsertionDelay(const StaState *sta) const override; + const Clock *targetClk(const StaState *sta) const override; + const ClockEdge *targetClkEdge(const StaState *sta) const override; + Path *targetClkPath() override; + const Path *targetClkPath() const override; + float targetClkTime(const StaState *sta) const override; + float targetClkOffset(const StaState *sta) const override; + Arrival targetClkArrival(const StaState *sta) const override; + Delay targetClkDelay(const StaState *sta) const override; + Delay targetClkInsertionDelay(const StaState *sta) const override; + float targetNonInterClkUncertainty(const StaState *sta) const override; + float interClkUncertainty(const StaState *sta) const override; + float targetClkUncertainty(const StaState *sta) const override; + Crpr crpr(const StaState *sta) const override; + Required requiredTime(const StaState *sta) const override; + Slack slack(const StaState *sta) const override; + Slack slackNoCrpr(const StaState *sta) const override; + int exceptPathCmp(const PathEnd *path_end, + const StaState *sta) const override; + void setPath(Path *path) override; protected: PathEndClkConstrained(Path *path, @@ -280,16 +281,16 @@ protected: Path *clk_path_; mutable Crpr crpr_; - mutable bool crpr_valid_; + mutable bool crpr_valid_{false}; }; class PathEndClkConstrainedMcp : public PathEndClkConstrained { public: - virtual MultiCyclePath *multiCyclePath() const { return mcp_; } - virtual float targetClkMcpAdjustment(const StaState *sta) const; - virtual int exceptPathCmp(const PathEnd *path_end, - const StaState *sta) const; + MultiCyclePath *multiCyclePath() const override { return mcp_; } + float targetClkMcpAdjustment(const StaState *sta) const override; + int exceptPathCmp(const PathEnd *path_end, + const StaState *sta) const override; protected: PathEndClkConstrainedMcp(Path *path, @@ -316,23 +317,23 @@ public: Path *clk_path, MultiCyclePath *mcp, const StaState *sta); - virtual PathEnd *copy() const; - virtual Type type() const; - virtual const char *typeName() const; - virtual void reportShort(const ReportPath *report) const; - virtual void reportFull(const ReportPath *report) const; - virtual bool isCheck() const { return true; } - virtual ArcDelay margin(const StaState *sta) const; - virtual float macroClkTreeDelay(const StaState *sta) const; - virtual const TimingRole *checkRole(const StaState *sta) const; - virtual TimingArc *checkArc() const { return check_arc_; } - virtual int exceptPathCmp(const PathEnd *path_end, - const StaState *sta) const; - virtual Delay clkSkew(const StaState *sta); + PathEnd *copy() const override; + Type type() const override; + const char *typeName() const override; + void reportShort(const ReportPath *report) const override; + void reportFull(const ReportPath *report) const override; + bool isCheck() const override { return true; } + ArcDelay margin(const StaState *sta) const override; + float macroClkTreeDelay(const StaState *sta) const override; + const TimingRole *checkRole(const StaState *sta) const override; + TimingArc *checkArc() const override { return check_arc_; } + int exceptPathCmp(const PathEnd *path_end, + const StaState *sta) const override; + Delay clkSkew(const StaState *sta) override; protected: Delay sourceClkDelay(const StaState *sta) const; - virtual Required requiredTimeNoCrpr(const StaState *sta) const; + Required requiredTimeNoCrpr(const StaState *sta) const override; TimingArc *check_arc_; Edge *check_edge_; @@ -349,25 +350,25 @@ public: MultiCyclePath *mcp, PathDelay *path_delay, const StaState *sta); - virtual Type type() const; - virtual const char *typeName() const; - virtual float sourceClkOffset(const StaState *sta) const; - virtual bool isCheck() const { return false; } - virtual bool isLatchCheck() const { return true; } - virtual PathDelay *pathDelay() const { return path_delay_; } - virtual PathEnd *copy() const; + Type type() const override; + const char *typeName() const override; + float sourceClkOffset(const StaState *sta) const override; + bool isCheck() const override { return false; } + bool isLatchCheck() const override { return true; } + PathDelay *pathDelay() const override { return path_delay_; } + PathEnd *copy() const override; Path *latchDisable(); const Path *latchDisable() const; - virtual void reportShort(const ReportPath *report) const; - virtual void reportFull(const ReportPath *report) const; - virtual const TimingRole *checkRole(const StaState *sta) const; - virtual Required requiredTime(const StaState *sta) const; - virtual Arrival borrow(const StaState *sta) const; - virtual float targetClkTime(const StaState *sta) const; - virtual float targetClkOffset(const StaState *sta) const; + void reportShort(const ReportPath *report) const override; + void reportFull(const ReportPath *report) const override; + const TimingRole *checkRole(const StaState *sta) const override; + Required requiredTime(const StaState *sta) const override; + Arrival borrow(const StaState *sta) const override; + float targetClkTime(const StaState *sta) const override; + float targetClkOffset(const StaState *sta) const override; Arrival targetClkWidth(const StaState *sta) const; - virtual int exceptPathCmp(const PathEnd *path_end, - const StaState *sta) const; + int exceptPathCmp(const PathEnd *path_end, + const StaState *sta) const override; void latchRequired(const StaState *sta, // Return values. Required &required, @@ -383,8 +384,8 @@ public: Crpr &open_crpr, Crpr &crpr_diff, Delay &max_borrow, - bool &borrow_limit_exists) const; - virtual bool ignoreClkLatency(const StaState *sta) const; + bool &borrow_limit_exists) const; + bool ignoreClkLatency(const StaState *sta) const override; protected: Path *disable_path_; @@ -404,23 +405,23 @@ public: Path *clk_path, MultiCyclePath *mcp, const StaState *sta); - virtual PathEnd *copy() const; - virtual Type type() const; - virtual const char *typeName() const; - virtual void reportShort(const ReportPath *report) const; - virtual void reportFull(const ReportPath *report) const; - virtual bool isOutputDelay() const { return true; } - virtual ArcDelay margin(const StaState *sta) const; - virtual const TimingRole *checkRole(const StaState *sta) const; - virtual const ClockEdge *targetClkEdge(const StaState *sta) const; - virtual Arrival targetClkArrivalNoCrpr(const StaState *sta) const; - virtual Delay targetClkDelay(const StaState *sta) const; - virtual Delay targetClkInsertionDelay(const StaState *sta) const; - virtual Crpr crpr(const StaState *sta) const; - virtual int exceptPathCmp(const PathEnd *path_end, - const StaState *sta) const; + PathEnd *copy() const override; + Type type() const override; + const char *typeName() const override; + void reportShort(const ReportPath *report) const override; + void reportFull(const ReportPath *report) const override; + bool isOutputDelay() const override { return true; } + ArcDelay margin(const StaState *sta) const override; + const TimingRole *checkRole(const StaState *sta) const override; + const ClockEdge *targetClkEdge(const StaState *sta) const override; + Delay targetClkDelay(const StaState *sta) const override; + Delay targetClkInsertionDelay(const StaState *sta) const override; + Crpr crpr(const StaState *sta) const override; + int exceptPathCmp(const PathEnd *path_end, + const StaState *sta) const override; protected: + Arrival targetClkArrivalNoCrpr(const StaState *sta) const override; Arrival tgtClkDelay(const ClockEdge *tgt_clk_edge, const TimingRole *check_role, const StaState *sta) const; @@ -444,16 +445,16 @@ public: MultiCyclePath *mcp, ArcDelay margin, const StaState *sta); - virtual PathEnd *copy() const; - virtual Type type() const; - virtual const char *typeName() const; - virtual void reportShort(const ReportPath *report) const; - virtual void reportFull(const ReportPath *report) const; - virtual bool isGatedClock() const { return true; } - virtual ArcDelay margin(const StaState *) const { return margin_; } - virtual const TimingRole *checkRole(const StaState *sta) const; - virtual int exceptPathCmp(const PathEnd *path_end, - const StaState *sta) const; + PathEnd *copy() const override; + Type type() const override; + const char *typeName() const override; + void reportShort(const ReportPath *report) const override; + void reportFull(const ReportPath *report) const override; + bool isGatedClock() const override { return true; } + ArcDelay margin(const StaState *) const override { return margin_; } + const TimingRole *checkRole(const StaState *sta) const override; + int exceptPathCmp(const PathEnd *path_end, + const StaState *sta) const override; protected: const TimingRole *check_role_; @@ -468,25 +469,25 @@ public: Path *data_clk_path, MultiCyclePath *mcp, const StaState *sta); - virtual PathEnd *copy() const; - virtual Type type() const; - virtual const char *typeName() const; - virtual void reportShort(const ReportPath *report) const; - virtual void reportFull(const ReportPath *report) const; - virtual bool isDataCheck() const { return true; } - virtual const ClockEdge *targetClkEdge(const StaState *sta) const; - virtual const TimingRole *checkRole(const StaState *sta) const; - virtual ArcDelay margin(const StaState *sta) const; - virtual int exceptPathCmp(const PathEnd *path_end, - const StaState *sta) const; - virtual const Path *dataClkPath() const { return data_clk_path_; } + PathEnd *copy() const override; + Type type() const override; + const char *typeName() const override; + void reportShort(const ReportPath *report) const override; + void reportFull(const ReportPath *report) const override; + bool isDataCheck() const override { return true; } + const ClockEdge *targetClkEdge(const StaState *sta) const override; + const TimingRole *checkRole(const StaState *sta) const override; + ArcDelay margin(const StaState *sta) const override; + int exceptPathCmp(const PathEnd *path_end, + const StaState *sta) const override; + const Path *dataClkPath() const override { return data_clk_path_; } protected: Path *clkPath(Path *path, const StaState *sta); - Arrival requiredTimeNoCrpr(const StaState *sta) const; + Arrival requiredTimeNoCrpr(const StaState *sta) const override; // setup uses zero cycle default - virtual int setupDefaultCycles() const { return 0; } + int setupDefaultCycles() const override { return 0; } Path *data_clk_path_; DataCheck *check_; @@ -514,29 +515,29 @@ public: Path *path, OutputDelay *output_delay, const StaState *sta); - virtual PathEnd *copy() const; - virtual Type type() const; - virtual const char *typeName() const; - virtual void reportShort(const ReportPath *report) const; - virtual void reportFull(const ReportPath *report) const; - virtual bool isPathDelay() const { return true; } - virtual const TimingRole *checkRole(const StaState *sta) const; - virtual bool pathDelayMarginIsExternal() const; - virtual PathDelay *pathDelay() const { return path_delay_; } - virtual ArcDelay margin(const StaState *sta) const; - virtual float sourceClkOffset(const StaState *sta) const; - virtual const ClockEdge *targetClkEdge(const StaState *sta) const; - virtual float targetClkTime(const StaState *sta) const; - virtual Arrival targetClkArrivalNoCrpr(const StaState *sta) const; - virtual float targetClkOffset(const StaState *sta) const; - virtual TimingArc *checkArc() const { return check_arc_; } - virtual Required requiredTime(const StaState *sta) const; - virtual int exceptPathCmp(const PathEnd *path_end, - const StaState *sta) const; + PathEnd *copy() const override; + Type type() const override; + const char *typeName() const override; + void reportShort(const ReportPath *report) const override; + void reportFull(const ReportPath *report) const override; + bool isPathDelay() const override { return true; } + const TimingRole *checkRole(const StaState *sta) const override; + bool pathDelayMarginIsExternal() const override; + PathDelay *pathDelay() const override { return path_delay_; } + ArcDelay margin(const StaState *sta) const override; + float sourceClkOffset(const StaState *sta) const override; + const ClockEdge *targetClkEdge(const StaState *sta) const override; + float targetClkTime(const StaState *sta) const override; + float targetClkOffset(const StaState *sta) const override; + TimingArc *checkArc() const override { return check_arc_; } + Required requiredTime(const StaState *sta) const override; + int exceptPathCmp(const PathEnd *path_end, + const StaState *sta) const override; [[nodiscard]] bool hasOutputDelay() const { return output_delay_ != nullptr; } - virtual bool ignoreClkLatency(const StaState *sta) const; + bool ignoreClkLatency(const StaState *sta) const override; protected: + Arrival targetClkArrivalNoCrpr(const StaState *sta) const override; void findSrcClkArrival(const StaState *sta); PathDelay *path_delay_; @@ -590,4 +591,4 @@ protected: const StaState *sta_; }; -} // namespace +} // namespace sta diff --git a/include/sta/PathExpanded.hh b/include/sta/PathExpanded.hh index ebb9d080..2a54e2a8 100644 --- a/include/sta/PathExpanded.hh +++ b/include/sta/PathExpanded.hh @@ -24,11 +24,11 @@ #pragma once -#include "TimingArc.hh" #include "GraphClass.hh" -#include "SearchClass.hh" #include "Path.hh" +#include "SearchClass.hh" #include "StaState.hh" +#include "TimingArc.hh" namespace sta { @@ -78,4 +78,4 @@ protected: const StaState *sta_; }; -} // namespace +} // namespace sta diff --git a/include/sta/PathGroup.hh b/include/sta/PathGroup.hh index c7c6c545..df180016 100644 --- a/include/sta/PathGroup.hh +++ b/include/sta/PathGroup.hh @@ -24,17 +24,17 @@ #pragma once +#include +#include #include #include #include -#include -#include -#include "SdcClass.hh" -#include "StaState.hh" -#include "SearchClass.hh" -#include "StringUtil.hh" #include "PathEnd.hh" +#include "SdcClass.hh" +#include "SearchClass.hh" +#include "StaState.hh" +#include "StringUtil.hh" namespace sta { @@ -52,20 +52,20 @@ class PathGroup public: // Path group that compares compare slacks. static PathGroup *makePathGroupArrival(std::string_view name, - int group_path_count, - int endpoint_path_count, + size_t group_path_count, + size_t endpoint_path_count, bool unique_pins, bool unique_edges, const MinMax *min_max, const StaState *sta); // Path group that compares arrival time, sorted by min_max. static PathGroup *makePathGroupSlack(std::string_view name, - int group_path_count, - int endpoint_path_count, + size_t group_path_count, + size_t endpoint_path_count, bool unique_pins, bool unique_edges, - float min_slack, - float max_slack, + float slack_min, + float slack_max, const StaState *sta); ~PathGroup(); const std::string &name() const { return name_; } @@ -77,19 +77,19 @@ public: // Predicate to determine if a PathEnd is worth saving. bool saveable(PathEnd *path_end); bool enumMinSlackUnderMin(PathEnd *path_end); - int maxPaths() const { return group_path_count_; } + size_t maxPaths() const { return group_path_count_; } // This does NOT delete the path ends. void clear(); - static int group_path_count_max; + static size_t group_path_count_max; protected: PathGroup(std::string_view name, - int group_path_count, - int endpoint_path_count, + size_t group_path_count, + size_t endpoint_path_count, bool unique_pins, bool unique_edges, - float min_slack, - float max_slack, + float slack_min, + float slack_max, bool cmp_slack, const MinMax *min_max, const StaState *sta); @@ -98,8 +98,8 @@ protected: void sort(); std::string name_; - int group_path_count_; - int endpoint_path_count_; + size_t group_path_count_; + size_t endpoint_path_count_; bool unique_pins_; bool unique_edges_; float slack_min_; @@ -116,8 +116,8 @@ protected: class PathGroups : public StaState { public: - PathGroups(int group_path_count, - int endpoint_path_count, + PathGroups(size_t group_path_count, + size_t endpoint_path_count, bool unique_pins, bool unique_edges, float slack_min, @@ -131,7 +131,7 @@ public: bool clk_gating_hold, bool unconstrained, const Mode *mode); - ~PathGroups(); + ~PathGroups() override; // Use scene nullptr to make PathEnds for all scenes. // The PathEnds in the vector are owned by the PathGroups. void makePathEnds(ExceptionTo *to, @@ -155,8 +155,8 @@ public: protected: void makeGroupPathEnds(ExceptionTo *to, - int group_path_count, - int endpoint_path_count, + size_t group_path_count, + size_t endpoint_path_count, bool unique_pins, bool unique_edges, const SceneSeq &scenes, @@ -170,8 +170,8 @@ protected: const MinMaxAll *min_max, PathEndVisitor *visitor); void enumPathEnds(PathGroup *group, - int group_path_count, - int endpoint_path_count, + size_t group_path_count, + size_t endpoint_path_count, bool unique_pins, bool unique_edges, bool cmp_slack); @@ -180,8 +180,8 @@ protected: void pushUnconstrainedPathEnds(PathEndSeq &path_ends, const MinMaxAll *min_max); - void makeGroups(int group_path_count, - int endpoint_path_count, + void makeGroups(size_t group_path_count, + size_t endpoint_path_count, bool unique_pins, bool unique_edges, float slack_min, @@ -199,8 +199,8 @@ protected: StringSeq pathGroupNames(); const Mode *mode_; - int group_path_count_; - int endpoint_path_count_; + size_t group_path_count_; + size_t endpoint_path_count_; bool unique_pins_; bool unique_edges_; float slack_min_; @@ -226,4 +226,4 @@ protected: static constexpr std::string_view unconstrained_group_name_ = "unconstrained"; }; -} // namespace +} // namespace sta diff --git a/include/sta/PatternMatch.hh b/include/sta/PatternMatch.hh index dc41363f..0fbed7e9 100644 --- a/include/sta/PatternMatch.hh +++ b/include/sta/PatternMatch.hh @@ -77,8 +77,8 @@ class RegexpCompileError : public Exception { public: RegexpCompileError(std::string_view pattern); - virtual ~RegexpCompileError() noexcept {} - virtual const char *what() const noexcept; + ~RegexpCompileError() noexcept override = default; + const char *what() const noexcept override; private: std::string error_; @@ -98,4 +98,4 @@ patternMatchNoCase(std::string_view pattern, bool patternWildcards(std::string_view pattern); -} // namespace +} // namespace sta diff --git a/include/sta/PinPair.hh b/include/sta/PinPair.hh index 073212ef..69e759fe 100644 --- a/include/sta/PinPair.hh +++ b/include/sta/PinPair.hh @@ -68,4 +68,4 @@ public: const PinPair &pair2) const; }; -} // namespace +} // namespace sta diff --git a/include/sta/PocvMode.hh b/include/sta/PocvMode.hh index d75785ec..d740234d 100644 --- a/include/sta/PocvMode.hh +++ b/include/sta/PocvMode.hh @@ -1,5 +1,5 @@ // OpenSTA, Static Timing Analyzer -// Copyright (c) 2025, Parallax Software, Inc. +// Copyright (c) 2026, 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 @@ -35,4 +35,4 @@ pocvModeName(PocvMode mode); PocvMode findPocvMode(std::string_view mode_name); -} // namespace +} // namespace sta diff --git a/include/sta/PortDelay.hh b/include/sta/PortDelay.hh index 78cb246d..ab71151a 100644 --- a/include/sta/PortDelay.hh +++ b/include/sta/PortDelay.hh @@ -59,9 +59,9 @@ protected: const Pin *pin_; const ClockEdge *clk_edge_; - bool source_latency_included_; - bool network_latency_included_; - const Pin *ref_pin_; + bool source_latency_included_{false}; + bool network_latency_included_{false}; + const Pin *ref_pin_{nullptr}; RiseFallMinMax delays_; PinSet leaf_pins_; }; @@ -108,4 +108,4 @@ private: const Network *network_; }; -} // namespace +} // namespace sta diff --git a/include/sta/PortDirection.hh b/include/sta/PortDirection.hh index 1d54271c..72d4f074 100644 --- a/include/sta/PortDirection.hh +++ b/include/sta/PortDirection.hh @@ -45,7 +45,7 @@ public: static PortDirection *unknown() { return unknown_; } static PortDirection *find(const char *dir_name); std::string_view name() const { return name_; } - int index() const { return index_; } + size_t index() const { return index_; } bool isInput() const { return this == input_; } // Input or bidirect. bool isAnyInput() const; @@ -66,10 +66,10 @@ public: private: PortDirection(const char *name, - int index); + size_t index); const char *name_; - int index_; + size_t index_; static PortDirection *input_; static PortDirection *output_; @@ -82,4 +82,4 @@ private: static PortDirection *unknown_; }; -} // namespace +} // namespace sta diff --git a/include/sta/PortExtCap.hh b/include/sta/PortExtCap.hh index 3e186b69..189ac33e 100644 --- a/include/sta/PortExtCap.hh +++ b/include/sta/PortExtCap.hh @@ -25,10 +25,10 @@ #pragma once #include "MinMax.hh" -#include "Transition.hh" -#include "RiseFallMinMax.hh" #include "MinMaxValues.hh" #include "NetworkClass.hh" +#include "RiseFallMinMax.hh" +#include "Transition.hh" namespace sta { @@ -38,7 +38,6 @@ using FanoutValues = MinMaxIntValues; class PortExtCap { public: - PortExtCap(); const Port *port() { return port_; } void pinCap(const RiseFall *rf, const MinMax *min_max, @@ -70,10 +69,10 @@ public: const FanoutValues *fanout() const { return &fanout_; } private: - const Port *port_; + const Port *port_{nullptr}; RiseFallMinMax pin_cap_; RiseFallMinMax wire_cap_; FanoutValues fanout_; }; -} // namespace +} // namespace sta diff --git a/include/sta/PowerClass.hh b/include/sta/PowerClass.hh index b3f2a6df..0794fc4c 100644 --- a/include/sta/PowerClass.hh +++ b/include/sta/PowerClass.hh @@ -24,12 +24,13 @@ #pragma once -#include #include +#include namespace sta { class Power; +class Instance; enum class PwrActivityOrigin { @@ -47,7 +48,7 @@ enum class PwrActivityOrigin class PwrActivity { public: - PwrActivity(); + PwrActivity() = default; PwrActivity(float density, float duty, PwrActivityOrigin origin); @@ -67,9 +68,9 @@ public: private: void check(); - float density_; // transitions / second - float duty_; // probability signal is high - PwrActivityOrigin origin_; + float density_{0.0}; // transitions / second + float duty_{0.0}; // probability signal is high + PwrActivityOrigin origin_{PwrActivityOrigin::unknown}; static constexpr float min_density = 1E-10; }; @@ -77,7 +78,7 @@ private: class PowerResult { public: - PowerResult(); + PowerResult() = default; void clear(); float internal() const { return internal_; } float switching() const { return switching_; } @@ -89,12 +90,12 @@ public: void incrLeakage(float pwr); private: - float internal_; - float switching_; - float leakage_; + float internal_{0.0}; + float switching_{0.0}; + float leakage_{0.0}; }; using InstPower = std::pair; using InstPowers = std::vector; -} // namespace +} // namespace sta diff --git a/include/sta/Property.hh b/include/sta/Property.hh index fd734437..e5834b61 100644 --- a/include/sta/Property.hh +++ b/include/sta/Property.hh @@ -24,16 +24,16 @@ #pragma once +#include #include #include #include -#include #include "LibertyClass.hh" #include "NetworkClass.hh" -#include "SearchClass.hh" -#include "SdcClass.hh" #include "PowerClass.hh" +#include "SdcClass.hh" +#include "SearchClass.hh" namespace sta { @@ -47,7 +47,7 @@ template class PropertyRegistry { public: - typedef std::function PropertyHandler; + using PropertyHandler = std::function; void defineProperty(std::string_view property, PropertyHandler handler); PropertyValue getProperty(TYPE object, @@ -63,7 +63,6 @@ class Properties { public: Properties(Sta *sta); - virtual ~Properties() {} PropertyValue getProperty(const Library *lib, std::string_view property); @@ -100,25 +99,25 @@ public: // return PropertyValue("bar"); // }); void defineProperty(std::string_view property, - PropertyRegistry::PropertyHandler handler); + PropertyRegistry::PropertyHandler &handler); void defineProperty(std::string_view property, - PropertyRegistry::PropertyHandler handler); + PropertyRegistry::PropertyHandler &handler); void defineProperty(std::string_view property, - PropertyRegistry::PropertyHandler handler); + PropertyRegistry::PropertyHandler &handler); void defineProperty(std::string_view property, - PropertyRegistry::PropertyHandler handler); + PropertyRegistry::PropertyHandler &handler); void defineProperty(std::string_view property, - PropertyRegistry::PropertyHandler handler); + PropertyRegistry::PropertyHandler &handler); void defineProperty(std::string_view property, - PropertyRegistry::PropertyHandler handler); + PropertyRegistry::PropertyHandler &handler); void defineProperty(std::string_view property, - PropertyRegistry::PropertyHandler handler); + PropertyRegistry::PropertyHandler &handler); void defineProperty(std::string_view property, - PropertyRegistry::PropertyHandler handler); + PropertyRegistry::PropertyHandler &handler); void defineProperty(std::string_view property, - PropertyRegistry::PropertyHandler handler); + PropertyRegistry::PropertyHandler &handler); void defineProperty(std::string_view property, - PropertyRegistry::PropertyHandler handler); + PropertyRegistry::PropertyHandler &handler); protected: PropertyValue portSlew(const Port *port, @@ -201,9 +200,9 @@ public: PropertyValue(ConstPathSeq *value); PropertyValue(PwrActivity *value); // Copy constructor. - PropertyValue(const PropertyValue &props); + PropertyValue(const PropertyValue &value); // Move constructor. - PropertyValue(PropertyValue &&props) noexcept; + PropertyValue(PropertyValue &&value) noexcept; ~PropertyValue(); Type type() const { return type_; } const Unit *unit() const { return unit_; } @@ -259,4 +258,4 @@ private: const Unit *unit_; }; -} // namespace +} // namespace sta diff --git a/include/sta/Report.hh b/include/sta/Report.hh index e8c39de3..c835a8ee 100644 --- a/include/sta/Report.hh +++ b/include/sta/Report.hh @@ -24,15 +24,15 @@ #pragma once -#include #include -#include -#include #include #include +#include +#include +#include -#include "Machine.hh" // __attribute__ #include "Format.hh" +#include "Machine.hh" // __attribute__ struct Tcl_Interp; @@ -51,12 +51,11 @@ class Report { public: Report(); - virtual ~Report(); - + virtual ~Report() = default; virtual void reportLine(const std::string &line); virtual void reportBlankLine(); - // Print formatted line using std::format (C++20). + // Print formatted line using std::format. template void report(std::string_view fmt, Args &&...args) @@ -210,28 +209,13 @@ protected: // Return the number of characters written. virtual size_t printConsole(const char *buffer, size_t length); - void printToBuffer(const char *fmt, ...) __attribute__((format(printf, 2, 3))); - - void printToBuffer(const char *fmt, - va_list args); - void printToBufferAppend(const char *fmt, - ...); - void printToBufferAppend(const char *fmt, - va_list args); - void printBufferLine(); void redirectStringPrint(const char *buffer, size_t length); - FILE *log_stream_; - FILE *redirect_stream_; - bool redirect_to_string_; + FILE *log_stream_{nullptr}; + FILE *redirect_stream_{nullptr}; + bool redirect_to_string_{false}; std::string redirect_string_; - // Buffer to support printf style arguments. - size_t buffer_size_; - char *buffer_; - // Length of string in buffer. - size_t buffer_length_; - std::mutex buffer_lock_; static Report *default_; std::set suppressed_msg_ids_; diff --git a/include/sta/ReportStd.hh b/include/sta/ReportStd.hh index c1743de8..b92821e8 100644 --- a/include/sta/ReportStd.hh +++ b/include/sta/ReportStd.hh @@ -33,4 +33,4 @@ class Report; Report * makeReportStd(); -} // namespace +} // namespace sta diff --git a/include/sta/ReportTcl.hh b/include/sta/ReportTcl.hh index 5f4a6cd0..9f48364c 100644 --- a/include/sta/ReportTcl.hh +++ b/include/sta/ReportTcl.hh @@ -43,7 +43,7 @@ class ReportTcl : public Report { public: ReportTcl(); - virtual ~ReportTcl(); + ~ReportTcl() override; void logBegin(std::string_view filename) override; void logEnd() override; void redirectFileBegin(std::string_view filename) override; @@ -68,13 +68,13 @@ private: const char *buffer, size_t length); - Tcl_Interp *interp_; + Tcl_Interp *interp_{nullptr}; // The original tcl channels. - Tcl_Channel tcl_stdout_; - Tcl_Channel tcl_stderr_; + Tcl_Channel tcl_stdout_{nullptr}; + Tcl_Channel tcl_stderr_{nullptr}; // Encapsulated channels that print on this object. - Tcl_Channel tcl_encap_stdout_; - Tcl_Channel tcl_encap_stderr_; + Tcl_Channel tcl_encap_stdout_{nullptr}; + Tcl_Channel tcl_encap_stderr_{nullptr}; }; -} // namespace +} // namespace sta diff --git a/include/sta/RiseFallMinMax.hh b/include/sta/RiseFallMinMax.hh index 3f9bca81..b3a8abcf 100644 --- a/include/sta/RiseFallMinMax.hh +++ b/include/sta/RiseFallMinMax.hh @@ -85,4 +85,4 @@ private: bool exists_[RiseFall::index_count][MinMax::index_count]; }; -} // namespace +} // namespace sta diff --git a/include/sta/RiseFallMinMaxDelay.hh b/include/sta/RiseFallMinMaxDelay.hh index 22b999c9..50c803aa 100644 --- a/include/sta/RiseFallMinMaxDelay.hh +++ b/include/sta/RiseFallMinMaxDelay.hh @@ -24,9 +24,9 @@ #pragma once +#include "Delay.hh" #include "MinMax.hh" #include "Transition.hh" -#include "Delay.hh" namespace sta { @@ -49,4 +49,4 @@ private: bool exists_[RiseFall::index_count][MinMax::index_count]; }; -} // namespace +} // namespace sta diff --git a/include/sta/RiseFallValues.hh b/include/sta/RiseFallValues.hh index e1198afe..5a49a25e 100644 --- a/include/sta/RiseFallValues.hh +++ b/include/sta/RiseFallValues.hh @@ -49,4 +49,4 @@ private: bool exists_[RiseFall::index_count]; }; -} // namespace +} // namespace sta diff --git a/include/sta/Scene.hh b/include/sta/Scene.hh index 83e57668..4807136f 100644 --- a/include/sta/Scene.hh +++ b/include/sta/Scene.hh @@ -24,9 +24,9 @@ #pragma once +#include #include #include -#include #include "GraphClass.hh" #include "SearchClass.hh" @@ -76,7 +76,7 @@ public: DcalcAPIndex checkClkSlewIndex(const MinMax *min_max) const; const LibertySeq &libertyLibraries(const MinMax *min_max) const; - int libertyIndex(const MinMax *min_max) const; + size_t libertyIndex(const MinMax *min_max) const; void addLiberty(LibertyLibrary *lib, const MinMax *min_max); @@ -95,4 +95,4 @@ protected: friend class Scenes; }; -} // namespace +} // namespace sta diff --git a/include/sta/Sdc.hh b/include/sta/Sdc.hh index eaf65e77..4d3f010d 100644 --- a/include/sta/Sdc.hh +++ b/include/sta/Sdc.hh @@ -24,25 +24,25 @@ #pragma once -#include #include -#include #include #include +#include +#include -#include "StringUtil.hh" -#include "MinMax.hh" -#include "StaState.hh" -#include "NetworkClass.hh" -#include "LibertyClass.hh" -#include "GraphClass.hh" -#include "SdcClass.hh" -#include "RiseFallValues.hh" #include "Clock.hh" -#include "DataCheck.hh" #include "CycleAccting.hh" +#include "DataCheck.hh" #include "ExceptionPath.hh" +#include "GraphClass.hh" +#include "LibertyClass.hh" +#include "MinMax.hh" +#include "NetworkClass.hh" #include "PinPair.hh" +#include "RiseFallValues.hh" +#include "SdcClass.hh" +#include "StaState.hh" +#include "StringUtil.hh" namespace sta { @@ -54,7 +54,7 @@ class DisabledPorts; class GraphLoop; class DeratingFactors; class DeratingFactorsGlobal; -class DeratingFactorsNet; +class DeratingFactors; class DeratingFactorsCell; class PatternMatch; class FindNetCaps; @@ -123,13 +123,12 @@ private: class NetWireCaps : public MinMaxFloatValues { public: - NetWireCaps(); bool subtractPinCap(const MinMax *min_max); void setSubtractPinCap(bool subtrace_pin_cap, const MinMax *min_max); private: - bool subtract_pin_cap_[MinMax::index_count]; + bool subtract_pin_cap_[MinMax::index_count]{false, false}; }; using ClockNameMap = std::map>; @@ -175,7 +174,7 @@ using InstancePvtMap = std::map; using PinMinPulseWidthMap = std::map; using ClockMinPulseWidthMap = std::map; using InstMinPulseWidthMap = std::map; -using NetDeratingFactorsMap = std::map; +using NetDeratingFactorsMap = std::map; using InstDeratingFactorsMap = std::map; using CellDeratingFactorsMap = std::map; using ClockGroupsSet = std::set; @@ -202,7 +201,7 @@ class Sdc : public StaState public: Sdc(Mode *mode, StaState *sta); - ~Sdc(); + ~Sdc() override; Mode *mode() const { return mode_; } // Note that Search may reference a Filter exception removed by clear(). void clear(); @@ -280,7 +279,7 @@ public: const LibertyCell *cell, const Port *port, const LibertyPort *from_port, - float *from_slews, + const DriveCellSlews &from_slews, const LibertyPort *to_port, const RiseFallBoth *rf, const MinMaxAll *min_max); @@ -317,13 +316,13 @@ public: bool &exists) const; void setSlewLimit(Clock *clk, const RiseFallBoth *rf, - const PathClkOrData clk_data, + PathClkOrData clk_data, const MinMax *min_max, float slew); bool haveClkSlewLimits() const; void slewLimit(const Clock *clk, const RiseFall *rf, - const PathClkOrData clk_data, + PathClkOrData clk_data, const MinMax *min_max, float &slew, bool &exists) const; @@ -500,12 +499,12 @@ public: Clock *to_clk, const RiseFallBoth *to_rf, const SetupHoldAll *setup_hold); - ClockGroups *makeClockGroups(const std::string &name, + ClockGroups *makeClockGroups(std::string_view name, bool logically_exclusive, bool physically_exclusive, bool asynchronous, bool allow_paths, - std::string comment); + std::string_view comment); void makeClockGroup(ClockGroups *clk_groups, ClockSet *clks); void removeClockGroups(const std::string &name); @@ -580,7 +579,7 @@ public: void setOutputDelay(const Pin *pin, const RiseFallBoth *rf, const Clock *clk, - const RiseFall *clk_tr, + const RiseFall *clk_rf, const Pin *ref_pin, bool source_latency_included, bool network_latency_included, @@ -1113,7 +1112,7 @@ protected: ExceptionPathSet &matches); void expandExceptionExcluding(ExceptionPath *exception, ExceptionPath *excluding, - ExceptionPathSet &expanded_matches); + ExceptionPathSet &expansions); void recordException1(ExceptionPath *exception); void recordExceptionFirstPts(ExceptionPath *exception); void recordExceptionFirstFrom(ExceptionPath *exception); @@ -1288,7 +1287,7 @@ protected: InstancePvtMap instance_pvt_maps_[MinMax::index_count]; MinMaxFloatValues voltages_; NetVoltageMap net_voltage_map_; - DeratingFactorsGlobal *derating_factors_; + DeratingFactorsGlobal *derating_factors_{nullptr}; NetDeratingFactorsMap net_derating_factors_; InstDeratingFactorsMap inst_derating_factors_; CellDeratingFactorsMap cell_derating_factors_; @@ -1297,7 +1296,7 @@ protected: // which iterating over the name map can't provide. ClockSeq clocks_; // Clocks are assigned an index. - int clk_index_; + int clk_index_{0}; // Default clock used for unclocked input arrivals. Clock *default_arrival_clk_; ClockNameMap clock_name_map_; @@ -1320,7 +1319,7 @@ protected: // clks in the same set_clock_group set. ClockPairSet clk_group_same_; ClockSenseMap clk_sense_map_; - ClockGatingCheck *clk_gating_check_; + ClockGatingCheck *clk_gating_check_{nullptr}; ClockGatingCheckMap clk_gating_check_map_; InstanceClockGatingCheckMap inst_clk_gating_check_map_; PinClockGatingCheckMap pin_clk_gating_check_map_; @@ -1335,7 +1334,7 @@ protected: // Input delays on hierarchical pins are indexed by the load pins. InputDelaysPinMap input_delay_leaf_pin_map_; InputDelaysPinMap input_delay_internal_pin_map_; - int input_delay_index_; + int input_delay_index_{0}; OutputDelaySet output_delays_; OutputDelaysPinMap output_delay_pin_map_; @@ -1369,9 +1368,9 @@ protected: InstanceSet disabled_clk_gating_checks_inst_; PinSet disabled_clk_gating_checks_pin_; ExceptionPathSet exceptions_; - size_t exception_id_; // Unique ID for exceptions. + size_t exception_id_{0}; // Unique ID for exceptions. - bool have_thru_hpin_exceptions_; + bool have_thru_hpin_exceptions_{false}; // First pin/clock/instance/net/edge exception point to exception set map. PinExceptionsMap first_from_pin_exceptions_; ClockExceptionsMap first_from_clk_exceptions_; @@ -1404,7 +1403,7 @@ protected: // Filter exception to tag arrivals for // report_timing -from pin|inst -through. // -to is always nullptr. - FilterPath *filter_; + FilterPath *filter_{nullptr}; InputDriveMap input_drive_map_; // set_LogicValue::one/zero/dc @@ -1429,4 +1428,4 @@ private: friend class GroupPathIterator; }; -} // namespace +} // namespace sta diff --git a/include/sta/SdcClass.hh b/include/sta/SdcClass.hh index dc0563b5..62c24efe 100644 --- a/include/sta/SdcClass.hh +++ b/include/sta/SdcClass.hh @@ -29,9 +29,10 @@ #include #include "LibertyClass.hh" -#include "NetworkClass.hh" #include "MinMaxValues.hh" +#include "NetworkClass.hh" #include "PinPair.hh" +#include "Transition.hh" namespace sta { @@ -126,11 +127,13 @@ using ExceptionStateSet = std::set; // Constraint applies to clock or data paths. enum class PathClkOrData { clk, data }; -const int path_clk_or_data_count = 2; +const size_t path_clk_or_data_count = 2; enum class TimingDerateType { cell_delay, cell_check, net_delay }; -constexpr int timing_derate_type_count = 3; +constexpr size_t timing_derate_type_count = 3; enum class TimingDerateCellType { cell_delay, cell_check }; -constexpr int timing_derate_cell_type_count = 2; +constexpr size_t timing_derate_cell_type_count = 2; -} // namespace +using DriveCellSlews = std::array; + +} // namespace sta diff --git a/include/sta/SdcCmdComment.hh b/include/sta/SdcCmdComment.hh index b1c70d0b..65b6b6e6 100644 --- a/include/sta/SdcCmdComment.hh +++ b/include/sta/SdcCmdComment.hh @@ -32,20 +32,18 @@ namespace sta { class SdcCmdComment { public: - SdcCmdComment(); - SdcCmdComment(std::string comment); + SdcCmdComment() = default; SdcCmdComment(std::string_view comment); const std::string &comment() { return comment_; } const std::string &comment() const { return comment_; } - void setComment(std::string comment); void setComment(std::string_view comment); protected: // Destructor is protected to prevent deletion of a derived // class with a pointer to this base class. - ~SdcCmdComment(); + ~SdcCmdComment() = default; std::string comment_; }; -} // namespace +} // namespace sta diff --git a/include/sta/SdcNetwork.hh b/include/sta/SdcNetwork.hh index 84b0b367..ea4c8304 100644 --- a/include/sta/SdcNetwork.hh +++ b/include/sta/SdcNetwork.hh @@ -217,15 +217,15 @@ public: InstanceSeq findInstancesMatching(const Instance *context, const PatternMatch *pattern) const override; Net *findNet(std::string_view path_name) const override; - Net *findNetRelative(const Instance *instance, - std::string_view net_name) const override; + Net *findNetRelative(const Instance *inst, + std::string_view path_name) const override; Net *findNet(const Instance *instance, std::string_view net_name) const override; NetSeq findNetsMatching(const Instance *parent, const PatternMatch *pattern) const override; void findInstNetsMatching(const Instance *instance, const PatternMatch *pattern, - NetSeq &nets) const override; + NetSeq &matches) const override; Instance *findChild(const Instance *parent, std::string_view name) const override; Pin *findPin(std::string_view path_name) const override; @@ -266,9 +266,9 @@ protected: std::string &path_tail) const; bool visitMatches(const Instance *parent, const PatternMatch *pattern, - std::function - visit_tail) const; + const std::function + &visit_tail) const; bool visitPinTail(const Instance *instance, const PatternMatch *tail, PinSeq &matches) const; @@ -290,4 +290,4 @@ std::string escapeBrackets(std::string_view name, const Network *network); -} // namespace +} // namespace sta diff --git a/include/sta/Search.hh b/include/sta/Search.hh index 5e9c5ccb..47fb6247 100644 --- a/include/sta/Search.hh +++ b/include/sta/Search.hh @@ -24,23 +24,23 @@ #pragma once -#include #include +#include #include -#include "MinMax.hh" -#include "Transition.hh" -#include "LibertyClass.hh" -#include "NetworkClass.hh" -#include "GraphClass.hh" #include "Delay.hh" +#include "GraphClass.hh" +#include "LibertyClass.hh" +#include "MinMax.hh" +#include "NetworkClass.hh" +#include "Path.hh" #include "SdcClass.hh" -#include "StaState.hh" #include "SearchClass.hh" #include "SearchPred.hh" -#include "VertexVisitor.hh" -#include "Path.hh" +#include "StaState.hh" #include "StringUtil.hh" +#include "Transition.hh" +#include "VertexVisitor.hh" namespace sta { @@ -76,8 +76,8 @@ class Search : public StaState { public: Search(StaState *sta); - virtual ~Search(); - virtual void copyState(const StaState *sta); + ~Search() override; + void copyState(const StaState *sta) override; // Reset to virgin state. void clear(); // When enabled, non-critical path arrivals are pruned to improve @@ -265,7 +265,7 @@ public: const Mode *mode, TagGroupBldr *tag_bldr); void setVertexArrivals(Vertex *vertex, - TagGroupBldr *group_bldr); + TagGroupBldr *tag_bldr); void tnsInvalid(Vertex *vertex); [[nodiscard]] bool arrivalsChanged(Vertex *vertex, TagGroupBldr *tag_bldr); @@ -314,7 +314,7 @@ public: Tag *findTag(Scene *scene, const RiseFall *rf, const MinMax *min_max, - const ClkInfo *tag_clk, + const ClkInfo *clk_info, bool is_clk, InputDelay *input_delay, bool is_segment_start, @@ -541,7 +541,7 @@ protected: void deletePaths(); // Delete with incremental tns/wns update. void deletePathsIncr(Vertex *vertex); - TagGroup *findTagGroup(TagGroupBldr *group_bldr); + TagGroup *findTagGroup(TagGroupBldr *tag_bldr); void deleteFilterTags(); void deleteFilterTagGroups(); void deleteFilterClkInfos(); @@ -582,9 +582,9 @@ protected: //////////////////////////////////////////////////////////////// // findPathEnds arg. - bool unconstrained_paths_; - bool crpr_path_pruning_enabled_; - bool crpr_approx_missing_requireds_; + bool unconstrained_paths_{false}; + bool crpr_path_pruning_enabled_{true}; + bool crpr_approx_missing_requireds_{true}; // Search predicates. SearchPred *search_thru_; @@ -592,9 +592,9 @@ protected: EvalPred *eval_pred_; // Some arrivals exist. - bool arrivals_exist_; + bool arrivals_exist_{false}; // Arrivals at start points have been initialized. - bool arrivals_seeded_; + bool arrivals_seeded_{false}; // Vertices with invalid arrival times to update and search from. VertexSet invalid_arrivals_; std::mutex invalid_arrivals_lock_; @@ -602,14 +602,14 @@ protected: ArrivalVisitor *arrival_visitor_; // Some requireds exist. - bool requireds_exist_; + bool requireds_exist_{false}; // Requireds have been seeded by searching arrivals to all endpoints. - bool requireds_seeded_; + bool requireds_seeded_{false}; // Vertices with invalid required times to update and search from. VertexSet invalid_requireds_; BfsBkwdIterator *required_iter_; - bool tns_exists_; + bool tns_exists_{false}; // Endpoint vertices with slacks that have changed since tns was found. VertexSet invalid_tns_; // Indexed by path_ap->index(). @@ -619,19 +619,19 @@ protected: std::mutex tns_lock_; // Indexed by path_ap->index(). - WorstSlacks *worst_slacks_; + WorstSlacks *worst_slacks_{nullptr}; // Use pointer to clk_info set so Tag.hh does not need to be included. ClkInfoSet *clk_info_set_; std::mutex clk_info_lock_; // Entries in tags_ may be missing where previous filter tags were deleted. - TagIndex tag_capacity_; + TagIndex tag_capacity_{128}; std::atomic tags_; // Use pointer to tag set so Tag.hh does not need to be included. TagSet *tag_set_; std::vector tags_prev_; - TagIndex tag_next_; + TagIndex tag_next_{0}; std::mutex tag_lock_; // Capacity of tag_groups_. @@ -639,7 +639,7 @@ protected: std::atomic tag_groups_; TagGroupSet *tag_group_set_; std::vector tag_groups_prev_; - TagGroupIndex tag_group_next_; + TagGroupIndex tag_group_next_{0}; // Holes in tag_groups_ left by deleting filter tag groups. std::vector tag_group_free_indices_; std::mutex tag_group_lock_; @@ -652,18 +652,18 @@ protected: std::mutex pending_clk_endpoints_lock_; VertexSet endpoints_; - bool endpoints_initialized_; + bool endpoints_initialized_{false}; VertexSet invalid_endpoints_; - bool have_filter_; - ExceptionFrom *filter_from_; - ExceptionThruSeq *filter_thrus_; - ExceptionTo *filter_to_; + bool have_filter_{false}; + ExceptionFrom *filter_from_{nullptr}; + ExceptionThruSeq *filter_thrus_{nullptr}; + ExceptionTo *filter_to_{nullptr}; VertexSet filtered_arrivals_; std::mutex filtered_arrivals_lock_; - bool found_downstream_clk_pins_; - bool postpone_latch_outputs_; + bool found_downstream_clk_pins_{false}; + bool postpone_latch_outputs_{false}; std::vector enum_paths_; VisitPathEnds *visit_path_ends_; @@ -691,12 +691,13 @@ public: using SearchPred::searchTo; protected: - bool search_thru_latches_; + bool search_thru_latches_{true}; }; // Class for visiting fanin/fanout paths of a vertex. // This used by forward/backward search to find arrival/required path times. -class PathVisitor : public VertexVisitor, public StaState +class PathVisitor : public VertexVisitor, + public StaState { public: // Uses search->evalPred() for search predicate. @@ -704,9 +705,24 @@ public: PathVisitor(SearchPred *pred, bool make_tag_cache, const StaState *sta); - virtual ~PathVisitor(); + ~PathVisitor() override; virtual void visitFaninPaths(Vertex *to_vertex); virtual void visitFanoutPaths(Vertex *from_vertex); + // Return false to stop visiting. + virtual bool visitFromToPath(const Pin *from_pin, + Vertex *from_vertex, + const RiseFall *from_rf, + Tag *from_tag, + Path *from_path, + const Arrival &from_arrival, + Edge *edge, + TimingArc *arc, + ArcDelay arc_delay, + Vertex *to_vertex, + const RiseFall *to_rf, + Tag *to_tag, + Arrival &to_arrival, + const MinMax *min_max) = 0; protected: // Return false to stop visiting. @@ -738,21 +754,6 @@ protected: Vertex *to_vertex, const RiseFall *to_rf, const MinMax *min_max); - // Return false to stop visiting. - virtual bool visitFromToPath(const Pin *from_pin, - Vertex *from_vertex, - const RiseFall *from_rf, - Tag *from_tag, - Path *from_path, - const Arrival &from_arrival, - Edge *edge, - TimingArc *arc, - ArcDelay arc_delay, - Vertex *to_vertex, - const RiseFall *to_rf, - Tag *to_tag, - Arrival &to_arrival, - const MinMax *min_max) = 0; SearchPred *pred_; TagSet *tag_cache_; @@ -764,29 +765,29 @@ class ArrivalVisitor : public PathVisitor { public: ArrivalVisitor(const StaState *sta); - virtual ~ArrivalVisitor(); + ~ArrivalVisitor() override; // Initialize the visitor. void init(bool always_to_endpoints, bool clks_only, SearchPred *pred); - void copyState(const StaState *sta); - virtual void visit(Vertex *vertex); - virtual VertexVisitor *copy() const; + void copyState(const StaState *sta) override; + void visit(Vertex *vertex) override; + VertexVisitor *copy() const override; // Return false to stop visiting. - virtual bool visitFromToPath(const Pin *from_pin, - Vertex *from_vertex, - const RiseFall *from_rf, - Tag *from_tag, - Path *from_path, - const Arrival &from_arrival, - Edge *edge, - TimingArc *arc, - ArcDelay arc_delay, - Vertex *to_vertex, - const RiseFall *to_rf, - Tag *to_tag, - Arrival &to_arrival, - const MinMax *min_max); + bool visitFromToPath(const Pin *from_pin, + Vertex *from_vertex, + const RiseFall *from_rf, + Tag *from_tag, + Path *from_path, + const Arrival &from_arrival, + Edge *edge, + TimingArc *arc, + ArcDelay arc_delay, + Vertex *to_vertex, + const RiseFall *to_rf, + Tag *to_tag, + Arrival &to_arrival, + const MinMax *min_max) override; void setAlwaysToEndpoints(bool to_endpoints); TagGroupBldr *tagBldr() const { return tag_bldr_; } @@ -814,7 +815,6 @@ protected: class RequiredCmp { public: - RequiredCmp(); void requiredsInit(Vertex *vertex, const StaState *sta); void requiredSet(size_t path_index, @@ -827,8 +827,8 @@ public: Required required(size_t path_index); protected: - ArrivalSeq requireds_; - bool have_requireds_; + ArrivalSeq requireds_{10}; + bool have_requireds_{false}; }; // Visitor called during backward search to record a @@ -837,31 +837,31 @@ class RequiredVisitor : public PathVisitor { public: RequiredVisitor(const StaState *sta); - virtual ~RequiredVisitor(); - virtual VertexVisitor *copy() const; - virtual void visit(Vertex *vertex); + ~RequiredVisitor() override; + VertexVisitor *copy() const override; + void visit(Vertex *vertex) override; + // Return false to stop visiting. + bool visitFromToPath(const Pin *from_pin, + Vertex *from_vertex, + const RiseFall *from_rf, + Tag *from_tag, + Path *from_path, + const Arrival &from_arrival, + Edge *edge, + TimingArc *arc, + ArcDelay arc_delay, + Vertex *to_vertex, + const RiseFall *to_rf, + Tag *to_tag, + Arrival &to_arrival, + const MinMax *min_max) override; protected: RequiredVisitor(bool make_tag_cache, const StaState *sta); - // Return false to stop visiting. - virtual bool visitFromToPath(const Pin *from_pin, - Vertex *from_vertex, - const RiseFall *from_rf, - Tag *from_tag, - Path *from_path, - const Arrival &from_arrival, - Edge *edge, - TimingArc *arc, - ArcDelay arc_delay, - Vertex *to_vertex, - const RiseFall *to_rf, - Tag *to_tag, - Arrival &to_arrival, - const MinMax *min_max); RequiredCmp *required_cmp_; VisitPathEnds *visit_path_ends_; }; -} // namespace +} // namespace sta diff --git a/include/sta/SearchClass.hh b/include/sta/SearchClass.hh index bd5a639b..9e3205b9 100644 --- a/include/sta/SearchClass.hh +++ b/include/sta/SearchClass.hh @@ -25,14 +25,14 @@ #pragma once #include -#include #include +#include -#include "VectorMap.hh" -#include "MinMaxValues.hh" #include "Delay.hh" -#include "NetworkClass.hh" #include "GraphClass.hh" +#include "MinMaxValues.hh" +#include "NetworkClass.hh" +#include "VectorMap.hh" namespace sta { @@ -129,4 +129,4 @@ static const int path_ap_index_bit_count = 8; // One path analysis point per scene min/max. static const int scene_count_max = (1 << path_ap_index_bit_count) / 2; -} // namespace +} // namespace sta diff --git a/include/sta/SearchPred.hh b/include/sta/SearchPred.hh index 0d688369..9bcdf9b8 100644 --- a/include/sta/SearchPred.hh +++ b/include/sta/SearchPred.hh @@ -24,9 +24,9 @@ #pragma once -#include "NetworkClass.hh" #include "GraphClass.hh" #include "LibertyClass.hh" +#include "NetworkClass.hh" #include "StaState.hh" namespace sta { @@ -47,7 +47,7 @@ class SearchPred { public: SearchPred(const StaState *sta); - virtual ~SearchPred() {} + virtual ~SearchPred() = default; // Search is allowed from from_vertex. virtual bool searchFrom(const Vertex *from_vertex, const Mode *mode) const = 0; @@ -158,4 +158,4 @@ hasFanout(Vertex *vertex, const Graph *graph, const Mode *mode); -} // namespace +} // namespace sta diff --git a/include/sta/Sequential.hh b/include/sta/Sequential.hh index 89b3f5a9..1b07075a 100644 --- a/include/sta/Sequential.hh +++ b/include/sta/Sequential.hh @@ -141,4 +141,4 @@ private: StateInternalValues next_values_; }; -} // namespace +} // namespace sta diff --git a/include/sta/Sta.hh b/include/sta/Sta.hh index 50eeb3ac..170f6647 100644 --- a/include/sta/Sta.hh +++ b/include/sta/Sta.hh @@ -24,27 +24,27 @@ #pragma once -#include +#include #include #include -#include +#include -#include "StringUtil.hh" -#include "LibertyClass.hh" -#include "NetworkClass.hh" -#include "SdcClass.hh" -#include "Scene.hh" -#include "GraphClass.hh" -#include "ParasiticsClass.hh" -#include "StaState.hh" -#include "VertexVisitor.hh" -#include "SearchClass.hh" -#include "PowerClass.hh" #include "ArcDelayCalc.hh" #include "CircuitSim.hh" -#include "Variables.hh" +#include "GraphClass.hh" +#include "LibertyClass.hh" +#include "NetworkClass.hh" +#include "ParasiticsClass.hh" +#include "PowerClass.hh" #include "Property.hh" #include "RiseFallMinMaxDelay.hh" +#include "Scene.hh" +#include "SdcClass.hh" +#include "SearchClass.hh" +#include "StaState.hh" +#include "StringUtil.hh" +#include "Variables.hh" +#include "VertexVisitor.hh" struct Tcl_Interp; @@ -81,7 +81,7 @@ using SlowDrvrIterator = Iterator; using CheckError = StringSeq; using CheckErrorSeq = std::vector; enum class CmdNamespace { sta, sdc }; -using ParasiticsNameMap = std::map; +using ParasiticsNameMap = std::map>; // Path::slack/arrival/required function. using PathDelayFunc = std::function; using GraphLoopSeq = std::vector; @@ -103,7 +103,6 @@ deleteAllMemory(); class Sta : public StaState { public: - Sta(); // The Sta is a FACTORY for the components. // makeComponents calls the make{Component} virtual functions. // Ideally this would be called by the Sta constructor, but a @@ -114,7 +113,7 @@ public: // pointers to some components have changed. // This must be called after changing any of the StaState components. virtual void updateComponentsState(); - virtual ~Sta(); + ~Sta() override; // Singleton accessor used by tcl command interpreter. static Sta *sta(); @@ -232,7 +231,7 @@ public: Sdc *sdc); // Set net wire capacitance (set_load -wire net). void setNetWireCap(const Net *net, - bool subtract_pin_load, + bool subtract_pin_cap, const MinMaxAll *min_max, float cap, Sdc *sdc); @@ -268,7 +267,7 @@ public: const LibertyCell *cell, const Port *port, const LibertyPort *from_port, - float *from_slews, + const DriveCellSlews &from_slews, const LibertyPort *to_port, const RiseFallBoth *rf, const MinMaxAll *min_max, @@ -312,7 +311,7 @@ public: Sdc *sdc); void setSlewLimit(Clock *clk, const RiseFallBoth *rf, - const PathClkOrData clk_data, + PathClkOrData clk_data, const MinMax *min_max, float slew, Sdc *sdc); @@ -385,7 +384,7 @@ public: const Mode *mode); void removePropagatedClock(Pin *pin, const Mode *mode); - void setClockSlew(Clock *clock, + void setClockSlew(Clock *clk, const RiseFallBoth *rf, const MinMaxAll *min_max, float slew, @@ -441,12 +440,12 @@ public: const RiseFallBoth *to_rf, const SetupHoldAll *setup_hold, Sdc *sdc); - ClockGroups *makeClockGroups(const std::string &name, + ClockGroups *makeClockGroups(std::string_view name, bool logically_exclusive, bool physically_exclusive, bool asynchronous, bool allow_paths, - std::string comment, + std::string_view comment, Sdc *sdc); void removeClockGroupsLogicallyExclusive(Sdc *sdc); void removeClockGroupsLogicallyExclusive(const std::string &name, @@ -700,7 +699,7 @@ public: InstanceSet findRegisterInstances(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode); PinSet findRegisterDataPins(ClockSet *clks, @@ -1157,9 +1156,9 @@ public: const SceneSeq &scenes, const MinMax *min_max); - const ArcDelay arcDelay(Edge *edge, - TimingArc *arc, - DcalcAPIndex ap_index); + ArcDelay arcDelay(Edge *edge, + TimingArc *arc, + DcalcAPIndex ap_index); // True if the timing arc has been back-annotated. bool arcDelayAnnotated(Edge *edge, TimingArc *arc, @@ -1193,8 +1192,8 @@ public: // Instances sorted by max driver pin slew. InstanceSeq slowDrivers(int count); - Parasitics *makeConcreteParasitics(std::string name, - std::string filename); + Parasitics *makeConcreteParasitics(std::string_view name, + std::string_view filename); // Annotate hierarchical "instance" with parasitics. // The parasitic analysis point is ap_name. // The parasitic memory footprint is much smaller if parasitic @@ -1525,23 +1524,23 @@ protected: bool report_variance, int digits, bool find_required, - PathDelayFunc get_path_delay); + const PathDelayFunc &get_path_delay); void reportDelaysWrtClks(Vertex *vertex, const Scene *scene, bool report_variance, int digits, bool find_required, - PathDelayFunc get_path_delay); + const PathDelayFunc &get_path_delay); void reportDelaysWrtClks(Vertex *vertex, const ClockEdge *clk_edge, const Scene *scene, bool report_variance, int digits, - PathDelayFunc get_path_delay); + const PathDelayFunc &get_path_delay); RiseFallMinMaxDelay findDelaysWrtClks(Vertex *vertex, const ClockEdge *clk_edge, const Scene *scene, - PathDelayFunc get_path_delay); + const PathDelayFunc &get_path_delay); std::string formatDelay(const RiseFall *rf, const MinMax *min_max, const RiseFallMinMaxDelay &delays, @@ -1615,30 +1614,30 @@ protected: Parasitics *parasitics); void deleteScenes(); - Scene *cmd_scene_; - CmdNamespace cmd_namespace_; - Instance *current_instance_; + Scene *cmd_scene_{nullptr}; + CmdNamespace cmd_namespace_{CmdNamespace::sdc}; + Instance *current_instance_{nullptr}; SceneNameMap scene_name_map_; ModeNameMap mode_name_map_; ParasiticsNameMap parasitics_name_map_; - VerilogReader *verilog_reader_; - CheckTiming *check_timing_; - CheckSlews *check_slews_; - CheckFanouts *check_fanouts_; - CheckCapacitances *check_capacitances_; - CheckMinPulseWidths *check_min_pulse_widths_; - CheckMinPeriods *check_min_periods_; - CheckMaxSkews *check_max_skews_; - ClkSkews *clk_skews_; - ReportPath *report_path_; - Power *power_; - Tcl_Interp *tcl_interp_; - bool update_genclks_; - EquivCells *equiv_cells_; - Properties properties_; + VerilogReader *verilog_reader_{nullptr}; + CheckTiming *check_timing_{nullptr}; + CheckSlews *check_slews_{nullptr}; + CheckFanouts *check_fanouts_{nullptr}; + CheckCapacitances *check_capacitances_{nullptr}; + CheckMinPulseWidths *check_min_pulse_widths_{nullptr}; + CheckMinPeriods *check_min_periods_{nullptr}; + CheckMaxSkews *check_max_skews_{nullptr}; + ClkSkews *clk_skews_{nullptr}; + ReportPath *report_path_{nullptr}; + Power *power_{nullptr}; + Tcl_Interp *tcl_interp_{nullptr}; + bool update_genclks_{false}; + EquivCells *equiv_cells_{nullptr}; + Properties properties_{this}; // Singleton sta used by tcl command interpreter. - static Sta *sta_; + inline static Sta *sta_{nullptr}; }; -} // namespace +} // namespace sta diff --git a/include/sta/StaMain.hh b/include/sta/StaMain.hh index 6d818c41..e588ab26 100644 --- a/include/sta/StaMain.hh +++ b/include/sta/StaMain.hh @@ -75,4 +75,4 @@ sourceTclFile(const char *filename, bool verbose, Tcl_Interp *interp); -} // namespace +} // namespace sta diff --git a/include/sta/StaState.hh b/include/sta/StaState.hh index 8f96e137..c0da5998 100644 --- a/include/sta/StaState.hh +++ b/include/sta/StaState.hh @@ -65,7 +65,7 @@ public: // Copy the state from sta. This is virtual so that a component // can notify sub-components. virtual void copyState(const StaState *sta); - virtual ~StaState() {} + virtual ~StaState() = default; Report *report() { return report_; } Report *report() const { return report_; } void setReport(Report *report); @@ -113,7 +113,7 @@ public: size_t scenePathCount() const; DcalcAPIndex dcalcAnalysisPtCount() const; - const SceneSet scenesSet(); + SceneSet scenesSet(); ModeSeq &modes() { return modes_; } const ModeSeq &modes() const { return modes_; } @@ -141,4 +141,4 @@ protected: DispatchQueue *dispatch_queue_; }; -} // namespace +} // namespace sta diff --git a/include/sta/Stats.hh b/include/sta/Stats.hh index 6968c8fe..79cd3ef4 100644 --- a/include/sta/Stats.hh +++ b/include/sta/Stats.hh @@ -40,12 +40,12 @@ public: void report(const char *step); private: - double elapsed_begin_; - double user_begin_; - double system_begin_; - size_t memory_begin_; + double elapsed_begin_{0.0}; + double user_begin_{0.0}; + double system_begin_{0.0}; + size_t memory_begin_{0}; Debug *debug_; Report *report_; }; -} // namespace +} // namespace sta diff --git a/include/sta/StringUtil.hh b/include/sta/StringUtil.hh index f9161a60..35a8cda9 100644 --- a/include/sta/StringUtil.hh +++ b/include/sta/StringUtil.hh @@ -1,5 +1,5 @@ // OpenSTA, Static Timing Analyzer -// Copyright (c) 2025, Parallax Software, Inc. +// Copyright (c) 2026, 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 @@ -25,13 +25,13 @@ #pragma once #include +#include #include #include +#include #include #include -#include // for strncasecmp #include -#include #include "Machine.hh" // __attribute__ @@ -64,6 +64,13 @@ stringBeginEq(const char *str1, return strncmp(str1, str2, strlen(str2)) == 0; } +inline bool +charEqual(unsigned char c1, + unsigned char c2) +{ + return std::tolower(c1) == std::tolower(c2); +} + // Case insensitive compare the beginning of str1 to str2. inline bool stringBeginEqual(std::string_view str, @@ -71,7 +78,7 @@ stringBeginEqual(std::string_view str, { if (str.size() < prefix.size()) return false; - return strncasecmp(str.data(), prefix.data(), prefix.size()) == 0; + return std::ranges::equal(str.substr(0, prefix.size()), prefix, charEqual); } // Case insensitive compare. @@ -79,19 +86,7 @@ inline bool stringEqual(std::string_view s1, std::string_view s2) { - return std::ranges::equal(s1, s2, [](unsigned char c1, unsigned char c2) { - return std::tolower(c1) == std::tolower(c2); - }); -} - -void -stringDeleteCheck(const char *str); - -// Delete for strings allocated with new char[]. -inline void -stringDelete(const char *str) -{ - delete [] str; + return std::ranges::equal(s1, s2, charEqual); } std::pair @@ -114,4 +109,4 @@ StringSeq parseTokens(const std::string &text, std::string_view delims = " \t"); -} // namespace +} // namespace sta diff --git a/include/sta/TableModel.hh b/include/sta/TableModel.hh index 3afce335..40855a75 100644 --- a/include/sta/TableModel.hh +++ b/include/sta/TableModel.hh @@ -30,10 +30,10 @@ #include #include -#include "MinMax.hh" -#include "Transition.hh" #include "LibertyClass.hh" +#include "MinMax.hh" #include "TimingModel.hh" +#include "Transition.hh" #include "Variables.hh" namespace sta { @@ -73,7 +73,6 @@ public: GateTableModel(LibertyCell *cell, TableModels *delay_models, TableModels *slew_models); - ~GateTableModel() override; void gateDelay(const Pvt *pvt, float in_slew, float load_cap, @@ -96,6 +95,7 @@ public: PocvMode pocv_mode, int digits) const override; float driveResistance(const Pvt *pvt) const override; + void setIsScaled(bool is_scaled) override; const TableModels *delayModels() const { return delay_models_.get(); } const TableModel *delayModel() const; @@ -112,10 +112,9 @@ protected: const Pvt *pvt, float &slew, float &cap) const; - void setIsScaled(bool is_scaled) override; float axisValue(const TableAxis *axis, - float load_cap, float in_slew, + float load_cap, float related_out_cap) const; float findValue(const Pvt *pvt, const TableModel *model, @@ -150,7 +149,6 @@ class CheckTableModel : public CheckTimingModel public: CheckTableModel(LibertyCell *cell, TableModels *check_models); - ~CheckTableModel() override; ArcDelay checkDelay(const Pvt *pvt, float from_slew, float to_slew, @@ -167,13 +165,13 @@ public: int digits) const override; const TableModels *checkModels() const { return check_models_.get(); } const TableModel *checkModel() const; + void setIsScaled(bool is_scaled) override; // Check the axes before making the model. // Return true if the model axes are supported. static bool checkAxes(const TableModel *table); protected: - void setIsScaled(bool is_scaled) override; float findValue(const Pvt *pvt, const TableModel *model, float from_slew, @@ -187,8 +185,8 @@ protected: float &axis_value2, float &axis_value3) const; float axisValue(const TableAxis *axis, - float load_cap, - float in_slew, + float from_slew, + float to_slew, float related_out_cap) const; std::string reportTableDelay(std::string_view result_name, const Pvt *pvt, @@ -247,19 +245,19 @@ public: TableAxisPtr axis1, TableAxisPtr axis2, TableAxisPtr axis3); - Table(Table &&table); + Table(Table &&table) noexcept; Table(const Table &table); - Table &operator=(Table &&table); + Table &operator=(Table &&table) noexcept; + void setIsScaled(bool is_scaled); void setScaleFactorType(ScaleFactorType type); int order() const { return order_; } const TableAxis *axis1() const { return axis1_.get(); } const TableAxis *axis2() const { return axis2_.get(); } const TableAxis *axis3() const { return axis3_.get(); } - const TableAxisPtr axis1ptr() const { return axis1_; } - const TableAxisPtr axis2ptr() const { return axis2_; } - const TableAxisPtr axis3ptr() const { return axis3_; } - void setIsScaled(bool is_scaled); + TableAxisPtr axis1ptr() const { return axis1_; } + TableAxisPtr axis2ptr() const { return axis2_; } + TableAxisPtr axis3ptr() const { return axis3_; } float value(size_t axis_idx1, size_t axis_idx2, @@ -440,7 +438,6 @@ protected: class ReceiverModel { public: - ~ReceiverModel(); void setCapacitanceModel(TableModel table_model, size_t segment, const RiseFall *rf); @@ -529,7 +526,7 @@ private: Table1Seq voltage_waveforms_; Table1Seq voltage_currents_; Table ref_times_; - float vdd_; + float vdd_{0.0F}; static constexpr size_t voltage_waveform_step_count_ = 100; }; @@ -546,4 +543,4 @@ private: TablePtr waveforms_; }; -} // namespace +} // namespace sta diff --git a/include/sta/TclTypeHelpers.hh b/include/sta/TclTypeHelpers.hh index acb4e164..628ee099 100644 --- a/include/sta/TclTypeHelpers.hh +++ b/include/sta/TclTypeHelpers.hh @@ -30,17 +30,17 @@ namespace sta { #if TCL_MAJOR_VERSION < 9 - typedef int Tcl_Size; + using Tcl_Size = int ; #endif StringSeq -tclListStringSeq(Tcl_Obj *const source, +tclListStringSeq(Tcl_Obj *source, Tcl_Interp *interp); StringSeq * -tclListStringSeqPtr(Tcl_Obj *const source, +tclListStringSeqPtr(Tcl_Obj *source, Tcl_Interp *interp); StringSet * -tclListStringSet(Tcl_Obj *const source, +tclListStringSet(Tcl_Obj *source, Tcl_Interp *interp); void @@ -64,4 +64,4 @@ ArcDcalcArg arcDcalcArgTcl(Tcl_Obj *obj, Tcl_Interp *interp); -} // namespace +} // namespace sta diff --git a/include/sta/TimingArc.hh b/include/sta/TimingArc.hh index 274f10e5..4f9d5445 100644 --- a/include/sta/TimingArc.hh +++ b/include/sta/TimingArc.hh @@ -24,14 +24,14 @@ #pragma once +#include #include #include #include -#include -#include "Transition.hh" #include "Delay.hh" #include "LibertyClass.hh" +#include "Transition.hh" namespace sta { @@ -86,7 +86,7 @@ enum class TimingType { std::string_view to_string(TimingType type); TimingType -findTimingType(std::string_view string); +findTimingType(std::string_view type_name); bool timingTypeIsCheck(TimingType type); ScaleFactorType @@ -107,15 +107,15 @@ public: FuncExpr *cond() const { return cond_; } void setCond(FuncExpr *cond); const std::string &sdfCond() const { return sdf_cond_; } - void setSdfCond(std::string cond); + void setSdfCond(std::string_view cond); const std::string &sdfCondStart() const { return sdf_cond_start_; } - void setSdfCondStart(std::string cond); + void setSdfCondStart(std::string_view cond); const std::string &sdfCondEnd() const { return sdf_cond_end_; } - void setSdfCondEnd(std::string cond); + void setSdfCondEnd(std::string_view cond); const std::string &modeName() const { return mode_name_; } - void setModeName(std::string name); + void setModeName(std::string_view name); const std::string &modeValue() const { return mode_value_; } - void setModeValue(std::string value); + void setModeValue(std::string_view value); TimingModel *model(const RiseFall *rf) const; void setModel(const RiseFall *rf, TimingModel *model); @@ -260,9 +260,9 @@ public: GateTableModel *gateTableModel() const; GateTableModel *gateTableModel(const Scene *scene, const MinMax *min_max) const; - const TimingArc *sceneArc(int ap_index) const; + const TimingArc *sceneArc(size_t lib_ap_index) const; void setSceneArc(TimingArc *scene_arc, - int ap_index); + size_t lib_ap_index); float driveResistance() const; ArcDelay intrinsicDelay() const; @@ -281,7 +281,7 @@ protected: const Transition *to_rf_; unsigned index_; TimingModel *model_; - ScaledTimingModelMap *scaled_models_; + ScaledTimingModelMap *scaled_models_{nullptr}; std::vector scene_arcs_; private: @@ -290,4 +290,4 @@ private: friend class TimingArcSet; }; -} // namespace +} // namespace sta diff --git a/include/sta/TimingModel.hh b/include/sta/TimingModel.hh index 55e1623e..36e25a36 100644 --- a/include/sta/TimingModel.hh +++ b/include/sta/TimingModel.hh @@ -38,7 +38,7 @@ class TimingModel { public: TimingModel(LibertyCell *cell); - virtual ~TimingModel() {} + virtual ~TimingModel() = default; virtual void setIsScaled(bool is_scaled) = 0; protected: @@ -97,4 +97,4 @@ public: int digits) const = 0; }; -} // namespace +} // namespace sta diff --git a/include/sta/TimingRole.hh b/include/sta/TimingRole.hh index 23a075f0..f07d6ed6 100644 --- a/include/sta/TimingRole.hh +++ b/include/sta/TimingRole.hh @@ -144,4 +144,4 @@ private: friend class TimingRoleLess; }; -} // namespace +} // namespace sta diff --git a/include/sta/Transition.hh b/include/sta/Transition.hh index 9d01abbc..16ccb025 100644 --- a/include/sta/Transition.hh +++ b/include/sta/Transition.hh @@ -47,43 +47,43 @@ public: // Singleton accessors. static const RiseFall *rise() { return &rise_; } static const RiseFall *fall() { return &fall_; } - static int riseIndex() { return rise_.sdf_triple_index_; } - static int fallIndex() { return fall_.sdf_triple_index_; } + static size_t riseIndex() { return rise_.sdf_triple_index_; } + static size_t fallIndex() { return fall_.sdf_triple_index_; } const std::string &to_string(bool use_short = false) const; const std::string &name() const { return name_; } const std::string &shortName() const { return short_name_; } - int index() const { return sdf_triple_index_; } + size_t index() const { return sdf_triple_index_; } const RiseFallBoth *asRiseFallBoth(); const RiseFallBoth *asRiseFallBoth() const; const Transition *asTransition() const; // Find transition corresponding to rf_str. - static const RiseFall *find(std::string_view rf_str); + static const RiseFall *find(std::string_view rf_name); // Find transition from index. - static const RiseFall *find(int index); + static const RiseFall *find(size_t index); const RiseFall *opposite() const; // for range support. // for (auto rf : RiseFall::range()) {} static const std::array &range() { return range_; } // for (auto rf_index : RiseFall::rangeIndex()) {} - static const std::array &rangeIndex() { return range_index_; } - static const int index_count = 2; - static const int index_max = (index_count - 1); - static const int index_bit_count = 1; + static const std::array &rangeIndex() { return range_index_; } + static const size_t index_count = 2; + static const size_t index_max = (index_count - 1); + static const size_t index_bit_count = 1; protected: RiseFall(std::string_view name, std::string_view short_name, - int sdf_triple_index); + size_t sdf_triple_index); const std::string name_; const std::string short_name_; - const int sdf_triple_index_; + const size_t sdf_triple_index_; static const RiseFall rise_; static const RiseFall fall_; static const std::array range_; - static const std::array range_index_; + static const std::array range_index_; }; // Rise/fall/risefall transition. @@ -97,35 +97,35 @@ public: const std::string &to_string(bool use_short = false) const; const std::string &name() const { return name_; } const std::string &shortName() const { return short_name_; } - int index() const { return sdf_triple_index_; } + size_t index() const { return sdf_triple_index_; } bool matches(const RiseFall *rf) const; bool matches(const Transition *tr) const; const RiseFall *asRiseFall() const { return as_rise_fall_; } // Find transition corresponding to string. - static const RiseFallBoth *find(std::string_view tr_str); + static const RiseFallBoth *find(std::string_view rf_name); // for (const auto rf : rf->range()) {} const std::vector &range() const { return range_; } // for (const auto rf_index : rf->rangeIndex()) {} - const std::vector &rangeIndex() const { return range_index_; } + const std::vector &rangeIndex() const { return range_index_; } - static const int index_count = 3; - static const int index_max = (index_count - 1); - static const int index_bit_count = 2; + static const size_t index_count = 3; + static const size_t index_max = (index_count - 1); + static const size_t index_bit_count = 2; protected: RiseFallBoth(std::string_view name, std::string_view short_name, - int sdf_triple_index, + size_t sdf_triple_index, const RiseFall *as_rise_fall, - std::vector range, - std::vector range_index); + const std::vector &range, + const std::vector &range_index); const std::string name_; const std::string short_name_; - const int sdf_triple_index_; + const size_t sdf_triple_index_; const RiseFall *as_rise_fall_; const std::vector range_; - const std::vector range_index_; + const std::vector range_index_; static const RiseFallBoth rise_; static const RiseFallBoth fall_; @@ -154,25 +154,25 @@ public: const std::string &to_string() const { return name_; } // As initial/final value pair. const std::string &asInitFinalString() const { return init_final_; } - int sdfTripleIndex() const { return sdf_triple_index_; } - int index() const { return sdf_triple_index_; } + size_t sdfTripleIndex() const { return sdf_triple_index_; } + size_t index() const { return sdf_triple_index_; } const RiseFall *asRiseFall() const { return as_rise_fall_; } const RiseFallBoth *asRiseFallBoth() const; bool matches(const Transition *tr) const; // Find transition corresponding to string. - static const Transition *find(std::string_view tr_str); - static int maxIndex() { return max_index_; } + static const Transition *find(std::string_view tr_name); + static size_t maxIndex() { return max_index_; } private: Transition(std::string_view name, std::string_view init_final, const RiseFall *as_rise_fall, - int sdf_triple_index); + size_t sdf_triple_index); const std::string name_; const std::string init_final_; const RiseFall *as_rise_fall_; - const int sdf_triple_index_; + const size_t sdf_triple_index_; static const Transition rise_; static const Transition fall_; @@ -187,12 +187,12 @@ private: static const Transition tr_XZ_; static const Transition tr_ZX_; static const Transition rise_fall_; - static const int index_count = 13; - static const int index_max = (index_count - 1); - static const int index_bit_count = 4; + static const size_t index_count = 13; + static const size_t index_max = (index_count - 1); + static const size_t index_bit_count = 4; static TransitionMap transition_map_; - static int max_index_; + static size_t max_index_; }; -} // namespace +} // namespace sta diff --git a/include/sta/Units.hh b/include/sta/Units.hh index 0067fe75..c3868f99 100644 --- a/include/sta/Units.hh +++ b/include/sta/Units.hh @@ -39,7 +39,7 @@ public: double staToUser(double value); // Convert from user interface units to sta units. double userToSta(double value); - void operator=(const Unit &unit); + Unit &operator=(const Unit &unit) = default; float scale() const { return scale_; } void setScale(float scale); // Mkmunpf abbreviation for scale. @@ -76,7 +76,7 @@ class Units public: Units(); Unit *find(std::string_view unit_name); - void operator=(const Units &units); + Units &operator=(const Units &units); Unit *timeUnit() { return &time_unit_; } const Unit *timeUnit() const { return &time_unit_; } Unit *capacitanceUnit() { return &capacitance_unit_; } @@ -105,4 +105,4 @@ private: Unit scalar_unit_; }; -} // namespace +} // namespace sta diff --git a/include/sta/Variables.hh b/include/sta/Variables.hh index 7e8e7a69..90c9fad2 100644 --- a/include/sta/Variables.hh +++ b/include/sta/Variables.hh @@ -34,7 +34,6 @@ enum class CrprMode { same_pin, same_transition }; class Variables { public: - Variables(); // TCL variable sta_crpr_enabled. bool crprEnabled() const { return crpr_enabled_; } void setCrprEnabled(bool enabled); @@ -78,23 +77,23 @@ public: PocvMode pocvMode() const { return pocv_mode_; } void setPocvMode(PocvMode mode); float pocvQuantile() const { return pocv_quantile_; } - void setPocvQuantile(float quartile); + void setPocvQuantile(float quantile); private: - bool crpr_enabled_; - CrprMode crpr_mode_; - bool propagate_gated_clock_enable_; - bool preset_clr_arcs_enabled_; - bool cond_default_arcs_enabled_; - bool bidirect_inst_paths_enabled_; - bool recovery_removal_checks_enabled_; - bool gated_clk_checks_enabled_; - bool clk_thru_tristate_enabled_; - bool dynamic_loop_breaking_; - bool propagate_all_clks_; - bool use_default_arrival_clock_; - PocvMode pocv_mode_; - float pocv_quantile_; + bool crpr_enabled_{true}; + CrprMode crpr_mode_{CrprMode::same_pin}; + bool propagate_gated_clock_enable_{true}; + bool preset_clr_arcs_enabled_{false}; + bool cond_default_arcs_enabled_{true}; + bool bidirect_inst_paths_enabled_{false}; + bool recovery_removal_checks_enabled_{true}; + bool gated_clk_checks_enabled_{true}; + bool clk_thru_tristate_enabled_{false}; + bool dynamic_loop_breaking_{false}; + bool propagate_all_clks_{false}; + bool use_default_arrival_clock_{false}; + PocvMode pocv_mode_{PocvMode::scalar}; + float pocv_quantile_{3.0}; }; -} // namespace +} // namespace sta diff --git a/include/sta/VectorMap.hh b/include/sta/VectorMap.hh index b78f76cf..5fa6990c 100644 --- a/include/sta/VectorMap.hh +++ b/include/sta/VectorMap.hh @@ -24,12 +24,12 @@ #pragma once -#include #include -#include #include #include #include +#include +#include namespace sta { @@ -99,14 +99,14 @@ private: Compare comp_; // Helper to find insertion point using binary search - typename storage_type::iterator findInsertPos(const Key& key) { + storage_type::iterator findInsertPos(const Key& key) { return std::lower_bound(data_.begin(), data_.end(), key, [this](const auto& pair, const Key& k) { return comp_(pair.first, k); }); } - typename storage_type::const_iterator findInsertPos(const Key& key) const { + storage_type::const_iterator findInsertPos(const Key& key) const { return std::lower_bound(data_.begin(), data_.end(), key, [this](const auto& pair, const Key& k) { return comp_(pair.first, k); @@ -126,15 +126,12 @@ private: using reference = proxy_type; using pointer = proxy_type*; - IteratorAdapter() = default; explicit IteratorAdapter(BaseIter it) : it_(it) {} // Conversion constructor: allow conversion from non-const to const iterator template - IteratorAdapter(const IteratorAdapter& other, - typename std::enable_if< - std::is_convertible_v - >::type* = nullptr) + requires std::is_convertible_v + IteratorAdapter(const IteratorAdapter& other) : it_(other.base()) {} reference operator*() { @@ -166,11 +163,8 @@ private: // Assignment operator: allow assignment from non-const to const iterator template - typename std::enable_if< - std::is_convertible_v, - IteratorAdapter& - >::type - operator=(const IteratorAdapter& other) { + requires std::is_convertible_v + IteratorAdapter& operator=(const IteratorAdapter& other) { it_ = other.base(); return *this; } @@ -263,7 +257,6 @@ public: using reverse_iterator = std::reverse_iterator; using const_reverse_iterator = std::reverse_iterator; - VectorMap() = default; explicit VectorMap(const Compare& comp) : comp_(comp) {} template diff --git a/include/sta/VerilogNamespace.hh b/include/sta/VerilogNamespace.hh index 5b874189..441b6ba2 100644 --- a/include/sta/VerilogNamespace.hh +++ b/include/sta/VerilogNamespace.hh @@ -39,12 +39,12 @@ std::string portVerilogName(std::string_view sta_name); std::string -moduleVerilogToSta(std::string_view sta_name); +moduleVerilogToSta(std::string_view module_name); std::string -instanceVerilogToSta(std::string_view sta_name); +instanceVerilogToSta(std::string_view inst_name); std::string -netVerilogToSta(std::string_view sta_name); +netVerilogToSta(std::string_view net_name); std::string -portVerilogToSta(std::string_view sta_name); +portVerilogToSta(std::string_view port_name); -} // namespace +} // namespace sta diff --git a/include/sta/VerilogReader.hh b/include/sta/VerilogReader.hh index b28e0f23..8d88e9e7 100644 --- a/include/sta/VerilogReader.hh +++ b/include/sta/VerilogReader.hh @@ -24,15 +24,15 @@ #pragma once +#include #include #include #include -#include #include "Format.hh" +#include "NetworkClass.hh" #include "Report.hh" #include "StringUtil.hh" -#include "NetworkClass.hh" namespace sta { @@ -104,12 +104,12 @@ public: ~VerilogReader(); bool read(std::string_view filename); - void makeModule(std::string &&module_name, + void makeModule(std::string_view module_vname, VerilogNetSeq *ports, VerilogStmtSeq *stmts, VerilogAttrStmtSeq *attr_stmts, int line); - void makeModule(std::string &&module_name, + void makeModule(std::string_view module_vname, VerilogStmtSeq *port_dcls, VerilogStmtSeq *stmts, VerilogAttrStmtSeq *attr_stmts, @@ -122,8 +122,8 @@ public: VerilogDclArg *arg, VerilogAttrStmtSeq *attr_stmts, int line); - VerilogDclArg *makeDclArg(std::string &&net_name); - VerilogDclArg*makeDclArg(VerilogAssign *assign); + VerilogDclArg *makeDclArg(std::string_view net_vname); + VerilogDclArg *makeDclArg(VerilogAssign *assign); VerilogDclBus *makeDclBus(PortDirection *dir, int from_index, int to_index, @@ -136,36 +136,36 @@ public: VerilogDclArgSeq *args, VerilogAttrStmtSeq *attr_stmts, int line); - VerilogInst *makeModuleInst(std::string &&module_name, - std::string &&inst_name, + VerilogInst *makeModuleInst(std::string_view module_vname, + std::string_view inst_vname, VerilogNetSeq *pins, VerilogAttrStmtSeq *attr_stmts, - const int line); + int line); VerilogAssign *makeAssign(VerilogNet *lhs, VerilogNet *rhs, int line); - VerilogNetScalar *makeNetScalar(std::string &&name); - VerilogNetPortRef *makeNetNamedPortRefScalarNet(std::string &&port_vname); - VerilogNetPortRef *makeNetNamedPortRefScalarNet(std::string &&port_name, - std::string &&net_name); - VerilogNetPortRef *makeNetNamedPortRefBitSelect(std::string &&port_name, - std::string &&bus_name, + VerilogNetScalar *makeNetScalar(std::string_view name); + VerilogNetPortRef *makeNetNamedPortRefScalarNet(std::string_view port_vname); + VerilogNetPortRef *makeNetNamedPortRefScalarNet(std::string_view port_vname, + std::string_view net_vname); + VerilogNetPortRef *makeNetNamedPortRefBitSelect(std::string_view port_vname, + std::string_view bus_vname, int index); - VerilogNetPortRef *makeNetNamedPortRefScalar(std::string &&port_name, + VerilogNetPortRef *makeNetNamedPortRefScalar(std::string_view port_vname, VerilogNet *net); - VerilogNetPortRef *makeNetNamedPortRefBit(std::string &&port_name, + VerilogNetPortRef *makeNetNamedPortRefBit(std::string_view port_vname, int index, VerilogNet *net); - VerilogNetPortRef *makeNetNamedPortRefPart(std::string &&port_name, + VerilogNetPortRef *makeNetNamedPortRefPart(std::string_view port_vname, int from_index, int to_index, VerilogNet *net); VerilogNetConcat *makeNetConcat(VerilogNetSeq *nets); - VerilogNetConstant *makeNetConstant(std::string &&constant, + VerilogNetConstant *makeNetConstant(std::string_view constant, int line); - VerilogNetBitSelect *makeNetBitSelect(std::string &&name, + VerilogNetBitSelect *makeNetBitSelect(std::string_view name, int index); - VerilogNetPartSelect *makeNetPartSelect(std::string &&name, + VerilogNetPartSelect *makeNetPartSelect(std::string_view name, int from_index, int to_index); VerilogModule *module(Cell *cell); @@ -306,8 +306,8 @@ protected: Debug *debug_; NetworkReader *network_; - Library *library_; - int black_box_index_; + Library *library_{nullptr}; + int black_box_index_{0}; VerilogModuleMap module_map_; VerilogErrorSeq link_errors_; const std::string zero_net_name_; diff --git a/include/sta/VerilogWriter.hh b/include/sta/VerilogWriter.hh index 2867c7ea..7e4cf6e0 100644 --- a/include/sta/VerilogWriter.hh +++ b/include/sta/VerilogWriter.hh @@ -34,4 +34,4 @@ writeVerilog(const char *filename, CellSeq *remove_cells, Network *network); -} // namespace +} // namespace sta diff --git a/include/sta/VertexId.hh b/include/sta/VertexId.hh index 864139bf..8e6181b7 100644 --- a/include/sta/VertexId.hh +++ b/include/sta/VertexId.hh @@ -34,4 +34,4 @@ using VertexId = ObjectId; static constexpr VertexId vertex_id_null = object_id_null; -} // namespace +} // namespace sta diff --git a/include/sta/VertexVisitor.hh b/include/sta/VertexVisitor.hh index 3b4a6176..e7aa7d36 100644 --- a/include/sta/VertexVisitor.hh +++ b/include/sta/VertexVisitor.hh @@ -24,8 +24,8 @@ #pragma once -#include "NetworkClass.hh" #include "GraphClass.hh" +#include "NetworkClass.hh" namespace sta { @@ -33,12 +33,10 @@ namespace sta { class VertexVisitor { public: - VertexVisitor() {} - virtual ~VertexVisitor() {} + virtual ~VertexVisitor() = default; virtual VertexVisitor *copy() const = 0; virtual void visit(Vertex *vertex) = 0; void operator()(Vertex *vertex) { visit(vertex); } - virtual void levelFinished() {} }; // Collect visited pins into a PinSet. @@ -47,11 +45,11 @@ class VertexPinCollector : public VertexVisitor public: VertexPinCollector(PinSet &pins); const PinSet &pins() const { return pins_; } - void visit(Vertex *vertex); - virtual VertexVisitor *copy() const; + void visit(Vertex *vertex) override; + VertexVisitor *copy() const override; protected: PinSet &pins_; }; -} // namespace +} // namespace sta diff --git a/include/sta/VisitPathEnds.hh b/include/sta/VisitPathEnds.hh index 74ef0496..8ac723f5 100644 --- a/include/sta/VisitPathEnds.hh +++ b/include/sta/VisitPathEnds.hh @@ -24,8 +24,8 @@ #pragma once -#include "SdcClass.hh" #include "GraphClass.hh" +#include "SdcClass.hh" #include "SearchClass.hh" #include "StaState.hh" @@ -142,7 +142,7 @@ protected: class PathEndVisitor { public: - virtual ~PathEndVisitor() {} + virtual ~PathEndVisitor() = default; virtual PathEndVisitor *copy() const = 0; // Begin visiting the path ends for a vertex / path_index. virtual void vertexBegin(Vertex *) {} @@ -152,4 +152,4 @@ public: virtual void vertexEnd(Vertex *) {} }; -} // namespace +} // namespace sta diff --git a/include/sta/Wireload.hh b/include/sta/Wireload.hh index 6ca8b536..c0dc9076 100644 --- a/include/sta/Wireload.hh +++ b/include/sta/Wireload.hh @@ -42,7 +42,7 @@ using WireloadForAreaSeq = std::vector; const char * wireloadTreeString(WireloadTree tree); WireloadTree -stringWireloadTree(std::string_view tree); +stringWireloadTree(std::string_view wire_load_type); const char * wireloadModeString(WireloadMode wire_load_mode); @@ -101,4 +101,4 @@ private: WireloadForAreaSeq wireloads_; }; -} // namespace +} // namespace sta diff --git a/liberty/EquivCells.cc b/liberty/EquivCells.cc index e4fbba44..3c40ca4d 100644 --- a/liberty/EquivCells.cc +++ b/liberty/EquivCells.cc @@ -24,17 +24,16 @@ #include "EquivCells.hh" +#include + #include "ContainerHelpers.hh" -#include "Hash.hh" -#include "MinMax.hh" -#include "PortDirection.hh" -#include "Transition.hh" -#include "TimingRole.hh" #include "FuncExpr.hh" -#include "TimingArc.hh" +#include "Hash.hh" #include "Liberty.hh" -#include "TableModel.hh" +#include "LibertyClass.hh" +#include "PortDirection.hh" #include "Sequential.hh" +#include "TimingArc.hh" namespace sta { @@ -208,8 +207,8 @@ hashCellPorts(const LibertyCell *cell) static unsigned hashPort(const LibertyPort *port) { - return hashString(port->name().c_str()) * 3 - + port->direction()->index() * 5; + return hashString(port->name()) * 3U + + port->direction()->index() * 5U; } static unsigned @@ -235,8 +234,8 @@ hashSequential(const Sequential *seq) hash += hashPort(seq->outputInv()) * 11; hash += hashFuncExpr(seq->clear()) * 13; hash += hashFuncExpr(seq->preset()) * 17; - hash += int(seq->clearPresetOutput()) * 19; - hash += int(seq->clearPresetOutputInv()) * 23; + hash += static_cast(seq->clearPresetOutput()) * 19; + hash += static_cast(seq->clearPresetOutputInv()) * 23; return hash; } @@ -501,4 +500,4 @@ equivCellTimingArcSets(const LibertyCell *cell1, } } -} // namespace +} // namespace sta diff --git a/liberty/FuncExpr.cc b/liberty/FuncExpr.cc index b127cd27..fbab8452 100644 --- a/liberty/FuncExpr.cc +++ b/liberty/FuncExpr.cc @@ -24,9 +24,11 @@ #include "FuncExpr.hh" -#include "StringUtil.hh" +#include +#include + #include "Liberty.hh" -#include "Network.hh" +#include "LibertyClass.hh" namespace sta { @@ -233,7 +235,6 @@ std::string FuncExpr::to_string(bool with_parens, char op) const { - std::string right = right_->to_string(true); std::string result; if (with_parens) result += '('; @@ -422,4 +423,4 @@ FuncExpr::less(const FuncExpr *expr1, return (expr1 == nullptr && expr2 != nullptr); } -} // namespace +} // namespace sta diff --git a/liberty/InternalPower.cc b/liberty/InternalPower.cc index ed2cad24..97960ff5 100644 --- a/liberty/InternalPower.cc +++ b/liberty/InternalPower.cc @@ -25,8 +25,13 @@ #include "InternalPower.hh" #include +#include +#include +#include "Error.hh" #include "FuncExpr.hh" +#include "LibertyClass.hh" +#include "Transition.hh" #include "TableModel.hh" #include "Liberty.hh" #include "Units.hh" @@ -76,7 +81,7 @@ InternalPowerModel::InternalPowerModel() : } InternalPowerModel::InternalPowerModel(std::shared_ptr model) : - model_(model) + model_(std::move(model)) { } @@ -192,4 +197,4 @@ InternalPowerModel::checkAxis(const TableAxis *axis) || var == TableAxisVariable::related_out_total_output_net_capacitance; } -} // namespace +} // namespace sta diff --git a/liberty/LeakagePower.cc b/liberty/LeakagePower.cc index 150a2cf1..5a303925 100644 --- a/liberty/LeakagePower.cc +++ b/liberty/LeakagePower.cc @@ -25,7 +25,6 @@ #include "LeakagePower.hh" #include "FuncExpr.hh" -#include "TableModel.hh" #include "Liberty.hh" namespace sta { @@ -55,4 +54,4 @@ LeakagePower::~LeakagePower() delete when_; } -} // namespace +} // namespace sta diff --git a/liberty/LibExprLex.ll b/liberty/LibExprLex.ll index 69402d84..0398225b 100644 --- a/liberty/LibExprLex.ll +++ b/liberty/LibExprLex.ll @@ -40,7 +40,7 @@ using sta::FuncExpr; #undef YY_DECL #define YY_DECL \ int \ -sta::LibExprScanner::lex(sta::LibExprParse::semantic_type *const yylval) +sta::LibExprScanner::lex(sta::LibExprParse::semantic_type *yylval) typedef sta::LibExprParse::token token; diff --git a/liberty/LibExprReader.cc b/liberty/LibExprReader.cc index d7427223..149be5b8 100644 --- a/liberty/LibExprReader.cc +++ b/liberty/LibExprReader.cc @@ -24,7 +24,6 @@ #include "FuncExpr.hh" -#include #include #include #include @@ -63,8 +62,7 @@ LibExprReader::LibExprReader(std::string_view func, func_(func), cell_(cell), error_msg_(error_msg), - report_(report), - result_(nullptr) + report_(report) { } diff --git a/liberty/LibExprReader.hh b/liberty/LibExprReader.hh index 6b0c8cbe..54299298 100644 --- a/liberty/LibExprReader.hh +++ b/liberty/LibExprReader.hh @@ -38,4 +38,4 @@ parseFuncExpr(std::string_view func, std::string_view error_msg, Report *report); -} // namespace +} // namespace sta diff --git a/liberty/LibExprReaderPvt.hh b/liberty/LibExprReaderPvt.hh index b6b27bc8..9ef029e2 100644 --- a/liberty/LibExprReaderPvt.hh +++ b/liberty/LibExprReaderPvt.hh @@ -59,7 +59,7 @@ private: const LibertyCell *cell_; std::string_view error_msg_; Report *report_; - FuncExpr *result_; + FuncExpr *result_{nullptr}; }; -} // namespace +} // namespace sta diff --git a/liberty/LibExprScanner.hh b/liberty/LibExprScanner.hh index f901be3d..cb0cb0b4 100644 --- a/liberty/LibExprScanner.hh +++ b/liberty/LibExprScanner.hh @@ -43,9 +43,7 @@ class LibExprScanner : public LibExprFlexLexer { public: LibExprScanner(std::istringstream &stream); - virtual ~LibExprScanner() {} - - virtual int lex(LibExprParse::semantic_type *const yylval); + virtual int lex(LibExprParse::semantic_type *yylval); // YY_DECL defined in LibertyLex.ll // Method body created by flex in LibertyLex.cc @@ -57,4 +55,4 @@ private: std::string token_; }; -} // namespace +} // namespace sta diff --git a/liberty/Liberty.cc b/liberty/Liberty.cc index de6f1f22..52d9351b 100644 --- a/liberty/Liberty.cc +++ b/liberty/Liberty.cc @@ -24,29 +24,39 @@ #include "Liberty.hh" +#include +#include +#include +#include +#include +#include + +#include "ConcreteLibrary.hh" #include "ContainerHelpers.hh" -#include "Format.hh" -#include "Mutex.hh" -#include "EnumNameMap.hh" -#include "Report.hh" #include "Debug.hh" +#include "Delay.hh" +#include "EnumNameMap.hh" #include "Error.hh" -#include "StringUtil.hh" -#include "PatternMatch.hh" -#include "Units.hh" -#include "Transition.hh" -#include "TimingRole.hh" +#include "Format.hh" #include "FuncExpr.hh" +#include "InternalPower.hh" +#include "LibertyClass.hh" +#include "MinMax.hh" +#include "Mutex.hh" +#include "Network.hh" +#include "NetworkClass.hh" +#include "ObjectId.hh" +#include "PatternMatch.hh" +#include "PortDirection.hh" +#include "Report.hh" +#include "Scene.hh" +#include "Sequential.hh" #include "TableModel.hh" #include "TimingArc.hh" -#include "InternalPower.hh" -#include "LeakagePower.hh" -#include "Sequential.hh" +#include "TimingRole.hh" +#include "Transition.hh" +#include "Units.hh" #include "Wireload.hh" -#include "EquivCells.hh" -#include "Network.hh" -#include "PortDirection.hh" -#include "Scene.hh" namespace sta { @@ -65,46 +75,13 @@ deleteLiberty() LibertyLibrary::LibertyLibrary(std::string_view name, std::string_view filename) : ConcreteLibrary(name, filename, true), - units_(new Units()), - delay_model_type_(DelayModelType::table), // default - nominal_process_(0.0), - nominal_voltage_(0.0), - nominal_temperature_(0.0), - scale_factors_(nullptr), - default_input_pin_cap_(0.0), - default_output_pin_cap_(0.0), - default_bidirect_pin_cap_(0.0), - default_fanout_load_(0.0), - default_fanout_load_exists_(false), - default_max_cap_(0.0), - default_max_cap_exists_(false), - default_max_fanout_(0.0), - default_max_fanout_exists_(false), - default_max_slew_(0.0), - default_max_slew_exists_(false), - slew_derate_from_library_(1.0), - default_wire_load_(nullptr), - default_wire_load_mode_(WireloadMode::unknown), - default_wire_load_selection_(nullptr), - default_operating_conditions_(nullptr), - ocv_arc_depth_(0.0), - default_ocv_derate_(nullptr), - buffers_(nullptr), - inverters_(nullptr) + units_(new Units()) { // Scalar templates are builtin. for (int i = 0; i != table_template_type_count; i++) { TableTemplateType type = static_cast(i); makeTableTemplate("scalar", type); } - - for (auto rf_index : RiseFall::rangeIndex()) { - wire_slew_degradation_tbls_[rf_index] = nullptr; - input_threshold_[rf_index] = input_threshold_default_; - output_threshold_[rf_index] = output_threshold_default_; - slew_lower_threshold_[rf_index] = slew_lower_threshold_default_; - slew_upper_threshold_[rf_index] = slew_upper_threshold_default_; - } } LibertyLibrary::~LibertyLibrary() @@ -204,10 +181,10 @@ LibertyLibrary::busDcls() const TableTemplate * LibertyLibrary::makeTableTemplate(std::string_view name, - TableTemplateType type) + TableTemplateType type) { std::string key(name); - auto [it, inserted] = template_maps_[int(type)].try_emplace(std::move(key), + auto [it, inserted] = template_maps_[static_cast(type)].try_emplace(std::move(key), std::string(name), type); return &it->second; @@ -217,15 +194,15 @@ TableTemplate * LibertyLibrary::findTableTemplate(std::string_view name, TableTemplateType type) { - return findStringValuePtr(template_maps_[int(type)], name); + return findStringValuePtr(template_maps_[static_cast(type)], name); } TableTemplateSeq LibertyLibrary::tableTemplates() const { TableTemplateSeq tbl_templates; - for (int type = 0; type < table_template_type_count; type++) { - for (auto &[key, tbl_template] : template_maps_[type]) + for (const auto & template_map : template_maps_) { + for (auto &[key, tbl_template] : template_map) tbl_templates.push_back(const_cast(&tbl_template)); } return tbl_templates; @@ -235,7 +212,7 @@ TableTemplateSeq LibertyLibrary::tableTemplates(TableTemplateType type) const { TableTemplateSeq tbl_templates; - for (auto &[key, tbl_template] : template_maps_[int(type)]) + for (auto &[key, tbl_template] : template_maps_[static_cast(type)]) tbl_templates.push_back(const_cast(&tbl_template)); return tbl_templates; } @@ -538,7 +515,7 @@ LibertyLibrary::defaultBidirectPinRes(const RiseFall *rf, float &res, bool &exists) const { - return default_inout_pin_res_.value(rf, res, exists); + default_inout_pin_res_.value(rf, res, exists); } void @@ -730,7 +707,7 @@ LibertyLibrary::makeScaledCell(std::string_view name, void LibertyLibrary::makeSceneMap(LibertyLibrary *lib, - int ap_index, + size_t lib_ap_index, Network *network, Report *report) { @@ -739,7 +716,7 @@ LibertyLibrary::makeSceneMap(LibertyLibrary *lib, LibertyCell *cell = cell_iter.next(); LibertyCell *link_cell = network->findLibertyCell(cell->name()); if (link_cell) - makeSceneMap(link_cell, cell, ap_index, report); + makeSceneMap(link_cell, cell, lib_ap_index, report); } } @@ -748,21 +725,21 @@ LibertyLibrary::makeSceneMap(LibertyLibrary *lib, void LibertyLibrary::makeSceneMap(LibertyCell *link_cell, LibertyCell *scene_cell, - int ap_index, + size_t lib_ap_index, Report *report) { - link_cell->setSceneCell(scene_cell, ap_index); - makeSceneMap(link_cell, scene_cell, true, ap_index, report); + link_cell->setSceneCell(scene_cell, lib_ap_index); + makeSceneMap(link_cell, scene_cell, true, lib_ap_index, report); // Check for brain damage in the other direction. - makeSceneMap(scene_cell, link_cell, false, ap_index, report); + makeSceneMap(scene_cell, link_cell, false, lib_ap_index, report); } void LibertyLibrary::makeSceneMap(LibertyCell *cell1, - LibertyCell *cell2, - bool link, - int ap_index, - Report *report) + LibertyCell *cell2, + bool link, + size_t lib_ap_index, + Report *report) { LibertyCellPortBitIterator port_iter1(cell1); while (port_iter1.hasNext()) { @@ -770,7 +747,7 @@ LibertyLibrary::makeSceneMap(LibertyCell *cell1, LibertyPort *port2 = cell2->findLibertyPort(port1->name()); if (port2) { if (link) - port1->setScenePort(port2, ap_index); + port1->setScenePort(port2, lib_ap_index); } else report->warn(1110, "cell {}/{} port {} not found in cell {}/{}.", @@ -794,7 +771,7 @@ LibertyLibrary::makeSceneMap(LibertyCell *cell1, TimingArc *arc1 = *arc_itr1; TimingArc *arc2 = *arc_itr2; if (TimingArc::equiv(arc1, arc2)) - arc1->setSceneArc(arc2, ap_index); + arc1->setSceneArc(arc2, lib_ap_index); } } } @@ -905,7 +882,7 @@ LibertyLibrary::findDriverWaveform(std::string_view name) DriverWaveform * LibertyLibrary::makeDriverWaveform(std::string_view name, - TablePtr waveforms) + const TablePtr &waveforms) { std::string key(name); auto [it, inserted] = driver_waveform_map_.try_emplace(std::move(key), @@ -939,30 +916,7 @@ LibertyCell::LibertyCell(LibertyLibrary *library, std::string_view name, std::string_view filename) : ConcreteCell(name, filename, true, library), - liberty_library_(library), - area_(0.0), - dont_use_(false), - is_macro_(false), - is_memory_(false), - is_pad_(false), - is_clock_cell_(false), - is_level_shifter_(false), - level_shifter_type_(LevelShifterType::HL_LH), - is_isolation_cell_(false), - always_on_(false), - switch_cell_type_(SwitchCellType::fine_grain), - interface_timing_(false), - clock_gate_type_(ClockGateType::none), - has_infered_reg_timing_arcs_(false), - statetable_(nullptr), - scale_factors_(nullptr), - test_cell_(nullptr), - ocv_arc_depth_(0.0), - ocv_derate_(nullptr), - leakage_power_(0.0), - leakage_power_exists_(false), - has_internal_ports_(false), - have_voltage_waveforms_(false) + liberty_library_(library) { liberty_cell_ = this; } @@ -1248,7 +1202,7 @@ LibertyCell::makeTimingArcSet(LibertyPort *from, { size_t set_index = timing_arc_sets_.size(); TimingArcSet *arc_set = new TimingArcSet(this, from, to, related_out, role, - attrs, set_index); + std::move(attrs), set_index); timing_arc_sets_.push_back(arc_set); return arc_set; } @@ -1314,7 +1268,7 @@ LibertyCell::finish(bool infer_latches, void LibertyCell::findDefaultCondArcs() { - for (auto [port_pair, sets] : port_timing_arc_set_map_) { + for (auto &[port_pair, sets] : port_timing_arc_set_map_) { bool has_cond_arcs = false; for (auto set : sets) { if (set->cond()) { @@ -1323,7 +1277,7 @@ LibertyCell::findDefaultCondArcs() } } if (has_cond_arcs) { - for (auto set : sets) { + for (auto &set : sets) { if (!set->cond()) set->setIsCondDefault(true); } @@ -1566,21 +1520,21 @@ LibertyCell::sceneCell(const Scene *scene, } LibertyCell * -LibertyCell::sceneCell(int ap_index) +LibertyCell::sceneCell(size_t lib_ap_index) { if (scene_cells_.empty()) return this; - else if (ap_index < static_cast(scene_cells_.size())) - return scene_cells_[ap_index]; + else if (lib_ap_index < scene_cells_.size()) + return scene_cells_[lib_ap_index]; else return nullptr; } bool LibertyCell::checkSceneCell(const Scene *scene, - const MinMax *min_max) const + const MinMax *min_max) const { - unsigned lib_index = scene->libertyIndex(min_max); + size_t lib_index = scene->libertyIndex(min_max); return scene_cells_.empty() || (lib_index < scene_cells_.size() && scene_cells_[lib_index]); @@ -1588,11 +1542,11 @@ LibertyCell::checkSceneCell(const Scene *scene, void LibertyCell::setSceneCell(LibertyCell *scene_cell, - int ap_index) + size_t lib_ap_index) { - if (ap_index >= static_cast(scene_cells_.size())) - scene_cells_.resize(ap_index + 1); - scene_cells_[ap_index] = scene_cell; + if (lib_ap_index >= scene_cells_.size()) + scene_cells_.resize(lib_ap_index + 1); + scene_cells_[lib_ap_index] = scene_cell; } //////////////////////////////////////////////////////////////// @@ -1872,19 +1826,19 @@ LibertyCell::latchEnable(const TimingArcSet *d_to_q_set, // Return values. const LibertyPort *&enable_port, const FuncExpr *&enable_func, - const RiseFall *&enable_edge) const + const RiseFall *&enable_rf) const { auto it = latch_d_to_q_map_.find(d_to_q_set); if (it != latch_d_to_q_map_.end()) { const LatchEnable &latch_enable = latch_enables_[it->second]; enable_port = latch_enable.enable(); enable_func = latch_enable.enableFunc(); - enable_edge = latch_enable.enableEdge(); + enable_rf = latch_enable.enableEdge(); } else { enable_port = nullptr; enable_func = nullptr; - enable_edge = nullptr; + enable_rf = nullptr; } } @@ -1997,41 +1951,9 @@ LibertyPort::LibertyPort(LibertyCell *cell, ConcretePort(name, is_bus, from_index, to_index, is_bundle, members, cell), liberty_cell_(cell), - bus_dcl_(bus_dcl), - pwr_gnd_type_(PwrGndType::none), - scan_signal_type_(ScanSignalType::none), - function_(nullptr), - tristate_enable_(nullptr), - scaled_ports_(nullptr), - fanout_load_(0.0), - fanout_load_exists_(false), - min_period_(0.0), - pulse_clk_trigger_(nullptr), - pulse_clk_sense_(nullptr), - related_ground_port_(nullptr), - related_power_port_(nullptr), - receiver_model_(nullptr), - driver_waveform_{nullptr, nullptr}, - min_pulse_width_exists_(false), - min_period_exists_(false), - is_clk_(false), - is_reg_clk_(false), - is_reg_output_(false), - is_latch_data_(false), - is_check_clk_(false), - is_clk_gate_clk_(false), - is_clk_gate_enable_(false), - is_clk_gate_out_(false), - is_pll_feedback_(false), - isolation_cell_data_(false), - isolation_cell_enable_(false), - level_shifter_data_(false), - is_switch_(false), - is_pad_(false) + bus_dcl_(bus_dcl) { liberty_port_ = this; - min_pulse_width_[RiseFall::riseIndex()] = 0.0; - min_pulse_width_[RiseFall::fallIndex()] = 0.0; } LibertyPort::~LibertyPort() @@ -2041,14 +1963,6 @@ LibertyPort::~LibertyPort() delete scaled_ports_; } -void -LibertyPort::setDirection(PortDirection *dir) -{ - ConcretePort::setDirection(dir); - if (dir->isInternal()) - liberty_cell_->setHasInternalPorts(true); -} - void LibertyPort::setScanSignalType(ScanSignalType type) { @@ -2130,12 +2044,6 @@ LibertyPort::findLibertyBusBit(int index) const return static_cast(findBusBit(index)); } -LibertyPort * -LibertyPort::bundlePort() const -{ - return static_cast(bundle_port_); -} - void LibertyPort::setCapacitance(float cap) { @@ -2306,7 +2214,7 @@ LibertyPort::setFunction(FuncExpr *func) int bit_offset = 0; while (member_iter.hasNext()) { LibertyPort *port_bit = member_iter.next(); - FuncExpr *sub_expr = (func) ? func->bitSubExpr(bit_offset) : nullptr; + FuncExpr *sub_expr = func ? func->bitSubExpr(bit_offset) : nullptr; port_bit->setFunction(sub_expr); bit_offset++; } @@ -2321,8 +2229,9 @@ LibertyPort::setTristateEnable(FuncExpr *enable) LibertyPortMemberIterator member_iter(this); while (member_iter.hasNext()) { LibertyPort *port_bit = member_iter.next(); - FuncExpr *sub_expr = - (enable) ? enable->bitSubExpr(port_bit->busBitIndex()) : nullptr; + FuncExpr *sub_expr = enable + ? enable->bitSubExpr(port_bit->busBitIndex()) + : nullptr; port_bit->setTristateEnable(sub_expr); } } @@ -2351,7 +2260,7 @@ LibertyPort::capacitanceLimit(const MinMax *min_max, float &limit, bool &exists) const { - return cap_limit_.value(min_max, limit, exists); + cap_limit_.value(min_max, limit, exists); } void @@ -2385,7 +2294,7 @@ LibertyPort::fanoutLimit(const MinMax *min_max, float &limit, bool &exists) const { - return fanout_limit_.value(min_max, limit, exists); + fanout_limit_.value(min_max, limit, exists); } void @@ -2613,34 +2522,34 @@ LibertyPort::scenePort(const Scene *scene, } LibertyPort * -LibertyPort::scenePort(int ap_index) +LibertyPort::scenePort(size_t lib_ap_index) { if (scene_ports_.empty()) return this; - else if (ap_index < static_cast(scene_ports_.size())) - return scene_ports_[ap_index]; + else if (lib_ap_index < scene_ports_.size()) + return scene_ports_[lib_ap_index]; else return nullptr; } const LibertyPort * -LibertyPort::scenePort(int ap_index) const +LibertyPort::scenePort(size_t lib_ap_index) const { if (scene_ports_.empty()) return this; - else if (ap_index < static_cast(scene_ports_.size())) - return scene_ports_[ap_index]; + else if (lib_ap_index < scene_ports_.size()) + return scene_ports_[lib_ap_index]; else return nullptr; } void LibertyPort::setScenePort(LibertyPort *scene_port, - int ap_index) + size_t lib_ap_index) { - if (ap_index >= static_cast(scene_ports_.size())) - scene_ports_.resize(ap_index + 1); - scene_ports_[ap_index] = scene_port; + if (lib_ap_index >= scene_ports_.size()) + scene_ports_.resize(lib_ap_index + 1); + scene_ports_[lib_ap_index] = scene_port; } void @@ -2658,7 +2567,7 @@ LibertyPort::setRelatedPowerPort(LibertyPort *related_power_port) void LibertyPort::setReceiverModel(ReceiverModelPtr receiver_model) { - receiver_model_ = receiver_model; + receiver_model_ = std::move(receiver_model); } std::string @@ -2667,8 +2576,7 @@ portLibertyToSta(std::string_view port_name) constexpr char bus_brkt_left = '['; constexpr char bus_brkt_right = ']'; std::string sta_name; - for (size_t i = 0; i < port_name.size(); i++) { - char ch = port_name[i]; + for (char ch : port_name) { if (ch == bus_brkt_left || ch == bus_brkt_right) sta_name += '\\'; @@ -2866,8 +2774,7 @@ ModeDef::findValueDef(std::string_view value) const //////////////////////////////////////////////////////////////// ModeValueDef::ModeValueDef(std::string_view value) : - value_(value), - cond_(nullptr) + value_(value) { } @@ -2899,21 +2806,14 @@ ModeValueDef::setSdfCond(std::string sdf_cond) //////////////////////////////////////////////////////////////// TableTemplate::TableTemplate(std::string_view name) : - name_(name), - type_(TableTemplateType::delay), - axis1_(nullptr), - axis2_(nullptr), - axis3_(nullptr) + name_(name) { } TableTemplate::TableTemplate(std::string_view name, TableTemplateType type) : name_(name), - type_(type), - axis1_(nullptr), - axis2_(nullptr), - axis3_(nullptr) + type_(type) { } @@ -2922,10 +2822,9 @@ TableTemplate::TableTemplate(std::string_view name, TableAxisPtr axis2, TableAxisPtr axis3) : name_(name), - type_(TableTemplateType::delay), - axis1_(axis1), - axis2_(axis2), - axis3_(axis3) + axis1_(std::move(axis1)), + axis2_(std::move(axis2)), + axis3_(std::move(axis3)) { } @@ -2938,19 +2837,19 @@ TableTemplate::setName(std::string_view name) void TableTemplate::setAxis1(TableAxisPtr axis) { - axis1_ = axis; + axis1_ = std::move(axis); } void TableTemplate::setAxis2(TableAxisPtr axis) { - axis2_ = axis; + axis2_ = std::move(axis); } void TableTemplate::setAxis3(TableAxisPtr axis) { - axis3_ = axis; + axis3_ = std::move(axis); } //////////////////////////////////////////////////////////////// @@ -2984,9 +2883,7 @@ Pvt::setTemperature(float temp) OperatingConditions::OperatingConditions(std::string_view name) : Pvt(0.0, 0.0, 0.0), - name_(name), - // Default wireload tree. - wire_load_tree_(WireloadTree::unknown) + name_(name) { } @@ -3081,11 +2978,10 @@ scaleFactorPvtName(ScaleFactorPvt pvt) ScaleFactors::ScaleFactors(std::string_view name) : name_(name) { - for (int type = 0; type < scale_factor_type_count; type++) { - for (int pvt = 0; pvt < scale_factor_pvt_count; pvt++) { - for (auto rf_index : RiseFall::rangeIndex()) { - scales_[type][pvt][rf_index] = 0.0; - } + for (auto &type_factors : scales_) { + for (auto pvt_factors : type_factors) { + for (size_t rf_index : RiseFall::rangeIndex()) + pvt_factors[rf_index] = 0.0; } } } @@ -3096,7 +2992,7 @@ ScaleFactors::setScale(ScaleFactorType type, const RiseFall *rf, float scale) { - scales_[int(type)][int(pvt)][rf->index()] = scale; + scales_[static_cast(type)][static_cast(pvt)][rf->index()] = scale; } void @@ -3104,7 +3000,7 @@ ScaleFactors::setScale(ScaleFactorType type, ScaleFactorPvt pvt, float scale) { - scales_[int(type)][int(pvt)][0] = scale; + scales_[static_cast(type)][static_cast(pvt)][0] = scale; } float @@ -3112,7 +3008,7 @@ ScaleFactors::scale(ScaleFactorType type, ScaleFactorPvt pvt, const RiseFall *rf) { - return scales_[int(type)][int(pvt)][rf->index()]; + return scales_[static_cast(type)][static_cast(pvt)][rf->index()]; } float @@ -3120,14 +3016,14 @@ ScaleFactors::scale(ScaleFactorType type, ScaleFactorPvt pvt, int rf_index) { - return scales_[int(type)][int(pvt)][rf_index]; + return scales_[static_cast(type)][static_cast(pvt)][rf_index]; } float ScaleFactors::scale(ScaleFactorType type, ScaleFactorPvt pvt) { - return scales_[int(type)][int(pvt)][0]; + return scales_[static_cast(type)][static_cast(pvt)][0]; } void @@ -3135,13 +3031,13 @@ ScaleFactors::report(Report *report) { std::string line = " "; for (int pvt_index = 0; pvt_index < scale_factor_pvt_count; pvt_index++) { - ScaleFactorPvt pvt = (ScaleFactorPvt) pvt_index; + ScaleFactorPvt pvt = static_cast(pvt_index); line += sta::format("{:>10}", scaleFactorPvtName(pvt)); } report->reportLine(line); for (int type_index = 0; type_index < scale_factor_type_count; type_index++) { - ScaleFactorType type = (ScaleFactorType) type_index; + ScaleFactorType type = static_cast(type_index); std::string line = sta::format("{:>10}", scaleFactorTypeName(type)); for (int pvt_index = 0; pvt_index < scale_factor_pvt_count; pvt_index++) { if (scaleFactorTypeRiseFallSuffix(type) @@ -3171,16 +3067,6 @@ TestCell::TestCell(LibertyLibrary *library, OcvDerate::OcvDerate(std::string_view name) : name_(name) -{ - for (auto el_index : EarlyLate::rangeIndex()) { - for (auto rf_index : RiseFall::rangeIndex()) { - derate_[rf_index][el_index][int(PathType::clk)] = nullptr; - derate_[rf_index][el_index][int(PathType::data)] = nullptr; - } - } -} - -OcvDerate::~OcvDerate() { } @@ -3189,7 +3075,7 @@ OcvDerate::derateTable(const RiseFall *rf, const EarlyLate *early_late, PathType path_type) { - return derate_[rf->index()][early_late->index()][int(path_type)].get(); + return derate_[rf->index()][early_late->index()][static_cast(path_type)].get(); } void @@ -3198,7 +3084,8 @@ OcvDerate::setDerateTable(const RiseFall *rf, const PathType path_type, TablePtr derate) { - derate_[rf->index()][early_late->index()][int(path_type)] = derate; + derate_[rf->index()][early_late->index()][static_cast(path_type)] + = std::move(derate); } -} // namespace +} // namespace sta diff --git a/liberty/Liberty.i b/liberty/Liberty.i index f0a9bc09..e1cfdc57 100644 --- a/liberty/Liberty.i +++ b/liberty/Liberty.i @@ -317,7 +317,6 @@ bool is_bundle_member() { return self->isBundleMember(); } bool has_members() { return self->hasMembers(); } LibertyPortMemberIterator * member_iterator() { return new LibertyPortMemberIterator(self); } -LibertyPort *bundle_port() { return self->bundlePort(); } bool is_pwr_gnd() { return self->isPwrGnd(); } std::string diff --git a/liberty/LibertyBuilder.cc b/liberty/LibertyBuilder.cc index f296fdec..c2571dd5 100644 --- a/liberty/LibertyBuilder.cc +++ b/liberty/LibertyBuilder.cc @@ -24,14 +24,21 @@ #include "LibertyBuilder.hh" -#include "PortDirection.hh" -#include "TimingRole.hh" +#include +#include +#include + +#include "ConcreteLibrary.hh" #include "FuncExpr.hh" +#include "Liberty.hh" +#include "LibertyClass.hh" +#include "PortDirection.hh" +#include "Transition.hh" +#include "Sequential.hh" +#include "TableModel.hh" #include "TimingArc.hh" #include "TimingModel.hh" -#include "TableModel.hh" -#include "Sequential.hh" -#include "Liberty.hh" +#include "TimingRole.hh" namespace sta { @@ -114,10 +121,10 @@ LibertyBuilder::makeBusPortBit(ConcreteLibrary *library, LibertyPort * LibertyBuilder::makePort(LibertyCell *cell, - std::string bit_name, + std::string_view bit_name, int bit_index) { - LibertyPort *port = new LibertyPort(cell, std::move(bit_name), false, nullptr, + LibertyPort *port = new LibertyPort(cell, bit_name, false, nullptr, bit_index, bit_index, false, nullptr); return port; } @@ -141,8 +148,7 @@ LibertyBuilder::makeTimingArcs(LibertyCell *cell, LibertyPort *from_port, LibertyPort *to_port, LibertyPort *related_out, - TimingArcAttrsPtr attrs, - int /* line */) + const TimingArcAttrsPtr &attrs) { FuncExpr *to_func = to_port->function(); Sequential *seq = (to_func && to_func->port()) @@ -300,7 +306,7 @@ LibertyBuilder::makeCombinationalArcs(LibertyCell *cell, LibertyPort *to_port, bool to_rise, bool to_fall, - TimingArcAttrsPtr attrs) + const TimingArcAttrsPtr &attrs) { FuncExpr *func = to_port->function(); FuncExpr *enable = to_port->tristateEnable(); @@ -384,7 +390,7 @@ LibertyBuilder::makeLatchDtoQArcs(LibertyCell *cell, LibertyPort *from_port, LibertyPort *to_port, TimingSense sense, - TimingArcAttrsPtr attrs) + const TimingArcAttrsPtr &attrs) { TimingArcSet *arc_set = cell->makeTimingArcSet(from_port, to_port, nullptr, TimingRole::latchDtoQ(), @@ -414,7 +420,7 @@ LibertyBuilder::makeRegLatchArcs(LibertyCell *cell, LibertyPort *from_port, LibertyPort *to_port, const RiseFall *from_rf, - TimingArcAttrsPtr attrs) + const TimingArcAttrsPtr &attrs) { FuncExpr *to_func = to_port->function(); if (to_func) { @@ -453,7 +459,7 @@ LibertyBuilder::makeFromTransitionArcs(LibertyCell *cell, LibertyPort *related_out, const RiseFall *from_rf, const TimingRole *role, - TimingArcAttrsPtr attrs) + const TimingArcAttrsPtr &attrs) { TimingArcSet *arc_set = cell->makeTimingArcSet(from_port, to_port, related_out, role, attrs); @@ -470,7 +476,7 @@ LibertyBuilder::makePresetClrArcs(LibertyCell *cell, LibertyPort *from_port, LibertyPort *to_port, const RiseFall *to_rf, - TimingArcAttrsPtr attrs) + const TimingArcAttrsPtr &attrs) { TimingArcSet *arc_set = nullptr; TimingModel *model = attrs->model(to_rf); @@ -506,7 +512,7 @@ LibertyBuilder::makeTristateEnableArcs(LibertyCell *cell, LibertyPort *to_port, bool to_rise, bool to_fall, - TimingArcAttrsPtr attrs) + const TimingArcAttrsPtr &attrs) { TimingArcSet *arc_set = cell->makeTimingArcSet(from_port, to_port, nullptr, TimingRole::tristateEnable(), @@ -577,7 +583,7 @@ LibertyBuilder::makeTristateDisableArcs(LibertyCell *cell, LibertyPort *to_port, bool to_rise, bool to_fall, - TimingArcAttrsPtr attrs) + const TimingArcAttrsPtr &attrs) { TimingArcSet *arc_set = cell->makeTimingArcSet(from_port, to_port, nullptr, TimingRole::tristateDisable(), @@ -646,7 +652,7 @@ TimingArcSet * LibertyBuilder::makeClockTreePathArcs(LibertyCell *cell, LibertyPort *to_port, const TimingRole *role, - TimingArcAttrsPtr attrs) + const TimingArcAttrsPtr &attrs) { TimingArcSet *arc_set = cell->makeTimingArcSet(nullptr, to_port, nullptr, role, attrs); @@ -680,7 +686,7 @@ LibertyBuilder::makeMinPulseWidthArcs(LibertyCell *cell, LibertyPort *to_port, LibertyPort *related_out, const TimingRole *role, - TimingArcAttrsPtr attrs) + const TimingArcAttrsPtr &attrs) { if (from_port == nullptr) from_port = to_port; @@ -715,4 +721,4 @@ LibertyBuilder::makeTimingArc(TimingArcSet *set, return new TimingArc(set, from_rf, to_rf, model); } -} // namespace +} // namespace sta diff --git a/liberty/LibertyBuilder.hh b/liberty/LibertyBuilder.hh index 27a07677..ff4d8946 100644 --- a/liberty/LibertyBuilder.hh +++ b/liberty/LibertyBuilder.hh @@ -63,31 +63,30 @@ public: LibertyPort *from_port, LibertyPort *to_port, LibertyPort *related_out, - TimingArcAttrsPtr attrs, - int line); + const TimingArcAttrsPtr &attrs); TimingArcSet *makeFromTransitionArcs(LibertyCell *cell, LibertyPort *from_port, LibertyPort *to_port, LibertyPort *related_out, const RiseFall *from_rf, const TimingRole *role, - TimingArcAttrsPtr attrs); + const TimingArcAttrsPtr &attrs); TimingArcSet *makeCombinationalArcs(LibertyCell *cell, LibertyPort *from_port, LibertyPort *to_port, bool to_rise, bool to_fall, - TimingArcAttrsPtr attrs); + const TimingArcAttrsPtr &attrs); TimingArcSet *makeClockTreePathArcs(LibertyCell *cell, LibertyPort *to_port, const TimingRole *role, - TimingArcAttrsPtr attrs); + const TimingArcAttrsPtr &attrs); TimingArcSet *makeMinPulseWidthArcs(LibertyCell *cell, LibertyPort *from_port, LibertyPort *to_port, LibertyPort *related_out, const TimingRole *role, - TimingArcAttrsPtr attrs); + const TimingArcAttrsPtr &attrs); protected: ConcretePort *makeBusPort(std::string_view name, @@ -102,7 +101,7 @@ protected: int to_index); // Bus port bit (internal to makeBusPortBits). LibertyPort *makePort(LibertyCell *cell, - std::string bit_name, + std::string_view bit_name, int bit_index); void makeBusPortBit(ConcreteLibrary *library, LibertyCell *cell, @@ -121,32 +120,32 @@ protected: LibertyPort *from_port, LibertyPort *to_port, TimingSense sense, - TimingArcAttrsPtr attrs); + const TimingArcAttrsPtr &attrs); TimingArcSet *makeRegLatchArcs(LibertyCell *cell, LibertyPort *from_port, LibertyPort *to_port, const RiseFall *from_rf, - TimingArcAttrsPtr attrs); + const TimingArcAttrsPtr &attrs); TimingArcSet *makePresetClrArcs(LibertyCell *cell, LibertyPort *from_port, LibertyPort *to_port, const RiseFall *to_rf, - TimingArcAttrsPtr attrs); + const TimingArcAttrsPtr &attrs); TimingArcSet *makeTristateEnableArcs(LibertyCell *cell, LibertyPort *from_port, LibertyPort *to_port, bool to_rise, bool to_fall, - TimingArcAttrsPtr attrs); + const TimingArcAttrsPtr &attrs); TimingArcSet *makeTristateDisableArcs(LibertyCell *cell, LibertyPort *from_port, LibertyPort *to_port, bool to_rise, bool to_fall, - TimingArcAttrsPtr attrs); + const TimingArcAttrsPtr &attrs); Debug *debug_; Report *report_; }; -} // namespace +} // namespace sta diff --git a/liberty/LibertyExt.cc b/liberty/LibertyExt.cc deleted file mode 100644 index 68f1fe77..00000000 --- a/liberty/LibertyExt.cc +++ /dev/null @@ -1,287 +0,0 @@ -// OpenSTA, Static Timing Analyzer -// Copyright (c) 2025, 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 . -// -// The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. -// -// Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// This notice may not be removed or altered from any source distribution. - -// This file illustratates how to customize the liberty file reader to -// read attributes that are not used by the STA. In this example: -// * code is called at the beginning of a library definition -// * a string attribute named "thingy" is parsed - -#include -#include -#include "Machine.hh" -#include "StringUtil.hh" -#include "LibertyReader.hh" -#include "LibertyReaderPvt.hh" -#include "LibertyBuilder.hh" -#include "Network.hh" -#include "ConcreteNetwork.hh" -#include "Sta.hh" - -// Import symbols from sta package (this example is in the global package). -using sta::Report; -using sta::Debug; -using sta::Network; -using sta::LibertyReader; -using sta::LibertyGroup; -using sta::LibertySimpleAttr; -using sta::TimingGroup; -using sta::LibertyCell; -using sta::LibertyPort; -using sta::LibertyLibrary; -using sta::TimingArcSet; -using sta::LibertyBuilder; -using sta::TimingRole; -using sta::TimingArcAttrs; -using sta::Sta; -using sta::stringCopy; - -// LibertyCell with Bigco thingy variable. -class BigcoCell : public LibertyCell -{ -public: - BigcoCell(LibertyLibrary *library, const char *name, const char *filename); - void setThingy(const char *thingy); - TimingArcSet *makeTimingArcSet(LibertyPort *from, - LibertyPort *to, - LibertyPort *related_out, - const TimingRole *role, - TimingArcAttrsPtr attrs) override; - -protected: - const char *thingy_; -}; - -BigcoCell::BigcoCell(LibertyLibrary *library, const char *name, - const char *filename) : - LibertyCell(library, name, filename), - thingy_(0) -{ -} - -void -BigcoCell::setThingy(const char *thingy) -{ - thingy_ = thingy; -} - -TimingArcSet * -BigcoCell::makeTimingArcSet(LibertyPort *from, - LibertyPort *to, - LibertyPort *related_out, - const TimingRole *role, - TimingArcAttrsPtr attrs) -{ - size_t set_index = timing_arc_sets_.size(); - TimingArcSet *arc_set = new BigcoTimingArcSet(this, from, to, related_out, - role, attrs, set_index); - timing_arc_sets_.push_back(arc_set); - - if (role == TimingRole::regClkToQ() - || role == TimingRole::latchEnToQ()) { - from->setIsRegClk(true); - to->setIsRegOutput(true); - } - if (role->isTimingCheck()) - from->setIsCheckClk(true); - return arc_set; -} - -//////////////////////////////////////////////////////////////// - -class BigcoTimingGroup : public TimingGroup -{ -public: - BigcoTimingGroup(int line); - const char *frob() const { return frob_; } - void setFrob(const char *frob); - -protected: - const char *frob_; -}; - -BigcoTimingGroup::BigcoTimingGroup(int line) : - TimingGroup(line), - frob_(0) -{ -} - -void -BigcoTimingGroup::setFrob(const char *frob) -{ - frob_ = frob; -} - -//////////////////////////////////////////////////////////////// - -class BigcoTimingArcSet : public TimingArcSet -{ -public: - BigcoTimingArcSet(LibertyCell *cell, LibertyPort *from, LibertyPort *to, - LibertyPort *related_out, const TimingRole *role, - TimingArcAttrsPtr attrs, size_t index); - -protected: - const char *frob_; -}; - -BigcoTimingArcSet::BigcoTimingArcSet(LibertyCell *cell, LibertyPort *from, - LibertyPort *to, - LibertyPort *related_out, - const TimingRole *role, - TimingArcAttrsPtr attrs, size_t index) : - TimingArcSet(cell, from, to, related_out, role, attrs, index) -{ - const char *frob = static_cast(attrs.get())->frob(); - if (frob) - frob_ = stringCopy(frob); -} - -//////////////////////////////////////////////////////////////// - -// Make Bigco objects instead of Liberty objects. -class BigcoLibertyBuilder : public LibertyBuilder -{ -public: - virtual LibertyCell *makeCell(LibertyLibrary *library, std::string_view name, - std::string_view filename); -}; - -LibertyCell * -BigcoLibertyBuilder::makeCell(LibertyLibrary *library, std::string_view name, - std::string_view filename) -{ - std::string name_str(name); - std::string filename_str(filename); - LibertyCell *cell = new BigcoCell(library, name_str.c_str(), filename_str.c_str()); - library->addCell(cell); - return cell; -} - -//////////////////////////////////////////////////////////////// - -// Liberty reader to parse Bigco attributes. -class BigcoLibertyReader : public LibertyReader -{ -public: - BigcoLibertyReader(LibertyBuilder *builder); - -protected: - virtual void visitAttr1(const LibertySimpleAttr *attr); - virtual void visitAttr2(const LibertySimpleAttr *attr); - virtual void beginLibrary(const LibertyGroup *group, - const LibertyGroup *library_group); - virtual TimingGroup *makeTimingGroup(int line); - virtual void beginCell(const LibertyGroup *group, - const LibertyGroup *library_group); -}; - -BigcoLibertyReader::BigcoLibertyReader(LibertyBuilder *builder) : - LibertyReader(builder) -{ -} - -bool -libertyCellRequired(const char *) -{ - // Predicate for cell names. - return true; -} - -// Prune cells from liberty file based on libertyCellRequired predicate. -void -BigcoLibertyReader::beginCell(const LibertyGroup *group, - const LibertyGroup *library_group) -{ - if (group->hasFirstParam() - && libertyCellRequired(group->firstParam().c_str())) - LibertyReader::beginCell(group, library_group); -} - -TimingGroup * -BigcoLibertyReader::makeTimingGroup(int line) -{ - return new BigcoTimingGroup(line); -} - -// Called at the beginning of a library group. -void -BigcoLibertyReader::beginLibrary(const LibertyGroup *group, - const LibertyGroup *library_group) -{ - LibertyReader::beginLibrary(group, library_group); - // Do Bigco stuff here. - printf("Bigco was here.\n"); -} - -void -BigcoLibertyReader::visitAttr1(const LibertySimpleAttr *attr) -{ - const char *thingy = getAttrString(attr); - if (thingy) { - printf("Bigco thingy attribute value is %s.\n", thingy); - if (cell_) - static_cast(cell_)->setThingy(thingy); - } -} - -void -BigcoLibertyReader::visitAttr2(const LibertySimpleAttr *attr) -{ - const char *frob = getAttrString(attr); - if (frob) { - if (timing_) - static_cast(timing_)->setFrob(frob); - } -} - -//////////////////////////////////////////////////////////////// - -// Define a BigcoSta class derived from the Sta class to install the -// new liberty reader/visitor in BigcoSta::makeLibertyReader. -class BigcoSta : public Sta -{ -public: - BigcoSta(); - -protected: - virtual LibertyLibrary *readLibertyFile(std::string_view filename, - bool infer_latches, - Network *network); -}; - -BigcoSta::BigcoSta() : - Sta() -{ -} - -// Replace Sta liberty file reader with Bigco's very own. -LibertyLibrary * -Sta::readLibertyFile(std::string_view filename, - bool infer_latches, - Network *network) -{ - BigcoLibertyBuilder builder; - BigcoLibertyReader reader(&builder); - return reader.readLibertyFile(filename, infer_latches, network); -} diff --git a/liberty/LibertyLex.ll b/liberty/LibertyLex.ll index 22edd696..6aab5689 100644 --- a/liberty/LibertyLex.ll +++ b/liberty/LibertyLex.ll @@ -34,7 +34,7 @@ #undef YY_DECL #define YY_DECL \ int \ -sta::LibertyScanner::lex(sta::LibertyParse::semantic_type *const yylval, \ +sta::LibertyScanner::lex(sta::LibertyParse::semantic_type *yylval, \ sta::LibertyParse::location_type *loc) // update location on matching diff --git a/liberty/LibertyParser.cc b/liberty/LibertyParser.cc index 446ce30d..ee9ef6c6 100644 --- a/liberty/LibertyParser.cc +++ b/liberty/LibertyParser.cc @@ -24,17 +24,20 @@ #include "LibertyParser.hh" -#include #include +#include #include #include +#include +#include #include "ContainerHelpers.hh" -#include "Zlib.hh" -#include "Report.hh" #include "Error.hh" -#include "StringUtil.hh" +#include "LibertyParse.hh" #include "LibertyScanner.hh" +#include "Report.hh" +#include "StringUtil.hh" +#include "util/gzstream.hh" namespace sta { @@ -235,8 +238,7 @@ LibertyScanner::LibertyScanner(std::istream *stream, stream_(stream), filename_(filename), reader_(reader), - report_(report), - stream_prev_(nullptr) + report_(report) { } @@ -427,7 +429,7 @@ const LibertyGroup * LibertyGroup::findSubgroup(std::string_view type) const { const LibertyGroupSeq &groups = findSubgroups(type); - if (groups.size() >= 1) + if (!groups.empty()) return groups[0]; else return nullptr; @@ -453,7 +455,7 @@ const LibertyComplexAttr * LibertyGroup::findComplexAttr(std::string_view attr_name) const { const LibertyComplexAttrSeq &attrs = findComplexAttrs(attr_name); - if (attrs.size() >= 1) + if (!attrs.empty()) return attrs[0]; else return nullptr; @@ -518,7 +520,7 @@ LibertyGroup::findAttrInt(std::string_view attr_name, //////////////////////////////////////////////////////////////// LibertySimpleAttr::LibertySimpleAttr(std::string &&name, - const LibertyAttrValue value, + LibertyAttrValue value, int line) : name_(std::move(name)), line_(line), @@ -529,7 +531,7 @@ LibertySimpleAttr::LibertySimpleAttr(std::string &&name, //////////////////////////////////////////////////////////////// LibertyComplexAttr::LibertyComplexAttr(std::string &&name, - const LibertyAttrValueSeq values, + LibertyAttrValueSeq values, int line) : name_(std::move(name)), values_(std::move(values)), @@ -542,7 +544,7 @@ LibertyComplexAttr::~LibertyComplexAttr() { deleteContents(values_); } const LibertyAttrValue * LibertyComplexAttr::firstValue() const { - if (values_.size() > 0) + if (!values_.empty()) return values_[0]; else return nullptr; diff --git a/liberty/LibertyParser.hh b/liberty/LibertyParser.hh index de9ec60c..607e9d71 100644 --- a/liberty/LibertyParser.hh +++ b/liberty/LibertyParser.hh @@ -103,7 +103,6 @@ private: class LibertyAttrValue { public: - LibertyAttrValue() {} LibertyAttrValue(float value); LibertyAttrValue(std::string &&value); bool isString() const; @@ -123,8 +122,8 @@ private: class LibertyGroup { public: - LibertyGroup(const std::string type, - const LibertyAttrValueSeq params, + LibertyGroup(std::string type, + LibertyAttrValueSeq params, int line); ~LibertyGroup(); void clear(); @@ -191,7 +190,7 @@ class LibertySimpleAttr { public: LibertySimpleAttr(std::string &&name, - const LibertyAttrValue value, + LibertyAttrValue value, int line); const std::string &name() const { return name_; } const LibertyAttrValue &value() const { return value_; }; @@ -210,7 +209,7 @@ class LibertyComplexAttr { public: LibertyComplexAttr(std::string &&name, - const LibertyAttrValueSeq values, + LibertyAttrValueSeq values, int line); ~LibertyComplexAttr(); const std::string &name() const { return name_; } @@ -269,8 +268,6 @@ private: class LibertyGroupVisitor { public: - LibertyGroupVisitor() {} - virtual ~LibertyGroupVisitor() {} virtual void begin(const LibertyGroup *group, LibertyGroup *parent_group) = 0; virtual void end(const LibertyGroup *group, @@ -284,4 +281,4 @@ void parseLibertyFile(std::string_view filename, LibertyGroupVisitor *library_visitor, Report *report); -} // namespace +} // namespace sta diff --git a/liberty/LibertyReader.cc b/liberty/LibertyReader.cc index a76b6893..991cf88e 100644 --- a/liberty/LibertyReader.cc +++ b/liberty/LibertyReader.cc @@ -27,31 +27,40 @@ #include #include #include +#include +#include #include #include +#include +#include "ConcreteLibrary.hh" #include "ContainerHelpers.hh" -#include "Format.hh" -#include "Report.hh" #include "Debug.hh" #include "EnumNameMap.hh" -#include "Units.hh" -#include "Transition.hh" -#include "FuncExpr.hh" -#include "TimingArc.hh" -#include "TableModel.hh" -#include "LeakagePower.hh" -#include "InternalPower.hh" -#include "LinearModel.hh" -#include "Wireload.hh" #include "EquivCells.hh" +#include "Format.hh" +#include "FuncExpr.hh" +#include "InternalPower.hh" #include "LibExprReader.hh" #include "Liberty.hh" #include "LibertyBuilder.hh" +#include "LibertyClass.hh" +#include "LibertyParser.hh" #include "LibertyReaderPvt.hh" -#include "PortDirection.hh" -#include "ParseBus.hh" +#include "LinearModel.hh" +#include "MinMax.hh" #include "Network.hh" +#include "NetworkClass.hh" +#include "ParseBus.hh" +#include "PortDirection.hh" +#include "Sequential.hh" +#include "StringUtil.hh" +#include "TableModel.hh" +#include "TimingArc.hh" +#include "TimingModel.hh" +#include "Transition.hh" +#include "Units.hh" +#include "Wireload.hh" extern int LibertyParse_debug; @@ -73,14 +82,12 @@ readLibertyFile(std::string_view filename, LibertyReader::LibertyReader(std::string_view filename, bool infer_latches, Network *network) : - LibertyGroupVisitor(), filename_(filename), infer_latches_(infer_latches), report_(network->report()), debug_(network->debug()), network_(network), - builder_(debug_, report_), - library_(nullptr) + builder_(debug_, report_) { defineVisitors(); } @@ -386,7 +393,7 @@ LibertyReader::readUnit(std::string_view unit_attr_name, size_t mult_end = units.find_first_not_of("0123456789"); float mult = 1.0F; std::string scale_suffix; - if (mult_end != units.npos) { + if (mult_end != std::string::npos) { std::string unit_mult = units.substr(0, mult_end); scale_suffix = units.substr(mult_end); if (unit_mult == "1") @@ -698,11 +705,11 @@ LibertyReader::readScaleFactors(const LibertyGroup *scale_group, ScaleFactors *scale_factors) { // Skip unknown type. - for (int type_index = 0; type_index < scale_factor_type_count - 1; type_index++) { + for (size_t type_index = 0; type_index < scale_factor_type_count - 1; type_index++) { ScaleFactorType type = static_cast(type_index); const std::string &type_name = scaleFactorTypeName(type); // Skip unknown pvt. - for (int pvt_index = 0; pvt_index < scale_factor_pvt_count - 1; pvt_index++) { + for (size_t pvt_index = 0; pvt_index < scale_factor_pvt_count - 1; pvt_index++) { ScaleFactorPvt pvt = static_cast(pvt_index); const std::string pvt_name = scaleFactorPvtName(pvt); std::string attr_name; @@ -1605,8 +1612,7 @@ LibertyReader::readMinPulseWidth(LibertyCell *cell, } } if (timing_attrs) - builder_.makeTimingArcs(cell, port, port, nullptr, timing_attrs, - port_group->line()); + builder_.makeTimingArcs(cell, port, port, nullptr, timing_attrs); } } @@ -1758,27 +1764,27 @@ LibertyReader::seqPortNames(const LibertyGroup *group, bool &has_size, size_t &size) { - if (group->params().size() == 1) { + has_size = false; + const size_t param_count = group->params().size(); + if (param_count == 1) { // out_port out_name = group->firstParam(); size = 1; - has_size = false; } - if (group->params().size() == 2) { + else if (param_count == 2) { // out_port, out_port_inv out_name = group->firstParam(); out_inv_name = group->secondParam(); size = 1; - has_size = false; } - else if (group->params().size() == 3) { + else if (param_count == 3) { LibertyAttrValue *third_value = group->params()[2]; auto [size_flt, size_valid] = third_value->floatValue(); if (size_valid) { // out_port, out_port_inv, bus_size out_name = group->firstParam(); out_inv_name = group->secondParam(); - size = static_cast(size_flt); + size = static_cast(size_flt); has_size = true; } else { @@ -1837,7 +1843,7 @@ LibertyReader::readCellAttributes(LibertyCell *cell, } readScaleFactors(cell, cell_group); - readLeagageGrouops(cell, cell_group); + readLeakageGrouops(cell, cell_group); readStatetable(cell, cell_group); readModeDefs(cell, cell_group); } @@ -1915,8 +1921,8 @@ LibertyReader::makeTimingArcs(LibertyCell *cell, { for (const LibertyGroup *timing_group : port_group->findSubgroups("timing")) { TimingArcAttrsPtr timing_attrs = std::make_shared(); - readTimingArcAttrs(cell, timing_group, timing_attrs); - makeTimingModels(cell, timing_group, timing_attrs); + readTimingArcAttrs(cell, timing_group, *timing_attrs); + makeTimingModels(cell, timing_group, *timing_attrs); LibertyPort *related_output_port = findLibertyPort(cell, timing_group, "related_output_pin"); @@ -1929,7 +1935,7 @@ LibertyReader::makeTimingArcs(LibertyCell *cell, to_port->direction()->isInput()) warn(1209, timing_group, "combinational timing to an input port."); - if (related_port_names.size() || related_bus_names.size()) { + if (!related_port_names.empty() || !related_bus_names.empty()) { for (const std::string &from_port_name : related_port_names) { debugPrint(debug_, "liberty", 2, " timing {} -> {}", from_port_name, to_port->name()); @@ -1949,8 +1955,7 @@ LibertyReader::makeTimingArcs(LibertyCell *cell, || timing_type == TimingType::max_clock_tree_path)) warn(1243, timing_group, "timing group missing related_pin/related_bus_pin."); else - makeTimingArcs(cell, to_port, related_output_port, - timing_attrs, timing_group->line()); + makeTimingArcs(cell, to_port, related_output_port, timing_attrs); } } } @@ -1958,14 +1963,14 @@ LibertyReader::makeTimingArcs(LibertyCell *cell, void LibertyReader::readTimingArcAttrs(LibertyCell *cell, const LibertyGroup *timing_group, - TimingArcAttrsPtr timing_attrs) + TimingArcAttrs &timing_attrs) { readTimingSense(timing_group, timing_attrs); readTimingType(timing_group, timing_attrs); readTimingWhen(cell, timing_group, timing_attrs); readTimingMode(timing_group, timing_attrs); readGroupAttrFloat("ocv_arc_depth", timing_group, - [timing_attrs](float v) { timing_attrs->setOcvArcDepth(v); }); + [&timing_attrs](float v) { timing_attrs.setOcvArcDepth(v); }); } void @@ -1983,17 +1988,17 @@ LibertyReader::readGroupAttrFloat(std::string_view attr_name, void LibertyReader::readTimingSense(const LibertyGroup *timing_group, - TimingArcAttrsPtr timing_attrs) + TimingArcAttrs &timing_attrs) { const LibertySimpleAttr *sense_attr = timing_group->findSimpleAttr("timing_sense"); if (sense_attr) { const std::string &sense_name = sense_attr->stringValue(); if (sense_name == "non_unate") - timing_attrs->setTimingSense(TimingSense::non_unate); + timing_attrs.setTimingSense(TimingSense::non_unate); else if (sense_name == "positive_unate") - timing_attrs->setTimingSense(TimingSense::positive_unate); + timing_attrs.setTimingSense(TimingSense::positive_unate); else if (sense_name == "negative_unate") - timing_attrs->setTimingSense(TimingSense::negative_unate); + timing_attrs.setTimingSense(TimingSense::negative_unate); else warn(1245, timing_group, "unknown timing_sense {}.", sense_name); } @@ -2001,7 +2006,7 @@ LibertyReader::readTimingSense(const LibertyGroup *timing_group, void LibertyReader::readTimingType(const LibertyGroup *timing_group, - TimingArcAttrsPtr timing_attrs) + TimingArcAttrs &timing_attrs) { TimingType type = TimingType::combinational; const LibertySimpleAttr *type_attr = timing_group->findSimpleAttr("timing_type"); @@ -2013,43 +2018,43 @@ LibertyReader::readTimingType(const LibertyGroup *timing_group, type = TimingType::combinational; } } - timing_attrs->setTimingType(type); + timing_attrs.setTimingType(type); } void LibertyReader::readTimingWhen(const LibertyCell *cell, const LibertyGroup *timing_group, - TimingArcAttrsPtr timing_attrs) + TimingArcAttrs &timing_attrs) { const LibertySimpleAttr *when_attr = timing_group->findSimpleAttr("when"); if (when_attr) { const std::string &when = when_attr->stringValue(); if (!when.empty()) { FuncExpr *when_expr = parseFunc(when, "when", cell, when_attr->line()); - timing_attrs->setCond(when_expr); + timing_attrs.setCond(when_expr); } } const LibertySimpleAttr *cond_attr = timing_group->findSimpleAttr("sdf_cond"); if (cond_attr) { const std::string &cond = cond_attr->stringValue(); - timing_attrs->setSdfCond(cond); + timing_attrs.setSdfCond(cond); } cond_attr = timing_group->findSimpleAttr("sdf_cond_start"); if (cond_attr) { const std::string &cond = cond_attr->stringValue(); - timing_attrs->setSdfCondStart(cond); + timing_attrs.setSdfCondStart(cond); } cond_attr = timing_group->findSimpleAttr("sdf_cond_end"); if (cond_attr) { const std::string &cond = cond_attr->stringValue(); - timing_attrs->setSdfCondEnd(cond); + timing_attrs.setSdfCondEnd(cond); } } void LibertyReader::readTimingMode(const LibertyGroup *timing_group, - TimingArcAttrsPtr timing_attrs) + TimingArcAttrs &timing_attrs) { const LibertyComplexAttrSeq &mode_attrs = timing_group->findComplexAttrs("mode"); if (!mode_attrs.empty()) { @@ -2058,13 +2063,13 @@ LibertyReader::readTimingMode(const LibertyGroup *timing_group, if (mode_values.size() == 2) { LibertyAttrValue *value = mode_values[0]; if (value->isString()) - timing_attrs->setModeName(value->stringValue()); + timing_attrs.setModeName(value->stringValue()); else warn(1248, mode_attr, "mode name is not a string."); value = mode_values[1]; if (value->isString()) - timing_attrs->setModeValue(value->stringValue()); + timing_attrs.setModeValue(value->stringValue()); else warn(1246, mode_attr, "mode value is not a string."); } @@ -2076,7 +2081,7 @@ LibertyReader::readTimingMode(const LibertyGroup *timing_group, void LibertyReader::makeTimingModels(LibertyCell *cell, const LibertyGroup *timing_group, - TimingArcAttrsPtr timing_attrs) + TimingArcAttrs &timing_attrs) { switch (cell->libertyLibrary()->delayModelType()) { case DelayModelType::cmos_linear: @@ -2096,7 +2101,7 @@ LibertyReader::makeTimingModels(LibertyCell *cell, void LibertyReader::makeLinearModels(LibertyCell *cell, const LibertyGroup *timing_group, - TimingArcAttrsPtr timing_attrs) + TimingArcAttrs &timing_attrs) { LibertyLibrary *library = cell->libertyLibrary(); for (const RiseFall *rf : RiseFall::range()) { @@ -2110,7 +2115,7 @@ LibertyReader::makeLinearModels(LibertyCell *cell, library->defaultIntrinsic(rf, intr, intr_exists); TimingModel *model = nullptr; if (intr_exists) { - if (timingTypeIsCheck(timing_attrs->timingType())) + if (timingTypeIsCheck(timing_attrs.timingType())) model = new CheckLinearModel(cell, intr); else { std::string res_attr_name = sta::format("{}_resistance", rf->to_string()); @@ -2124,7 +2129,7 @@ LibertyReader::makeLinearModels(LibertyCell *cell, res, res_exists); model = new GateLinearModel(cell, intr, res); } - timing_attrs->setModel(rf, model); + timing_attrs.setModel(rf, model); } } } @@ -2132,7 +2137,7 @@ LibertyReader::makeLinearModels(LibertyCell *cell, void LibertyReader::makeTableModels(LibertyCell *cell, const LibertyGroup *timing_group, - TimingArcAttrsPtr timing_attrs) + TimingArcAttrs &timing_attrs) { bool found_model = false; for (const RiseFall *rf : RiseFall::range()) { @@ -2169,11 +2174,11 @@ LibertyReader::makeTableModels(LibertyCell *cell, ReceiverModelPtr receiver_model = readReceiverCapacitance(timing_group, rf); OutputWaveforms *output_waveforms = readOutputWaveforms(timing_group, rf); - timing_attrs->setModel(rf, new GateTableModel(cell, delay_models, - slew_models, - receiver_model, - output_waveforms)); - TimingType timing_type = timing_attrs->timingType(); + timing_attrs.setModel(rf, new GateTableModel(cell, delay_models, + slew_models, + std::move(receiver_model), + output_waveforms)); + TimingType timing_type = timing_attrs.timingType(); if (isGateTimingType(timing_type)) { if (slew_model == nullptr) warn(1210, timing_group, "missing {}_transition.", rf->name()); @@ -2185,7 +2190,7 @@ LibertyReader::makeTableModels(LibertyCell *cell, std::string constraint_attr_name = sta::format("{}_constraint", rf->to_string()); ScaleFactorType scale_factor_type = - timingTypeScaleFactorType(timing_attrs->timingType()); + timingTypeScaleFactorType(timing_attrs.timingType()); TableModel *check_model = readTableModel(timing_group, constraint_attr_name, rf, TableTemplateType::delay, @@ -2199,7 +2204,7 @@ LibertyReader::makeTableModels(LibertyCell *cell, sta::format("ocv_mean_shift_{}_constraiint", rf->to_string()), sta::format("ocv_skewness_{}_constraiint", rf->to_string()), rf, check_models, CheckTableModel::checkAxes); - timing_attrs->setModel(rf, new CheckTableModel(cell, check_models)); + timing_attrs.setModel(rf, new CheckTableModel(cell, check_models)); found_model = true; } } @@ -2232,7 +2237,7 @@ LibertyReader::readTableModel(const LibertyGroup *timing_group, TableTemplateType template_type, float scale, ScaleFactorType scale_factor_type, - const std::function check_axes) + const std::function &check_axes) { const LibertyGroup *table_group = timing_group->findSubgroup(table_group_name); if (table_group) @@ -2249,7 +2254,7 @@ LibertyReader::readLvfModels(const LibertyGroup *timing_group, const std::string &skewness_group_name, const RiseFall *rf, TableModels *table_models, - const std::function check_axes) + const std::function &check_axes) { TableModelsEarlyLate sigmas = readEarlyLateTableModels(timing_group, @@ -2295,7 +2300,7 @@ LibertyReader::readEarlyLateTableModels(const LibertyGroup *timing_group, TableTemplateType template_type, float scale, ScaleFactorType scale_factor_type, - const std::function check_axes) + const std::function &check_axes) { TableModelsEarlyLate models{}; for (const LibertyGroup *table_group : timing_group->findSubgroups(table_group_name)){ @@ -2578,41 +2583,41 @@ LibertyReader::makeTimingArcs(LibertyCell *cell, LibertyPort *to_port, LibertyPort *related_out_port, bool one_to_one, - TimingArcAttrsPtr timing_attrs, + const TimingArcAttrsPtr &timing_attrs, int timing_line) { PortNameBitIterator from_port_iter(cell, from_port_name, this, timing_line); if (from_port_iter.size() == 1 && !to_port->hasMembers()) { // one -> one - if (from_port_iter.hasNext()) { - LibertyPort *from_port = from_port_iter.next(); + if (from_port_iter.PortNameBitIterator::hasNext()) { + LibertyPort *from_port = from_port_iter.PortNameBitIterator::next(); if (from_port->direction()->isOutput()) warn(1212, timing_line, "timing group from output port."); builder_.makeTimingArcs(cell, from_port, to_port, related_out_port, - timing_attrs, timing_line); + timing_attrs); } } else if (from_port_iter.size() > 1 && !to_port->hasMembers()) { // bus -> one - while (from_port_iter.hasNext()) { - LibertyPort *from_port = from_port_iter.next(); + while (from_port_iter.PortNameBitIterator::hasNext()) { + LibertyPort *from_port = from_port_iter.PortNameBitIterator::next(); if (from_port->direction()->isOutput()) warn(1213, timing_line, "timing group from output port."); builder_.makeTimingArcs(cell, from_port, to_port, related_out_port, - timing_attrs, timing_line); + timing_attrs); } } else if (from_port_iter.size() == 1 && to_port->hasMembers()) { // one -> bus - if (from_port_iter.hasNext()) { - LibertyPort *from_port = from_port_iter.next(); + if (from_port_iter.PortNameBitIterator::hasNext()) { + LibertyPort *from_port = from_port_iter.PortNameBitIterator::next(); if (from_port->direction()->isOutput()) warn(1214, timing_line, "timing group from output port."); LibertyPortMemberIterator bit_iter(to_port); while (bit_iter.hasNext()) { LibertyPort *to_port_bit = bit_iter.next(); builder_.makeTimingArcs(cell, from_port, to_port_bit, related_out_port, - timing_attrs, timing_line); + timing_attrs); } } } @@ -2631,33 +2636,31 @@ LibertyReader::makeTimingArcs(LibertyCell *cell, // align to/from iterators for one-to-one mapping while (from_size > to_size) { from_size--; - from_port_iter.next(); + from_port_iter.PortNameBitIterator::next(); } while (to_size > from_size) { to_size--; to_port_iter.next(); } // make timing arcs - while (from_port_iter.hasNext() && to_port_iter.hasNext()) { - LibertyPort *from_port_bit = from_port_iter.next(); + while (from_port_iter.PortNameBitIterator::hasNext() && to_port_iter.hasNext()) { + LibertyPort *from_port_bit = from_port_iter.PortNameBitIterator::next(); LibertyPort *to_port_bit = to_port_iter.next(); if (from_port_bit->direction()->isOutput()) warn(1215, timing_line, "timing group from output port."); builder_.makeTimingArcs(cell, from_port_bit, to_port_bit, - related_out_port, timing_attrs, - timing_line); + related_out_port, timing_attrs); } } else { // cross product - while (from_port_iter.hasNext()) { - LibertyPort *from_port_bit = from_port_iter.next(); + while (from_port_iter.PortNameBitIterator::hasNext()) { + LibertyPort *from_port_bit = from_port_iter.PortNameBitIterator::next(); LibertyPortMemberIterator to_port_iter(to_port); while (to_port_iter.hasNext()) { LibertyPort *to_port_bit = to_port_iter.next(); builder_.makeTimingArcs(cell, from_port_bit, to_port_bit, - related_out_port, timing_attrs, - timing_line); + related_out_port, timing_attrs); } } } @@ -2668,28 +2671,25 @@ void LibertyReader::makeTimingArcs(LibertyCell *cell, LibertyPort *to_port, LibertyPort *related_out_port, - TimingArcAttrsPtr timing_attrs, - int timing_line) + const TimingArcAttrsPtr &timing_attrs) { if (to_port->hasMembers()) { LibertyPortMemberIterator bit_iter(to_port); while (bit_iter.hasNext()) { LibertyPort *to_port_bit = bit_iter.next(); builder_.makeTimingArcs(cell, nullptr, to_port_bit, - related_out_port, timing_attrs, - timing_line); + related_out_port, timing_attrs); } } else builder_.makeTimingArcs(cell, nullptr, to_port, - related_out_port, timing_attrs, - timing_line); + related_out_port, timing_attrs); } //////////////////////////////////////////////////////////////// void -LibertyReader::readLeagageGrouops(LibertyCell *cell, +LibertyReader::readLeakageGrouops(LibertyCell *cell, const LibertyGroup *cell_group) { for (const LibertyGroup *leak_group : cell_group->findSubgroups("leakage_power")) { @@ -3553,12 +3553,7 @@ PortNameBitIterator::PortNameBitIterator(LibertyCell *cell, int line) : cell_(cell), visitor_(visitor), - line_(line), - port_(nullptr), - bit_iterator_(nullptr), - range_bus_port_(nullptr), - range_name_next_(nullptr), - size_(0) + line_(line) { init(port_name); } @@ -3703,4 +3698,4 @@ OutputWaveform::releaseCurrents() return currents_.release(); } -} // namespace +} // namespace sta diff --git a/liberty/LibertyReader.hh b/liberty/LibertyReader.hh index 27fed80a..030c42e8 100644 --- a/liberty/LibertyReader.hh +++ b/liberty/LibertyReader.hh @@ -36,4 +36,4 @@ readLibertyFile(std::string_view filename, bool infer_latches, Network *network); -} // namespace +} // namespace sta diff --git a/liberty/LibertyReaderPvt.hh b/liberty/LibertyReaderPvt.hh index 28683aef..cd4a1627 100644 --- a/liberty/LibertyReaderPvt.hh +++ b/liberty/LibertyReaderPvt.hh @@ -69,20 +69,22 @@ public: LibertyReader(std::string_view filename, bool infer_latches, Network *network); - virtual LibertyLibrary *readLibertyFile(std::string_view filename); + LibertyLibrary *readLibertyFile(std::string_view filename); LibertyLibrary *library() { return library_; } const LibertyLibrary *library() const { return library_; } - virtual void beginLibrary(const LibertyGroup *group, - LibertyGroup *library_group); - virtual void endLibrary(const LibertyGroup *group, - LibertyGroup *null_group); - virtual void visitAttr(const LibertySimpleAttr *attr); - virtual void visitAttr(const LibertyComplexAttr *attr); - virtual void visitVariable(LibertyVariable *var); - // Extension points for custom attributes (e.g. LibertyExt). - virtual void visitAttr1(const LibertySimpleAttr *) {} - virtual void visitAttr2(const LibertySimpleAttr *) {} + void beginLibrary(const LibertyGroup *group, + LibertyGroup *library_group); + void endLibrary(const LibertyGroup *group, + LibertyGroup *null_group); + void visitAttr(const LibertySimpleAttr *attr) override; + void visitAttr(const LibertyComplexAttr *attr) override; + void visitVariable(LibertyVariable *var) override; + + void begin(const LibertyGroup *group, + LibertyGroup *parent_group) override; + void end(const LibertyGroup *group, + LibertyGroup *parent_group) override; void endCell(const LibertyGroup *group, LibertyGroup *library_group); @@ -108,11 +110,6 @@ public: std::string_view name_attr); protected: - virtual void begin(const LibertyGroup *group, - LibertyGroup *library_group); - virtual void end(const LibertyGroup *group, - LibertyGroup *library_group); - // Library gruops. void makeLibrary(const LibertyGroup *library_group); void readLibraryAttributes(const LibertyGroup *library_group); @@ -146,7 +143,7 @@ protected: void readScaleFactors(const LibertyGroup *scale_group, ScaleFactors *scale_factors); void readOcvDerateFactors(LibertyCell *cell, - const LibertyGroup *library_group); + const LibertyGroup *parent_group); void readDefaultOcvDerateGroup(const LibertyGroup *library_group); void readNormalizedDriverWaveform(const LibertyGroup *library_group); void readSlewDegradations(const LibertyGroup *library_group); @@ -246,7 +243,7 @@ protected: TableTemplateType template_type, float scale, ScaleFactorType scale_factor_type, - const std::function check_axes); + const std::function &check_axes); TableModelsEarlyLate readEarlyLateTableModels(const LibertyGroup *timing_group, std::string_view table_group_name, @@ -254,7 +251,7 @@ protected: TableTemplateType template_type, float scale, ScaleFactorType scale_factor_type, - const std::function check_axes); + const std::function &check_axes); ReceiverModelPtr readReceiverCapacitance(const LibertyGroup *timing_group, const RiseFall *rf); void readReceiverCapacitance(const LibertyGroup *timing_group, @@ -280,13 +277,13 @@ protected: float scale); void makeTimingModels(LibertyCell *cell, const LibertyGroup *timing_group, - TimingArcAttrsPtr timing_attrs); + TimingArcAttrs &timing_attrs); void makeLinearModels(LibertyCell *cell, const LibertyGroup *timing_group, - TimingArcAttrsPtr timing_attrs); + TimingArcAttrs &timing_attrs); void makeTableModels(LibertyCell *cell, const LibertyGroup *timing_group, - TimingArcAttrsPtr timing_attrs); + TimingArcAttrs &timing_attrs); void readLvfModels(const LibertyGroup *timing_group, const std::string &sigma_group_name, const std::string &std_dev_group_name, @@ -294,7 +291,7 @@ protected: const std::string &skewness_group_name, const RiseFall *rf, TableModels *table_models, - const std::function check_axes); + const std::function &check_axes); TableAxisPtr makeTableAxis(const LibertyGroup *table_group, std::string_view index_attr_name, @@ -305,16 +302,16 @@ protected: float scale = 1.0F); void readTimingArcAttrs(LibertyCell *cell, const LibertyGroup *timing_group, - TimingArcAttrsPtr timing_attrs); + TimingArcAttrs &timing_attrs); void readTimingSense(const LibertyGroup *timing_group, - TimingArcAttrsPtr timing_attrs); + TimingArcAttrs &timing_attrs); void readTimingType(const LibertyGroup *timing_group, - TimingArcAttrsPtr timing_attrs); + TimingArcAttrs &timing_attrs); void readTimingWhen(const LibertyCell *cell, const LibertyGroup *timing_group, - TimingArcAttrsPtr timing_attrs); + TimingArcAttrs &timing_attrs); void readTimingMode(const LibertyGroup *timing_group, - TimingArcAttrsPtr timing_attrs); + TimingArcAttrs &timing_attrs); void makePortFuncs(LibertyCell *cell, const LibertyPortSeq &ports, const LibertyGroup *port_group); @@ -356,19 +353,18 @@ protected: LibertyPort *to_port, LibertyPort *related_out_port, bool one_to_one, - TimingArcAttrsPtr timing_attrs, + const TimingArcAttrsPtr &timing_attrs, int timing_line); void makeTimingArcs(LibertyCell *cell, LibertyPort *to_port, LibertyPort *related_out_port, - TimingArcAttrsPtr timing_attrs, - int timing_line); + const TimingArcAttrsPtr &timing_attrs); void readInternalPowerGroups(LibertyCell *cell, const LibertyPortSeq &ports, const LibertyGroup *port_group); - void readLeagageGrouops(LibertyCell *cell, - const LibertyGroup *port_group); + void readLeakageGrouops(LibertyCell *cell, + const LibertyGroup *cell_group); void readCellAttributes(LibertyCell *cell, const LibertyGroup *cell_group); @@ -524,7 +520,7 @@ protected: Network *network_; LibertyBuilder builder_; LibertyVariableMap var_map_; - LibertyLibrary *library_; + LibertyLibrary *library_{nullptr}; LibraryGroupVisitorMap group_begin_map_; LibraryGroupVisitorMap group_end_map_; @@ -554,7 +550,7 @@ public: std::string_view port_name, LibertyReader *visitor, int line); - ~PortNameBitIterator(); + ~PortNameBitIterator() override; bool hasNext() override; LibertyPort *next() override; unsigned size() const { return size_; } @@ -566,22 +562,22 @@ protected: LibertyCell *cell_; LibertyReader *visitor_; int line_; - LibertyPort *port_; - LibertyPortMemberIterator *bit_iterator_; - LibertyPort *range_bus_port_; + LibertyPort *port_{nullptr}; + LibertyPortMemberIterator *bit_iterator_{nullptr}; + LibertyPort *range_bus_port_{nullptr}; std::string range_bus_name_; - LibertyPort *range_name_next_; - int range_from_; - int range_to_; - int range_bit_; - unsigned size_; + LibertyPort *range_name_next_{nullptr}; + int range_from_{0}; + int range_to_{0}; + int range_bit_{0}; + unsigned size_{0}; }; class OutputWaveform { public: - OutputWaveform(float axis_value1, - float axis_value2, + OutputWaveform(float slew, + float cap, Table *currents, float reference_time); float slew() const { return slew_; } @@ -597,4 +593,4 @@ private: float reference_time_; }; -} // namespace +} // namespace sta diff --git a/liberty/LibertyScanner.hh b/liberty/LibertyScanner.hh index bb42f4c3..06c9ef5e 100644 --- a/liberty/LibertyScanner.hh +++ b/liberty/LibertyScanner.hh @@ -48,9 +48,7 @@ public: std::string_view filename, LibertyParser *reader, Report *report); - virtual ~LibertyScanner() {} - - virtual int lex(LibertyParse::semantic_type *const yylval, + virtual int lex(LibertyParse::semantic_type *yylval, LibertyParse::location_type *yylloc); // YY_DECL defined in LibertyLex.ll // Method body created by flex in LibertyLex.cc @@ -71,7 +69,7 @@ private: // Previous lex state for include files. std::string filename_prev_; - std::istream *stream_prev_; + std::istream *stream_prev_{nullptr}; }; -} // namespace +} // namespace sta diff --git a/liberty/LibertyWriter.cc b/liberty/LibertyWriter.cc index 79d4f780..ab8b8177 100644 --- a/liberty/LibertyWriter.cc +++ b/liberty/LibertyWriter.cc @@ -24,11 +24,16 @@ #include "LibertyWriter.hh" -#include #include +#include #include +#include +#include "Error.hh" #include "Format.hh" +#include "LibertyClass.hh" +#include "MinMax.hh" +#include "Transition.hh" #include "Units.hh" #include "FuncExpr.hh" #include "PortDirection.hh" @@ -494,6 +499,8 @@ LibertyWriter::writeTableModel(const TableModel *model) case 3: report_->error(1342, "3 axis table models not supported."); break; + default: + break; } } diff --git a/liberty/LinearModel.cc b/liberty/LinearModel.cc index 4d96138e..d64bfc27 100644 --- a/liberty/LinearModel.cc +++ b/liberty/LinearModel.cc @@ -24,6 +24,14 @@ #include "LinearModel.hh" +#include +#include + +#include "Delay.hh" +#include "LibertyClass.hh" +#include "MinMax.hh" +#include "PocvMode.hh" +#include "TimingModel.hh" #include "Units.hh" #include "Liberty.hh" @@ -139,4 +147,4 @@ CheckLinearModel::setIsScaled(bool) { } -} // namespace +} // namespace sta diff --git a/liberty/Sequential.cc b/liberty/Sequential.cc index 5106f11c..0fffdbe2 100644 --- a/liberty/Sequential.cc +++ b/liberty/Sequential.cc @@ -25,6 +25,8 @@ #include "Sequential.hh" #include "FuncExpr.hh" +#include "LibertyClass.hh" +#include "NetworkClass.hh" namespace sta { @@ -119,4 +121,4 @@ StatetableRow::StatetableRow(StateInputValues &input_values, { } -} // namespace +} // namespace sta diff --git a/liberty/TableModel.cc b/liberty/TableModel.cc index 676d29af..5cdd92f2 100644 --- a/liberty/TableModel.cc +++ b/liberty/TableModel.cc @@ -24,14 +24,25 @@ #include "TableModel.hh" +#include #include +#include +#include #include +#include +#include "Delay.hh" #include "Error.hh" -#include "EnumNameMap.hh" #include "ContainerHelpers.hh" -#include "Units.hh" +#include "EnumNameMap.hh" +#include "Format.hh" +#include "LibertyClass.hh" #include "Liberty.hh" +#include "MinMax.hh" +#include "PocvMode.hh" +#include "TimingModel.hh" +#include "Transition.hh" +#include "Units.hh" namespace sta { @@ -61,7 +72,7 @@ GateTableModel::GateTableModel(LibertyCell *cell, GateTimingModel(cell), delay_models_(delay_models), slew_models_(slew_models), - receiver_model_(receiver_model), + receiver_model_(std::move(receiver_model)), output_waveforms_(output_waveforms) { } @@ -77,8 +88,6 @@ GateTableModel::GateTableModel(LibertyCell *cell, { } -GateTableModel::~GateTableModel() = default; - const TableModel * GateTableModel::delayModel() const { @@ -115,8 +124,7 @@ GateTableModel::gateDelay(const Pvt *pvt, if (slew_models_ && slew_models_->model()) { drvr_slew = findValue(pvt, slew_models_->model(), in_slew, load_cap, 0.0); // Clip negative slews to zero. - if (drvr_slew < 0.0) - drvr_slew = 0.0; + drvr_slew = std::max(drvr_slew, 0.0F); } else drvr_slew = 0.0; @@ -358,8 +366,7 @@ GateTableModel::maxCapSlew(float in_slew, slew = 0.0; } // Clip negative slews to zero. - if (slew < 0.0) - slew = 0.0; + slew = std::max(slew, 0.0F); } float @@ -410,8 +417,6 @@ GateTableModel::checkAxis(const TableAxis *axis) //////////////////////////////////////////////////////////////// -ReceiverModel::~ReceiverModel() = default; - void ReceiverModel::setCapacitanceModel(TableModel table_model, size_t segment, @@ -450,8 +455,6 @@ CheckTableModel::CheckTableModel(LibertyCell *cell, { } -CheckTableModel::~CheckTableModel() = default; - const TableModel * CheckTableModel::checkModel() const { @@ -760,9 +763,9 @@ TableModel::TableModel(TablePtr table, TableTemplate *tbl_template, ScaleFactorType scale_factor_type, const RiseFall *rf) : - table_(table), + table_(std::move(table)), tbl_template_(tbl_template), - scale_factor_type_(int(scale_factor_type)), + scale_factor_type_(static_cast(scale_factor_type)), rf_index_(rf->index()), is_scaled_(false) { @@ -783,7 +786,7 @@ TableModel::scaleFactorType() const void TableModel::setScaleFactorType(ScaleFactorType type) { - scale_factor_type_ = int(type); + scale_factor_type_ = static_cast(type); } void @@ -950,7 +953,7 @@ Table::Table(FloatSeq *values, order_(1), value_(0.0), values1_(std::move(*values)), - axis1_(axis1) + axis1_(std::move(axis1)) { delete values; } @@ -960,7 +963,7 @@ Table::Table(FloatSeq &&values, order_(1), value_(0.0), values1_(std::move(values)), - axis1_(axis1) + axis1_(std::move(axis1)) { } @@ -970,8 +973,8 @@ Table::Table(FloatTable &&values, order_(2), value_(0.0), values_table_(std::move(values)), - axis1_(axis1), - axis2_(axis2) + axis1_(std::move(axis1)), + axis2_(std::move(axis2)) { } @@ -982,36 +985,27 @@ Table::Table(FloatTable &&values, order_(3), value_(0.0), values_table_(std::move(values)), - axis1_(axis1), - axis2_(axis2), - axis3_(axis3) + axis1_(std::move(axis1)), + axis2_(std::move(axis2)), + axis3_(std::move(axis3)) { } -Table::Table(Table &&table) : +Table::Table(Table &&table) noexcept : order_(table.order_), value_(table.value_), values1_(std::move(table.values1_)), values_table_(std::move(table.values_table_)), - axis1_(table.axis1_), - axis2_(table.axis2_), - axis3_(table.axis3_) + axis1_(std::move(table.axis1_)), + axis2_(std::move(table.axis2_)), + axis3_(std::move(table.axis3_)) { } -Table::Table(const Table &table) : - order_(table.order_), - value_(table.value_), - values1_(table.values1_), - values_table_(table.values_table_), - axis1_(table.axis1_), - axis2_(table.axis2_), - axis3_(table.axis3_) -{ -} +Table::Table(const Table &table) = default; Table & -Table::operator=(Table &&table) +Table::operator=(Table &&table) noexcept { if (this != &table) { order_ = table.order_; @@ -1788,12 +1782,11 @@ OutputWaveforms::OutputWaveforms(TableAxisPtr slew_axis, const RiseFall *rf, Table1Seq ¤t_waveforms, Table ref_times) : - slew_axis_(slew_axis), - cap_axis_(cap_axis), + slew_axis_(std::move(slew_axis)), + cap_axis_(std::move(cap_axis)), rf_(rf), current_waveforms_(current_waveforms), - ref_times_(std::move(ref_times)), - vdd_(0.0) + ref_times_(std::move(ref_times)) { } @@ -2211,7 +2204,7 @@ OutputWaveforms::finalResistance() DriverWaveform::DriverWaveform(std::string name, TablePtr waveforms) : name_(std::move(name)), - waveforms_(waveforms) + waveforms_(std::move(waveforms)) { } diff --git a/liberty/TimingArc.cc b/liberty/TimingArc.cc index a254b7cd..ae99b043 100644 --- a/liberty/TimingArc.cc +++ b/liberty/TimingArc.cc @@ -22,16 +22,27 @@ // // This notice may not be removed or altered from any source distribution. -#include "TimingModel.hh" +#include "TimingArc.hh" + +#include +#include +#include +#include +#include #include "ContainerHelpers.hh" +#include "Delay.hh" #include "EnumNameMap.hh" +#include "Error.hh" #include "FuncExpr.hh" -#include "TimingRole.hh" +#include "LibertyClass.hh" #include "Liberty.hh" -#include "TimingArc.hh" -#include "TableModel.hh" +#include "MinMax.hh" #include "Sdc.hh" +#include "TableModel.hh" +#include "TimingModel.hh" +#include "TimingRole.hh" +#include "Transition.hh" namespace sta { @@ -88,34 +99,34 @@ TimingArcAttrs::setCond(FuncExpr *cond) } void -TimingArcAttrs::setSdfCond(std::string cond) +TimingArcAttrs::setSdfCond(std::string_view cond) { - sdf_cond_ = std::move(cond); + sdf_cond_ = cond; sdf_cond_start_ = sdf_cond_end_ = sdf_cond_; } void -TimingArcAttrs::setSdfCondStart(std::string cond) +TimingArcAttrs::setSdfCondStart(std::string_view cond) { - sdf_cond_start_ = std::move(cond); + sdf_cond_start_ = cond; } void -TimingArcAttrs::setSdfCondEnd(std::string cond) +TimingArcAttrs::setSdfCondEnd(std::string_view cond) { - sdf_cond_end_ = std::move(cond); + sdf_cond_end_ = cond; } void -TimingArcAttrs::setModeName(std::string name) +TimingArcAttrs::setModeName(std::string_view name) { - mode_name_ = std::move(name); + mode_name_ = name; } void -TimingArcAttrs::setModeValue(std::string value) +TimingArcAttrs::setModeValue(std::string_view value) { - mode_value_ = std::move(value); + mode_value_ = value; } TimingModel * @@ -176,7 +187,7 @@ TimingArcSet::TimingArcSet(LibertyCell *, to_(to), related_out_(related_out), role_(role), - attrs_(attrs), + attrs_(std::move(attrs)), is_cond_default_(false), index_(index), from_arc1_{nullptr, nullptr}, @@ -191,7 +202,7 @@ TimingArcSet::TimingArcSet(const TimingRole *role, to_(nullptr), related_out_(nullptr), role_(role), - attrs_(attrs), + attrs_(std::move(attrs)), is_cond_default_(false), index_(0), from_arc1_{nullptr, nullptr}, @@ -235,7 +246,8 @@ TimingArcSet::addTimingArc(TimingArc *arc) { size_t arc_index = arcs_.size(); // Rise/fall to rise/fall. - if (arc_index > RiseFall::index_count * RiseFall::index_count) + if (arc_index > static_cast(RiseFall::index_count) + * RiseFall::index_count) criticalError(243, "timing arc max index exceeded\n"); arcs_.push_back(arc); @@ -531,8 +543,7 @@ TimingArc::TimingArc(TimingArcSet *set, set_(set), from_rf_(from_rf), to_rf_(to_rf), - model_(model), - scaled_models_(nullptr) + model_(model) { index_ = set->addTimingArc(this); } @@ -633,10 +644,10 @@ TimingArc::setIndex(size_t index) } const TimingArc * -TimingArc::sceneArc(int ap_index) const +TimingArc::sceneArc(size_t lib_ap_index) const { - if (ap_index < static_cast(scene_arcs_.size())) { - TimingArc *scene_arc = scene_arcs_[ap_index]; + if (lib_ap_index < scene_arcs_.size()) { + TimingArc *scene_arc = scene_arcs_[lib_ap_index]; if (scene_arc) return scene_arc; } @@ -645,11 +656,11 @@ TimingArc::sceneArc(int ap_index) const void TimingArc::setSceneArc(TimingArc *scene_arc, - int ap_index) + size_t lib_ap_index) { - if (ap_index >= static_cast(scene_arcs_.size())) - scene_arcs_.resize(ap_index + 1); - scene_arcs_[ap_index] = scene_arc; + if (lib_ap_index >= scene_arcs_.size()) + scene_arcs_.resize(lib_ap_index + 1); + scene_arcs_[lib_ap_index] = scene_arc; } //////////////////////////////////////////////////////////////// @@ -845,4 +856,4 @@ timingTypeScaleFactorType(TimingType type) return ScaleFactorType::unknown; } -} // namespace +} // namespace sta diff --git a/liberty/TimingModel.cc b/liberty/TimingModel.cc index 3acc7b95..5e31059a 100644 --- a/liberty/TimingModel.cc +++ b/liberty/TimingModel.cc @@ -24,6 +24,8 @@ #include "TimingModel.hh" +#include "LibertyClass.hh" + namespace sta { GateTimingModel::GateTimingModel(LibertyCell *cell) : @@ -36,4 +38,4 @@ CheckTimingModel::CheckTimingModel(LibertyCell *cell) : { } -} // namespace +} // namespace sta diff --git a/liberty/TimingRole.cc b/liberty/TimingRole.cc index ace8d7de..672a6498 100644 --- a/liberty/TimingRole.cc +++ b/liberty/TimingRole.cc @@ -24,6 +24,8 @@ #include "TimingRole.hh" +#include "MinMax.hh" + namespace sta { TimingRoleMap TimingRole::timing_roles_; @@ -184,4 +186,4 @@ TimingRole::less(const TimingRole *role1, return role1->index() < role2->index(); } -} // namespace +} // namespace sta diff --git a/liberty/Units.cc b/liberty/Units.cc index 6e5a4e34..6d1c3f06 100644 --- a/liberty/Units.cc +++ b/liberty/Units.cc @@ -57,15 +57,6 @@ Unit::setScaleAbbrevSuffix() scale_abbrev_suffix_ = scaleAbbreviation() + suffix_; } -void -Unit::operator=(const Unit &unit) -{ - scale_ = unit.scale_; - suffix_ = unit.suffix_; - scale_abbrev_suffix_ = unit.scale_abbrev_suffix_; - digits_ = unit.digits_; -} - double Unit::staToUser(double value) { @@ -213,7 +204,7 @@ Units::find(std::string_view unit_name) return nullptr; } -void +Units & Units::operator=(const Units &units) { time_unit_ = *units.timeUnit(); @@ -224,6 +215,7 @@ Units::operator=(const Units &units) power_unit_ = *units.powerUnit(); distance_unit_ = *units.distanceUnit(); scalar_unit_ = *units.scalarUnit(); + return *this; } -} // namespace +} // namespace sta diff --git a/liberty/Wireload.cc b/liberty/Wireload.cc index 1c30df10..e416ebb3 100644 --- a/liberty/Wireload.cc +++ b/liberty/Wireload.cc @@ -25,8 +25,13 @@ #include "Wireload.hh" #include +#include +#include +#include +#include -#include "StringUtil.hh" +#include "ContainerHelpers.hh" +#include "LibertyClass.hh" #include "Liberty.hh" namespace sta { @@ -124,8 +129,7 @@ Wireload::findWireload(float fanout, if (fanout < fanout0) { // Extrapolate from lowest fanout entry. length = fanout_lengths_[0]->second - (fanout0 - fanout) * slope_; - if (length < 0) - length = 0; + length = std::max(length, 0.0F); } else if (fanout == fanout0) length = fanout_lengths_[0]->second; @@ -304,4 +308,4 @@ stringWireloadMode(std::string_view wire_load_mode) return WireloadMode::unknown; } -} // namespace +} // namespace sta diff --git a/network/ConcreteLibrary.cc b/network/ConcreteLibrary.cc index 3864239c..77b335a1 100644 --- a/network/ConcreteLibrary.cc +++ b/network/ConcreteLibrary.cc @@ -28,11 +28,11 @@ #include #include +#include "ConcreteNetwork.hh" #include "ContainerHelpers.hh" +#include "ParseBus.hh" #include "PatternMatch.hh" #include "PortDirection.hh" -#include "ParseBus.hh" -#include "ConcreteNetwork.hh" namespace sta { @@ -44,9 +44,7 @@ ConcreteLibrary::ConcreteLibrary(std::string_view name, name_(name), id_(ConcreteNetwork::nextObjectId()), filename_(filename), - is_liberty_(is_liberty), - bus_brkt_left_('['), - bus_brkt_right_(']') + is_liberty_(is_liberty) { } @@ -125,9 +123,6 @@ ConcreteCell::ConcreteCell(std::string_view name, id_(ConcreteNetwork::nextObjectId()), filename_(filename), library_(library), - liberty_cell_(nullptr), - ext_cell_(nullptr), - port_bit_count_(0), is_leaf_(is_leaf) { } @@ -234,7 +229,7 @@ ConcreteCell::makeBusPortBit(ConcretePort *bus_port, } ConcretePort * -ConcreteCell::makePort(std::string bit_name, +ConcreteCell::makePort(std::string_view bit_name, int bit_index) { ConcretePort *port = new ConcretePort(bit_name, false, @@ -351,9 +346,9 @@ BusPort::addBusBit(ConcretePort *port, } void -ConcreteCell::groupBusPorts(const char bus_brkt_left, - const char bus_brkt_right, - std::function port_msb_first) +ConcreteCell::groupBusPorts(char bus_brkt_left, + char bus_brkt_right, + const std::function &port_msb_first) { const char bus_brkts_left[2]{bus_brkt_left, '\0'}; const char bus_brkts_right[2]{bus_brkt_right, '\0'}; @@ -415,15 +410,11 @@ ConcretePort::ConcretePort(std::string_view name, id_(ConcreteNetwork::nextObjectId()), cell_(cell), direction_(PortDirection::unknown()), - liberty_port_(nullptr), - ext_port_(nullptr), - pin_index_(-1), is_bundle_(is_bundle), is_bus_(is_bus), from_index_(from_index), to_index_(to_index), - member_ports_(member_ports), - bundle_port_(nullptr) + member_ports_(member_ports) { } @@ -575,9 +566,7 @@ ConcretePort::memberIterator() const ConcreteCellPortBitIterator::ConcreteCellPortBitIterator(const ConcreteCell* cell) : ports_(cell->ports_), - port_iter_(ports_.begin()), - member_iter_(nullptr), - next_(nullptr) + port_iter_(ports_.begin()) { findNext(); } @@ -625,4 +614,4 @@ ConcreteCellPortBitIterator::findNext() next_ = nullptr; } -} // namespace +} // namespace sta diff --git a/network/ConcreteNetwork.cc b/network/ConcreteNetwork.cc index 44cc8a0a..df99ff9d 100644 --- a/network/ConcreteNetwork.cc +++ b/network/ConcreteNetwork.cc @@ -24,15 +24,16 @@ #include "ConcreteNetwork.hh" +#include #include #include -#include "PatternMatch.hh" -#include "Report.hh" -#include "Liberty.hh" -#include "PortDirection.hh" #include "ConcreteLibrary.hh" +#include "Liberty.hh" #include "Network.hh" +#include "PatternMatch.hh" +#include "PortDirection.hh" +#include "Report.hh" namespace sta { @@ -105,13 +106,12 @@ private: ConcreteInstanceNetMap *nets_; ConcreteInstanceNetMap::iterator iter_; - ConcreteNet *next_; + ConcreteNet *next_{nullptr}; }; ConcreteInstanceNetIterator:: ConcreteInstanceNetIterator(ConcreteInstanceNetMap *nets): - nets_(nets), - next_(nullptr) + nets_(nets) { if (nets) { iter_ = nets->begin(); @@ -161,7 +161,7 @@ private: const ConcretePinSeq &pins_; int pin_count_; - int pin_index_; + int pin_index_{0}; ConcretePin *next_; }; @@ -169,8 +169,7 @@ ConcreteInstancePinIterator:: ConcreteInstancePinIterator(const ConcreteInstance *inst, int pin_count) : pins_(inst->pins_), - pin_count_(pin_count), - pin_index_(0) + pin_count_(pin_count) { findNext(); } @@ -271,24 +270,31 @@ ObjectId ConcreteNetwork::object_id_ = 0; ConcreteNetwork::ConcreteNetwork() : NetworkReader(), - top_instance_(nullptr), - constant_nets_{NetSet(this), NetSet(this)}, link_func_(nullptr) { } ConcreteNetwork::~ConcreteNetwork() { - clear(); + // Cannot call virtual functions in destructor. + clearImpl(); +} + +void +ConcreteNetwork::clearImpl() +{ + if (top_instance_) + deleteInstanceImpl(top_instance_); + top_instance_ = nullptr; + deleteCellNetworkViewsImpl(); + deleteContents(library_seq_); + library_map_.clear(); } void ConcreteNetwork::clear() { - deleteTopInstance(); - deleteCellNetworkViews(); - deleteContents(library_seq_); - library_map_.clear(); + clearImpl(); Network::clear(); } @@ -303,6 +309,12 @@ ConcreteNetwork::deleteTopInstance() void ConcreteNetwork::deleteCellNetworkViews() +{ + deleteCellNetworkViewsImpl(); +} + +void +ConcreteNetwork::deleteCellNetworkViewsImpl() { for (auto [cell, view] : cell_network_view_map_) { if (view) @@ -361,7 +373,6 @@ class ConcreteLibertyLibraryIterator : public Iterator { public: ConcreteLibertyLibraryIterator(const ConcreteNetwork *network); - virtual ~ConcreteLibertyLibraryIterator(); bool hasNext() override; LibertyLibrary *next() override; @@ -370,22 +381,17 @@ private: const ConcreteLibrarySeq &libs_; ConcreteLibrarySeq::const_iterator iter_; - LibertyLibrary *next_; + LibertyLibrary *next_{nullptr}; }; ConcreteLibertyLibraryIterator:: ConcreteLibertyLibraryIterator(const ConcreteNetwork *network): libs_(network->library_seq_), - iter_(libs_.begin()), - next_(nullptr) + iter_(libs_.begin()) { findNext(); } -ConcreteLibertyLibraryIterator::~ConcreteLibertyLibraryIterator() -{ -} - bool ConcreteLibertyLibraryIterator::hasNext() { @@ -462,7 +468,7 @@ ConcreteNetwork::deleteLibrary(Library *library) { ConcreteLibrary *clib = reinterpret_cast(library); library_map_.erase(clib->name()); - library_seq_.erase(std::find(library_seq_.begin(), library_seq_.end(), clib)); + library_seq_.erase(std::ranges::find(library_seq_, clib)); delete clib; } @@ -721,7 +727,7 @@ class ConcreteCellPortIterator1 : public CellPortIterator { public: ConcreteCellPortIterator1(const ConcreteCell *cell); - ~ConcreteCellPortIterator1(); + ~ConcreteCellPortIterator1() override; bool hasNext() override { return iter_->hasNext(); } Port *next() override; @@ -758,7 +764,7 @@ class ConcreteCellPortBitIterator1 : public CellPortIterator { public: ConcreteCellPortBitIterator1(const ConcreteCell *cell); - ~ConcreteCellPortBitIterator1(); + ~ConcreteCellPortBitIterator1() override; bool hasNext() override { return iter_->hasNext(); } Port *next() override; @@ -905,19 +911,18 @@ class ConcretePortMemberIterator1 : public PortMemberIterator { public: ConcretePortMemberIterator1(const ConcretePort *port); - ~ConcretePortMemberIterator1(); + ~ConcretePortMemberIterator1() override; bool hasNext() override; Port *next() override; private: ConcretePortMemberIterator *iter_; - ConcretePort *next_; + ConcretePort *next_{nullptr}; }; ConcretePortMemberIterator1::ConcretePortMemberIterator1(const ConcretePort * port) : - iter_(port->memberIterator()), - next_(nullptr) + iter_(port->memberIterator()) { } @@ -1051,7 +1056,7 @@ ConcreteNetwork::findInstNetsMatching(const Instance *instance, { const ConcreteInstance *inst = reinterpret_cast(instance); - return inst->findNetsMatching(pattern, matches); + inst->findNetsMatching(pattern, matches); } //////////////////////////////////////////////////////////////// @@ -1191,13 +1196,13 @@ ConcreteNetwork::instance(const Net *net) const bool ConcreteNetwork::isPower(const Net *net) const { - return constant_nets_[int(LogicValue::one)].contains(const_cast(net)); + return constant_nets_[static_cast(LogicValue::one)].contains(const_cast(net)); } bool ConcreteNetwork::isGround(const Net *net) const { - return constant_nets_[int(LogicValue::zero)].contains(const_cast(net)); + return constant_nets_[static_cast(LogicValue::zero)].contains(const_cast(net)); } NetPinIterator * @@ -1308,6 +1313,12 @@ ConcreteNetwork::replaceCell(Instance *inst, void ConcreteNetwork::deleteInstance(Instance *inst) +{ + deleteInstanceImpl(inst); +} + +void +ConcreteNetwork::deleteInstanceImpl(Instance *inst) { ConcreteInstance *cinst = reinterpret_cast(inst); ConcreteInstanceNetMap *nets = cinst->nets_; @@ -1504,8 +1515,7 @@ ConcreteNetwork::deletePin(Pin *pin) ConcreteNet *cnet = cpin->net(); if (cnet) disconnectNetPin(cnet, cpin); - ConcreteInstance *cinst = - reinterpret_cast(cpin->instance()); + ConcreteInstance *cinst = cpin->instance(); if (cinst) cinst->deletePin(cpin); delete cpin; @@ -1533,16 +1543,15 @@ ConcreteNetwork::deleteNet(Net *net) pin->net_ = nullptr; } - constant_nets_[int(LogicValue::zero)].erase(net); - constant_nets_[int(LogicValue::one)].erase(net); + constant_nets_[static_cast(LogicValue::zero)].erase(net); + constant_nets_[static_cast(LogicValue::one)].erase(net); PinSet *drvrs = findKey(net_drvr_pin_map_, net); if (drvrs) { delete drvrs; net_drvr_pin_map_.erase(net); } - ConcreteInstance *cinst = - reinterpret_cast(cnet->instance()); + ConcreteInstance *cinst = cnet->instance(); cinst->deleteNet(cnet); delete cnet; } @@ -1550,8 +1559,8 @@ ConcreteNetwork::deleteNet(Net *net) void ConcreteNetwork::clearConstantNets() { - constant_nets_[int(LogicValue::zero)].clear(); - constant_nets_[int(LogicValue::one)].clear(); + constant_nets_[static_cast(LogicValue::zero)].clear(); + constant_nets_[static_cast(LogicValue::one)].clear(); } void @@ -1560,15 +1569,15 @@ ConcreteNetwork::addConstantNet(Net *net, { if (value == LogicValue::zero || value == LogicValue::one) - constant_nets_[int(value)].insert(net); + constant_nets_[static_cast(value)].insert(net); } ConstantPinIterator * ConcreteNetwork::constantPinIterator() { return new NetworkConstantPinIterator(this, - constant_nets_[int(LogicValue::zero)], - constant_nets_[int(LogicValue::one)]); + constant_nets_[static_cast(LogicValue::zero)], + constant_nets_[static_cast(LogicValue::one)]); } //////////////////////////////////////////////////////////////// @@ -1617,9 +1626,7 @@ ConcreteInstance::ConcreteInstance(std::string_view name, name_(name), id_(ConcreteNetwork::nextObjectId()), cell_(cell), - parent_(parent), - children_(nullptr), - nets_(nullptr) + parent_(parent) { initPins(); } @@ -1738,13 +1745,13 @@ ConcreteInstance::addChild(ConcreteInstance *child) { if (children_ == nullptr) children_ = new ConcreteInstanceChildMap; - (*children_)[child->name().data()] = child; + (*children_)[child->name()] = child; } void ConcreteInstance::deleteChild(ConcreteInstance *child) { - children_->erase(child->name().data()); + children_->erase(child->name()); } void @@ -1769,7 +1776,7 @@ ConcreteInstance::addNet(ConcreteNet *net) { if (nets_ == nullptr) nets_ = new ConcreteInstanceNetMap; - (*nets_)[net->name().data()] = net; + (*nets_)[net->name()] = net; } void @@ -1778,13 +1785,13 @@ ConcreteInstance::addNet(std::string_view, { if (nets_ == nullptr) nets_ = new ConcreteInstanceNetMap; - (*nets_)[net->name().data()] = net; + (*nets_)[net->name()] = net; } void ConcreteInstance::deleteNet(ConcreteNet *net) { - nets_->erase(net->name().data()); + nets_->erase(net->name()); } void @@ -1801,15 +1808,11 @@ ConcretePin::ConcretePin(ConcreteInstance *instance, instance_(instance), port_(port), net_(net), - term_(nullptr), - id_(ConcreteNetwork::nextObjectId()), - net_next_(nullptr), - net_prev_(nullptr), - vertex_id_(vertex_id_null) + id_(ConcreteNetwork::nextObjectId()) { } -std::string_view +const std::string& ConcretePin::name() const { return port_->name(); @@ -1823,12 +1826,11 @@ ConcretePin::setVertexId(VertexId id) //////////////////////////////////////////////////////////////// -std::string_view +const std::string & ConcreteTerm::name() const { ConcretePin *cpin = reinterpret_cast(pin_); - const ConcretePort *cport = - reinterpret_cast(cpin->port()); + const ConcretePort *cport = cpin->port(); return cport->name(); } @@ -1836,8 +1838,7 @@ ConcreteTerm::ConcreteTerm(ConcretePin *pin, ConcreteNet *net) : pin_(pin), net_(net), - id_(ConcreteNetwork::nextObjectId()), - net_next_(nullptr) + id_(ConcreteNetwork::nextObjectId()) { } @@ -1847,10 +1848,7 @@ ConcreteNet::ConcreteNet(std::string_view name, ConcreteInstance *instance) : name_(name), id_(ConcreteNetwork::nextObjectId()), - instance_(instance), - pins_(nullptr), - terms_(nullptr), - merged_into_(nullptr) + instance_(instance) { } @@ -2125,4 +2123,4 @@ ConcreteBindingTbl::ensureBinding(Net *proto_net, return net; } -} // namespace +} // namespace sta diff --git a/network/HpinDrvrLoad.cc b/network/HpinDrvrLoad.cc index ab76900d..8aaf57b4 100644 --- a/network/HpinDrvrLoad.cc +++ b/network/HpinDrvrLoad.cc @@ -32,7 +32,7 @@ namespace sta { -typedef std::set HpinDrvrLoads; +using HpinDrvrLoads = std::set; static void visitPinsAboveNet2(const Pin *hpin, @@ -52,8 +52,8 @@ visitPinsBelowNet2(const Pin *hpin, PinSet *hpin_path, const Network *network); static void -visitHpinDrvrLoads(HpinDrvrLoads drvrs, - HpinDrvrLoads loads, +visitHpinDrvrLoads(HpinDrvrLoads &drvrs, + HpinDrvrLoads &loads, HpinDrvrLoadVisitor *visitor); void @@ -249,8 +249,8 @@ visitPinsBelowNet2(const Pin *hpin, } static void -visitHpinDrvrLoads(HpinDrvrLoads drvrs, - HpinDrvrLoads loads, +visitHpinDrvrLoads(HpinDrvrLoads &drvrs, + HpinDrvrLoads &loads, HpinDrvrLoadVisitor *visitor) { for (HpinDrvrLoad *drvr : drvrs) { @@ -326,4 +326,4 @@ HpinDrvrLoadLess::operator()(const HpinDrvrLoad *drvr_load1, return load1 < load2; } -} // namespace +} // namespace sta diff --git a/network/Network.cc b/network/Network.cc index ca1f085d..d096d842 100644 --- a/network/Network.cc +++ b/network/Network.cc @@ -29,22 +29,15 @@ #include #include "ContainerHelpers.hh" -#include "StringUtil.hh" -#include "PatternMatch.hh" #include "Liberty.hh" +#include "ParseBus.hh" +#include "PatternMatch.hh" #include "PortDirection.hh" #include "Scene.hh" -#include "ParseBus.hh" +#include "StringUtil.hh" namespace sta { -Network::Network() : - default_liberty_(nullptr), - divider_('/'), - escape_('\\') -{ -} - Network::~Network() { deleteContents(net_drvr_pin_map_); @@ -264,7 +257,7 @@ Network::pathName(const Instance *instance) const InstanceSeq inst_path; path(instance, inst_path); std::string path_name; - while (inst_path.size()) { + while (!inst_path.empty()) { const Instance *inst = inst_path.back(); path_name += name(inst); inst_path.pop_back(); @@ -1184,7 +1177,7 @@ Network::setPathEscape(char escape) //////////////////////////////////////////////////////////////// -typedef std::vector InstanceChildIteratorSeq; +using InstanceChildIteratorSeq = std::vector; class LeafInstanceIterator1 : public LeafInstanceIterator { @@ -1200,15 +1193,14 @@ private: const Network *network_; InstanceChildIteratorSeq pending_child_iters_; InstanceChildIterator *child_iter_; - Instance *next_; + Instance *next_{nullptr}; }; LeafInstanceIterator1::LeafInstanceIterator1(const Instance *inst, const Network *network) : network_(network), - child_iter_(network->childIterator(inst)), - next_(nullptr) + child_iter_(network->childIterator(inst)) { pending_child_iters_.reserve(8); nextInst(); @@ -1632,7 +1624,6 @@ Network::pathNameLast(std::string_view path_name, char divider = pathDivider(); size_t div_pos = path_name.rfind(divider); - size_t path_end = path_name.size(); while (div_pos > 0) { if (div_pos == std::string_view::npos) return; @@ -1642,27 +1633,18 @@ Network::pathNameLast(std::string_view path_name, last = path_name.substr(div_pos + 1); return; } - path_end = div_pos - 1; - div_pos = path_name.rfind(divider, path_end); + div_pos = path_name.rfind(divider, div_pos - 1); } } //////////////////////////////////////////////////////////////// -NetworkEdit::NetworkEdit() : - Network() -{ -} - -//////////////////////////////////////////////////////////////// - NetworkConstantPinIterator:: NetworkConstantPinIterator(const Network *network, NetSet &zero_nets, NetSet &one_nets) : ConstantPinIterator(), - network_(network), - constant_pins_{PinSet(network), PinSet(network)} + network_(network) { findConstantPins(zero_nets, constant_pins_[0]); findConstantPins(one_nets, constant_pins_[1]); @@ -1687,7 +1669,7 @@ NetworkConstantPinIterator::findConstantPins(NetSet &nets, bool NetworkConstantPinIterator::hasNext() { - if (pin_iter_ != constant_pins_[(int)value_].end()) + if (pin_iter_ != constant_pins_[static_cast(value_)].end()) return true; else if (value_ == LogicValue::zero) { value_ = LogicValue::one; @@ -1818,8 +1800,8 @@ visitPinsBelowNet1(const Pin *hpin, } static void -visitDrvrLoads(PinSet drvrs, - PinSet loads, +visitDrvrLoads(PinSet &drvrs, + PinSet &loads, HierPinThruVisitor *visitor) { for (const Pin *drvr : drvrs) { @@ -1921,8 +1903,8 @@ visitDrvrLoadsThruNet(const Net *net, char logicValueString(LogicValue value) { - static char str[] = "01X^v"; - return str[int(value)]; + static char names[] = "01X^v"; + return names[static_cast(value)]; } //////////////////////////////////////////////////////////////// @@ -2040,4 +2022,4 @@ NetSet::NetSet(const Network *network) : { } -} // namespace +} // namespace sta diff --git a/network/Network.i b/network/Network.i index 6af7c8a3..f36a91a0 100644 --- a/network/Network.i +++ b/network/Network.i @@ -28,8 +28,10 @@ %{ #include "Network.hh" -#include "StringUtil.hh" + #include + +#include "StringUtil.hh" %} //////////////////////////////////////////////////////////////// diff --git a/network/NetworkCmp.cc b/network/NetworkCmp.cc index cda43af7..2d0db2db 100644 --- a/network/NetworkCmp.cc +++ b/network/NetworkCmp.cc @@ -26,9 +26,9 @@ #include -#include "StringUtil.hh" #include "Liberty.hh" #include "Network.hh" +#include "StringUtil.hh" namespace sta { @@ -137,4 +137,4 @@ sortByPathName(NetSet *set, return nets; } -} // namespace +} // namespace sta diff --git a/network/ParseBus.cc b/network/ParseBus.cc index eb7f9898..f71e2e4f 100644 --- a/network/ParseBus.cc +++ b/network/ParseBus.cc @@ -90,7 +90,7 @@ parseBusName(std::string_view name, && left + 1 < len && isdigit(name[left + 1])) { is_bus = true; - bus_name.append(name.data(), left); + bus_name.append(name.substr(0, left)); // Simple bus subscript. index = std::stoi(std::string(name.substr(left + 1))); } @@ -146,17 +146,17 @@ parseBusName(std::string_view name, && left + 1 < len && (isdigit(name[left + 1]) || name[left + 1] == '*')) { is_bus = true; - bus_name.append(name.data(), left); - if (name[left + 1] == '*') - subscript_wild = true; + bus_name.append(name.substr(0, left)); + // Check for bus range. + size_t range = name.find(':', left); + if (range != std::string_view::npos) { + is_range = true; + from = std::stoi(std::string(name.substr(left + 1))); + to = std::stoi(std::string(name.substr(range + 1))); + } else { - // Check for bus range. - size_t range = name.find(':', left); - if (range != std::string_view::npos) { - is_range = true; - from = std::stoi(std::string(name.substr(left + 1))); - to = std::stoi(std::string(name.substr(range + 1))); - } + if (left + 1 < len && name[left + 1] == '*') + subscript_wild = true; else from = to = std::stoi(std::string(name.substr(left + 1))); } @@ -194,4 +194,4 @@ escapeChars(std::string_view token, return escaped; } -} // namespace +} // namespace sta diff --git a/network/PortDirection.cc b/network/PortDirection.cc index 608eb2b0..90df7a35 100644 --- a/network/PortDirection.cc +++ b/network/PortDirection.cc @@ -76,7 +76,7 @@ PortDirection::destroy() } PortDirection::PortDirection(const char *name, - int index) : + size_t index) : name_(name), index_(index) { @@ -135,4 +135,4 @@ PortDirection::isPowerGround() const || this == well_; } -} // namespace +} // namespace sta diff --git a/network/SdcNetwork.cc b/network/SdcNetwork.cc index e36b0acd..0542f95a 100644 --- a/network/SdcNetwork.cc +++ b/network/SdcNetwork.cc @@ -24,14 +24,13 @@ #include "SdcNetwork.hh" -#include "StringUtil.hh" -#include "PatternMatch.hh" #include "ParseBus.hh" +#include "PatternMatch.hh" +#include "StringUtil.hh" namespace sta { NetworkNameAdapter::NetworkNameAdapter(Network *network) : - NetworkEdit(), network_(network), network_edit_(dynamic_cast(network)) { @@ -822,9 +821,8 @@ SdcNetwork::findInstancesMatching1(const Instance *context, InstanceSeq &matches) const { visitMatches(context, pattern, - [&](const Instance *instance, - const PatternMatch *tail) - { + [&] (const Instance *instance, + const PatternMatch *tail) { size_t match_count = matches.size(); network_->findChildrenMatching(instance, tail, matches); return matches.size() != match_count; @@ -1193,7 +1191,7 @@ SdcNetwork::visitMatches(const Instance *parent, const PatternMatch *pattern, const std::function - visit_tail) const + &visit_tail) const { int divider_count, path_length; scanPath(pattern->pattern(), divider_count, path_length); @@ -1271,4 +1269,4 @@ escapeBrackets(std::string_view name, return escapeChars(name, '[', ']', network->pathEscape()); } -} // namespace +} // namespace sta diff --git a/network/VerilogNamespace.cc b/network/VerilogNamespace.cc index 28f07dc0..ed63cd3e 100644 --- a/network/VerilogNamespace.cc +++ b/network/VerilogNamespace.cc @@ -26,8 +26,8 @@ #include -#include "StringUtil.hh" #include "ParseBus.hh" +#include "StringUtil.hh" namespace sta { @@ -38,7 +38,7 @@ staToVerilog(std::string_view sta_name); static std::string staToVerilog2(std::string_view sta_name); static std::string -verilogToSta(const std::string_view verilog_name); +verilogToSta(std::string_view verilog_name); std::string cellVerilogName(std::string_view sta_name) @@ -219,4 +219,4 @@ verilogToSta(std::string_view verilog_name) return std::string(verilog_name); } -} // namespace +} // namespace sta diff --git a/parasitics/ConcreteParasitics.cc b/parasitics/ConcreteParasitics.cc index d85b4fa6..e015d5e2 100644 --- a/parasitics/ConcreteParasitics.cc +++ b/parasitics/ConcreteParasitics.cc @@ -26,18 +26,18 @@ #include // max -#include "Report.hh" +#include "ConcreteParasiticsPvt.hh" #include "Debug.hh" #include "Error.hh" -#include "Mutex.hh" -#include "MinMax.hh" -#include "Network.hh" -#include "Wireload.hh" #include "Liberty.hh" -#include "Sdc.hh" +#include "MinMax.hh" +#include "Mutex.hh" +#include "Network.hh" #include "Parasitics.hh" -#include "ConcreteParasiticsPvt.hh" +#include "Report.hh" #include "Scene.hh" +#include "Sdc.hh" +#include "Wireload.hh" // Multiple inheritance is used to share elmore and pi model base // classes, but care is taken to make sure there are no loops in the @@ -45,10 +45,6 @@ namespace sta { -ConcreteParasitic::~ConcreteParasitic() -{ -} - bool ConcreteParasitic::isPiElmore() const { @@ -138,8 +134,7 @@ ConcretePi::ConcretePi(float c2, float c1) : c2_(c2), rpi_(rpi), - c1_(c1), - is_reduced_(false) + c1_(c1) { } @@ -257,12 +252,6 @@ ConcretePiElmore::unannotatedLoads(const Pin *drvr_pin, //////////////////////////////////////////////////////////////// -ConcretePoleResidue::ConcretePoleResidue() : - poles_(nullptr), - residues_(nullptr) -{ -} - ConcretePoleResidue::~ConcretePoleResidue() { delete poles_; @@ -380,7 +369,7 @@ ConcretePiPoleResidue::unannotatedLoads(const Pin *drvr_pin, //////////////////////////////////////////////////////////////// ConcreteParasiticNode::ConcreteParasiticNode(const Net *net, - int id, + uint32_t id, bool is_external) : is_net_(true), is_external_(is_external), @@ -449,7 +438,7 @@ ConcreteParasiticNode::net(const Network *network) const //////////////////////////////////////////////////////////////// -ConcreteParasiticDevice::ConcreteParasiticDevice(size_t id, +ConcreteParasiticDevice::ConcreteParasiticDevice(uint32_t id, float value, ConcreteParasiticNode *node1, ConcreteParasiticNode *node2) : @@ -470,7 +459,7 @@ ConcreteParasiticDevice::replaceNode(ConcreteParasiticNode *from_node, node2_ = to_node; } -ConcreteParasiticResistor::ConcreteParasiticResistor(size_t id, +ConcreteParasiticResistor::ConcreteParasiticResistor(uint32_t id, float value, ConcreteParasiticNode *node1, ConcreteParasiticNode *node2) : @@ -478,7 +467,7 @@ ConcreteParasiticResistor::ConcreteParasiticResistor(size_t id, { } -ConcreteParasiticCapacitor::ConcreteParasiticCapacitor(size_t id, +ConcreteParasiticCapacitor::ConcreteParasiticCapacitor(uint32_t id, float value, ConcreteParasiticNode *node1, ConcreteParasiticNode *node2) : @@ -494,15 +483,15 @@ ConcreteParasiticNetwork::ConcreteParasiticNetwork(const Net *net, net_(net), sub_nodes_(network), pin_nodes_(network), - max_node_id_(0), includes_pin_caps_(includes_pin_caps) { } -ConcreteParasiticNetwork::ConcreteParasiticNetwork(ConcreteParasiticNetwork &¶sitic): +ConcreteParasiticNetwork::ConcreteParasiticNetwork(ConcreteParasiticNetwork &¶sitic) + noexcept : net_(parasitic.net_), - sub_nodes_(parasitic.sub_nodes_), - pin_nodes_(parasitic.pin_nodes_), + sub_nodes_(std::move(parasitic.sub_nodes_)), + pin_nodes_(std::move(parasitic.pin_nodes_)), max_node_id_(parasitic.max_node_id_), includes_pin_caps_(parasitic.includes_pin_caps_) { @@ -586,7 +575,7 @@ ConcreteParasiticNetwork::capacitance() const ConcreteParasiticNode * ConcreteParasiticNetwork::findParasiticNode(const Net *net, - int id, + uint32_t id, const Network *) const { NetIdPair net_id(net, id); @@ -609,7 +598,7 @@ ConcreteParasiticNetwork::findParasiticNode(const Pin *pin) const ConcreteParasiticNode * ConcreteParasiticNetwork::ensureParasiticNode(const Net *net, - int id, + uint32_t id, const Network *network) { ConcreteParasiticNode *node; @@ -620,7 +609,7 @@ ConcreteParasiticNetwork::ensureParasiticNode(const Net *net, node = new ConcreteParasiticNode(net, id, network->highestNetAbove(net1) != net_); sub_nodes_[net_id] = node; if (net == net_) - max_node_id_ = std::max((int) max_node_id_, id); + max_node_id_ = std::max(max_node_id_, id); } else node = id_node->second; @@ -752,8 +741,8 @@ NetIdPairLess::operator()(const NetIdPair &net_id1, //////////////////////////////////////////////////////////////// -ConcreteParasitics::ConcreteParasitics(std::string name, - std::string filename, +ConcreteParasitics::ConcreteParasitics(std::string_view name, + std::string_view filename, StaState *sta) : Parasitics(sta), name_(name), @@ -763,7 +752,7 @@ ConcreteParasitics::ConcreteParasitics(std::string name, ConcreteParasitics::~ConcreteParasitics() { - deleteParasitics(); + deleteParasiticsImpl(); } bool @@ -781,6 +770,12 @@ ConcreteParasitics::clear() void ConcreteParasitics::deleteParasitics() +{ + deleteParasiticsImpl(); +} + +void +ConcreteParasitics::deleteParasiticsImpl() { for (auto &[drvr, parasitics] : drvr_parasitic_map_) { for (size_t i = 0; i < min_max_rise_fall_count; i++) @@ -1209,7 +1204,7 @@ ConcreteParasitics::includesPinCaps(const Parasitic *parasitic) const ParasiticNode * ConcreteParasitics::findParasiticNode(Parasitic *parasitic, const Net *net, - int id, + uint32_t id, const Network *network) const { const ConcreteParasiticNetwork *cparasitic = @@ -1220,7 +1215,7 @@ ConcreteParasitics::findParasiticNode(Parasitic *parasitic, ParasiticNode * ConcreteParasitics::ensureParasiticNode(Parasitic *parasitic, const Net *net, - int id, + uint32_t id, const Network *network) { ConcreteParasiticNetwork *cparasitic = @@ -1257,7 +1252,7 @@ ConcreteParasitics::incrCap(ParasiticNode *node, void ConcreteParasitics::makeCapacitor(Parasitic *parasitic, - size_t index, + uint32_t id, float cap, ParasiticNode *node1, ParasiticNode *node2) @@ -1265,7 +1260,7 @@ ConcreteParasitics::makeCapacitor(Parasitic *parasitic, ConcreteParasiticNode *cnode1 = static_cast(node1); ConcreteParasiticNode *cnode2 = static_cast(node2); ConcreteParasiticCapacitor *capacitor = - new ConcreteParasiticCapacitor(index, cap, cnode1, cnode2); + new ConcreteParasiticCapacitor(id, cap, cnode1, cnode2); ConcreteParasiticNetwork *cparasitic = static_cast(parasitic); cparasitic->addCapacitor(capacitor); @@ -1273,14 +1268,14 @@ ConcreteParasitics::makeCapacitor(Parasitic *parasitic, void ConcreteParasitics::makeResistor(Parasitic *parasitic, - size_t index, + uint32_t id, float res, ParasiticNode *node1, ParasiticNode *node2) { ConcreteParasiticNode *cnode1 = static_cast(node1); ConcreteParasiticNode *cnode2 = static_cast(node2); - ParasiticResistor *resistor = new ConcreteParasiticResistor(index, res, + ParasiticResistor *resistor = new ConcreteParasiticResistor(id, res, cnode1, cnode2); ConcreteParasiticNetwork *cparasitic = static_cast(parasitic); @@ -1363,7 +1358,7 @@ ConcreteParasitics::isExternal(const ParasiticNode *node) const //////////////////////////////////////////////////////////////// -size_t +uint32_t ConcreteParasitics::id(const ParasiticResistor *resistor) const { const ConcreteParasiticResistor *cresistor = @@ -1397,7 +1392,7 @@ ConcreteParasitics::node2(const ParasiticResistor *resistor) const //////////////////////////////////////////////////////////////// -size_t +uint32_t ConcreteParasitics::id(const ParasiticCapacitor *capacitor) const { const ConcreteParasiticCapacitor *ccapacitor = @@ -1439,4 +1434,4 @@ ConcreteParasitics::unannotatedLoads(const Parasitic *parasitic, return cparasitic->unannotatedLoads(drvr_pin, this); } -} // namespace +} // namespace sta diff --git a/parasitics/ConcreteParasitics.hh b/parasitics/ConcreteParasitics.hh index a6486736..936609c1 100644 --- a/parasitics/ConcreteParasitics.hh +++ b/parasitics/ConcreteParasitics.hh @@ -50,10 +50,10 @@ using ConcreteParasiticNetworkMap = std::map + #include "Liberty.hh" -#include "PortDirection.hh" #include "Network.hh" -#include "Sdc.hh" #include "Parasitics.hh" +#include "PortDirection.hh" +#include "Sdc.hh" +#include "Wireload.hh" namespace sta { @@ -205,8 +207,7 @@ EstimateParasitics::estimatePiElmoreBalanced(const Pin *drvr_pin, else { c1 = static_cast(y2 * y2 / y3); c2 = static_cast(y1 - y2 * y2 / y3); - if (c2 < 0.0) - c2 = 0.0; + c2 = std::max(c2, 0.0f); rpi = static_cast(-y3 * y3 / (y2 * y2 * y2)); } elmore_res = static_cast(res_fanout); @@ -215,28 +216,4 @@ EstimateParasitics::estimatePiElmoreBalanced(const Pin *drvr_pin, } } -#if 0 -static void -selectWireload(Network *network) -{ - // Look for a default wireload selection group. - WireloadSelection *selection; - float area = instanceArea(network->topInstance(), network); - Wireload *wireload = selection->findWireload(area); -} - -static float -instanceArea(Instance *inst, - Network *network) -{ - float area = 0.0; - LeafInstanceIterator *inst_iter = network->leafInstanceIterator(); - while (network->hasNext(inst_iter)) { - Instance *leaf = network->next(inst_iter); - area += network->cell(leaf)->area(); - } - return area; -} -#endif - -} // namespace +} // namespace sta diff --git a/parasitics/EstimateParasitics.hh b/parasitics/EstimateParasitics.hh index f41cd5fe..f762198f 100644 --- a/parasitics/EstimateParasitics.hh +++ b/parasitics/EstimateParasitics.hh @@ -24,11 +24,11 @@ #pragma once -#include "StaState.hh" #include "LibertyClass.hh" #include "NetworkClass.hh" -#include "SdcClass.hh" #include "ParasiticsClass.hh" +#include "SdcClass.hh" +#include "StaState.hh" namespace sta { @@ -57,8 +57,8 @@ public: protected: void estimatePiElmoreBest(const Pin *drvr_pin, - float net_pin_cap, float wireload_cap, + float net_pin_cap, const RiseFall *rf, const Scene *scene, const MinMax *min_max, @@ -95,4 +95,4 @@ protected: bool &elmore_use_load_cap); }; -} // namespace +} // namespace sta diff --git a/parasitics/Parasitics.cc b/parasitics/Parasitics.cc index 69187f95..086ad9b4 100644 --- a/parasitics/Parasitics.cc +++ b/parasitics/Parasitics.cc @@ -24,23 +24,22 @@ #include "Parasitics.hh" -#include "Error.hh" #include "Debug.hh" -#include "Units.hh" +#include "Error.hh" +#include "EstimateParasitics.hh" #include "Liberty.hh" -#include "Wireload.hh" #include "Network.hh" #include "PortDirection.hh" -#include "Sdc.hh" -#include "Scene.hh" #include "ReduceParasitics.hh" -#include "EstimateParasitics.hh" +#include "Scene.hh" +#include "Sdc.hh" +#include "Units.hh" +#include "Wireload.hh" namespace sta { Parasitics::Parasitics(StaState *sta) : - StaState(sta), - coupling_cap_factor_(1.0) + StaState(sta) { } diff --git a/parasitics/ReduceParasitics.cc b/parasitics/ReduceParasitics.cc index 4282a7f4..231cdeba 100644 --- a/parasitics/ReduceParasitics.cc +++ b/parasitics/ReduceParasitics.cc @@ -28,21 +28,21 @@ #include #include -#include "Error.hh" #include "Debug.hh" -#include "MinMax.hh" +#include "Error.hh" #include "Liberty.hh" +#include "MinMax.hh" #include "Network.hh" -#include "Sdc.hh" -#include "Scene.hh" #include "Parasitics.hh" +#include "Scene.hh" +#include "Sdc.hh" namespace sta { -typedef std::map ParasiticNodeValueMap; -typedef std::map ResistorCurrentMap; -typedef std::set ParasiticResistorSet; -typedef std::set ParasiticNodeSet; +using ParasiticNodeValueMap = std::map; +using ResistorCurrentMap = std::map; +using ParasiticResistorSet = std::set; +using ParasiticNodeSet = std::set; class ReduceToPi : public StaState { @@ -82,26 +82,21 @@ protected: Parasitics *parasitics_; bool includes_pin_caps_; - float coupling_cap_multiplier_; - const RiseFall *rf_; - const Scene *scene_; - const MinMax *min_max_; + float coupling_cap_multiplier_ {1.0}; + const RiseFall *rf_ {nullptr}; + const Scene *scene_ {nullptr}; + const MinMax *min_max_ {nullptr}; ParasiticNodeResistorMap resistor_map_; ParasiticNodeCapacitorMap capacitor_map_; ParasiticNodeSet visited_nodes_; ParasiticNodeValueMap node_values_; ParasiticResistorSet loop_resistors_; - bool pin_caps_one_value_; + bool pin_caps_one_value_ {true}; }; ReduceToPi::ReduceToPi(StaState *sta) : - StaState(sta), - coupling_cap_multiplier_(1.0), - rf_(nullptr), - scene_(nullptr), - min_max_(nullptr), - pin_caps_one_value_(true) + StaState(sta) { } @@ -340,7 +335,7 @@ ReduceToPiElmore::makePiElmore(const Parasitic *parasitic_network, Parasitic *pi_elmore = parasitics_->makePiElmore(drvr_pin, rf, min_max, c2, rpi, c1); parasitics_->setIsReducedParasiticNetwork(pi_elmore, true); - reduceElmoreDfs(drvr_pin, drvr_node, 0, 0.0, pi_elmore); + reduceElmoreDfs(drvr_pin, drvr_node, nullptr, 0.0, pi_elmore); return pi_elmore; } @@ -383,7 +378,7 @@ class ReduceToPiPoleResidue2 : public ReduceToPi { public: ReduceToPiPoleResidue2(StaState *sta); - ~ReduceToPiPoleResidue2(); + ~ReduceToPiPoleResidue2() override; void findPolesResidues(const Parasitic *parasitic_network, Parasitic *pi_pole_residue, const Pin *drvr_pin, @@ -424,12 +419,11 @@ private: // Resistor/capacitor currents. ResistorCurrentMap currents_; - ParasiticNodeValueMap *moments_; + ParasiticNodeValueMap *moments_ {nullptr}; }; ReduceToPiPoleResidue2::ReduceToPiPoleResidue2(StaState *sta) : - ReduceToPi(sta), - moments_(nullptr) + ReduceToPi(sta) { } @@ -526,10 +520,10 @@ ReduceToPiPoleResidue2::findMoments(const Pin *drvr_pin, // current thru the resistors. Thus, there is no point in doing a // pass to find the zero'th moments. for (int moment_index = 1; moment_index < moment_count; moment_index++) { - double rd_i = findBranchCurrents(drvr_pin, drvr_node, 0, moment_index); + double rd_i = findBranchCurrents(drvr_pin, drvr_node, nullptr, moment_index); double rd_volt = rd_i * rd; setMoment(drvr_node, 0.0, moment_index); - findMoments(drvr_pin, drvr_node, -rd_volt, 0, moment_index); + findMoments(drvr_pin, drvr_node, -rd_volt, nullptr, moment_index); } } @@ -688,4 +682,4 @@ ReduceToPiPoleResidue2::findPolesResidues(Parasitic *pi_pole_residue, } } -} // namespace +} // namespace sta diff --git a/parasitics/ReduceParasitics.hh b/parasitics/ReduceParasitics.hh index 2fd62362..8268d857 100644 --- a/parasitics/ReduceParasitics.hh +++ b/parasitics/ReduceParasitics.hh @@ -55,4 +55,4 @@ reduceToPiPoleResidue2(const Parasitic *parasitic_network, const MinMax *min_max, StaState *sta); -} // namespace +} // namespace sta diff --git a/parasitics/ReportParasiticAnnotation.cc b/parasitics/ReportParasiticAnnotation.cc index f91db926..f9651e57 100644 --- a/parasitics/ReportParasiticAnnotation.cc +++ b/parasitics/ReportParasiticAnnotation.cc @@ -24,15 +24,15 @@ #include "ReportParasiticAnnotation.hh" +#include "ArcDelayCalc.hh" #include "ContainerHelpers.hh" -#include "Report.hh" +#include "Graph.hh" #include "Network.hh" #include "NetworkCmp.hh" -#include "PortDirection.hh" -#include "Graph.hh" -#include "Scene.hh" #include "Parasitics.hh" -#include "ArcDelayCalc.hh" +#include "PortDirection.hh" +#include "Report.hh" +#include "Scene.hh" namespace sta { @@ -43,7 +43,7 @@ public: bool report_unannotated, const Scene *scene, StaState *sta); - void report(); + void reportAnnotation(); private: void reportAnnotationCounts(); @@ -67,7 +67,7 @@ reportParasiticAnnotation(Parasitics *parasitics, { ReportParasiticAnnotation report_annotation(parasitics, report_unannotated, scene, sta); - report_annotation.report(); + report_annotation.reportAnnotation(); } ReportParasiticAnnotation::ReportParasiticAnnotation(Parasitics *parasitics, @@ -83,7 +83,7 @@ ReportParasiticAnnotation::ReportParasiticAnnotation(Parasitics *parasitics, } void -ReportParasiticAnnotation::report() +ReportParasiticAnnotation::reportAnnotation() { findCounts(); reportAnnotationCounts(); @@ -132,7 +132,7 @@ ReportParasiticAnnotation::findCounts() arc_delay_calc_->findParasitic(pin, RiseFall::rise(), scene_, min_max_); if (parasitic) { PinSet unannotated_loads = parasitics_->unannotatedLoads(parasitic, pin); - if (unannotated_loads.size() > 0) + if (!unannotated_loads.empty()) partially_annotated_.push_back(pin); } else diff --git a/parasitics/ReportParasiticAnnotation.hh b/parasitics/ReportParasiticAnnotation.hh index 6c9274d4..fab788bf 100644 --- a/parasitics/ReportParasiticAnnotation.hh +++ b/parasitics/ReportParasiticAnnotation.hh @@ -36,4 +36,4 @@ reportParasiticAnnotation(Parasitics *parasitics, const Scene *scene, StaState *sta); -} // namespace +} // namespace sta diff --git a/parasitics/SpefNamespace.cc b/parasitics/SpefNamespace.cc index 4a1d7063..9c380a01 100644 --- a/parasitics/SpefNamespace.cc +++ b/parasitics/SpefNamespace.cc @@ -114,4 +114,4 @@ staToSpef(std::string_view sta_name, return spef_name; } -} // namespace +} // namespace sta diff --git a/parasitics/SpefNamespace.hh b/parasitics/SpefNamespace.hh index 4ec55f29..6761b21e 100644 --- a/parasitics/SpefNamespace.hh +++ b/parasitics/SpefNamespace.hh @@ -42,4 +42,4 @@ staToSpef(std::string_view sta_name, char path_divider, char path_escape); -} // namespace +} // namespace sta diff --git a/parasitics/SpefParse.yy b/parasitics/SpefParse.yy index e527d781..fed603c0 100755 --- a/parasitics/SpefParse.yy +++ b/parasitics/SpefParse.yy @@ -47,10 +47,18 @@ sta::SpefParse::error(const location_type &loc, %code requires { #include +#include "StringUtil.hh" namespace sta { // Bison's C++ variant skeleton cannot use void as a semantic type. struct SpefParseVoid {}; +class SpefReader; +class SpefScanner; +class Net; +class Pin; +class PortDirection; +class SpefRspfPi; +class SpefTriple; } } diff --git a/parasitics/SpefReader.cc b/parasitics/SpefReader.cc index 84eacea7..05141673 100644 --- a/parasitics/SpefReader.cc +++ b/parasitics/SpefReader.cc @@ -28,21 +28,21 @@ #include #include -#include "Zlib.hh" -#include "Stats.hh" -#include "Report.hh" +#include "ArcDelayCalc.hh" #include "Debug.hh" -#include "StringUtil.hh" -#include "Transition.hh" #include "Liberty.hh" #include "Network.hh" -#include "PortDirection.hh" -#include "Sdc.hh" #include "Parasitics.hh" +#include "PortDirection.hh" +#include "Report.hh" #include "Scene.hh" -#include "ArcDelayCalc.hh" -#include "SpefReaderPvt.hh" +#include "Sdc.hh" #include "SpefNamespace.hh" +#include "SpefReaderPvt.hh" +#include "Stats.hh" +#include "StringUtil.hh" +#include "Transition.hh" +#include "Zlib.hh" #include "parasitics/SpefScanner.hh" namespace sta { @@ -84,25 +84,11 @@ SpefReader::SpefReader(std::string_view filename, reduce_(reduce), scene_(scene), min_max_(min_max), - // defaults - divider_('\0'), - delimiter_('\0'), - bus_brkt_left_('\0'), - bus_brkt_right_('\0'), - net_(nullptr), - triple_index_(0), - time_scale_(1.0), - cap_scale_(1.0), - res_scale_(1.0), - induct_scale_(1.0), - parasitics_(parasitics), - parasitic_(nullptr) + parasitics_(parasitics) { parasitics->setCouplingCapFactor(coupling_cap_factor); } -SpefReader::~SpefReader() {} - bool SpefReader::read() { @@ -454,7 +440,7 @@ SpefReader::findParasiticNode(std::string_view name, if (net) { // : if (isDigits(name2)) { - int id = std::stoi(name2); + uint32_t id = std::stoi(name2); if (local_only && !network_->isConnected(net, net_)) warn(1653, "{}{}{} not connected to net {}.", name1, delimiter_, name2, network_->pathName(net_)); @@ -489,7 +475,7 @@ SpefReader::findParasiticNode(std::string_view name, } void -SpefReader::makeCapacitor(int, +SpefReader::makeCapacitor(uint32_t, std::string_view node_name, SpefTriple *cap) { @@ -502,7 +488,7 @@ SpefReader::makeCapacitor(int, } void -SpefReader::makeCapacitor(int id, +SpefReader::makeCapacitor(uint32_t id, std::string_view node_name1, std::string_view node_name2, SpefTriple *cap) @@ -525,7 +511,7 @@ SpefReader::makeCapacitor(int id, } void -SpefReader::makeResistor(int id, +SpefReader::makeResistor(uint32_t id, std::string_view node_name1, std::string_view node_name2, SpefTriple *res) diff --git a/parasitics/SpefReader.hh b/parasitics/SpefReader.hh index d07e8a63..4708fc1c 100644 --- a/parasitics/SpefReader.hh +++ b/parasitics/SpefReader.hh @@ -27,9 +27,9 @@ #include #include -#include "Zlib.hh" #include "MinMax.hh" #include "ParasiticsClass.hh" +#include "Zlib.hh" namespace sta { @@ -52,7 +52,7 @@ readSpefFile(std::string_view filename, bool reduce, const Scene *scene, const MinMaxAll *min_max, - Parasitics *parasirics, + Parasitics *parasitics, StaState *sta); -} // namespace +} // namespace sta diff --git a/parasitics/SpefReaderPvt.hh b/parasitics/SpefReaderPvt.hh index 272d7ef1..4b1b90ff 100644 --- a/parasitics/SpefReaderPvt.hh +++ b/parasitics/SpefReaderPvt.hh @@ -28,11 +28,11 @@ #include #include -#include "Zlib.hh" -#include "StringUtil.hh" #include "NetworkClass.hh" #include "ParasiticsClass.hh" #include "StaState.hh" +#include "StringUtil.hh" +#include "Zlib.hh" namespace sta { @@ -58,7 +58,7 @@ public: const MinMaxAll *min_max, Parasitics *parasitics, StaState *sta); - virtual ~SpefReader(); + ~SpefReader() override = default; bool read(); char divider() const { return divider_; } void setDivider(char divider); @@ -94,14 +94,14 @@ public: void dspfBegin(Net *net, SpefTriple *total_cap); void dspfFinish(); - void makeCapacitor(int id, + void makeCapacitor(uint32_t id, std::string_view node_name, SpefTriple *cap); - void makeCapacitor(int id, + void makeCapacitor(uint32_t id, std::string_view node_name1, std::string_view node_name2, SpefTriple *cap); - void makeResistor(int id, + void makeResistor(uint32_t id, std::string_view node_name1, std::string_view node_name2, SpefTriple *res); @@ -134,21 +134,21 @@ private: const Scene *scene_; const MinMaxAll *min_max_; // Normally no need to keep device names. - char divider_; - char delimiter_; - char bus_brkt_left_; - char bus_brkt_right_; - Net *net_; + char divider_{'\0'}; + char delimiter_{'\0'}; + char bus_brkt_left_{'\0'}; + char bus_brkt_right_{'\0'}; + Net *net_{nullptr}; - int triple_index_; - float time_scale_; - float cap_scale_; - float res_scale_; - float induct_scale_; + int triple_index_{0}; + float time_scale_{1.0}; + float cap_scale_{1.0}; + float res_scale_{1.0}; + float induct_scale_{1.0}; SpefNameMap name_map_; StringSeq design_flow_; Parasitics *parasitics_; - Parasitic *parasitic_; + Parasitic *parasitic_{nullptr}; }; class SpefTriple @@ -181,4 +181,4 @@ private: SpefTriple *c1_; }; -} // namespace +} // namespace sta diff --git a/parasitics/SpefScanner.hh b/parasitics/SpefScanner.hh index c87a43c0..d9c21b86 100644 --- a/parasitics/SpefScanner.hh +++ b/parasitics/SpefScanner.hh @@ -46,9 +46,7 @@ public: std::string_view filename, SpefReader *reader, Report *report); - virtual ~SpefScanner() {} - - virtual int lex(SpefParse::semantic_type *const yylval, + virtual int lex(SpefParse::semantic_type *yylval, SpefParse::location_type *yylloc); // YY_DECL defined in SpefLex.ll // Method body created by flex in SpefLex.cc @@ -66,4 +64,4 @@ private: std::string token_; }; -} // namespace +} // namespace sta diff --git a/power/Power.cc b/power/Power.cc index 78d9adce..da1b5e08 100644 --- a/power/Power.cc +++ b/power/Power.cc @@ -26,38 +26,52 @@ #include // max #include // abs +#include +#include +#include +#include -#include "cudd.h" -#include "ContainerHelpers.hh" -#include "Stats.hh" -#include "Debug.hh" -#include "EnumNameMap.hh" -#include "Hash.hh" -#include "MinMax.hh" -#include "Units.hh" -#include "Transition.hh" -#include "TimingRole.hh" -#include "Liberty.hh" -#include "InternalPower.hh" -#include "LeakagePower.hh" -#include "Sequential.hh" -#include "TimingArc.hh" -#include "FuncExpr.hh" -#include "PortDirection.hh" -#include "Network.hh" -#include "Clock.hh" -#include "Sdc.hh" -#include "Mode.hh" -#include "Graph.hh" -#include "GraphDelayCalc.hh" -#include "Scene.hh" -#include "Path.hh" -#include "search/Levelize.hh" -#include "search/Sim.hh" -#include "Search.hh" #include "Bfs.hh" #include "ClkNetwork.hh" +#include "Clock.hh" +#include "ContainerHelpers.hh" +#include "Debug.hh" +#include "Delay.hh" +#include "EnumNameMap.hh" +#include "Error.hh" +#include "FuncExpr.hh" +#include "Graph.hh" +#include "GraphClass.hh" +#include "GraphDelayCalc.hh" +#include "Hash.hh" +#include "InternalPower.hh" +#include "LeakagePower.hh" +#include "Liberty.hh" +#include "LibertyClass.hh" +#include "MinMax.hh" +#include "Mode.hh" +#include "Network.hh" +#include "NetworkClass.hh" +#include "NetworkCmp.hh" +#include "Path.hh" +#include "PortDirection.hh" +#include "PowerClass.hh" #include "ReportPower.hh" +#include "Scene.hh" +#include "Sdc.hh" +#include "SdcClass.hh" +#include "Search.hh" +#include "SearchClass.hh" +#include "Sequential.hh" +#include "Stats.hh" +#include "TimingArc.hh" +#include "TimingRole.hh" +#include "Transition.hh" +#include "Units.hh" +#include "VertexVisitor.hh" +#include "cudd.h" +#include "search/Levelize.hh" +#include "search/Sim.hh" // Related liberty not supported: // library @@ -90,16 +104,7 @@ static EnumNameMap pwr_activity_origin_map = { Power::Power(StaState *sta) : StaState(sta), - scene_(nullptr), - global_activity_(), - input_activity_(), // default set in ensureActivities. - seq_activity_map_(100, - SeqPinHash(network_), - SeqPinEqual()), - activities_valid_(false), - bdd_(sta), - instance_powers_(InstanceIdLess(network_)), - instance_powers_valid_(false) + bdd_(sta) { } @@ -399,7 +404,7 @@ Power::sortInstsByPower(const InstanceSeq &insts, InstPowers inst_pwrs; for (const Instance *inst : insts) { PowerResult inst_power = power(inst, scene); - inst_pwrs.push_back(std::make_pair(inst, inst_power)); + inst_pwrs.emplace_back(inst, inst_power); } // Sort by total power (descending) @@ -505,7 +510,7 @@ Power::highestInstPowers(size_t count, while (inst_iter->hasNext()) { Instance *inst = inst_iter->next(); PowerResult pwr = power(inst, scene); - inst_pwrs.push_back(std::make_pair(inst, pwr)); + inst_pwrs.emplace_back(inst, pwr); } delete inst_iter; @@ -570,8 +575,8 @@ public: PropActivityVisitor(Power *power, const Mode *mode, BfsFwdIterator *bfs); - virtual VertexVisitor *copy() const; - virtual void visit(Vertex *vertex); + VertexVisitor *copy() const override; + void visit(Vertex *vertex) override; InstanceSet &visitedRegs() { return visited_regs_; } void init(); float maxChange() const { return max_change_; } @@ -583,8 +588,8 @@ private: static constexpr float change_tolerance_ = .01; InstanceSet visited_regs_; - float max_change_; - const Pin *max_change_pin_; + float max_change_{0.0}; + const Pin *max_change_pin_{nullptr}; BfsFwdIterator *bfs_; Power *power_; const Mode *mode_; @@ -595,8 +600,6 @@ PropActivityVisitor::PropActivityVisitor(Power *power, BfsFwdIterator *bfs) : StaState(power), visited_regs_(network_), - max_change_(0.0), - max_change_pin_(nullptr), bfs_(bfs), power_(power), mode_(mode) @@ -1445,28 +1448,15 @@ Power::findSwitchingPower(const Instance *inst, class LeakageSummary { public: - LeakageSummary(); - - bool cond_exists; - float cond_leakage; - float cond_duty_sum; - bool cond_true_exists; - float cond_true_leakage; - bool uncond_exists; - float uncond_leakage; + bool cond_exists{false}; + float cond_leakage{0.0}; + float cond_duty_sum{0.0}; + bool cond_true_exists{false}; + float cond_true_leakage{0.0}; + bool uncond_exists{false}; + float uncond_leakage{0.0}; }; -LeakageSummary::LeakageSummary() : - cond_exists(false), - cond_leakage(0.0), - cond_duty_sum(0.0), - cond_true_exists(false), - cond_true_leakage(0.0), - uncond_exists(false), - uncond_leakage(0.0) -{ -} - void Power::findLeakagePower(const Instance *inst, LibertyCell *cell, @@ -1804,13 +1794,6 @@ Power::powerInvalid() //////////////////////////////////////////////////////////////// -PowerResult::PowerResult() : - internal_(0.0), - switching_(0.0), - leakage_(0.0) -{ -} - void PowerResult::clear() { @@ -1863,13 +1846,6 @@ PwrActivity::PwrActivity(float density, check(); } -PwrActivity::PwrActivity() : - density_(0.0), - duty_(0.0), - origin_(PwrActivityOrigin::unknown) -{ -} - void PwrActivity::setDensity(float density) { diff --git a/power/Power.hh b/power/Power.hh index 72471047..8a19f309 100644 --- a/power/Power.hh +++ b/power/Power.hh @@ -24,16 +24,16 @@ #pragma once -#include #include #include +#include -#include "StaConfig.hh" // CUDD -#include "Network.hh" -#include "SdcClass.hh" -#include "PowerClass.hh" -#include "StaState.hh" #include "Bdd.hh" +#include "Network.hh" +#include "PowerClass.hh" +#include "SdcClass.hh" +#include "StaConfig.hh" // CUDD +#include "StaState.hh" struct DdNode; struct DdManager; @@ -107,20 +107,20 @@ public: PowerResult power(const Instance *inst, const Scene *scene); - void setGlobalActivity(float activity, + void setGlobalActivity(float density, float duty); void unsetGlobalActivity(); - void setInputActivity(float activity, + void setInputActivity(float density, float duty); void unsetInputActivity(); void setInputPortActivity(const Port *input_port, - float activity, + float density, float duty); void unsetInputPortActivity(const Port *input_port); PwrActivity pinActivity(const Pin *pin, const Scene *scene); void setUserActivity(const Pin *pin, - float activity, + float density, float duty, PwrActivityOrigin origin); void unsetUserActivity(const Pin *pin); @@ -255,7 +255,7 @@ protected: size_t pinCount(); private: - const Scene *scene_; + const Scene *scene_{nullptr}; // Port/pin activities set by set_pin_activity. // set_pin_activity -global PwrActivity global_activity_; @@ -265,15 +265,18 @@ private: PwrActivityMap user_activity_map_; // Propagated activities. PwrActivityMap activity_map_; - PwrSeqActivityMap seq_activity_map_; - bool activities_valid_; + PwrSeqActivityMap seq_activity_map_{100, + SeqPinHash(network_), + SeqPinEqual()}; + bool activities_valid_{false}; Bdd bdd_; - std::map instance_powers_; - bool instance_powers_valid_; + std::map instance_powers_{ + InstanceIdLess(network_)}; + bool instance_powers_valid_{false}; static constexpr int max_activity_passes_ = 50; friend class PropActivityVisitor; }; -} // namespace +} // namespace sta diff --git a/power/Power.i b/power/Power.i index bc818668..52d77af7 100644 --- a/power/Power.i +++ b/power/Power.i @@ -25,12 +25,13 @@ %module power %{ -#include "Sta.hh" -#include "Sdc.hh" -#include "Mode.hh" #include "power/Power.hh" -#include "power/VcdReader.hh" + +#include "Mode.hh" +#include "Sdc.hh" +#include "Sta.hh" #include "power/SaifReader.hh" +#include "power/VcdReader.hh" using namespace sta; diff --git a/power/ReportPower.cc b/power/ReportPower.cc index 00407ff6..16de910a 100644 --- a/power/ReportPower.cc +++ b/power/ReportPower.cc @@ -24,12 +24,12 @@ #include "ReportPower.hh" -#include #include +#include -#include "Report.hh" -#include "Network.hh" #include "Format.hh" +#include "Network.hh" +#include "Report.hh" namespace sta { diff --git a/power/ReportPower.hh b/power/ReportPower.hh index 0486f8d7..105a9a00 100644 --- a/power/ReportPower.hh +++ b/power/ReportPower.hh @@ -26,9 +26,9 @@ #include -#include "StaState.hh" #include "NetworkClass.hh" #include "PowerClass.hh" +#include "StaState.hh" namespace sta { @@ -90,4 +90,4 @@ private: int digits); }; -} // namespace +} // namespace sta diff --git a/power/SaifParse.yy b/power/SaifParse.yy index 9413cbce..a447a0cb 100644 --- a/power/SaifParse.yy +++ b/power/SaifParse.yy @@ -60,6 +60,10 @@ sta::SaifParse::error(const location_type &loc, %define api.parser.class {SaifParse} %define api.value.type variant +%code requires { +#include "power/SaifReaderPvt.hh" +} + // expected shift/reduce conflicts %expect 2 diff --git a/power/SaifReader.cc b/power/SaifReader.cc index 98e21e76..b05b6c12 100644 --- a/power/SaifReader.cc +++ b/power/SaifReader.cc @@ -29,18 +29,18 @@ #include #include -#include "Error.hh" #include "Debug.hh" -#include "Stats.hh" -#include "Report.hh" +#include "Error.hh" +#include "Liberty.hh" #include "Network.hh" #include "PortDirection.hh" -#include "Liberty.hh" -#include "Sdc.hh" #include "Power.hh" +#include "Report.hh" +#include "Sdc.hh" +#include "Sta.hh" +#include "Stats.hh" #include "power/SaifReaderPvt.hh" #include "power/SaifScanner.hh" -#include "Sta.hh" namespace sta { @@ -60,11 +60,6 @@ SaifReader::SaifReader(const char *filename, StaState(sta), filename_(filename), scope_(scope), - divider_('/'), - escape_('\\'), - timescale_(1.0E-9F), // default units of ns - duration_(0.0), - in_scope_level_(0), power_(sta->power()) { } diff --git a/power/SaifReader.hh b/power/SaifReader.hh index e9197914..8f408fd9 100644 --- a/power/SaifReader.hh +++ b/power/SaifReader.hh @@ -33,4 +33,4 @@ readSaif(const char *filename, const char *scope, Sta *sta); -} // namespace +} // namespace sta diff --git a/power/SaifReaderPvt.hh b/power/SaifReaderPvt.hh index c0fee41f..243e14dc 100644 --- a/power/SaifReaderPvt.hh +++ b/power/SaifReaderPvt.hh @@ -26,14 +26,13 @@ #include #include -#include -#include #include -#include +#include +#include -#include "Zlib.hh" #include "NetworkClass.hh" #include "StaState.hh" +#include "Zlib.hh" // Header for SaifReader.cc to communicate with SaifLex.cc, SaifParse.cc @@ -73,16 +72,16 @@ private: const char *filename_; const char *scope_; // Divider delimited scope to begin annotation. - char divider_; - char escape_; - double timescale_; - int64_t duration_; + char divider_ = '/'; + char escape_ = '\\'; + double timescale_ = 1.0E-9; // default units of ns + int64_t duration_ = 0; std::vector saif_scope_; // Scope during parsing. - size_t in_scope_level_; + size_t in_scope_level_ = 0; std::vector path_; // Path within scope. std::set annotated_pins_; Power *power_; }; -} // namespace +} // namespace sta diff --git a/power/SaifScanner.hh b/power/SaifScanner.hh index 0fa4a805..9ca6867f 100644 --- a/power/SaifScanner.hh +++ b/power/SaifScanner.hh @@ -36,6 +36,7 @@ namespace sta { class Report; +class SaifReader; class SaifScanner : public SaifFlexLexer { @@ -44,9 +45,7 @@ public: const std::string &filename, SaifReader *reader, Report *report); - virtual ~SaifScanner() {} - - virtual int lex(SaifParse::semantic_type *const yylval, + virtual int lex(SaifParse::semantic_type *yylval, SaifParse::location_type *yylloc); // YY_DECL defined in SaifLex.ll // Method body created by flex in SaifLex.cc @@ -63,4 +62,4 @@ private: std::string token_; }; -} // namespace +} // namespace sta diff --git a/power/VcdParse.cc b/power/VcdParse.cc index ea0d71a7..2a841427 100644 --- a/power/VcdParse.cc +++ b/power/VcdParse.cc @@ -28,10 +28,10 @@ #include #include -#include "Stats.hh" -#include "Report.hh" -#include "Error.hh" #include "EnumNameMap.hh" +#include "Error.hh" +#include "Report.hh" +#include "Stats.hh" namespace sta { @@ -106,11 +106,6 @@ VcdParse::read(const char *filename, VcdParse::VcdParse(Report *report, Debug *debug) : - reader_(nullptr), - file_line_(0), - stmt_line_(0), - time_(0), - prev_time_(0), report_(report), debug_(debug) { @@ -237,7 +232,7 @@ VcdParse::parseVarValues() report_->fileError(807, filename_, file_line_, "unknown variable {}", id); else { // Reverse the bus value to match the bit order in the VCD file. - std::reverse(bus_value.begin(), bus_value.end()); + std::ranges::reverse(bus_value); reader_->varAppendBusValue(id, time_, bus_value); } } diff --git a/power/VcdParse.hh b/power/VcdParse.hh index 69a3f7d0..66f5d28f 100644 --- a/power/VcdParse.hh +++ b/power/VcdParse.hh @@ -28,8 +28,8 @@ #include #include -#include "Zlib.hh" #include "StaState.hh" +#include "Zlib.hh" namespace sta { @@ -78,15 +78,15 @@ private: std::string readStmtString(); std::vector readStmtTokens(); - VcdReader *reader_; + VcdReader *reader_ = nullptr; gzFile stream_; std::string token_; const char *filename_; - int file_line_; - int stmt_line_; + int file_line_ = 0; + int stmt_line_ = 0; - VcdTime time_; - VcdTime prev_time_; + VcdTime time_ = 0; + VcdTime prev_time_ = 0; VcdScope scope_; Report *report_; @@ -97,7 +97,7 @@ private: class VcdReader { public: - virtual ~VcdReader() {} + virtual ~VcdReader() = default; virtual void setDate(std::string_view date) = 0; virtual void setComment(std::string_view comment) = 0; virtual void setVersion(std::string_view version) = 0; @@ -139,4 +139,4 @@ private: uint64_t bus_value_; }; -} // namespace +} // namespace sta diff --git a/power/VcdReader.cc b/power/VcdReader.cc index ee6e6037..a300c90f 100644 --- a/power/VcdReader.cc +++ b/power/VcdReader.cc @@ -25,21 +25,21 @@ #include "VcdReader.hh" #include -#include +#include #include #include -#include "VcdParse.hh" #include "Debug.hh" -#include "Network.hh" #include "Liberty.hh" -#include "PortDirection.hh" -#include "VerilogNamespace.hh" -#include "ParseBus.hh" -#include "Sdc.hh" #include "Mode.hh" +#include "Network.hh" +#include "ParseBus.hh" +#include "PortDirection.hh" #include "Power.hh" +#include "Sdc.hh" #include "Sta.hh" +#include "VcdParse.hh" +#include "VerilogNamespace.hh" namespace sta { @@ -48,7 +48,6 @@ namespace sta { class VcdCount { public: - VcdCount(); double transitionCount() const { return transition_count_; } VcdTime highTime(VcdTime time_max) const; void incrCounts(VcdTime time, @@ -60,20 +59,12 @@ public: private: PinSeq pins_; - VcdTime prev_time_; - char prev_value_; - VcdTime high_time_; - double transition_count_; + VcdTime prev_time_ = -1; + char prev_value_ = '\0'; + VcdTime high_time_ = 0; + double transition_count_ = 0; }; -VcdCount::VcdCount() : - prev_time_(-1), - prev_value_('\0'), - high_time_(0), - transition_count_(0) -{ -} - void VcdCount::addPin(const Pin *pin) { @@ -157,9 +148,9 @@ private: const std::string scope_; - double time_scale_; - VcdTime time_min_; - VcdTime time_max_; + double time_scale_ = 1.0; + VcdTime time_min_ = 0; + VcdTime time_max_ = 0; VcdIdCountsMap vcd_count_map_; const Network *sdc_network_; @@ -172,9 +163,6 @@ VcdCountReader::VcdCountReader(std::string_view scope, Report *report, Debug *debug) : scope_(scope), - time_scale_(1.0), - time_min_(0), - time_max_(0), sdc_network_(sdc_network), report_(report), debug_(debug) @@ -299,16 +287,14 @@ VcdCountReader::varAppendValue(const std::string &id, if (itr != vcd_count_map_.end()) { VcdCounts &vcd_counts = itr->second; if (debug_->check("read_vcd", 3)) { - for (size_t bit_idx = 0; bit_idx < vcd_counts.size(); bit_idx++) { - VcdCount &vcd_count = vcd_counts[bit_idx]; + for (auto &vcd_count : vcd_counts) { for (const Pin *pin : vcd_count.pins()) { debugPrint(debug_, "read_vcd", 3, "{} time {} value {}", sdc_network_->pathName(pin), time, value); } } } - for (size_t bit_idx = 0; bit_idx < vcd_counts.size(); bit_idx++) { - VcdCount &vcd_count = vcd_counts[bit_idx]; + for (auto &vcd_count : vcd_counts) { vcd_count.incrCounts(time, value); } } diff --git a/power/VcdReader.hh b/power/VcdReader.hh index 205779a6..e3b0bafc 100644 --- a/power/VcdReader.hh +++ b/power/VcdReader.hh @@ -36,4 +36,4 @@ readVcdActivities(std::string_view filename, std::string_view mode_name, Sta *sta); -} // namespace +} // namespace sta diff --git a/sdc/Clock.cc b/sdc/Clock.cc index f2c91633..d38e384b 100644 --- a/sdc/Clock.cc +++ b/sdc/Clock.cc @@ -25,17 +25,18 @@ #include "Clock.hh" #include +#include #include "ContainerHelpers.hh" #include "Error.hh" #include "Format.hh" -#include "StringUtil.hh" -#include "MinMax.hh" -#include "Transition.hh" -#include "TimingRole.hh" -#include "Network.hh" #include "Graph.hh" +#include "MinMax.hh" +#include "Network.hh" #include "Sdc.hh" +#include "StringUtil.hh" +#include "TimingRole.hh" +#include "Transition.hh" namespace sta { @@ -47,26 +48,8 @@ Clock::Clock(std::string_view name, const Network *network) : name_(name), pins_(network), - add_to_pins_(false), leaf_pins_(network), - period_(0.0), - waveform_(nullptr), - waveform_valid_(false), - index_(index), - clk_edges_(nullptr), - is_propagated_(false), - uncertainties_(nullptr), - is_generated_(false), - src_pin_(nullptr), - master_clk_(nullptr), - master_clk_infered_(false), - divide_by_(0), - multiply_by_(0), - duty_cycle_(0), - invert_(false), - combinational_(false), - edges_(nullptr), - edge_shifts_(nullptr) + index_(index) { makeClkEdges(); } @@ -87,7 +70,7 @@ Clock::initClk(PinSet *pins, waveform_valid_ = true; period_ = period; setClkEdgeTimes(); - setComment(std::move(comment)); + setComment(comment); } bool @@ -244,22 +227,22 @@ Clock::removeSlew() void Clock::setSlewLimit(const RiseFallBoth *rf, - const PathClkOrData clk_data, + PathClkOrData clk_data, const MinMax *min_max, float slew) { - slew_limits_[int(clk_data)].setValue(rf, min_max, slew); + slew_limits_[static_cast(clk_data)].setValue(rf, min_max, slew); } void Clock::slewLimit(const RiseFall *rf, - const PathClkOrData clk_data, + PathClkOrData clk_data, const MinMax *min_max, // Return values. float &slew, bool &exists) const { - slew_limits_[int(clk_data)].value(rf, min_max, slew, exists); + slew_limits_[static_cast(clk_data)].value(rf, min_max, slew, exists); } void @@ -343,7 +326,7 @@ Clock::initGeneratedClk(PinSet *pins, invert_ = invert; combinational_ = combinational; is_propagated_ = is_propagated; - setComment(std::move(comment)); + setComment(comment); delete edges_; if (edges @@ -451,25 +434,29 @@ Clock::generateEdgesClk(const Clock *src_clk) if (edges_->size() == 3) { const FloatSeq *src_wave = src_clk->waveform(); size_t src_size = src_wave->size(); + int src_size_int = static_cast(src_size); float src_period = src_clk->period(); int edge0_1 = (*edges_)[0] - 1; - float rise = (*src_wave)[edge0_1 % src_size] - + (edge0_1 / src_size) * src_period; + div_t edge0_div = std::div(edge0_1, src_size_int); + float rise = (*src_wave)[edge0_div.rem] + + static_cast(edge0_div.quot) * src_period; if (edge_shifts_) rise += (*edge_shifts_)[0]; waveform_->push_back(rise); int edge1_1 = (*edges_)[1] - 1; - float fall = (*src_wave)[edge1_1 % src_size] - + (edge1_1 / src_size) * src_period; + div_t edge1_div = std::div(edge1_1, src_size_int); + float fall = (*src_wave)[edge1_div.rem] + + static_cast(edge1_div.quot) * src_period; if (edge_shifts_) fall += (*edge_shifts_)[1]; waveform_->push_back(fall); int edge2_1 = (*edges_)[2] - 1; - period_ = (*src_wave)[edge2_1 % src_size] - + (edge2_1 / src_size) * src_period - rise; + div_t edge2_div = std::div(edge2_1, src_size_int); + period_ = (*src_wave)[edge2_div.rem] + + static_cast(edge2_div.quot) * src_period - rise; if (edge_shifts_) period_ += (*edge_shifts_)[2]; } @@ -522,7 +509,7 @@ Clock::isDivideByOneCombinational() const return combinational_ && divide_by_ == 1 && multiply_by_ == 0 - && edge_shifts_ == 0; + && edge_shifts_ == nullptr; } //////////////////////////////////////////////////////////////// @@ -532,15 +519,10 @@ ClockEdge::ClockEdge(Clock *clock, clock_(clock), rf_(rf), name_(sta::format("{} {}", clock_->name(), rf_->shortName())), - time_(0.0), index_(clock_->index() * RiseFall::index_count + rf_->index()) { } -ClockEdge::~ClockEdge() -{ -} - void ClockEdge::setTime(float time) { @@ -714,4 +696,4 @@ compare(const ClockSet *set1, return sta::compare(set1, set2, ClockIndexLess()); } -} // namespace +} // namespace sta diff --git a/sdc/ClockGatingCheck.cc b/sdc/ClockGatingCheck.cc index ca706cfe..a8cb5763 100644 --- a/sdc/ClockGatingCheck.cc +++ b/sdc/ClockGatingCheck.cc @@ -26,15 +26,10 @@ namespace sta { -ClockGatingCheck::ClockGatingCheck() : - active_value_(LogicValue::unknown) -{ -} - void ClockGatingCheck::setActiveValue(LogicValue value) { active_value_ = value; } -} // namespace +} // namespace sta diff --git a/sdc/ClockGroups.cc b/sdc/ClockGroups.cc index 776b54a2..279ae3c2 100644 --- a/sdc/ClockGroups.cc +++ b/sdc/ClockGroups.cc @@ -29,13 +29,13 @@ namespace sta { -ClockGroups::ClockGroups(const std::string &name, +ClockGroups::ClockGroups(std::string_view name, bool logically_exclusive, bool physically_exclusive, bool asynchronous, bool allow_paths, - std::string comment) : - SdcCmdComment(std::move(comment)), + std::string_view comment) : + SdcCmdComment(comment), name_(name), logically_exclusive_(logically_exclusive), physically_exclusive_(physically_exclusive), @@ -70,4 +70,4 @@ ClockGroups::removeClock(Clock *clk) } } -} // namespace +} // namespace sta diff --git a/sdc/ClockInsertion.cc b/sdc/ClockInsertion.cc index 6a0b0545..91a6c00a 100644 --- a/sdc/ClockInsertion.cc +++ b/sdc/ClockInsertion.cc @@ -93,4 +93,4 @@ ClockInsertion::delays(const EarlyLate *early_late) return &delays_[early_late->index()]; } -} // namespace +} // namespace sta diff --git a/sdc/ClockLatency.cc b/sdc/ClockLatency.cc index 7912cd3f..9ef63d26 100644 --- a/sdc/ClockLatency.cc +++ b/sdc/ClockLatency.cc @@ -87,4 +87,4 @@ ClockLatency::delays() return &delays_; } -} // namespace +} // namespace sta diff --git a/sdc/CycleAccting.cc b/sdc/CycleAccting.cc index a3baf716..8c0ca1eb 100644 --- a/sdc/CycleAccting.cc +++ b/sdc/CycleAccting.cc @@ -24,16 +24,16 @@ #include "CycleAccting.hh" -#include // ceil #include // max +#include // ceil +#include "Clock.hh" #include "ContainerHelpers.hh" #include "Debug.hh" #include "Fuzzy.hh" -#include "Units.hh" -#include "TimingRole.hh" -#include "Clock.hh" #include "Sdc.hh" +#include "TimingRole.hh" +#include "Units.hh" namespace sta { @@ -110,8 +110,7 @@ CycleAcctings::reportClkToClkMaxCycleWarnings(Report *report) CycleAccting::CycleAccting(const ClockEdge *src, const ClockEdge *tgt) : src_(src), - tgt_(tgt), - max_cycles_exceeded_(false) + tgt_(tgt) { for (int i = 0; i <= TimingRole::index_max; i++) { delay_[i] = MinMax::min()->initValue(); @@ -429,4 +428,4 @@ CycleAcctingEqual::operator()(const CycleAccting *acct1, && acct1->target() == acct2->target(); } -} // namespace +} // namespace sta diff --git a/sdc/DataCheck.cc b/sdc/DataCheck.cc index c3095188..a538c6a0 100644 --- a/sdc/DataCheck.cc +++ b/sdc/DataCheck.cc @@ -46,8 +46,8 @@ DataCheck::margin(const RiseFall *from_rf, float &margin, bool &exists) const { - return margins_[from_rf->index()].value(to_rf, setup_hold, - margin, exists); + margins_[from_rf->index()].value(to_rf, setup_hold, + margin, exists); } void @@ -120,4 +120,4 @@ DataCheckLess::operator()(const DataCheck *check1, && clkCmp(clk1, clk2) < 0))); } -} // namespace +} // namespace sta diff --git a/sdc/DeratingFactors.cc b/sdc/DeratingFactors.cc index f187f20b..8b13bf2c 100644 --- a/sdc/DeratingFactors.cc +++ b/sdc/DeratingFactors.cc @@ -26,16 +26,16 @@ namespace sta { -inline int +inline size_t index(TimingDerateType type) { - return int(type); + return static_cast(type); } -inline int +inline size_t index(TimingDerateCellType type) { - return int(type); + return static_cast(type); } DeratingFactors::DeratingFactors() @@ -49,8 +49,8 @@ DeratingFactors::setFactor(PathClkOrData clk_data, const EarlyLate *early_late, float factor) { - for (auto rf1 : rf->range()) - factors_[int(clk_data)].setValue(rf1, early_late, factor); + for (const RiseFall *rf1 : rf->range()) + factors_[static_cast(clk_data)].setValue(rf1, early_late, factor); } void @@ -60,14 +60,14 @@ DeratingFactors::factor(PathClkOrData clk_data, float &factor, bool &exists) const { - factors_[int(clk_data)].value(rf, early_late, factor, exists); + factors_[static_cast(clk_data)].value(rf, early_late, factor, exists); } void DeratingFactors::clear() { - for (int clk_data = 0; clk_data < path_clk_or_data_count;clk_data++) - factors_[int(clk_data)].clear(); + for (RiseFallMinMax &factors : factors_) + factors.clear(); } void @@ -91,7 +91,7 @@ DeratingFactors::isOneValue(PathClkOrData clk_data, bool &is_one_value, float &value) const { - is_one_value = factors_[int(clk_data)].isOneValue(early_late, value); + is_one_value = factors_[static_cast(clk_data)].isOneValue(early_late, value); } bool @@ -143,8 +143,8 @@ DeratingFactorsGlobal::factor(TimingDerateCellType type, void DeratingFactorsGlobal::clear() { - for (int type = 0; type < timing_derate_type_count; type++) - factors_[type].clear(); + for (DeratingFactors &factors : factors_) + factors.clear(); } DeratingFactors * @@ -184,8 +184,8 @@ DeratingFactorsCell::factor(TimingDerateCellType type, void DeratingFactorsCell::clear() { - for (int type = 0; type < timing_derate_cell_type_count; type++) - factors_[type].clear(); + for (DeratingFactors &factors : factors_) + factors.clear(); } DeratingFactors * @@ -211,10 +211,4 @@ DeratingFactorsCell::isOneValue(const EarlyLate *early_late, value = value1; } -//////////////////////////////////////////////////////////////// - -DeratingFactorsNet::DeratingFactorsNet() -{ -} - -} // namespace +} // namespace sta diff --git a/sdc/DisabledPorts.cc b/sdc/DisabledPorts.cc index 9c3fa921..311a2439 100644 --- a/sdc/DisabledPorts.cc +++ b/sdc/DisabledPorts.cc @@ -26,21 +26,13 @@ #include -#include "StringUtil.hh" -#include "TimingRole.hh" #include "Liberty.hh" #include "Network.hh" +#include "StringUtil.hh" +#include "TimingRole.hh" namespace sta { -DisabledPorts::DisabledPorts() : - all_(false), - from_(nullptr), - to_(nullptr), - from_to_(nullptr) -{ -} - DisabledPorts::~DisabledPorts() { delete from_; @@ -122,9 +114,7 @@ DisabledPorts::isDisabled(LibertyPort *from, //////////////////////////////////////////////////////////////// DisabledCellPorts::DisabledCellPorts(LibertyCell *cell) : - DisabledPorts(), - cell_(cell), - arc_sets_(nullptr) + cell_(cell) { } @@ -159,15 +149,10 @@ DisabledCellPorts::isDisabled(TimingArcSet *arc_set) const class DisabledCellPortsLess { public: - DisabledCellPortsLess(); bool operator()(const DisabledCellPorts *disable1, const DisabledCellPorts *disable2); }; -DisabledCellPortsLess::DisabledCellPortsLess() -{ -} - bool DisabledCellPortsLess::operator()(const DisabledCellPorts *disable1, const DisabledCellPorts *disable2) @@ -190,7 +175,6 @@ sortByName(const DisabledCellPortsMap *cell_map) //////////////////////////////////////////////////////////////// DisabledInstancePorts::DisabledInstancePorts(Instance *inst) : - DisabledPorts(), inst_(inst) { } @@ -263,4 +247,4 @@ sortByName(const LibertyPortPairSet *set) return pairs; } -} +} // namespace sta diff --git a/sdc/ExceptionPath.cc b/sdc/ExceptionPath.cc index e3cb2dd5..151c98ad 100644 --- a/sdc/ExceptionPath.cc +++ b/sdc/ExceptionPath.cc @@ -26,16 +26,16 @@ #include -#include "Format.hh" +#include "Clock.hh" #include "ContainerHelpers.hh" +#include "Format.hh" #include "MinMax.hh" -#include "TimingRole.hh" -#include "Units.hh" -#include "Transition.hh" -#include "PortDirection.hh" #include "Network.hh" #include "NetworkCmp.hh" -#include "Clock.hh" +#include "PortDirection.hh" +#include "TimingRole.hh" +#include "Transition.hh" +#include "Units.hh" namespace sta { @@ -99,8 +99,7 @@ ExceptionPath::ExceptionPath(ExceptionFrom *from, to_(to), min_max_(min_max), own_pts_(own_pts), - priority_(priority), - id_(0) + priority_(priority) { makeStates(); } @@ -524,7 +523,7 @@ PathDelay::to_string(const Network *network) const fromThruToString(network)); } -const char * +std::string_view PathDelay::typeString() const { return "Path"; @@ -604,7 +603,7 @@ FalsePath::tighterThan(ExceptionPath *) const return false; } -const char * +std::string_view FalsePath::typeString() const { return "False"; @@ -633,7 +632,7 @@ LoopPath::LoopPath(ExceptionThruSeq *thrus, { } -const char * +std::string_view LoopPath::typeString() const { return "Loop"; @@ -726,7 +725,7 @@ MultiCyclePath::to_string(const Network *network) const fromThruToString(network)); } -const char * +std::string_view MultiCyclePath::typeString() const { return "Multicycle"; @@ -759,7 +758,7 @@ FilterPath::FilterPath(ExceptionFrom *from, { } -const char * +std::string_view FilterPath::typeString() const { return "Filter"; @@ -827,11 +826,7 @@ GroupPath::GroupPath(std::string_view name, { } -GroupPath::~GroupPath() -{ -} - -const char * +std::string_view GroupPath::typeString() const { return "Group"; @@ -882,8 +877,7 @@ const int ExceptionPt::to_string_max_objects_ = 20; ExceptionPt::ExceptionPt(const RiseFallBoth *rf, bool own_pts) : rf_(rf), - own_pts_(own_pts), - hash_(0) + own_pts_(own_pts) { } @@ -922,7 +916,7 @@ ExceptionFromTo::ExceptionFromTo(PinSet *pins, delete insts_; insts_ = nullptr; } - findHash(network); + ExceptionFromTo::findHash(network); } ExceptionFromTo::~ExceptionFromTo() @@ -1484,7 +1478,6 @@ ExceptionThru::ExceptionThru(PinSet *pins, const Network *network) : ExceptionPt(rf, own_pts), pins_(pins), - edges_(nullptr), nets_(nets), insts_(insts) { @@ -2103,9 +2096,7 @@ ExceptionThru::deletePinBefore(const Pin *pin, //////////////////////////////////////////////////////////////// ExceptionPtIterator::ExceptionPtIterator(const ExceptionPath *exception) : - exception_(exception), - from_done_(false), - to_done_(false) + exception_(exception) { if (exception->thrus()) thru_iter_ = exception->thrus()->begin(); @@ -2177,7 +2168,7 @@ ExpandedExceptionVisitor::visitExpansions() } } else - expandThrus(0); + expandThrus(nullptr); } void @@ -2282,7 +2273,6 @@ ExceptionState::ExceptionState(ExceptionPath *exception, int index) : exception_(exception), next_thru_(next_thru), - next_state_(nullptr), index_(index) { } @@ -2385,11 +2375,10 @@ class InsertPinPairsThru : public HierPinThruVisitor public: InsertPinPairsThru(PinPairSet *pairs, const Network *network); + void visit(const Pin *drvr, + const Pin *load) override; protected: - virtual void visit(const Pin *drvr, - const Pin *load); - PinPairSet *pairs_; const Network *network_; }; @@ -2432,11 +2421,10 @@ class DeletePinPairsThru : public HierPinThruVisitor public: DeletePinPairsThru(PinPairSet *pairs, const Network *network); + void visit(const Pin *drvr, + const Pin *load) override; protected: - virtual void visit(const Pin *drvr, - const Pin *load); - PinPairSet *pairs_; const Network *network_; }; @@ -2465,4 +2453,4 @@ deletePinPairsThruHierPin(const Pin *hpin, visitDrvrLoadsThruHierPin(hpin, network, &visitor); } -} // namespace +} // namespace sta diff --git a/sdc/FilterObjects.cc b/sdc/FilterObjects.cc index 45e59997..509e48df 100644 --- a/sdc/FilterObjects.cc +++ b/sdc/FilterObjects.cc @@ -1,5 +1,5 @@ // OpenSTA, Static Timing Analyzer -// Copyright (c) 2025, Parallax Software, Inc. +// Copyright (c) 2026, 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 @@ -24,20 +24,33 @@ #include "FilterObjects.hh" -#include +#include +#include #include #include +#include #include -#include #include #include +#include +#include -#include "NetworkClass.hh" +#include "Clock.hh" +#include "ContainerHelpers.hh" +#include "Format.hh" +#include "GraphClass.hh" +#include "GraphCmp.hh" +#include "Liberty.hh" +#include "LibertyClass.hh" #include "Network.hh" -#include "StringUtil.hh" -#include "Property.hh" +#include "NetworkClass.hh" +#include "PathEnd.hh" #include "PatternMatch.hh" +#include "Property.hh" +#include "SdcClass.hh" +#include "SearchClass.hh" #include "Sta.hh" +#include "StringUtil.hh" namespace sta { @@ -46,6 +59,7 @@ class FilterExpr public: struct Token { + virtual ~Token() = default; enum class Kind { skip = 0, predicate, @@ -72,6 +86,7 @@ public: PredicateToken(std::string_view property, std::string_view op, std::string_view arg); + ~PredicateToken() override = default; const std::string &property() const { return property_; } const std::string &op() const { return op_; } const std::string &arg() const { return arg_; } @@ -142,7 +157,7 @@ FilterExpr::lex() }; std::vector> result; - const char* ptr = &raw_[0]; + const char* ptr = raw_.data(); bool match = false; while (*ptr != '\0') { match = false; @@ -197,7 +212,7 @@ FilterExpr::shuntingYard(std::vector> &infix) case Token::Kind::op_and: // The operators' enum values are ascending by precedence: // inv > and > or - while (operator_stack.size() + while (!operator_stack.empty() && operator_stack.top()->kind() > token->kind()) { output.push_back(std::move(operator_stack.top())); operator_stack.pop(); @@ -220,7 +235,7 @@ FilterExpr::shuntingYard(std::vector> &infix) case Token::Kind::op_rparen: if (operator_stack.empty()) report_->error(2601, "-filter extraneous )."); - while (operator_stack.size() + while (!operator_stack.empty() && operator_stack.top()->kind() != Token::Kind::op_lparen) { output.push_back(std::move(operator_stack.top())); operator_stack.pop(); @@ -236,7 +251,7 @@ FilterExpr::shuntingYard(std::vector> &infix) } } - while (operator_stack.size()) { + while (!operator_stack.empty()) { if (operator_stack.top()->kind() == Token::Kind::op_lparen) report_->error(2603, "-filter unmatched (."); output.push_back(std::move(operator_stack.top())); @@ -284,6 +299,7 @@ filterObjects(std::string_view property, template static std::vector filterObjects(std::string_view filter_expression, const std::vector *objects, + const std::function &object_less, Sta *sta) { Report *report = sta->report(); @@ -294,6 +310,8 @@ filterObjects(std::string_view filter_expression, std::set all; for (auto object: *objects) all.insert(object); + // Delete objects before parsing so errors to not leak them. + delete objects; FilterExpr filter(filter_expression, report); auto postfix = filter.postfix(); @@ -366,19 +384,19 @@ filterObjects(std::string_view filter_expression, case PropertyValue::Type::pin: case PropertyValue::Type::net: case PropertyValue::Type::clk: - is_defined = value.to_string(network) != ""; + is_defined = !value.to_string(network).empty(); break; case PropertyValue::Type::none: is_defined = false; break; case PropertyValue::Type::pins: - is_defined = value.pins()->size() > 0; + is_defined = !value.pins()->empty(); break; case PropertyValue::Type::clks: - is_defined = value.clocks()->size() > 0; + is_defined = !value.clocks()->empty(); break; case PropertyValue::Type::paths: - is_defined = value.paths()->size() > 0; + is_defined = !value.paths()->empty(); break; case PropertyValue::Type::pwr_activity: is_defined = value.pwrActivity().isSet(); @@ -400,7 +418,7 @@ filterObjects(std::string_view filter_expression, eval_stack.push(result); } } - if (eval_stack.size() == 0) + if (eval_stack.empty()) report->error(2607, "-filter expression is empty."); if (eval_stack.size() > 1) // huh? @@ -408,96 +426,139 @@ filterObjects(std::string_view filter_expression, auto result_set = eval_stack.top(); result.resize(result_set.size()); std::copy(result_set.begin(), result_set.end(), result.begin()); - std::map objects_i; - for (size_t i = 0; i < objects->size(); ++i) - objects_i[objects->at(i)] = i; - std::sort(result.begin(), result.end(), - [&](T* a, T* b) { - return objects_i[a] < objects_i[b]; - }); - delete objects; + sort(result, [object_less] (T *obj1, T *obj2) { + return object_less(obj1, obj2); + }); } return result; } PortSeq filterPorts(std::string_view filter_expression, - PortSeq *objects, + PortSeq *ports, Sta *sta) { - return filterObjects(filter_expression, objects, sta); + Network *network = sta->network(); + return filterObjects(filter_expression, ports, + [network] (const Port *port1, + const Port *port2) { + return network->name(port1) < network->name(port2); + }, sta); } InstanceSeq filterInstances(std::string_view filter_expression, - InstanceSeq *objects, + InstanceSeq *insts, Sta *sta) { - return filterObjects(filter_expression, objects, sta); + Network *network = sta->network(); + return filterObjects(filter_expression, insts, + [network] (const Instance *inst1, + const Instance *inst2) { + return network->name(inst1) < network->name(inst2); + }, sta); } PinSeq filterPins(std::string_view filter_expression, - PinSeq *objects, + PinSeq *pins, Sta *sta) { - return filterObjects(filter_expression, objects, sta); + Network *network = sta->network(); + return filterObjects(filter_expression, pins, + [network] (const Pin *pin1, + const Pin *pin2) { + return network->pathName(pin1) < network->pathName(pin2); + }, sta); } NetSeq filterNets(std::string_view filter_expression, - NetSeq *objects, + NetSeq *nets, Sta *sta) { - return filterObjects(filter_expression, objects, sta); + Network *network = sta->network(); + return filterObjects(filter_expression, nets, + [network] (const Net *net1, + const Net *net2) { + return network->pathName(net1) < network->pathName(net2); + }, sta); } ClockSeq filterClocks(std::string_view filter_expression, - ClockSeq *objects, + ClockSeq *clks, Sta *sta) { - return filterObjects(filter_expression, objects, sta); + return filterObjects(filter_expression, clks, + [] (const Clock *clk1, + const Clock *clk2) { + return clk1->name() < clk2->name(); + }, sta); } LibertyCellSeq filterLibCells(std::string_view filter_expression, - LibertyCellSeq *objects, + LibertyCellSeq *cells, Sta *sta) { - return filterObjects(filter_expression, objects, sta); + return filterObjects(filter_expression, cells, + [] (const LibertyCell *cell1, + const LibertyCell *cell2) { + return cell1->name() < cell2->name(); + }, sta); } LibertyPortSeq filterLibPins(std::string_view filter_expression, - LibertyPortSeq *objects, + LibertyPortSeq *ports, Sta *sta) { - return filterObjects(filter_expression, objects, sta); + return filterObjects(filter_expression, ports, + [] (const LibertyPort *port1, + const LibertyPort *port2) { + return port1->name() < port2->name(); + }, sta); } LibertyLibrarySeq filterLibertyLibraries(std::string_view filter_expression, - LibertyLibrarySeq *objects, + LibertyLibrarySeq *libs, Sta *sta) { - return filterObjects(filter_expression, objects, sta); + return filterObjects(filter_expression, libs, + [] (const LibertyLibrary *lib1, + const LibertyLibrary *lib2) { + return lib1->name() < lib2->name(); + }, sta); } EdgeSeq filterTimingArcs(std::string_view filter_expression, - EdgeSeq *objects, + EdgeSeq *edges, Sta *sta) { - return filterObjects(filter_expression, objects, sta); + Network *network = sta->network(); + Graph *graph = sta->graph(); + EdgeLess edge_less(network, graph); + return filterObjects(filter_expression, edges, + [edge_less] (const Edge *edge1, + const Edge *edge2) { + return edge_less.operator()(edge1, edge2); + }, sta); } PathEndSeq filterPathEnds(std::string_view filter_expression, - PathEndSeq *objects, + PathEndSeq *ends, Sta *sta) { - return filterObjects(filter_expression, objects, sta); + PathEndLess end_less(true, sta); + return filterObjects(filter_expression, ends, + [end_less] (const PathEnd *end1, + const PathEnd *end2) { + return end_less.operator()(end1, end2); + }, sta); } StringSeq diff --git a/sdc/InputDrive.cc b/sdc/InputDrive.cc index 26b06e57..8f93a7f8 100644 --- a/sdc/InputDrive.cc +++ b/sdc/InputDrive.cc @@ -24,6 +24,8 @@ #include "InputDrive.hh" +#include "SdcClass.hh" + namespace sta { InputDrive::InputDrive() @@ -90,7 +92,7 @@ void InputDrive::setDriveCell(const LibertyLibrary *library, const LibertyCell *cell, const LibertyPort *from_port, - float *from_slews, + const DriveCellSlews &from_slews, const LibertyPort *to_port, const RiseFallBoth *rf, const MinMaxAll *min_max) @@ -120,20 +122,21 @@ InputDrive::driveCell(const RiseFall *rf, // Return values. const LibertyCell *&cell, const LibertyPort *&from_port, - float *&from_slews, + const DriveCellSlews *&from_slews, const LibertyPort *&to_port) const { InputDriveCell *drive = drive_cells_[rf->index()][min_max->index()]; if (drive) { cell = drive->cell(); from_port = drive->fromPort(); - from_slews = drive->fromSlews(); + from_slews = &drive->fromSlews(); to_port = drive->toPort(); } else { cell = nullptr; from_port = nullptr; - from_slews = nullptr; + static constexpr DriveCellSlews slews_zero{0.0, 0.0}; + from_slews = &slews_zero; to_port = nullptr; } } @@ -182,14 +185,14 @@ InputDrive::slew(const RiseFall *rf, InputDriveCell::InputDriveCell(const LibertyLibrary *library, const LibertyCell *cell, const LibertyPort *from_port, - float *from_slews, + const DriveCellSlews &from_slews, const LibertyPort *to_port) : library_(library), cell_(cell), from_port_(from_port), + from_slews_(from_slews), to_port_(to_port) { - setFromSlews(from_slews); } void @@ -217,10 +220,9 @@ InputDriveCell::setToPort(const LibertyPort *to_port) } void -InputDriveCell::setFromSlews(float *from_slews) +InputDriveCell::setFromSlews(const DriveCellSlews &from_slews) { - for (auto rf_index : RiseFall::rangeIndex()) - from_slews_[rf_index] = from_slews[rf_index]; + from_slews_ = from_slews; } bool @@ -235,4 +237,4 @@ InputDriveCell::equal(const InputDriveCell *drive) const && to_port_ == drive->to_port_; } -} // namespace +} // namespace sta diff --git a/sdc/PinPair.cc b/sdc/PinPair.cc index 05eac4d1..7c90d92b 100644 --- a/sdc/PinPair.cc +++ b/sdc/PinPair.cc @@ -77,4 +77,4 @@ PinPairSet::PinPairSet(const Network *network) : { } -} // namespace +} // namespace sta diff --git a/sdc/PortDelay.cc b/sdc/PortDelay.cc index db0c0263..94d3bbb2 100644 --- a/sdc/PortDelay.cc +++ b/sdc/PortDelay.cc @@ -24,8 +24,8 @@ #include "PortDelay.hh" -#include "Sdc.hh" #include "Network.hh" +#include "Sdc.hh" namespace sta { @@ -34,10 +34,6 @@ PortDelay::PortDelay(const Pin *pin, const Network *network) : pin_(pin), clk_edge_(clk_edge), - source_latency_included_(false), - network_latency_included_(false), - ref_pin_(nullptr), - delays_(), leaf_pins_(network) { } @@ -132,4 +128,4 @@ PortDelayLess::operator() (const PortDelay *delay1, return clkEdgeLess(delay1->clkEdge(), delay2->clkEdge()); } -} // namespace +} // namespace sta diff --git a/sdc/PortExtCap.cc b/sdc/PortExtCap.cc index 377c818f..9802628c 100644 --- a/sdc/PortExtCap.cc +++ b/sdc/PortExtCap.cc @@ -26,11 +26,6 @@ namespace sta { -PortExtCap::PortExtCap() : - port_(nullptr) -{ -} - void PortExtCap::pinCap(const RiseFall *rf, const MinMax *min_max, @@ -90,4 +85,4 @@ PortExtCap::fanout(const MinMax *min_max, fanout_.value(min_max, fanout, exists); } -} // namespace +} // namespace sta diff --git a/sdc/Sdc.cc b/sdc/Sdc.cc index 27d64569..ed8b54ac 100644 --- a/sdc/Sdc.cc +++ b/sdc/Sdc.cc @@ -25,40 +25,49 @@ #include "Sdc.hh" #include +#include #include +#include +#include +#include -#include "ContainerHelpers.hh" -#include "Stats.hh" -#include "Debug.hh" -#include "Mutex.hh" -#include "Report.hh" -#include "Variables.hh" -#include "PatternMatch.hh" -#include "MinMax.hh" -#include "TimingRole.hh" -#include "TimingArc.hh" -#include "Liberty.hh" -#include "Transition.hh" -#include "PortDirection.hh" -#include "Network.hh" -#include "RiseFallMinMax.hh" #include "Clock.hh" -#include "ClockLatency.hh" -#include "ClockInsertion.hh" -#include "CycleAccting.hh" -#include "PortDelay.hh" -#include "ExceptionPath.hh" -#include "PortExtCap.hh" -#include "DisabledPorts.hh" -#include "InputDrive.hh" -#include "DataCheck.hh" #include "ClockGatingCheck.hh" #include "ClockGroups.hh" +#include "ClockInsertion.hh" +#include "ClockLatency.hh" +#include "ContainerHelpers.hh" +#include "CycleAccting.hh" +#include "DataCheck.hh" +#include "Debug.hh" #include "DeratingFactors.hh" -#include "HpinDrvrLoad.hh" -#include "search/Levelize.hh" -#include "Scene.hh" +#include "DisabledPorts.hh" +#include "ExceptionPath.hh" +#include "Format.hh" #include "Graph.hh" +#include "HpinDrvrLoad.hh" +#include "InputDrive.hh" +#include "Liberty.hh" +#include "LibertyClass.hh" +#include "MinMax.hh" +#include "Mutex.hh" +#include "Network.hh" +#include "NetworkClass.hh" +#include "PatternMatch.hh" +#include "PinPair.hh" +#include "PortDelay.hh" +#include "PortDirection.hh" +#include "PortExtCap.hh" +#include "Report.hh" +#include "RiseFallMinMax.hh" +#include "Scene.hh" +#include "SdcClass.hh" +#include "Stats.hh" +#include "TimingArc.hh" +#include "TimingRole.hh" +#include "Transition.hh" +#include "Variables.hh" +#include "search/Levelize.hh" namespace sta { @@ -94,8 +103,6 @@ Sdc::Sdc(Mode *mode, StaState *sta) : StaState(sta), mode_(mode), - derating_factors_(nullptr), - clk_index_(0), clock_pin_map_(10, PinIdHash(network_)), clock_leaf_pin_map_(10, PinIdHash(network_)), clk_hpin_disables_(network_), @@ -105,14 +112,12 @@ Sdc::Sdc(Mode *mode, edge_clk_latency_map_(network_), clk_insertions_(network_), clk_sense_map_(network_), - clk_gating_check_(nullptr), cycle_acctings_(this), input_delay_pin_map_(PinIdLess(network_)), input_delay_ref_pin_map_(PinIdLess(network_)), input_delay_leaf_pin_map_(PinIdLess(network_)), input_delay_internal_pin_map_(PinIdLess(network_)), - input_delay_index_(0), output_delay_pin_map_(PinIdLess(network_)), output_delay_ref_pin_map_(PinIdLess(network_)), @@ -127,14 +132,11 @@ Sdc::Sdc(Mode *mode, disabled_wire_edges_(network_), disabled_clk_gating_checks_inst_(network_), disabled_clk_gating_checks_pin_(network_), - exception_id_(0), - have_thru_hpin_exceptions_(false), first_thru_edge_exceptions_(0, PinPairHash(network_), PinPairEqual()), path_delay_internal_from_(network_), path_delay_internal_from_break_(network_), path_delay_internal_to_(network_), - path_delay_internal_to_break_(network_), - filter_(nullptr) + path_delay_internal_to_break_(network_) { initVariables(); setWireload(nullptr, MinMaxAll::all()); @@ -150,7 +152,7 @@ Sdc::makeDefaultArrivalClock() waveform->push_back(0.0); waveform->push_back(0.0); default_arrival_clk_ = new Clock("input port clock", clk_index_++, network_); - default_arrival_clk_->initClk(0, false, 0.0, waveform, "", network_); + default_arrival_clk_->initClk(nullptr, false, 0.0, waveform, "", network_); } Sdc::~Sdc() @@ -577,9 +579,9 @@ Sdc::setTimingDerate(const Net *net, const EarlyLate *early_late, float derate) { - DeratingFactorsNet *factors = findKey(net_derating_factors_, net); + DeratingFactors *factors = findKey(net_derating_factors_, net); if (factors == nullptr) { - factors = new DeratingFactorsNet; + factors = new DeratingFactors; net_derating_factors_[net] = factors; } factors->setFactor(clk_data, rf, early_late, derate); @@ -663,7 +665,7 @@ Sdc::timingDerateNet(const Pin *pin, const EarlyLate *early_late) const { const Net *net = network_->net(pin); - DeratingFactorsNet *factors = findKey(net_derating_factors_, net); + DeratingFactors *factors = findKey(net_derating_factors_, net); if (factors) { float factor; bool exists; @@ -717,7 +719,7 @@ Sdc::setDriveCell(const LibertyLibrary *library, const LibertyCell *cell, const Port *port, const LibertyPort *from_port, - float *from_slews, + const DriveCellSlews &from_slews, const LibertyPort *to_port, const RiseFallBoth *rf, const MinMaxAll *min_max) @@ -760,7 +762,7 @@ Sdc::ensureInputDrive(const Port *port) void Sdc::setSlewLimit(Clock *clk, const RiseFallBoth *rf, - const PathClkOrData clk_data, + PathClkOrData clk_data, const MinMax *min_max, float slew) { @@ -777,7 +779,7 @@ Sdc::haveClkSlewLimits() const void Sdc::slewLimit(const Clock *clk, const RiseFall *rf, - const PathClkOrData clk_data, + PathClkOrData clk_data, const MinMax *min_max, float &slew, bool &exists) const @@ -971,7 +973,7 @@ Sdc::makeClock(std::string_view name, deleteClkPinMappings(clk); else { // Fresh clock definition. - clk = new Clock(std::move(name), clk_index_++, network_); + clk = new Clock(name, clk_index_++, network_); clk->setIsPropagated(variables_->propagateAllClocks()); clocks_.push_back(clk); // Use the copied name in the map. @@ -1041,8 +1043,8 @@ Sdc::deletePinClocks(Clock *defining_clk, { // Find all the clocks defined on pins to avoid finding the clock's // vertex pins multiple times. - ClockSet clks; if (pins) { + ClockSet clks; for (const Pin *pin : *pins) { ClockSet *pin_clks = findKey(clock_pin_map_, pin); if (pin_clks) { @@ -1050,19 +1052,19 @@ Sdc::deletePinClocks(Clock *defining_clk, clks.insert(clk); } } - } - for (Clock *clk : clks) { - deleteClkPinMappings(clk); - for (const Pin *pin : *pins) - clk->deletePin(pin); - if (clk != defining_clk) { - if (clk->pins().empty()) - removeClock(clk); - else { - clk->makeLeafPins(network_); - // One of the remaining clock pins may use a vertex pin that - // was deleted above. - makeClkPinMappings(clk); + for (Clock *clk : clks) { + deleteClkPinMappings(clk); + for (const Pin *pin : *pins) + clk->deletePin(pin); + if (clk != defining_clk) { + if (clk->pins().empty()) + removeClock(clk); + else { + clk->makeLeafPins(network_); + // One of the remaining clock pins may use a vertex pin that + // was deleted above. + makeClkPinMappings(clk); + } } } } @@ -1132,7 +1134,7 @@ Sdc::removeClock(Clock *clk) clearCycleAcctings(); deleteClkPinMappings(clk); - clocks_.erase(std::find(clocks_.begin(), clocks_.end(), clk)); + clocks_.erase(std::ranges::find(clocks_, clk)); clock_name_map_.erase(clk->name()); delete clk; } @@ -1287,9 +1289,9 @@ public: Sdc *sdc); bool drvrLoadExists(const Pin *drvr, const Pin *load); + void visit(HpinDrvrLoad *drvr_load) override; protected: - void visit(HpinDrvrLoad *drvr_load) override; void makeClkHpinDisables(const Pin *clk_src, const Pin *drvr, const Pin *load); @@ -1303,7 +1305,6 @@ protected: FindClkHpinDisables::FindClkHpinDisables(Clock *clk, const Network *network, Sdc *sdc) : - HpinDrvrLoadVisitor(), clk_(clk), drvr_loads_(network), network_(network), @@ -1468,11 +1469,10 @@ class MakeClkLatencyEdge : public HierPinThruVisitor public: MakeClkLatencyEdge(ClockLatency *latency, EdgeClockLatencyMap &edge_clk_latency_map); - -private: void visit(const Pin *drvr, const Pin *load) override; +private: ClockLatency *latency_; EdgeClockLatencyMap &edge_clk_latency_map_; }; @@ -1941,12 +1941,12 @@ ClockInsertionkLess::operator()(const ClockInsertion *insert1, //////////////////////////////////////////////////////////////// ClockGroups * -Sdc::makeClockGroups(const std::string &name, +Sdc::makeClockGroups(std::string_view name, bool logically_exclusive, bool physically_exclusive, bool asynchronous, bool allow_paths, - std::string comment) + std::string_view comment) { std::string group_name; if (name.empty()) @@ -1960,7 +1960,7 @@ Sdc::makeClockGroups(const std::string &name, ClockGroups *groups = new ClockGroups(group_name, logically_exclusive, physically_exclusive, asynchronous, allow_paths, - std::move(comment)); + comment); clk_groups_name_map_[groups->name()] = groups; return groups; } @@ -3561,18 +3561,16 @@ class DisableEdgesThruHierPin : public HierPinThruVisitor public: DisableEdgesThruHierPin(PinPairSet *pairs, Graph *graph); - -protected: void visit(const Pin *drvr, const Pin *load) override; +protected: PinPairSet *pairs_; Graph *graph_; }; DisableEdgesThruHierPin::DisableEdgesThruHierPin(PinPairSet *pairs, Graph *graph) : - HierPinThruVisitor(), pairs_(pairs), graph_(graph) { @@ -3602,18 +3600,16 @@ class RemoveDisableEdgesThruHierPin : public HierPinThruVisitor public: RemoveDisableEdgesThruHierPin(PinPairSet *pairs, Graph *graph); - -protected: void visit(const Pin *drvr, const Pin *load) override; +protected: PinPairSet *pairs_; Graph *graph_; }; RemoveDisableEdgesThruHierPin::RemoveDisableEdgesThruHierPin(PinPairSet *pairs, Graph *graph) : - HierPinThruVisitor(), pairs_(pairs), graph_(graph) { @@ -4083,7 +4079,7 @@ void Sdc::clearGroupPathMap() { // GroupPath exceptions are deleted with other exceptions. - for (auto [name, groups] : group_path_map_) { + for (auto &[name, groups] : group_path_map_) { deleteContents(*groups); delete groups; } @@ -4396,17 +4392,17 @@ Sdc::deleteMatchingExceptions(ExceptionPath *exception) ExceptionPathSet matches; findMatchingExceptions(exception, matches); - ExceptionPathSet expanded_matches; + ExceptionPathSet expansions; for (ExceptionPath *match : matches) // Expand the matching exception into a set of exceptions that // that do not cover the new exception. Do not record them // to prevent merging with the match, which will be deleted. - expandExceptionExcluding(match, exception, expanded_matches); + expandExceptionExcluding(match, exception, expansions); for (ExceptionPath *match : matches) deleteException(match); - for (ExceptionPath *match : expanded_matches) + for (ExceptionPath *match : expansions) addException(match); } @@ -5783,11 +5779,6 @@ findLeafDriverPins(const Pin *pin, //////////////////////////////////////////////////////////////// -NetWireCaps::NetWireCaps() : - subtract_pin_cap_{false, false} -{ -} - bool NetWireCaps::subtractPinCap(const MinMax *min_max) { @@ -5801,4 +5792,4 @@ NetWireCaps::setSubtractPinCap(bool subtrace_pin_cap, subtract_pin_cap_[min_max->index()] = subtrace_pin_cap; } -} // namespace +} // namespace sta diff --git a/sdc/Sdc.i b/sdc/Sdc.i index 60107704..996424b3 100644 --- a/sdc/Sdc.i +++ b/sdc/Sdc.i @@ -27,15 +27,17 @@ %include "std_string.i" %{ +#include "Sdc.hh" + #include -#include "Sdc.hh" -#include "Wireload.hh" #include "Clock.hh" +#include "FilterObjects.hh" #include "PortDelay.hh" #include "Property.hh" -#include "FilterObjects.hh" +#include "SdcClass.hh" #include "Sta.hh" +#include "Wireload.hh" using namespace sta; @@ -1076,7 +1078,7 @@ set_drive_cell_cmd(LibertyLibrary *library, { Sta *sta = Sta::sta(); Sdc *sdc = sta->cmdSdc(); - float from_slews[RiseFall::index_count]; + DriveCellSlews from_slews; from_slews[RiseFall::riseIndex()] = from_slew_rise; from_slews[RiseFall::fallIndex()] = from_slew_fall; sta->setDriveCell(library, cell, port, from_port, from_slews, diff --git a/sdc/SdcCmdComment.cc b/sdc/SdcCmdComment.cc index 083812ad..adbf6e4a 100644 --- a/sdc/SdcCmdComment.cc +++ b/sdc/SdcCmdComment.cc @@ -22,39 +22,21 @@ // // This notice may not be removed or altered from any source distribution. -#include "StringUtil.hh" #include "SdcCmdComment.hh" +#include "StringUtil.hh" + namespace sta { -SdcCmdComment::SdcCmdComment() -{ -} - -SdcCmdComment::SdcCmdComment(std::string comment) : - comment_(std::move(comment)) -{ -} - SdcCmdComment::SdcCmdComment(std::string_view comment) : comment_(comment) { } -SdcCmdComment::~SdcCmdComment() -{ -} - -void -SdcCmdComment::setComment(std::string comment) -{ - comment_ = std::move(comment); -} - void SdcCmdComment::setComment(std::string_view comment) { comment_ = comment; } -} // namespace +} // namespace sta diff --git a/sdc/Variables.cc b/sdc/Variables.cc index f877fc45..81650eb4 100644 --- a/sdc/Variables.cc +++ b/sdc/Variables.cc @@ -26,24 +26,6 @@ namespace sta { -Variables::Variables() : - crpr_enabled_(true), - crpr_mode_(CrprMode::same_pin), - propagate_gated_clock_enable_(true), - preset_clr_arcs_enabled_(false), - cond_default_arcs_enabled_(true), - bidirect_inst_paths_enabled_(false), - recovery_removal_checks_enabled_(true), - gated_clk_checks_enabled_(true), - clk_thru_tristate_enabled_(false), - dynamic_loop_breaking_(false), - propagate_all_clks_(false), - use_default_arrival_clock_(false), - pocv_mode_(PocvMode::scalar), - pocv_quantile_(3.0) -{ -} - void Variables::setCrprEnabled(bool enabled) { @@ -136,4 +118,4 @@ Variables::setPocvQuantile(float quantile) pocv_quantile_ = quantile; } -} // namespace +} // namespace sta diff --git a/sdc/WriteSdc.cc b/sdc/WriteSdc.cc index 3af1de6a..8f6d8caa 100644 --- a/sdc/WriteSdc.cc +++ b/sdc/WriteSdc.cc @@ -26,47 +26,47 @@ #include #include -#include #include #include #include +#include -#include "ContainerHelpers.hh" -#include "Format.hh" -#include "Zlib.hh" -#include "Report.hh" -#include "Error.hh" -#include "Units.hh" -#include "Transition.hh" -#include "Liberty.hh" -#include "Wireload.hh" -#include "Network.hh" -#include "PortDirection.hh" -#include "NetworkCmp.hh" -#include "Graph.hh" -#include "GraphCmp.hh" -#include "RiseFallValues.hh" -#include "PortDelay.hh" -#include "ExceptionPath.hh" -#include "PortExtCap.hh" -#include "DisabledPorts.hh" #include "ClockGroups.hh" #include "ClockInsertion.hh" #include "ClockLatency.hh" -#include "InputDrive.hh" +#include "ContainerHelpers.hh" #include "DataCheck.hh" #include "DeratingFactors.hh" -#include "Sdc.hh" +#include "DisabledPorts.hh" +#include "Error.hh" +#include "ExceptionPath.hh" +#include "Format.hh" #include "Fuzzy.hh" -#include "StaState.hh" +#include "Graph.hh" +#include "GraphCmp.hh" +#include "InputDrive.hh" +#include "Liberty.hh" +#include "Network.hh" +#include "NetworkCmp.hh" +#include "PortDelay.hh" +#include "PortDirection.hh" +#include "PortExtCap.hh" +#include "Report.hh" +#include "RiseFallValues.hh" #include "Scene.hh" +#include "Sdc.hh" +#include "StaState.hh" +#include "Transition.hh" +#include "Units.hh" #include "Variables.hh" +#include "Wireload.hh" #include "WriteSdcPvt.hh" +#include "Zlib.hh" namespace sta { -typedef std::set ClockSenseSet; -typedef std::vector ClockSenseSeq; +using ClockSenseSet = std::set; +using ClockSenseSeq = std::vector; static std::string_view transRiseFallFlag(const RiseFall *rf); @@ -88,8 +88,8 @@ timingDerateTypeKeyword(TimingDerateType type); class WriteSdcObject { public: - WriteSdcObject() {} - virtual ~WriteSdcObject() {} + WriteSdcObject() = default; + virtual ~WriteSdcObject() = default; virtual void write() const = 0; }; @@ -98,7 +98,7 @@ class WriteGetPort : public WriteSdcObject public: WriteGetPort(const Port *port, const WriteSdc *writer); - virtual void write() const; + void write() const override; private: const Port *port_; @@ -125,7 +125,7 @@ public: bool map_hpin_to_drvr, const Clock *clk, const WriteSdc *writer); - virtual void write() const; + void write() const override; private: const Pin *pin_; @@ -159,7 +159,7 @@ public: WriteGetPin(const Pin *pin, bool map_hpin_to_drvr, const WriteSdc *writer); - virtual void write() const; + void write() const override; private: const Pin *pin_; @@ -187,7 +187,7 @@ class WriteGetNet : public WriteSdcObject public: WriteGetNet(const Net *net, const WriteSdc *writer); - virtual void write() const; + void write() const override; private: const Net *net_; @@ -212,7 +212,7 @@ class WriteGetInstance : public WriteSdcObject public: WriteGetInstance(const Instance *inst, const WriteSdc *writer); - virtual void write() const; + void write() const override; private: const Instance *inst_; @@ -237,7 +237,7 @@ class WriteGetLibCell : public WriteSdcObject public: WriteGetLibCell(const LibertyCell *cell, const WriteSdc *writer); - virtual void write() const; + void write() const override; private: const LibertyCell *cell_; @@ -262,7 +262,7 @@ class WriteGetClock : public WriteSdcObject public: WriteGetClock(const Clock *clk, const WriteSdc *writer); - virtual void write() const; + void write() const override; private: const Clock *clk_; @@ -321,10 +321,6 @@ WriteSdc::WriteSdc(const Sdc *sdc, { } -WriteSdc::~WriteSdc() -{ -} - void WriteSdc::write(std::string_view filename, bool gzip) @@ -1666,7 +1662,7 @@ WriteSdc::writeDrivingCell(Port *port, const LibertyCell *cell = drive_cell->cell(); const LibertyPort *from_port = drive_cell->fromPort(); const LibertyPort *to_port = drive_cell->toPort(); - float *from_slews = drive_cell->fromSlews(); + const DriveCellSlews &from_slews = drive_cell->fromSlews(); const LibertyLibrary *lib = drive_cell->library(); sta::print(stream_, "set_driving_cell"); if (rf) @@ -1888,7 +1884,7 @@ WriteSdc::writeDerating(DeratingFactorsGlobal *factors) const } } else { - for (int type_index = 0; + for (size_t type_index = 0; type_index < timing_derate_type_count; type_index++) { TimingDerateType type = static_cast(type_index); @@ -1935,7 +1931,7 @@ WriteSdc::writeDerating(DeratingFactors *factors, } } else { - for (int clk_data_index = 0; + for (size_t clk_data_index = 0; clk_data_index < path_clk_or_data_count; clk_data_index++) { PathClkOrData clk_data = static_cast(clk_data_index); @@ -2855,9 +2851,9 @@ setupHoldFlag(const MinMax *min_max) void WriteSdc::writeCmdComment(SdcCmdComment *cmd) const { - const std::string comment = cmd->comment(); + const std::string &comment = cmd->comment(); if (!comment.empty()) sta::print(stream_, " -comment {{{}}}", comment); } -} // namespace +} // namespace sta diff --git a/sdc/WriteSdc.hh b/sdc/WriteSdc.hh index 0e2b33c3..15b8c725 100644 --- a/sdc/WriteSdc.hh +++ b/sdc/WriteSdc.hh @@ -46,4 +46,4 @@ writeSdc(const Sdc *sdc, bool gzip, bool no_timestamp); -} // namespace +} // namespace sta diff --git a/sdc/WriteSdcPvt.hh b/sdc/WriteSdcPvt.hh index 88600c77..94a1a591 100644 --- a/sdc/WriteSdcPvt.hh +++ b/sdc/WriteSdcPvt.hh @@ -27,10 +27,10 @@ #include #include -#include "Zlib.hh" -#include "NetworkClass.hh" #include "GraphClass.hh" +#include "NetworkClass.hh" #include "Sdc.hh" +#include "Zlib.hh" namespace sta { @@ -46,7 +46,7 @@ public: bool native, int digits, bool no_timestamp); - virtual ~WriteSdc(); + ~WriteSdc() override = default; void write(std::string_view filename, bool gzip); @@ -275,4 +275,4 @@ protected: gzFile stream_; }; -} // namespace +} // namespace sta diff --git a/sdf/ReportAnnotation.cc b/sdf/ReportAnnotation.cc index dce57ee1..cca76e65 100644 --- a/sdf/ReportAnnotation.cc +++ b/sdf/ReportAnnotation.cc @@ -26,15 +26,15 @@ #include -#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 "Liberty.hh" +#include "Network.hh" +#include "Report.hh" #include "Sdc.hh" +#include "StringUtil.hh" +#include "TimingArc.hh" +#include "TimingRole.hh" namespace sta { @@ -126,16 +126,16 @@ void reportAnnotatedDelay(const Scene *scene, bool report_cells, bool report_nets, - bool from_in_ports, - bool to_out_ports, + bool report_in_ports, + bool report_out_ports, int max_lines, bool report_annotated, bool report_unannotated, bool report_constant_arcs, StaState *sta) { - ReportAnnotated report(scene, report_cells, report_nets, from_in_ports, - to_out_ports, max_lines, report_annotated, + ReportAnnotated report(scene, report_cells, report_nets, report_in_ports, + report_out_ports, max_lines, report_annotated, report_unannotated, report_constant_arcs, sta); report.reportDelayAnnotation(); } diff --git a/sdf/ReportAnnotation.hh b/sdf/ReportAnnotation.hh index cc810464..c9291cee 100644 --- a/sdf/ReportAnnotation.hh +++ b/sdf/ReportAnnotation.hh @@ -56,4 +56,4 @@ reportAnnotatedCheck(const Scene *scene, bool report_constant_arcs, StaState *sta); -} // namespace +} // namespace sta diff --git a/sdf/Sdf.i b/sdf/Sdf.i index 89b1fdd2..271e9f60 100644 --- a/sdf/Sdf.i +++ b/sdf/Sdf.i @@ -26,10 +26,11 @@ %{ #include -#include "sdf/ReportAnnotation.hh" -#include "sdf/SdfWriter.hh" + #include "Search.hh" #include "Sta.hh" +#include "sdf/ReportAnnotation.hh" +#include "sdf/SdfWriter.hh" using sta::Sta; using sta::AnalysisType; diff --git a/sdf/SdfParse.yy b/sdf/SdfParse.yy index 7570f5df..68e05c57 100644 --- a/sdf/SdfParse.yy +++ b/sdf/SdfParse.yy @@ -44,6 +44,22 @@ sta::SdfParse::error(const location_type &loc, } %} +%code requires { +#include +#include +#include "StringUtil.hh" + +namespace sta { +class SdfScanner; +class SdfReader; +class Transition; +class SdfPortSpec; +class SdfTriple; + +using SdfTripleSeq = std::vector; +} +} + %require "3.2" %skeleton "lalr1.cc" %debug diff --git a/sdf/SdfReader.cc b/sdf/SdfReader.cc index 6a5bfd0b..007de2ba 100644 --- a/sdf/SdfReader.cc +++ b/sdf/SdfReader.cc @@ -24,24 +24,24 @@ #include "sdf/SdfReader.hh" -#include #include +#include #include #include #include "ContainerHelpers.hh" -#include "Zlib.hh" -#include "Error.hh" #include "Debug.hh" -#include "Stats.hh" -#include "Report.hh" -#include "MinMax.hh" -#include "TimingArc.hh" -#include "Network.hh" -#include "SdcNetwork.hh" +#include "Error.hh" #include "Graph.hh" +#include "MinMax.hh" +#include "Network.hh" +#include "Report.hh" #include "Scene.hh" #include "Sdc.hh" +#include "SdcNetwork.hh" +#include "Stats.hh" +#include "TimingArc.hh" +#include "Zlib.hh" #include "sdf/SdfReaderPvt.hh" #include "sdf/SdfScanner.hh" @@ -107,20 +107,12 @@ SdfReader::SdfReader(std::string_view filename, StaState(sta), filename_(filename), path_(path), - triple_min_index_(0), - triple_max_index_(2), arc_delay_min_index_(arc_min_index), arc_delay_max_index_(arc_max_index), analysis_type_(analysis_type), unescaped_dividers_(unescaped_dividers), is_incremental_only_(is_incremental_only), - cond_use_(cond_use), - divider_('/'), - escape_('\\'), - instance_(nullptr), - in_timing_check_(false), - in_incremental_(false), - timescale_(1.0E-9F) // default units of ns + cond_use_(cond_use) { if (unescaped_dividers) network_ = makeSdcNetwork(network_); @@ -747,7 +739,7 @@ SdfReader::setEdgeArcDelaysCondUse(Edge *edge, void SdfReader::setEdgeArcDelaysCondUse(Edge *edge, TimingArc *arc, - float *value, + const float *value, int triple_index, int arc_delay_index, const MinMax *min_max) @@ -819,11 +811,11 @@ SdfReader::makeCondPortSpec(std::string_view cond_port) // Search from end to find port name because condition may contain spaces. std::string cond_port1(cond_port); trimRight(cond_port1); - auto port_idx = cond_port1.find_last_of(" "); - if (port_idx != cond_port1.npos) { + auto port_idx = cond_port1.find_last_of(' '); + if (port_idx != std::string::npos) { std::string port1 = cond_port1.substr(port_idx + 1); - size_t cond_end = cond_port1.find_last_not_of(" ", port_idx); - if (cond_end != cond_port1.npos) { + size_t cond_end = cond_port1.find_last_not_of(' ', port_idx); + if (cond_end != std::string::npos) { std::string cond1 = cond_port1.substr(0, cond_end + 1); return new SdfPortSpec(Transition::riseFall(), port1, cond1); } @@ -847,7 +839,7 @@ SdfReader::deleteTripleSeq(SdfTripleSeq *triples) SdfTriple * SdfReader::makeTriple() { - return new SdfTriple(0, 0, 0); + return new SdfTriple(nullptr, nullptr, nullptr); } SdfTriple * diff --git a/sdf/SdfReader.hh b/sdf/SdfReader.hh index 47598d5d..5bb2e8e5 100644 --- a/sdf/SdfReader.hh +++ b/sdf/SdfReader.hh @@ -63,4 +63,4 @@ readSdf(std::string_view filename, MinMaxAll *cond_use, StaState *sta); -} // namespace +} // namespace sta diff --git a/sdf/SdfReaderPvt.hh b/sdf/SdfReaderPvt.hh index 3b12d02e..3a53e391 100644 --- a/sdf/SdfReaderPvt.hh +++ b/sdf/SdfReaderPvt.hh @@ -28,14 +28,14 @@ #include #include -#include "TimingRole.hh" -#include "Transition.hh" +#include "GraphClass.hh" #include "LibertyClass.hh" #include "NetworkClass.hh" -#include "GraphClass.hh" #include "Report.hh" #include "SdcClass.hh" #include "StaState.hh" +#include "TimingRole.hh" +#include "Transition.hh" namespace sta { @@ -58,7 +58,7 @@ public: bool is_incremental_only, MinMaxAll *cond_use, StaState *sta); - ~SdfReader(); + ~SdfReader() override; bool read(); void setDivider(char divider); @@ -80,7 +80,7 @@ public: SdfTriple *triple); void setEdgeArcDelaysCondUse(Edge *edge, TimingArc *arc, - float *value, + const float *value, int triple_index, int arc_delay_index, const MinMax *min_max); @@ -126,7 +126,7 @@ public: void port(std::string_view o_pin_name, SdfTripleSeq *triples); void device(SdfTripleSeq *triples); - void device(std::string_view to_pin_name, + void device(std::string_view to_port_name, SdfTripleSeq *triples); SdfTriple *makeTriple(); @@ -151,7 +151,7 @@ public: void setInTimingCheck(bool in); bool inIncremental() const { return in_incremental_; } void setInIncremental(bool incr); - std::string makeBusName(std::string_view bus_name, + std::string makeBusName(std::string_view base_name, int index); std::string_view filename() const { return filename_; } int sdfLine() const; @@ -209,8 +209,8 @@ private: SdfScanner *scanner_; std::string_view path_; // Which values to pull out of the sdf triples. - int triple_min_index_; - int triple_max_index_; + int triple_min_index_{0}; + int triple_max_index_{2}; // Which arc delay value to deposit the sdf values into. int arc_delay_min_index_; int arc_delay_max_index_; @@ -219,15 +219,15 @@ private: bool is_incremental_only_; MinMaxAll *cond_use_; - char divider_; - char escape_; - Instance *instance_; + char divider_{'/'}; + char escape_{'\\'}; + Instance *instance_{nullptr}; std::string cell_name_; - bool in_timing_check_; - bool in_incremental_; - float timescale_; + bool in_timing_check_{false}; + bool in_incremental_{false}; + float timescale_{1.0E-9F}; // default units of ns static const int null_index_ = -1; }; -} // namespace +} // namespace sta diff --git a/sdf/SdfScanner.hh b/sdf/SdfScanner.hh index bcb0c6cd..8d0d5b43 100644 --- a/sdf/SdfScanner.hh +++ b/sdf/SdfScanner.hh @@ -46,9 +46,7 @@ public: std::string_view filename, SdfReader *reader, Report *report); - virtual ~SdfScanner() {} - - virtual int lex(SdfParse::semantic_type *const yylval, + virtual int lex(SdfParse::semantic_type *yylval, SdfParse::location_type *yylloc); // YY_DECL defined in SdfLex.ll // Method body created by flex in SdfLex.cc @@ -65,4 +63,4 @@ private: std::string token_; }; -} // namespace +} // namespace sta diff --git a/sdf/SdfWriter.cc b/sdf/SdfWriter.cc index 0d750092..79750e88 100644 --- a/sdf/SdfWriter.cc +++ b/sdf/SdfWriter.cc @@ -30,21 +30,21 @@ #include #include "Format.hh" -#include "Zlib.hh" -#include "StaConfig.hh" // STA_VERSION #include "Fuzzy.hh" -#include "StringUtil.hh" -#include "Units.hh" -#include "TimingRole.hh" -#include "TimingArc.hh" -#include "Liberty.hh" -#include "Sdc.hh" -#include "MinMaxValues.hh" -#include "Network.hh" #include "Graph.hh" #include "GraphDelayCalc.hh" -#include "StaState.hh" +#include "Liberty.hh" +#include "MinMaxValues.hh" +#include "Network.hh" #include "Scene.hh" +#include "Sdc.hh" +#include "StaConfig.hh" // STA_VERSION +#include "StaState.hh" +#include "StringUtil.hh" +#include "TimingArc.hh" +#include "TimingRole.hh" +#include "Units.hh" +#include "Zlib.hh" namespace sta { @@ -118,7 +118,7 @@ private: bool include_typ_; float timescale_; - char sdf_escape_; + char sdf_escape_{'\\'}; char network_escape_; int digits_; @@ -146,7 +146,6 @@ writeSdf(std::string_view filename, SdfWriter::SdfWriter(StaState *sta) : StaState(sta), - sdf_escape_('\\'), network_escape_(network_->pathEscape()) { } @@ -824,4 +823,4 @@ SdfWriter::sdfPortName(const Pin *pin) return sdf_name; } -} // namespace +} // namespace sta diff --git a/sdf/SdfWriter.hh b/sdf/SdfWriter.hh index 98ca6f7d..4cec60d9 100644 --- a/sdf/SdfWriter.hh +++ b/sdf/SdfWriter.hh @@ -42,4 +42,4 @@ writeSdf(std::string_view filename, bool no_version, StaState *sta); -} // namespace +} // namespace sta diff --git a/search/Bdd.cc b/search/Bdd.cc index 7d5bf55f..0e1ff726 100644 --- a/search/Bdd.cc +++ b/search/Bdd.cc @@ -24,10 +24,10 @@ #include "Bdd.hh" -#include "cudd.h" -#include "StaConfig.hh" -#include "Report.hh" #include "FuncExpr.hh" +#include "Report.hh" +#include "StaConfig.hh" +#include "cudd.h" namespace sta { @@ -57,6 +57,7 @@ Bdd::funcBdd(const FuncExpr *expr) case FuncExpr::Op::not_: left = funcBdd(expr->left()); if (left) + // NOLINTNEXTLINE(performance-no-int-to-ptr) result = Cudd_Not(left); break; case FuncExpr::Op::or_: @@ -161,4 +162,4 @@ Bdd::clearVarMap() bdd_var_idx_port_map_.clear(); } -} // namespace +} // namespace sta diff --git a/search/Bfs.cc b/search/Bfs.cc index 4cc7f769..bc4c9e92 100644 --- a/search/Bfs.cc +++ b/search/Bfs.cc @@ -25,14 +25,14 @@ #include "Bfs.hh" -#include "Report.hh" #include "Debug.hh" -#include "Mutex.hh" #include "DispatchQueue.hh" -#include "Network.hh" #include "Graph.hh" -#include "Sdc.hh" #include "Levelize.hh" +#include "Mutex.hh" +#include "Network.hh" +#include "Report.hh" +#include "Sdc.hh" #include "SearchPred.hh" namespace sta { @@ -69,8 +69,6 @@ BfsIterator::ensureSize() } } -BfsIterator::~BfsIterator() {} - void BfsIterator::clear() { @@ -154,7 +152,6 @@ BfsIterator::visit(Level to_level, } } level_vertices.clear(); - visitor->levelFinished(); } return visit_count; } @@ -170,6 +167,7 @@ BfsIterator::visitParallel(Level to_level, visit_count = visit(to_level, visitor); else { std::vector visitors; + visitors.reserve(thread_count_); for (int k = 0; k < thread_count_; k++) visitors.push_back(visitor->copy()); while (levelLessOrEqual(first_level_, last_level_) @@ -209,7 +207,6 @@ BfsIterator::visitParallel(Level to_level, } dispatch_queue_->finishTasks(); } - visitor->levelFinished(); level_vertices.clear(); visit_count += vertex_count; } @@ -295,7 +292,7 @@ void BfsIterator::checkInQueue(Vertex *vertex) { Level level = vertex->level(); - if (static_cast(queue_.size()) > level) { + if (std::cmp_greater(queue_.size(), level)) { for (Vertex *v : queue_[level]) { if (v == vertex) { if (vertex->bfsInQueue(bfs_index_)) @@ -330,7 +327,7 @@ BfsIterator::remove(Vertex *vertex) { // If the iterator has not been inited the queue will be empty. Level level = vertex->level(); - if (vertex->bfsInQueue(bfs_index_) && static_cast(queue_.size()) > level) { + if (vertex->bfsInQueue(bfs_index_) && std::cmp_greater(queue_.size(), level)) { debugPrint(debug_, "bfs", 2, "remove {}", vertex->to_string(this)); for (Vertex *&v : queue_[level]) { if (v == vertex) { diff --git a/search/CheckCapacitances.cc b/search/CheckCapacitances.cc index 41ccd9c2..24983ba5 100644 --- a/search/CheckCapacitances.cc +++ b/search/CheckCapacitances.cc @@ -24,23 +24,25 @@ #include "CheckCapacitances.hh" +#include + +#include "ClkNetwork.hh" #include "ContainerHelpers.hh" #include "Fuzzy.hh" -#include "Liberty.hh" -#include "Network.hh" -#include "Sdc.hh" -#include "Mode.hh" -#include "InputDrive.hh" -#include "GraphDelayCalc.hh" -#include "StaState.hh" -#include "Scene.hh" -#include "PortDirection.hh" -#include "Sim.hh" #include "Graph.hh" #include "GraphDelayCalc.hh" -#include "ClkNetwork.hh" +#include "InputDrive.hh" +#include "Liberty.hh" +#include "MinMax.hh" +#include "Mode.hh" +#include "Network.hh" +#include "NetworkClass.hh" +#include "PortDirection.hh" +#include "Scene.hh" +#include "Sdc.hh" +#include "Sim.hh" +#include "StaState.hh" #include "Transition.hh" -#include "BoundedHeap.hh" namespace sta { @@ -158,7 +160,7 @@ CheckCapacitances::findLimit(const Pin *pin, for (auto rf : RiseFall::range()) { const LibertyCell *cell; const LibertyPort *from_port; - float *from_slews; + const DriveCellSlews *from_slews; const LibertyPort *to_port; drive->driveCell(rf, min_max, cell, from_port, from_slews, to_port); if (to_port) { @@ -210,21 +212,21 @@ CheckCapacitances::findLimit(const Pin *pin, CapacitanceCheckSeq & CheckCapacitances::check(const Net *net, size_t max_count, - bool violations, + bool violators, const SceneSeq &scenes, const MinMax *min_max) { clear(); - if (violations) - return checkViolations(net, scenes, min_max); + if (violators) + return checkViolators(net, scenes, min_max); else return checkMaxCount(net, max_count, scenes, min_max); } CapacitanceCheckSeq & -CheckCapacitances::checkViolations(const Net *net, - const SceneSeq &scenes, - const MinMax *min_max) +CheckCapacitances::checkViolators(const Net *net, + const SceneSeq &scenes, + const MinMax *min_max) { const Network *network = sta_->network(); if (net) { @@ -366,4 +368,4 @@ CapacitanceCheck::CapacitanceCheck(const Pin *pin, { } -} // namespace +} // namespace sta diff --git a/search/CheckCapacitances.hh b/search/CheckCapacitances.hh index bcd72051..fc105dfa 100644 --- a/search/CheckCapacitances.hh +++ b/search/CheckCapacitances.hh @@ -24,14 +24,16 @@ #pragma once +#include #include +#include "BoundedHeap.hh" #include "MinMax.hh" -#include "Transition.hh" #include "NetworkClass.hh" +#include "Scene.hh" #include "SdcClass.hh" #include "StaState.hh" -#include "BoundedHeap.hh" +#include "Transition.hh" namespace sta { @@ -110,9 +112,9 @@ protected: const SceneSeq &scenes, const MinMax *min_max, CapacitanceCheckHeap &heap); - CapacitanceCheckSeq &checkViolations(const Net *net, - const SceneSeq &scenes, - const MinMax *min_max); + CapacitanceCheckSeq &checkViolators(const Net *net, + const SceneSeq &scenes, + const MinMax *min_max); CapacitanceCheckSeq &checkMaxCount(const Net *net, size_t max_count, const SceneSeq &scenes, @@ -124,5 +126,5 @@ protected: CapacitanceCheckSeq checks_; }; -} // namespace +} // namespace sta diff --git a/search/CheckFanouts.cc b/search/CheckFanouts.cc index 07e2f0af..b5ffae22 100644 --- a/search/CheckFanouts.cc +++ b/search/CheckFanouts.cc @@ -24,18 +24,23 @@ #include "CheckFanouts.hh" +#include + +#include "ClkNetwork.hh" #include "ContainerHelpers.hh" #include "Fuzzy.hh" -#include "Liberty.hh" -#include "Network.hh" -#include "Sdc.hh" -#include "Mode.hh" -#include "InputDrive.hh" -#include "Sim.hh" -#include "PortDirection.hh" #include "Graph.hh" -#include "Search.hh" -#include "ClkNetwork.hh" +#include "InputDrive.hh" +#include "Liberty.hh" +#include "MinMax.hh" +#include "Mode.hh" +#include "Network.hh" +#include "NetworkClass.hh" +#include "PortDirection.hh" +#include "Scene.hh" +#include "Sdc.hh" +#include "Sim.hh" +#include "Transition.hh" namespace sta { @@ -106,10 +111,10 @@ CheckFanouts::findLimit(const Pin *pin, } InputDrive *drive = sdc->findInputDrive(port); if (drive) { - for (auto rf : RiseFall::range()) { + for (const RiseFall *rf : RiseFall::range()) { const LibertyCell *cell; const LibertyPort *from_port; - float *from_slews; + const DriveCellSlews *from_slews; const LibertyPort *to_port; drive->driveCell(rf, min_max, cell, from_port, from_slews, to_port); if (to_port) { @@ -331,4 +336,4 @@ FanoutCheckSlackLess::operator()(const FanoutCheck &check1, && sta_->network()->pinLess(check1.pin(), check2.pin())); } -} // namespace +} // namespace sta diff --git a/search/CheckFanouts.hh b/search/CheckFanouts.hh index 1bcb647b..a4b8e7ab 100644 --- a/search/CheckFanouts.hh +++ b/search/CheckFanouts.hh @@ -24,13 +24,16 @@ #pragma once +#include #include +#include "BoundedHeap.hh" #include "MinMax.hh" +#include "Mode.hh" #include "NetworkClass.hh" #include "SdcClass.hh" #include "Sta.hh" -#include "BoundedHeap.hh" +#include "StaState.hh" namespace sta { @@ -122,5 +125,5 @@ protected: FanoutCheckHeap heap_; }; -} // namespace +} // namespace sta diff --git a/search/CheckMaxSkews.cc b/search/CheckMaxSkews.cc index 20cb5224..663694b3 100644 --- a/search/CheckMaxSkews.cc +++ b/search/CheckMaxSkews.cc @@ -24,14 +24,19 @@ #include "CheckMaxSkews.hh" -#include "TimingRole.hh" -#include "TimingArc.hh" +#include + +#include "ContainerHelpers.hh" +#include "Delay.hh" +#include "Graph.hh" #include "Liberty.hh" #include "Network.hh" -#include "Graph.hh" -#include "Clock.hh" +#include "NetworkClass.hh" #include "Path.hh" #include "Search.hh" +#include "TimingArc.hh" +#include "TimingRole.hh" +#include "Transition.hh" namespace sta { @@ -40,10 +45,6 @@ CheckMaxSkews::CheckMaxSkews(StaState *sta) : { } -CheckMaxSkews::~CheckMaxSkews() -{ -} - void CheckMaxSkews::clear() { @@ -208,4 +209,4 @@ MaxSkewSlackLess::operator()(const MaxSkewCheck &check1, && sta_->network()->pinLess(check1.clkPin(sta_), check2.clkPin(sta_))); } -} // namespace +} // namespace sta diff --git a/search/CheckMaxSkews.hh b/search/CheckMaxSkews.hh index dc64f0c0..2d23a9e7 100644 --- a/search/CheckMaxSkews.hh +++ b/search/CheckMaxSkews.hh @@ -24,14 +24,17 @@ #pragma once +#include #include -#include "GraphClass.hh" #include "Delay.hh" -#include "StaState.hh" -#include "SearchClass.hh" +#include "GraphClass.hh" +#include "LibertyClass.hh" +#include "NetworkClass.hh" #include "Path.hh" -#include "MinMax.hh" +#include "Scene.hh" +#include "SearchClass.hh" +#include "StaState.hh" namespace sta { @@ -66,7 +69,6 @@ class CheckMaxSkews { public: CheckMaxSkews(StaState *sta); - ~CheckMaxSkews(); void clear(); // Return max skew checks. // net=null check all nets @@ -95,4 +97,4 @@ protected: const StaState *sta_; }; -} // namespace +} // namespace sta diff --git a/search/CheckMinPeriods.cc b/search/CheckMinPeriods.cc index 195187c5..ef32b972 100644 --- a/search/CheckMinPeriods.cc +++ b/search/CheckMinPeriods.cc @@ -24,13 +24,21 @@ #include "CheckMinPeriods.hh" -#include "Liberty.hh" -#include "Network.hh" -#include "Sdc.hh" +#include + #include "Clock.hh" +#include "ContainerHelpers.hh" +#include "Delay.hh" #include "Graph.hh" #include "GraphDelayCalc.hh" +#include "Liberty.hh" +#include "Mode.hh" +#include "Network.hh" +#include "NetworkClass.hh" +#include "Sdc.hh" +#include "SdcClass.hh" #include "Search.hh" +#include "SearchPred.hh" namespace sta { @@ -205,4 +213,4 @@ MinPeriodSlackLess::operator()(const MinPeriodCheck &check1, check2.clk())))); } -} // namespace +} // namespace sta diff --git a/search/CheckMinPeriods.hh b/search/CheckMinPeriods.hh index 9a0caa13..87596108 100644 --- a/search/CheckMinPeriods.hh +++ b/search/CheckMinPeriods.hh @@ -24,13 +24,17 @@ #pragma once -#include "NetworkClass.hh" -#include "GraphClass.hh" +#include +#include + +#include "BoundedHeap.hh" #include "Delay.hh" +#include "GraphClass.hh" +#include "NetworkClass.hh" +#include "Scene.hh" #include "SdcClass.hh" #include "SearchClass.hh" #include "StaState.hh" -#include "BoundedHeap.hh" namespace sta { @@ -96,4 +100,4 @@ protected: StaState *sta_; }; -} // namespace +} // namespace sta diff --git a/search/CheckMinPulseWidths.cc b/search/CheckMinPulseWidths.cc index fc5b0c07..bd3ae5f8 100644 --- a/search/CheckMinPulseWidths.cc +++ b/search/CheckMinPulseWidths.cc @@ -24,22 +24,28 @@ #include "CheckMinPulseWidths.hh" +#include +#include + +#include "ClkInfo.hh" +#include "Clock.hh" #include "ContainerHelpers.hh" #include "Debug.hh" -#include "TimingRole.hh" +#include "Delay.hh" +#include "Graph.hh" +#include "GraphClass.hh" #include "Liberty.hh" #include "Network.hh" -#include "Graph.hh" -#include "Clock.hh" -#include "Sdc.hh" -#include "GraphDelayCalc.hh" -#include "ClkInfo.hh" -#include "Tag.hh" +#include "NetworkClass.hh" #include "Path.hh" -#include "Scene.hh" -#include "SearchPred.hh" #include "PathEnd.hh" +#include "Scene.hh" +#include "Sdc.hh" #include "Search.hh" +#include "SearchClass.hh" +#include "SearchPred.hh" +#include "Tag.hh" +#include "TimingArc.hh" #include "search/Crpr.hh" namespace sta { @@ -130,7 +136,7 @@ CheckMinPulseWidths::checkVertex(Vertex *vertex, if (isClkEnd(path_vertex, mode) && path->isClock(search) && !path->tag(sta_)->clkInfo()->isGenClkSrcPath() - && scene_set.find(path->scene(sta_)) != scene_set.end() + && scene_set.contains(path->scene(sta_)) && path->minMax(sta_) == min_max) { float min_width; bool exists; @@ -386,4 +392,4 @@ MinPulseWidthSlackLess::operator()(const MinPulseWidthCheck &check1, < check2.openPath()->rfIndex(sta_)))); } -} // namespace +} // namespace sta diff --git a/search/CheckMinPulseWidths.hh b/search/CheckMinPulseWidths.hh index 27e2aff3..5cd503cf 100644 --- a/search/CheckMinPulseWidths.hh +++ b/search/CheckMinPulseWidths.hh @@ -24,15 +24,19 @@ #pragma once +#include #include #include -#include +#include "BoundedHeap.hh" +#include "Delay.hh" +#include "GraphClass.hh" +#include "NetworkClass.hh" +#include "Path.hh" +#include "Scene.hh" #include "SdcClass.hh" #include "SearchClass.hh" #include "StaState.hh" -#include "Path.hh" -#include "BoundedHeap.hh" namespace sta { @@ -107,4 +111,4 @@ protected: StaState *sta_; }; -} // namespace +} // namespace sta diff --git a/search/CheckSlews.cc b/search/CheckSlews.cc index 760aeee5..748cc336 100644 --- a/search/CheckSlews.cc +++ b/search/CheckSlews.cc @@ -24,21 +24,28 @@ #include "CheckSlews.hh" +#include + +#include "ClkNetwork.hh" +#include "Clock.hh" +#include "ContainerHelpers.hh" +#include "Delay.hh" #include "Fuzzy.hh" -#include "Liberty.hh" -#include "Network.hh" -#include "Sdc.hh" -#include "Mode.hh" -#include "InputDrive.hh" #include "Graph.hh" -#include "GraphDelayCalc.hh" -#include "StaState.hh" -#include "Scene.hh" +#include "GraphClass.hh" +#include "InputDrive.hh" +#include "Liberty.hh" +#include "MinMax.hh" +#include "Mode.hh" +#include "Network.hh" +#include "NetworkClass.hh" #include "Path.hh" #include "PortDirection.hh" -#include "Sim.hh" -#include "Search.hh" -#include "ClkNetwork.hh" +#include "Scene.hh" +#include "Sdc.hh" +#include "SdcClass.hh" +#include "StaState.hh" +#include "Transition.hh" namespace sta { @@ -290,7 +297,7 @@ CheckSlews::findLimit(const Pin *pin, for (auto rf : RiseFall::range()) { const LibertyCell *cell; const LibertyPort *from_port; - float *from_slews; + const DriveCellSlews *from_slews; const LibertyPort *to_port; drive->driveCell(rf, min_max, cell, from_port, from_slews, to_port); if (to_port) { @@ -417,4 +424,4 @@ SlewCheckSlackLess::operator()(const SlewCheck &check1, && sta_->network()->pinLess(check1.pin(), check2.pin())); } -} // namespace +} // namespace sta diff --git a/search/CheckSlews.hh b/search/CheckSlews.hh index 6921c53d..ca43bd5e 100644 --- a/search/CheckSlews.hh +++ b/search/CheckSlews.hh @@ -24,15 +24,19 @@ #pragma once -#include "MinMax.hh" -#include "Transition.hh" -#include "NetworkClass.hh" -#include "GraphClass.hh" +#include +#include + +#include "BoundedHeap.hh" #include "Delay.hh" +#include "GraphClass.hh" +#include "LibertyClass.hh" +#include "MinMax.hh" +#include "NetworkClass.hh" +#include "Scene.hh" #include "SdcClass.hh" #include "StaState.hh" -#include "BoundedHeap.hh" -#include "Network.hh" +#include "Transition.hh" namespace sta { @@ -164,5 +168,5 @@ protected: const StaState *sta_; }; -} // namespace +} // namespace sta diff --git a/search/CheckTiming.cc b/search/CheckTiming.cc index 9b83593f..f64975e5 100644 --- a/search/CheckTiming.cc +++ b/search/CheckTiming.cc @@ -24,33 +24,30 @@ #include "CheckTiming.hh" -#include "Error.hh" -#include "TimingRole.hh" -#include "Network.hh" -#include "NetworkCmp.hh" -#include "PortDirection.hh" -#include "Graph.hh" -#include "PortDelay.hh" -#include "ExceptionPath.hh" -#include "Sdc.hh" -#include "Mode.hh" -#include "SearchPred.hh" -#include "Levelize.hh" -#include "Bfs.hh" -#include "Search.hh" -#include "Genclks.hh" -#include "Path.hh" -#include "Sim.hh" #include "ClkNetwork.hh" +#include "ExceptionPath.hh" +#include "Format.hh" +#include "Genclks.hh" +#include "Graph.hh" +#include "GraphClass.hh" +#include "Levelize.hh" +#include "Mode.hh" +#include "Network.hh" +#include "NetworkClass.hh" +#include "NetworkCmp.hh" +#include "Path.hh" +#include "PortDelay.hh" +#include "PortDirection.hh" +#include "Sdc.hh" +#include "SdcClass.hh" +#include "Sim.hh" +#include "StaState.hh" +#include "TimingRole.hh" namespace sta { CheckTiming::CheckTiming(StaState *sta) : - StaState(sta), - mode_(nullptr), - sdc_(nullptr), - sim_(nullptr), - clk_network_(nullptr) + StaState(sta) { } @@ -224,12 +221,12 @@ CheckTiming::checkLoops() last_edge = edge; } if (last_edge) { - error->push_back("| loop cut point"); + error->emplace_back("| loop cut point"); const Pin *pin = last_edge->to(graph_)->pin(); error->push_back(sdc_network_->pathName(pin)); // Separator between loops. - error->push_back("--------------------------------"); + error->emplace_back("--------------------------------"); } } } @@ -394,4 +391,4 @@ CheckTiming::pushClkErrors(const char *msg, } } -} // namespace +} // namespace sta diff --git a/search/CheckTiming.hh b/search/CheckTiming.hh index 94f845b5..ca7b9886 100644 --- a/search/CheckTiming.hh +++ b/search/CheckTiming.hh @@ -24,13 +24,15 @@ #pragma once +#include #include -#include "StringUtil.hh" -#include "NetworkClass.hh" #include "GraphClass.hh" +#include "Mode.hh" +#include "NetworkClass.hh" #include "SdcClass.hh" #include "StaState.hh" +#include "StringUtil.hh" namespace sta { @@ -43,8 +45,8 @@ class CheckTiming : public StaState { public: CheckTiming(StaState *sta); - ~CheckTiming(); - CheckErrorSeq &check(const Mode *sdc, + ~CheckTiming() override; + CheckErrorSeq &check(const Mode *mode, bool no_input_delay, bool no_output_delay, bool reg_multiple_clks, @@ -62,7 +64,7 @@ protected: bool reg_no_clks); void checkUnconstrainedEndpoints(); bool hasClkedArrival(Vertex *vertex); - void checkNoOutputDelay(PinSet &ends); + void checkNoOutputDelay(PinSet &no_departure); void checkUnconstrainedOutputs(PinSet &unconstrained_ends); void checkUnconstrainedSetups(PinSet &unconstrained_ends); void checkLoops(); @@ -76,10 +78,10 @@ protected: ClockSet &clks); CheckErrorSeq errors_; - const Mode *mode_; - const Sdc *sdc_; - const Sim *sim_; - const ClkNetwork *clk_network_; + const Mode *mode_{nullptr}; + const Sdc *sdc_{nullptr}; + const Sim *sim_{nullptr}; + const ClkNetwork *clk_network_{nullptr}; }; -} // namespace +} // namespace sta diff --git a/search/ClkDelays.hh b/search/ClkDelays.hh index e8a15749..5c410a9e 100644 --- a/search/ClkDelays.hh +++ b/search/ClkDelays.hh @@ -24,10 +24,11 @@ #pragma once +#include "Delay.hh" #include "MinMax.hh" +#include "Path.hh" #include "StaState.hh" #include "Transition.hh" -#include "Path.hh" namespace sta { @@ -41,7 +42,7 @@ public: // Return values. Delay &insertion, Delay &delay, - float &internal_latency, + float &lib_clk_delay, Delay &latency, Path &path, bool &exists) const; @@ -49,7 +50,7 @@ public: const RiseFall *end_rf, const MinMax *min_max, // Return values. - Delay &delay, + Delay &latency, bool &exists) const; static Delay latency(Path *clk_path, StaState *sta); @@ -76,4 +77,4 @@ private: bool exists_[RiseFall::index_count][RiseFall::index_count][MinMax::index_count]; }; -} // namespace +} // namespace sta diff --git a/search/ClkInfo.cc b/search/ClkInfo.cc index e3e3a05a..53526799 100644 --- a/search/ClkInfo.cc +++ b/search/ClkInfo.cc @@ -26,13 +26,13 @@ #include -#include "Units.hh" -#include "Network.hh" #include "Graph.hh" -#include "Sdc.hh" +#include "Network.hh" #include "Scene.hh" +#include "Sdc.hh" #include "Search.hh" #include "Tag.hh" +#include "Units.hh" namespace sta { @@ -67,10 +67,6 @@ ClkInfo::ClkInfo(Scene *scene, findHash(sta); } -ClkInfo::~ClkInfo() -{ -} - void ClkInfo::findHash(const StaState *sta) { @@ -377,4 +373,4 @@ ClkInfo::cmp(const ClkInfo *clk_info1, return 0; } -} // namespace +} // namespace sta diff --git a/search/ClkInfo.hh b/search/ClkInfo.hh index 5efe7cab..a83529d5 100644 --- a/search/ClkInfo.hh +++ b/search/ClkInfo.hh @@ -24,10 +24,19 @@ #pragma once -#include "Transition.hh" -#include "SearchClass.hh" -#include "Sdc.hh" +#include +#include + +#include "Clock.hh" +#include "Delay.hh" +#include "GraphClass.hh" +#include "MinMax.hh" +#include "NetworkClass.hh" #include "Path.hh" +#include "Sdc.hh" +#include "SearchClass.hh" +#include "StaState.hh" +#include "Transition.hh" namespace sta { @@ -49,7 +58,6 @@ public: const MinMax *min_max, const Path *crpr_clk_path, const StaState *sta); - ~ClkInfo(); std::string to_string(const StaState *sta) const; Scene *scene() const { return scene_; } const MinMax *minMax() const; @@ -111,7 +119,6 @@ class ClkInfoLess { public: ClkInfoLess(const StaState *sta); - ~ClkInfoLess() {} bool operator()(const ClkInfo *clk_info1, const ClkInfo *clk_info2) const; @@ -136,4 +143,4 @@ protected: const StaState *sta_; }; -} // namespace +} // namespace sta diff --git a/search/ClkLatency.cc b/search/ClkLatency.cc index bc2d75f9..1e972abc 100644 --- a/search/ClkLatency.cc +++ b/search/ClkLatency.cc @@ -26,18 +26,18 @@ #include +#include "ClkInfo.hh" +#include "Clock.hh" #include "ContainerHelpers.hh" -#include "Report.hh" #include "Debug.hh" -#include "Units.hh" +#include "Graph.hh" #include "Liberty.hh" #include "Network.hh" -#include "Clock.hh" -#include "Graph.hh" #include "Path.hh" -#include "StaState.hh" +#include "Report.hh" #include "Search.hh" -#include "ClkInfo.hh" +#include "StaState.hh" +#include "Units.hh" namespace sta { diff --git a/search/ClkLatency.hh b/search/ClkLatency.hh index a07a4b76..313ff871 100644 --- a/search/ClkLatency.hh +++ b/search/ClkLatency.hh @@ -26,12 +26,11 @@ #include -#include "SdcClass.hh" -#include "StaState.hh" -#include "Transition.hh" -#include "SearchClass.hh" -#include "Path.hh" #include "ClkDelays.hh" +#include "SdcClass.hh" +#include "Scene.hh" +#include "SearchClass.hh" +#include "StaState.hh" namespace sta { @@ -60,4 +59,4 @@ protected: int digits); }; -} // namespace +} // namespace sta diff --git a/search/ClkNetwork.cc b/search/ClkNetwork.cc index 5f757b89..93a29496 100644 --- a/search/ClkNetwork.cc +++ b/search/ClkNetwork.cc @@ -24,22 +24,21 @@ #include "ClkNetwork.hh" -#include "Debug.hh" -#include "Network.hh" -#include "Graph.hh" #include "Bfs.hh" -#include "Sdc.hh" +#include "Debug.hh" +#include "Graph.hh" #include "Mode.hh" -#include "SearchPred.hh" +#include "Network.hh" +#include "Sdc.hh" #include "Search.hh" +#include "SearchPred.hh" namespace sta { ClkNetwork::ClkNetwork(Mode *mode, StaState *sta) : StaState(sta), - mode_(mode), - clk_pins_valid_(false) + mode_(mode) { } @@ -264,4 +263,4 @@ ClkNetwork::idealClkSlew(const Pin *pin, return 0.0; } -} // namespace +} // namespace sta diff --git a/search/ClkSkew.cc b/search/ClkSkew.cc index 89eab1ea..f4408669 100644 --- a/search/ClkSkew.cc +++ b/search/ClkSkew.cc @@ -24,35 +24,34 @@ #include "ClkSkew.hh" -#include // abs #include +#include // abs #include -#include #include +#include -#include "Fuzzy.hh" -#include "Report.hh" +#include "Bfs.hh" +#include "Crpr.hh" #include "Debug.hh" #include "DispatchQueue.hh" -#include "Units.hh" -#include "TimingArc.hh" +#include "Fuzzy.hh" +#include "Graph.hh" #include "Liberty.hh" #include "Network.hh" -#include "Graph.hh" -#include "Sdc.hh" -#include "Bfs.hh" #include "Path.hh" -#include "StaState.hh" -#include "SearchPred.hh" -#include "Search.hh" -#include "Crpr.hh" #include "PathEnd.hh" +#include "Report.hh" +#include "Sdc.hh" +#include "Search.hh" +#include "SearchPred.hh" +#include "StaState.hh" +#include "TimingArc.hh" +#include "Units.hh" namespace sta { ClkSkews::ClkSkews(StaState *sta) : StaState(sta), - include_internal_latency_(true), fanout_pred_(this) { } @@ -204,8 +203,8 @@ ClkSkews::findClkSkew(ConstClockSeq &clks, dispatch_queue_->finishTasks(); // Reduce skews from each register source. - for (size_t i = 0; i < partial_skews.size(); i++) { - for (auto &[clk, partial_skew] : partial_skews[i]) { + for (auto & i : partial_skews) { + for (auto &[clk, partial_skew] : i) { auto itr = skews_.find(clk); if (itr == skews_.end()) { // Insert new entry using emplace with piecewise_construct @@ -410,15 +409,6 @@ ClkSkew::ClkSkew(const ClkSkew &clk_skew) skew_ = clk_skew.skew_; } -void -ClkSkew::operator=(const ClkSkew &clk_skew) -{ - src_path_ = clk_skew.src_path_; - tgt_path_ = clk_skew.tgt_path_; - include_internal_latency_ = clk_skew.include_internal_latency_; - skew_ = clk_skew.skew_; -} - Arrival ClkSkew::srcLatency(const StaState *sta) { diff --git a/search/ClkSkew.hh b/search/ClkSkew.hh index 1ce1cf43..3a49ff3f 100644 --- a/search/ClkSkew.hh +++ b/search/ClkSkew.hh @@ -25,15 +25,19 @@ #pragma once #include - #include +#include "Delay.hh" +#include "GraphClass.hh" +#include "MinMax.hh" +#include "Mode.hh" +#include "Path.hh" +#include "Scene.hh" #include "SdcClass.hh" -#include "StaState.hh" -#include "Transition.hh" #include "SearchClass.hh" #include "SearchPred.hh" -#include "Path.hh" +#include "StaState.hh" +#include "Transition.hh" namespace sta { @@ -49,7 +53,7 @@ public: bool include_internal_latency, StaState *sta); ClkSkew(const ClkSkew &clk_skew); - void operator=(const ClkSkew &clk_skew); + ClkSkew &operator=(const ClkSkew &clk_skew) = default; Path *srcPath() { return src_path_; } Path *tgtPath() { return tgt_path_; } Arrival srcLatency(const StaState *sta); @@ -128,9 +132,9 @@ protected: ConstClockSeq clks_; ConstClockSet clk_set_; SceneSet scenes_set_; - bool include_internal_latency_; + bool include_internal_latency_{true}; FanOutSrchPred fanout_pred_; ClkSkewMap skews_; }; -} // namespace +} // namespace sta diff --git a/search/Crpr.cc b/search/Crpr.cc index 3d1295bb..105f3a5c 100644 --- a/search/Crpr.cc +++ b/search/Crpr.cc @@ -27,20 +27,20 @@ #include #include // abs -#include "Debug.hh" -#include "Network.hh" -#include "Graph.hh" -#include "Sdc.hh" -#include "Path.hh" #include "ClkInfo.hh" +#include "Debug.hh" +#include "Genclks.hh" +#include "Graph.hh" +#include "Mode.hh" +#include "Network.hh" +#include "Path.hh" +#include "PathEnd.hh" +#include "Sdc.hh" +#include "Search.hh" #include "Tag.hh" #include "TagGroup.hh" -#include "VisitPathEnds.hh" -#include "PathEnd.hh" -#include "Search.hh" -#include "Genclks.hh" #include "Variables.hh" -#include "Mode.hh" +#include "VisitPathEnds.hh" namespace sta { @@ -384,4 +384,4 @@ CheckCrpr::crprPossible(const Clock *clk1, || intersects(&clk1->pins(), &clk2->pins(), network_)); } -} // namespace +} // namespace sta diff --git a/search/Crpr.hh b/search/Crpr.hh index 5c7e6e4f..64ac97b0 100644 --- a/search/Crpr.hh +++ b/search/Crpr.hh @@ -24,9 +24,13 @@ #pragma once +#include "Clock.hh" +#include "Delay.hh" +#include "NetworkClass.hh" +#include "Path.hh" #include "SdcClass.hh" -#include "StaState.hh" #include "SearchClass.hh" +#include "StaState.hh" namespace sta { @@ -41,7 +45,7 @@ public: // Find the maximum possible crpr (clock min/max delta delay) for path. Arrival maxCrpr(const ClkInfo *clk_info); // Timing check CRPR. - Crpr checkCrpr(const Path *src_clk_path, + Crpr checkCrpr(const Path *src_path, const Path *tgt_clk_path); void checkCrpr(const Path *src_path, const Path *tgt_clk_path, @@ -51,7 +55,7 @@ public: // Output delay CRPR. Crpr outputDelayCrpr(const Path *src_clk_path, const ClockEdge *tgt_clk_edge); - void outputDelayCrpr(const Path *src_clk_path, + void outputDelayCrpr(const Path *src_path, const ClockEdge *tgt_clk_edge, // Return values. Crpr &crpr, @@ -83,7 +87,7 @@ private: bool same_pin, // Return values. Crpr &crpr, - Pin *&common_pin); + Pin *&crpr_pin); Path *portClkPath(const ClockEdge *clk_edge, const Pin *clk_src_pin, const Scene *scene, @@ -93,4 +97,4 @@ private: float crprArrivalDiff(const Path *path); }; -} // namespace +} // namespace sta diff --git a/search/FindRegister.cc b/search/FindRegister.cc index 8c0f3969..bafcf79c 100644 --- a/search/FindRegister.cc +++ b/search/FindRegister.cc @@ -24,18 +24,18 @@ #include "FindRegister.hh" -#include "TimingRole.hh" -#include "FuncExpr.hh" -#include "TimingArc.hh" -#include "Sequential.hh" -#include "Liberty.hh" -#include "Network.hh" -#include "Graph.hh" -#include "Sdc.hh" -#include "Mode.hh" #include "Clock.hh" -#include "SearchPred.hh" +#include "FuncExpr.hh" +#include "Graph.hh" +#include "Liberty.hh" +#include "Mode.hh" +#include "Network.hh" +#include "Sdc.hh" #include "Search.hh" +#include "SearchPred.hh" +#include "Sequential.hh" +#include "TimingArc.hh" +#include "TimingRole.hh" namespace sta { @@ -82,10 +82,10 @@ class FindRegVisitor : public StaState { public: FindRegVisitor(const StaState *sta); - virtual ~FindRegVisitor() {} + ~FindRegVisitor() override = default; void visitRegs(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode); @@ -93,7 +93,7 @@ private: void visitRegs(const Pin *clk_pin, TimingSense clk_sense, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches); virtual void visitReg(Instance *inst) = 0; virtual void visitSequential(Instance *inst, @@ -101,7 +101,7 @@ private: void visitFanoutRegs(Vertex *from_vertex, TimingSense from_sense, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, SearchPred &clk_pred, VertexSet &visited_vertices, @@ -111,7 +111,7 @@ private: LibertyCell *cell, TimingSense clk_sense, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, // Return values. bool &has_seqs, @@ -119,7 +119,7 @@ private: bool findInferedSequential(LibertyCell *cell, TimingSense clk_sense, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches); bool hasTimingCheck(LibertyCell *cell, LibertyPort *clk, @@ -135,7 +135,7 @@ FindRegVisitor::FindRegVisitor(const StaState *sta) : void FindRegVisitor::visitRegs(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode) { @@ -148,14 +148,14 @@ FindRegVisitor::visitRegs(ClockSet *clks, Vertex *vertex, *bidirect_drvr_vertex; graph_->pinVertices(pin, vertex, bidirect_drvr_vertex); visitFanoutRegs(vertex, TimingSense::positive_unate, - clk_rf, edge_triggered, + clk_rf, registers, latches, clk_pred, visited_vertices, mode); // Clocks defined on bidirect pins blow it out both ends. if (bidirect_drvr_vertex) visitFanoutRegs(bidirect_drvr_vertex, TimingSense::positive_unate, - clk_rf, edge_triggered, + clk_rf, registers, latches, clk_pred, visited_vertices, mode); } @@ -165,7 +165,7 @@ FindRegVisitor::visitRegs(ClockSet *clks, for (Vertex *vertex : graph_->regClkVertices()) { visitRegs(vertex->pin(), TimingSense::positive_unate, RiseFallBoth::riseFall(), - edge_triggered, latches); + registers, latches); } } } @@ -174,7 +174,7 @@ void FindRegVisitor::visitFanoutRegs(Vertex *from_vertex, TimingSense from_sense, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, SearchPred &clk_pred, VertexSet &visited_vertices, @@ -190,11 +190,11 @@ FindRegVisitor::visitFanoutRegs(Vertex *from_vertex, const Pin *to_pin = to_vertex->pin(); TimingSense to_sense = pathSenseThru(from_sense, edge->sense()); if (to_vertex->isRegClk()) - visitRegs(to_pin, to_sense, clk_rf, edge_triggered, latches); + visitRegs(to_pin, to_sense, clk_rf, registers, latches); // Even register clock pins can have combinational fanout arcs. if (clk_pred.searchThru(edge, mode) && clk_pred.searchTo(to_vertex, mode)) - visitFanoutRegs(to_vertex, to_sense, clk_rf, edge_triggered, latches, + visitFanoutRegs(to_vertex, to_sense, clk_rf, registers, latches, clk_pred, visited_vertices, mode); } } @@ -204,20 +204,20 @@ void FindRegVisitor::visitRegs(const Pin *clk_pin, TimingSense clk_sense, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches) { Instance *inst = network_->instance(clk_pin); LibertyCell *cell = network_->libertyCell(inst); - if (!edge_triggered || !latches + if (!registers || !latches || clk_rf != RiseFallBoth::riseFall()) { bool matches, has_seqs; findSequential(clk_pin, inst, cell, clk_sense, clk_rf, - edge_triggered, latches, + registers, latches, has_seqs, matches); if (!has_seqs) matches = findInferedSequential(cell, clk_sense, clk_rf, - edge_triggered, latches); + registers, latches); if (matches) visitReg(inst); } @@ -233,7 +233,7 @@ FindRegVisitor::findSequential(const Pin *clk_pin, LibertyCell *cell, TimingSense clk_sense, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, // Return values. bool &has_seqs, @@ -243,7 +243,7 @@ FindRegVisitor::findSequential(const Pin *clk_pin, matches = false; for (const Sequential &seq : cell->sequentials()) { has_seqs = true; - if ((seq.isRegister() && edge_triggered) + if ((seq.isRegister() && registers) || (seq.isLatch() && latches)) { if (clk_rf == RiseFallBoth::riseFall()) { visitSequential(inst, &seq); @@ -272,7 +272,7 @@ bool FindRegVisitor::findInferedSequential(LibertyCell *cell, TimingSense clk_sense, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches) { bool matches = false; @@ -288,7 +288,7 @@ FindRegVisitor::findInferedSequential(LibertyCell *cell, const TimingRole *role = arc_set->role(); if (tr_matches && ((role == TimingRole::regClkToQ() - && edge_triggered) + && registers) || (role == TimingRole::latchEnToQ() && latches))) { matches = true; @@ -317,7 +317,7 @@ public: FindRegInstances(const StaState *sta); InstanceSet findRegs(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode); @@ -338,11 +338,11 @@ FindRegInstances::FindRegInstances(const StaState *sta) : InstanceSet FindRegInstances::findRegs(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode) { - visitRegs(clks, clk_rf, edge_triggered, latches, mode); + visitRegs(clks, clk_rf, registers, latches, mode); return regs_; } @@ -361,13 +361,13 @@ FindRegInstances::visitReg(Instance *inst) InstanceSet findRegInstances(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode, const StaState *sta) { FindRegInstances find_regs(sta); - return find_regs.findRegs(clks, clk_rf, edge_triggered, latches, mode); + return find_regs.findRegs(clks, clk_rf, registers, latches, mode); } //////////////////////////////////////////////////////////////// @@ -378,14 +378,15 @@ public: FindRegPins(const StaState *sta); PinSet findPins(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode); -protected: +private: void visitReg(Instance *inst) override; void visitSequential(Instance *inst, const Sequential *seq) override; +protected: virtual bool matchPin(Pin *pin); void visitExpr(FuncExpr *expr, Instance *inst, @@ -406,11 +407,11 @@ FindRegPins::FindRegPins(const StaState *sta) : PinSet FindRegPins::findPins(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode) { - visitRegs(clks, clk_rf, edge_triggered, latches, mode); + visitRegs(clks, clk_rf, registers, latches, mode); return pins_; } @@ -460,7 +461,7 @@ class FindRegDataPins : public FindRegPins public: FindRegDataPins(const StaState *sta); -private: +protected: bool matchPin(Pin *pin) override; FuncExpr *seqExpr1(const Sequential *seq) override; FuncExpr *seqExpr2(const Sequential *seq) override; @@ -511,13 +512,13 @@ hasMinPulseWidthCheck(LibertyPort *port) PinSet findRegDataPins(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode, const StaState *sta) { FindRegDataPins find_regs(sta); - return find_regs.findPins(clks, clk_rf, edge_triggered, latches, mode); + return find_regs.findPins(clks, clk_rf, registers, latches, mode); } //////////////////////////////////////////////////////////////// @@ -527,7 +528,7 @@ class FindRegClkPins : public FindRegPins public: FindRegClkPins(const StaState *sta); -private: +protected: bool matchPin(Pin *pin) override; FuncExpr *seqExpr1(const Sequential *seq) override; FuncExpr *seqExpr2(const Sequential *seq) override; @@ -569,13 +570,13 @@ FindRegClkPins::seqExpr2(const Sequential *) PinSet findRegClkPins(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode, const StaState *sta) { FindRegClkPins find_regs(sta); - return find_regs.findPins(clks, clk_rf, edge_triggered, latches, mode); + return find_regs.findPins(clks, clk_rf, registers, latches, mode); } //////////////////////////////////////////////////////////////// @@ -585,7 +586,7 @@ class FindRegAsyncPins : public FindRegPins public: FindRegAsyncPins(const StaState *sta); -private: +protected: bool matchPin(Pin *pin) override; FuncExpr *seqExpr1(const Sequential *seq) override { return seq->clear(); } FuncExpr *seqExpr2(const Sequential *seq) override { return seq->preset(); } @@ -612,13 +613,13 @@ FindRegAsyncPins::matchPin(Pin *pin) PinSet findRegAsyncPins(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode, const StaState *sta) { FindRegAsyncPins find_regs(sta); - return find_regs.findPins(clks, clk_rf, edge_triggered, latches, mode); + return find_regs.findPins(clks, clk_rf, registers, latches, mode); } //////////////////////////////////////////////////////////////// @@ -628,15 +629,17 @@ class FindRegOutputPins : public FindRegPins public: FindRegOutputPins(const StaState *sta); -private: +protected: bool matchPin(Pin *pin) override; + // Unused. + FuncExpr *seqExpr1(const Sequential *seq) override; + FuncExpr *seqExpr2(const Sequential *seq) override; + +private: void visitSequential(Instance *inst, const Sequential *seq) override; void visitOutput(LibertyPort *port, Instance *inst); - // Unused. - FuncExpr *seqExpr1(const Sequential *seq) override; - FuncExpr *seqExpr2(const Sequential *seq) override; }; FindRegOutputPins::FindRegOutputPins(const StaState *sta) : @@ -704,13 +707,13 @@ FindRegOutputPins::seqExpr2(const Sequential *) PinSet findRegOutputPins(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode, const StaState *sta) { FindRegOutputPins find_regs(sta); - return find_regs.findPins(clks, clk_rf, edge_triggered, latches, mode); + return find_regs.findPins(clks, clk_rf, registers, latches, mode); } //////////////////////////////////////////////////////////////// @@ -722,7 +725,7 @@ initPathSenseThru1(TimingSense from, TimingSense thru, TimingSense to) { - path_sense_thru[int(from)][int(thru)] = to; + path_sense_thru[static_cast(from)][static_cast(thru)] = to; } void @@ -787,7 +790,7 @@ static TimingSense pathSenseThru(TimingSense from_sense, TimingSense thru_sense) { - return path_sense_thru[int(from_sense)][int(thru_sense)]; + return path_sense_thru[static_cast(from_sense)][static_cast(thru_sense)]; } -} // namespace +} // namespace sta diff --git a/search/FindRegister.hh b/search/FindRegister.hh index 65ec3d61..36f9cd89 100644 --- a/search/FindRegister.hh +++ b/search/FindRegister.hh @@ -25,44 +25,46 @@ #pragma once #include "LibertyClass.hh" +#include "Mode.hh" #include "NetworkClass.hh" #include "SdcClass.hh" #include "StaState.hh" +#include "Transition.hh" namespace sta { InstanceSet findRegInstances(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode, const StaState *sta); PinSet findRegDataPins(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode, const StaState *sta); PinSet findRegClkPins(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode, const StaState *sta); PinSet findRegAsyncPins(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode, const StaState *sta); PinSet findRegOutputPins(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode, const StaState *sta); @@ -70,4 +72,4 @@ findRegOutputPins(ClockSet *clks, void initPathSenseThru(); -} // namespace +} // namespace sta diff --git a/search/GatedClk.cc b/search/GatedClk.cc index fdba28de..11880d02 100644 --- a/search/GatedClk.cc +++ b/search/GatedClk.cc @@ -24,15 +24,15 @@ #include "GatedClk.hh" +#include "ClkNetwork.hh" #include "FuncExpr.hh" -#include "Liberty.hh" -#include "PortDirection.hh" -#include "Network.hh" #include "Graph.hh" +#include "Liberty.hh" #include "Mode.hh" +#include "Network.hh" +#include "PortDirection.hh" #include "Sdc.hh" #include "Search.hh" -#include "ClkNetwork.hh" namespace sta { @@ -259,4 +259,4 @@ GatedClk::gatedClkActiveTrans(LogicValue active_value, return leading_rf->opposite(); } -} // namespace +} // namespace sta diff --git a/search/GatedClk.hh b/search/GatedClk.hh index aeade0c5..c6853dbc 100644 --- a/search/GatedClk.hh +++ b/search/GatedClk.hh @@ -26,10 +26,14 @@ #include -#include "SdcClass.hh" #include "GraphClass.hh" -#include "SearchClass.hh" +#include "LibertyClass.hh" +#include "MinMax.hh" +#include "Mode.hh" +#include "NetworkClass.hh" +#include "SdcClass.hh" #include "StaState.hh" +#include "Transition.hh" namespace sta { @@ -64,4 +68,4 @@ protected: FuncExprSet &funcs) const; }; -} // namespace +} // namespace sta diff --git a/search/Genclks.cc b/search/Genclks.cc index 3dee07b9..48dbea19 100644 --- a/search/Genclks.cc +++ b/search/Genclks.cc @@ -26,25 +26,25 @@ #include -#include "ContainerHelpers.hh" -#include "Stats.hh" -#include "Debug.hh" -#include "Report.hh" -#include "Network.hh" -#include "PortDirection.hh" -#include "Graph.hh" -#include "Sdc.hh" -#include "Mode.hh" -#include "ExceptionPath.hh" -#include "Clock.hh" -#include "StaState.hh" -#include "SearchPred.hh" #include "Bfs.hh" -#include "TagGroup.hh" -#include "Scene.hh" +#include "Clock.hh" +#include "ContainerHelpers.hh" +#include "Debug.hh" +#include "ExceptionPath.hh" +#include "Graph.hh" #include "Levelize.hh" +#include "Mode.hh" +#include "Network.hh" #include "Path.hh" +#include "PortDirection.hh" +#include "Report.hh" +#include "Scene.hh" +#include "Sdc.hh" #include "Search.hh" +#include "SearchPred.hh" +#include "StaState.hh" +#include "Stats.hh" +#include "TagGroup.hh" #include "Variables.hh" namespace sta { @@ -69,7 +69,7 @@ protected: Level gclk_level_; VertexSet fanins_; EdgeSet fdbk_edges_; - bool found_latch_fdbk_edges_; + bool found_latch_fdbk_edges_{false}; FilterPath *src_filter_; }; @@ -80,7 +80,6 @@ GenclkInfo::GenclkInfo(Clock *gclk, gclk_(gclk), gclk_level_(gclk_level), fanins_(makeVertexSet(sta->graph())), - found_latch_fdbk_edges_(false), src_filter_(src_filter) { } @@ -99,7 +98,6 @@ Genclks::Genclks(const Mode *mode, StaState *sta) : StaState(sta), mode_(mode), - found_insertion_delays_(false), vertex_src_paths_map_(graph_) { } @@ -229,8 +227,9 @@ GenClkMasterSearchPred::GenClkMasterSearchPred(const StaState *sta) : bool GenClkMasterSearchPred::searchThruAllow(const TimingRole *role) const { - return (role->isWire() || role == TimingRole::combinational() - || role->regClkToQ()); + return role->isWire() + || role == TimingRole::combinational() + || role == TimingRole::regClkToQ(); } //////////////////////////////////////////////////////////////// @@ -339,8 +338,9 @@ GenClkFaninSrchPred::GenClkFaninSrchPred(Clock *gclk, bool GenClkFaninSrchPred::searchThruAllow(const TimingRole *role) const { - return (role == TimingRole::combinational() || role == TimingRole::wire() - || !combinational_); + return role == TimingRole::combinational() + || role == TimingRole::wire() + || !combinational_; } void @@ -682,6 +682,7 @@ bool GenClkArrivalSearchPred::searchTo(const Vertex *to_vertex, const Mode *mode) const { + // NOLINTNEXTLINE(bugprone-parent-virtual-call) return SearchPred0::searchTo(to_vertex, mode); } @@ -716,13 +717,11 @@ GenclkSrcArrivalVisitor::GenclkSrcArrivalVisitor(Clock *gclk, BfsFwdIterator *insert_iter, GenclkInfo *genclk_info, const Mode *mode) : - ArrivalVisitor(mode), + ArrivalVisitor(mode->sta()), gclk_(gclk), insert_iter_(insert_iter), genclk_info_(genclk_info), - srch_pred_(gclk_, - genclk_info, - mode), + srch_pred_(gclk_, genclk_info, mode->sta()), mode_(mode), sdc_(mode->sdc()), genclks_(mode->genclks()) @@ -736,15 +735,11 @@ GenclkSrcArrivalVisitor::GenclkSrcArrivalVisitor(Clock *gclk, bool always_to_endpoints, SearchPred *pred, const Mode *mode) : - ArrivalVisitor(always_to_endpoints, - pred, - mode), + ArrivalVisitor(always_to_endpoints, pred, this), gclk_(gclk), insert_iter_(insert_iter), genclk_info_(genclk_info), - srch_pred_(gclk, - genclk_info, - mode), + srch_pred_(gclk, genclk_info, this), mode_(mode), sdc_(mode->sdc()), genclks_(mode->genclks()) @@ -816,7 +811,7 @@ Genclks::copyGenClkSrcPaths(Vertex *vertex, void Genclks::clearSrcPaths() { - for (auto [vertex, paths] : vertex_src_paths_map_) { + for (const auto& [vertex, paths] : vertex_src_paths_map_) { for (const Path *path : paths) delete path; } @@ -888,11 +883,14 @@ Genclks::recordSrcPaths(Clock *gclk) } } // Don't warn if the master clock is ideal. - if (!found_src_paths && gclk->masterClk() && gclk->masterClk()->isPropagated()) - report_->warn( - 1062, - "generated clock {} source pin {} missing paths from master clock {}.", - gclk->name(), network_->pathName(gclk_pin), gclk->masterClk()->name()); + if (!found_src_paths + && gclk->masterClk() + && gclk->masterClk()->isPropagated()) + report_->warn(1062, + "generated clock {} source pin {} missing paths from master clock {}.", + gclk->name(), + network_->pathName(gclk_pin), + gclk->masterClk()->name()); } deleteGenclkSrcPaths(gclk); } @@ -901,7 +899,7 @@ void Genclks::deleteGenclkSrcPaths(Clock *gclk) { GenclkInfo *genclk_info = genclkInfo(gclk); - GenClkInsertionSearchPred srch_pred(gclk, genclk_info, mode_); + GenClkInsertionSearchPred srch_pred(gclk, genclk_info, mode_->sta()); BfsFwdIterator insert_iter(BfsIndex::other, &srch_pred, this); FilterPath *src_filter = genclk_info->srcFilter(); seedSrcPins(gclk, src_filter, insert_iter); diff --git a/search/Genclks.hh b/search/Genclks.hh index 195e9538..67cc55de 100644 --- a/search/Genclks.hh +++ b/search/Genclks.hh @@ -24,14 +24,20 @@ #pragma once +#include #include +#include +#include -#include "Transition.hh" -#include "NetworkClass.hh" +#include "Clock.hh" #include "Graph.hh" +#include "MinMax.hh" +#include "Mode.hh" +#include "NetworkClass.hh" #include "SdcClass.hh" #include "SearchClass.hh" #include "StaState.hh" +#include "Transition.hh" namespace sta { @@ -59,7 +65,7 @@ class Genclks : public StaState public: Genclks(const Mode *mode, StaState *sta); - virtual ~Genclks(); + ~Genclks() override; void clear(); void ensureInsertionDelays(); VertexSet *fanins(const Clock *clk); @@ -137,10 +143,10 @@ private: void deleteGenclkSrcPaths(Clock *gclk); const Mode *mode_; - bool found_insertion_delays_; + bool found_insertion_delays_{false}; GenclkSrcPathMap genclk_src_paths_; GenclkInfoMap genclk_info_map_; VertexGenclkSrcPathsMap vertex_src_paths_map_; }; -} // namespace +} // namespace sta diff --git a/search/Latches.cc b/search/Latches.cc index c701e7fd..f8d5b68e 100644 --- a/search/Latches.cc +++ b/search/Latches.cc @@ -24,21 +24,21 @@ #include "Latches.hh" -#include "Debug.hh" -#include "TimingRole.hh" -#include "TimingArc.hh" -#include "Liberty.hh" -#include "Network.hh" -#include "Graph.hh" -#include "ExceptionPath.hh" -#include "Sdc.hh" -#include "Mode.hh" #include "ClkInfo.hh" -#include "Tag.hh" -#include "Sim.hh" -#include "PathEnd.hh" -#include "Search.hh" #include "Crpr.hh" +#include "Debug.hh" +#include "ExceptionPath.hh" +#include "Graph.hh" +#include "Liberty.hh" +#include "Mode.hh" +#include "Network.hh" +#include "PathEnd.hh" +#include "Sdc.hh" +#include "Search.hh" +#include "Sim.hh" +#include "Tag.hh" +#include "TimingArc.hh" +#include "TimingRole.hh" namespace sta { @@ -603,4 +603,4 @@ Latches::isLatchDtoQ(const Edge *edge, && latchDtoQState(edge, mode) == LatchEnableState::enabled; } -} // namespace +} // namespace sta diff --git a/search/Latches.hh b/search/Latches.hh index 33980a20..4d31e8d5 100644 --- a/search/Latches.hh +++ b/search/Latches.hh @@ -24,10 +24,15 @@ #pragma once +#include "Delay.hh" #include "GraphClass.hh" -#include "SearchClass.hh" +#include "LibertyClass.hh" +#include "Mode.hh" +#include "NetworkClass.hh" #include "SdcClass.hh" +#include "SearchClass.hh" #include "StaState.hh" +#include "Transition.hh" namespace sta { @@ -108,4 +113,4 @@ protected: const ClockEdge *en_clk_edge); }; -} // namespace +} // namespace sta diff --git a/search/Levelize.cc b/search/Levelize.cc index e794ac7a..519a7427 100644 --- a/search/Levelize.cc +++ b/search/Levelize.cc @@ -30,30 +30,25 @@ #include #include "ContainerHelpers.hh" -#include "Report.hh" #include "Debug.hh" -#include "Stats.hh" -#include "TimingRole.hh" -#include "PortDirection.hh" -#include "Network.hh" -#include "Sdc.hh" -#include "Mode.hh" #include "Graph.hh" #include "GraphCmp.hh" -#include "Variables.hh" #include "GraphDelayCalc.hh" +#include "Mode.hh" +#include "Network.hh" +#include "PortDirection.hh" +#include "Report.hh" +#include "Sdc.hh" +#include "Stats.hh" +#include "TimingRole.hh" +#include "Variables.hh" namespace sta { Levelize::Levelize(StaState *sta) : StaState(sta), - levelized_(false), - levels_valid_(false), - max_level_(0), - level_space_(10), roots_(makeVertexSet(sta)), relevelize_from_(makeVertexSet(sta)), - observer_(nullptr), drvr_vertices_level_valid_(false) { } @@ -110,7 +105,7 @@ Levelize::ensureLevelized() if (levelized_) relevelize(); else - levelize(); + findLevels(); } } @@ -118,7 +113,7 @@ Levelize::ensureLevelized() #define setOnPath(on_path) setVisited2(on_path) void -Levelize::levelize() +Levelize::findLevels() { Stats stats(debug_, report_); debugPrint(debug_, "levelize", 1, "levelize"); diff --git a/search/Levelize.hh b/search/Levelize.hh index 80396cf3..822bcd83 100644 --- a/search/Levelize.hh +++ b/search/Levelize.hh @@ -25,11 +25,10 @@ #pragma once #include +#include +#include -#include "NetworkClass.hh" -#include "SdcClass.hh" #include "Graph.hh" -#include "SearchPred.hh" #include "StaState.hh" namespace sta { @@ -46,7 +45,7 @@ class Levelize : public StaState { public: Levelize(StaState *sta); - virtual ~Levelize(); + ~Levelize() override; // Space between initially assigned levels that is filled in by // incremental levelization. Set level space before levelization. void setLevelSpace(Level space); @@ -73,9 +72,9 @@ public: void setObserver(LevelizeObserver *observer); void checkLevels(); // Public for regression testing. - void levelize(); + void findLevels(); const VertexSeq &levelizedDrvrVertices(); - + protected: void findRoots(); VertexSeq sortedRootsWithFanout(); @@ -107,17 +106,17 @@ protected: void reportPath(EdgeSeq &path) const; void levelizeDrvrVertices(); - bool levelized_; - bool levels_valid_; - Level max_level_; - Level level_space_; + bool levelized_{false}; + bool levels_valid_{false}; + Level max_level_{0}; + Level level_space_{10}; VertexSet roots_; VertexSet relevelize_from_; GraphLoopSeq loops_; EdgeSet loop_edges_; EdgeSet disabled_loop_edges_; EdgeSet latch_d_to_q_edges_; - LevelizeObserver *observer_; + LevelizeObserver *observer_{nullptr}; VertexSeq levelized_drvr_vertices_; bool drvr_vertices_level_valid_; }; @@ -141,10 +140,9 @@ private: class LevelizeObserver { public: - LevelizeObserver() {} - virtual ~LevelizeObserver() {} + virtual ~LevelizeObserver() = default; virtual void levelsChangedBefore() = 0; virtual void levelChangedBefore(Vertex *vertex) = 0; }; -} // namespace +} // namespace sta diff --git a/search/MakeTimingModel.cc b/search/MakeTimingModel.cc index d4fd82f0..7e61d19c 100644 --- a/search/MakeTimingModel.cc +++ b/search/MakeTimingModel.cc @@ -26,29 +26,43 @@ #include "MakeTimingModelPvt.hh" #include -#include +#include #include +#include +#include +#include +#include +#include "ArcDelayCalc.hh" +#include "ClkDelays.hh" +#include "Clock.hh" +#include "ContainerHelpers.hh" #include "Debug.hh" -#include "Units.hh" -#include "Transition.hh" -#include "Liberty.hh" -#include "TimingArc.hh" -#include "TableModel.hh" -#include "liberty/LibertyBuilder.hh" -#include "Network.hh" -#include "PortDirection.hh" -#include "Scene.hh" -#include "GraphDelayCalc.hh" -#include "Sdc.hh" -#include "StaState.hh" +#include "Delay.hh" #include "Graph.hh" +#include "GraphClass.hh" +#include "GraphDelayCalc.hh" +#include "Liberty.hh" +#include "LibertyClass.hh" +#include "Network.hh" +#include "NetworkClass.hh" +#include "Path.hh" #include "PathEnd.hh" +#include "PortDirection.hh" +#include "RiseFallMinMax.hh" +#include "Scene.hh" +#include "Sdc.hh" +#include "SdcClass.hh" #include "Search.hh" #include "Sta.hh" +#include "StaState.hh" +#include "TableModel.hh" +#include "TimingArc.hh" +#include "TimingRole.hh" +#include "Transition.hh" +#include "Units.hh" #include "VisitPathEnds.hh" -#include "ArcDelayCalc.hh" -#include "ClkLatency.hh" +#include "liberty/LibertyBuilder.hh" namespace sta { @@ -73,13 +87,10 @@ MakeTimingModel::MakeTimingModel(std::string_view lib_name, cell_name_(cell_name), filename_(filename), scene_(scene), - cell_(nullptr), min_max_(MinMax::max()), lib_builder_(new LibertyBuilder(debug_, report_)), - tbl_template_index_(1), sdc_(scene->sdc()), - sdc_backup_(nullptr), sta_(sta) { scenes_.insert(scene_); @@ -232,20 +243,18 @@ class MakeEndTimingArcs : public PathEndVisitor public: MakeEndTimingArcs(Sta *sta); MakeEndTimingArcs(const MakeEndTimingArcs &) = default; - ~MakeEndTimingArcs() override {} PathEndVisitor *copy() const override; void visit(PathEnd *path_end) override; void setInputRf(const RiseFall *input_rf); const ClockEdgeDelays &margins() const { return margins_; } private: - const RiseFall *input_rf_; + const RiseFall *input_rf_{nullptr}; ClockEdgeDelays margins_; Sta *sta_; }; MakeEndTimingArcs::MakeEndTimingArcs(Sta *sta) : - input_rf_(nullptr), sta_(sta) { } @@ -673,8 +682,7 @@ MakeTimingModel::makeGateModelTable(const Pin *output_pin, const FloatSeq &drvr_axis_values = drvr_load_axis->values(); FloatSeq *load_values = new FloatSeq; FloatSeq *slew_values = new FloatSeq; - for (size_t i = 0; i < drvr_axis_values.size(); i++) { - float load_cap = drvr_axis_values[i]; + for (float load_cap : drvr_axis_values) { // get slew from driver input pin float gate_delay, gate_slew; drvr_gate_model->gateDelay(pvt, in_slew1, load_cap, @@ -723,7 +731,7 @@ MakeTimingModel::makeGateModelTable(const Pin *output_pin, TableTemplate * MakeTimingModel::ensureTableTemplate(const TableTemplate *drvr_template, - TableAxisPtr load_axis) + const TableAxisPtr &load_axis) { TableTemplate *model_template = findKey(template_map_, drvr_template); if (model_template == nullptr) { diff --git a/search/MakeTimingModel.hh b/search/MakeTimingModel.hh index 9056bce7..201c6548 100644 --- a/search/MakeTimingModel.hh +++ b/search/MakeTimingModel.hh @@ -39,4 +39,4 @@ makeTimingModel(std::string_view lib_name, const Scene *scene, Sta *sta); -} // namespace +} // namespace sta diff --git a/search/MakeTimingModelPvt.hh b/search/MakeTimingModelPvt.hh index 07470e4e..47dba148 100644 --- a/search/MakeTimingModelPvt.hh +++ b/search/MakeTimingModelPvt.hh @@ -28,11 +28,14 @@ #include #include +#include "Delay.hh" #include "LibertyClass.hh" +#include "NetworkClass.hh" +#include "RiseFallMinMax.hh" +#include "Scene.hh" #include "SdcClass.hh" #include "SearchClass.hh" #include "StaState.hh" -#include "RiseFallMinMax.hh" namespace sta { @@ -61,7 +64,7 @@ public: std::string_view filename, const Scene *scene, Sta *sta); - ~MakeTimingModel(); + ~MakeTimingModel() override; LibertyLibrary *makeTimingModel(); private: @@ -96,7 +99,7 @@ private: Delay delay, const RiseFall *rf); TableTemplate *ensureTableTemplate(const TableTemplate *drvr_template, - TableAxisPtr load_axis); + const TableAxisPtr &load_axis); const TableAxis *loadCapacitanceAxis(const TableModel *table); LibertyPort *modelPort(const Pin *pin); @@ -110,15 +113,15 @@ private: const Scene *scene_; SceneSet scenes_; LibertyLibrary *library_; - LibertyCell *cell_; + LibertyCell *cell_{nullptr}; const MinMax *min_max_; LibertyBuilder *lib_builder_; // Output driver table model template to model template. std::map template_map_; - int tbl_template_index_; + int tbl_template_index_{1}; Sdc *sdc_; - Sdc *sdc_backup_; + Sdc *sdc_backup_{nullptr}; Sta *sta_; }; -} // namespace +} // namespace sta diff --git a/search/Mode.cc b/search/Mode.cc index a73ea28e..f822ff92 100644 --- a/search/Mode.cc +++ b/search/Mode.cc @@ -22,27 +22,28 @@ // // This notice may not be removed or altered from any source distribution. +#include + #include "Mode.hh" -#include "Sdc.hh" -#include "Sim.hh" #include "ClkNetwork.hh" #include "Genclks.hh" #include "PathGroup.hh" +#include "Sdc.hh" +#include "Sim.hh" namespace sta { Mode::Mode(std::string_view name, size_t mode_index, StaState *sta) : - StaState(sta), name_(name), mode_index_(mode_index), sdc_(new Sdc(this, sta)), sim_(new Sim(sta)), clk_network_(new ClkNetwork(this, sta)), genclks_(new Genclks(this, sta)), - path_groups_(nullptr) + sta_(sta) { } @@ -58,7 +59,7 @@ Mode::~Mode() void Mode::copyState(const StaState *sta) { - StaState::copyState(sta); + sta_->copyState(sta); sdc_->copyState(sta); sim_->copyState(sta); clk_network_->copyState(sta); @@ -84,10 +85,11 @@ void Mode::removeScene(Scene *scene) { // std iterators just plain suck - scenes_.erase(std::remove(scenes_.begin(), scenes_.end(), scene), scenes_.end()); + auto tail = std::ranges::remove(scenes_, scene); + scenes_.erase(tail.begin(), tail.end()); } -const SceneSet +SceneSet Mode::sceneSet() const { SceneSet scenes; @@ -143,4 +145,4 @@ Mode::pathGroups(const PathEnd *path_end) const return PathGroupSeq(); } -} // namespace +} // namespace sta diff --git a/search/Path.cc b/search/Path.cc index e7f78bde..2dcc621e 100644 --- a/search/Path.cc +++ b/search/Path.cc @@ -24,16 +24,27 @@ #include "Path.hh" -#include "TimingRole.hh" -#include "TimingArc.hh" -#include "Network.hh" -#include "Graph.hh" +#include +#include + #include "Clock.hh" +#include "Delay.hh" +#include "Format.hh" +#include "Graph.hh" +#include "GraphClass.hh" +#include "Mode.hh" +#include "Network.hh" +#include "NetworkClass.hh" +#include "Sdc.hh" +#include "SdcClass.hh" +#include "Search.hh" +#include "SearchClass.hh" +#include "StaState.hh" #include "Tag.hh" #include "TagGroup.hh" -#include "Sdc.hh" -#include "Mode.hh" -#include "Search.hh" +#include "TimingArc.hh" +#include "TimingRole.hh" +#include "VertexId.hh" namespace sta { @@ -326,7 +337,7 @@ Path::pathAnalysisPtIndex(const StaState *sta) const return scene(sta)->pathIndex(minMax(sta)); } -const Slew +Slew Path::slew(const StaState *sta) const { DcalcAPIndex slew_index = scene(sta)->dcalcAnalysisPtIndex(minMax(sta)); @@ -786,8 +797,6 @@ VertexPathIterator::findNext() next_ = nullptr; } -VertexPathIterator::~VertexPathIterator() {} - bool VertexPathIterator::hasNext() { diff --git a/search/PathEnd.cc b/search/PathEnd.cc index da7d0d77..81920752 100644 --- a/search/PathEnd.cc +++ b/search/PathEnd.cc @@ -24,33 +24,32 @@ #include "PathEnd.hh" -#include "Debug.hh" -#include "TimingRole.hh" -#include "TimingArc.hh" -#include "Liberty.hh" -#include "Network.hh" -#include "Graph.hh" -#include "Clock.hh" -#include "PortDelay.hh" -#include "DataCheck.hh" -#include "Sdc.hh" -#include "Mode.hh" -#include "ExceptionPath.hh" #include "ClkInfo.hh" -#include "Tag.hh" -#include "Search.hh" -#include "ReportPath.hh" -#include "Sim.hh" +#include "Clock.hh" +#include "DataCheck.hh" +#include "Debug.hh" +#include "ExceptionPath.hh" +#include "Graph.hh" #include "Latches.hh" -#include "StaState.hh" +#include "Liberty.hh" +#include "Mode.hh" +#include "Network.hh" #include "PathExpanded.hh" +#include "PortDelay.hh" +#include "ReportPath.hh" +#include "Sdc.hh" +#include "Search.hh" +#include "Sim.hh" +#include "StaState.hh" +#include "Tag.hh" +#include "TimingArc.hh" +#include "TimingRole.hh" #include "search/Crpr.hh" namespace sta { PathEnd::PathEnd(Path *path) : - path_(path), - path_group_(nullptr) + path_(path) { } @@ -419,6 +418,14 @@ PathEnd::checkInterClkUncertainty(const ClockEdge *src_clk_edge, exists = false; } +bool +PathEnd::ignoreClkLatency(const Path *path, + PathDelay *path_delay, + const StaState *sta) +{ + return path_delay->ignoreClkLatency() && !path->isClock(sta); +} + //////////////////////////////////////////////////////////////// void @@ -507,8 +514,7 @@ PathEndClkConstrained::PathEndClkConstrained(Path *path, Path *clk_path) : PathEnd(path), clk_path_(clk_path), - crpr_(0.0), - crpr_valid_(false) + crpr_(0.0) { } @@ -609,9 +615,7 @@ PathEndClkConstrained::targetClkTime(const StaState *sta) const Arrival PathEndClkConstrained::targetClkArrival(const StaState *sta) const { - return delaySum(targetClkArrivalNoCrpr(sta), - checkCrpr(sta), - sta); + return delaySum(targetClkArrivalNoCrpr(sta), checkCrpr(sta), sta); } Arrival @@ -1090,7 +1094,7 @@ PathEndLatchCheck::PathEndLatchCheck(Path *path, clk_path_ = enable_path; Search *search = sta->search(); // Same as PathEndPathDelay::findRequired. - if (path_delay_ && ignoreClkLatency(sta)) + if (path_delay_ && PathEnd::ignoreClkLatency(path_, path_delay_, sta)) src_clk_arrival_ = search->pathClkPathArrival(path_); } @@ -1266,7 +1270,7 @@ int PathEndLatchCheck::exceptPathCmp(const PathEnd *path_end, const StaState *sta) const { - int cmp = PathEndClkConstrainedMcp::exceptPathCmp(path_end, sta); + int cmp = PathEndCheck::exceptPathCmp(path_end, sta); if (cmp == 0) { const PathEndLatchCheck *path_end2 = dynamic_cast(path_end); @@ -1765,7 +1769,7 @@ PathEndPathDelay::typeName() const void PathEndPathDelay::findSrcClkArrival(const StaState *sta) { - if (ignoreClkLatency(sta)) { + if (PathEnd::ignoreClkLatency(path_, path_delay_, sta)) { Search *search = sta->search(); src_clk_arrival_ = search->pathClkPathArrival(path_); } @@ -1851,14 +1855,6 @@ PathEnd::pathDelaySrcClkOffset(const Path *path, return offset; } -bool -PathEnd::ignoreClkLatency(const Path *path, - PathDelay *path_delay, - const StaState *sta) -{ - return path_delay->ignoreClkLatency() && !path->isClock(sta); -} - const ClockEdge * PathEndPathDelay::targetClkEdge(const StaState *sta) const { @@ -2119,4 +2115,4 @@ PathEndNoCrprLess::operator()(const PathEnd *path_end1, return cmp < 0; } -} // namespace +} // namespace sta diff --git a/search/PathEnum.cc b/search/PathEnum.cc index 437966a8..c285b8f9 100644 --- a/search/PathEnum.cc +++ b/search/PathEnum.cc @@ -24,20 +24,28 @@ #include "PathEnum.hh" +#include +#include +#include +#include + #include "Debug.hh" +#include "Delay.hh" #include "Error.hh" -#include "Fuzzy.hh" -#include "TimingRole.hh" -#include "TimingArc.hh" -#include "Network.hh" -#include "Sdc.hh" -#include "Mode.hh" #include "Graph.hh" -#include "Tag.hh" -#include "Search.hh" +#include "GraphClass.hh" #include "Latches.hh" -#include "PathEnd.hh" +#include "Mode.hh" +#include "Network.hh" #include "Path.hh" +#include "PathEnd.hh" +#include "Sdc.hh" +#include "Search.hh" +#include "SearchClass.hh" +#include "Tag.hh" +#include "TimingArc.hh" +#include "TimingRole.hh" +#include "VertexVisitor.hh" namespace sta { @@ -118,10 +126,7 @@ PathEnum::PathEnum(size_t group_path_count, endpoint_path_count_(endpoint_path_count), unique_pins_(unique_pins), unique_edges_(unique_edges), - div_queue_(DiversionGreater(sta)), - div_count_(0), - inserts_pruned_(false), - next_(nullptr) + div_queue_(DiversionGreater(sta)) { } @@ -260,6 +265,15 @@ public: Arrival &to_arrival, const MinMax *min_max) override; + void visit(Vertex *) override {} // Not used. + +protected: + bool visitEdge(const Pin *from_pin, + Vertex *from_vertex, + Edge *edge, + const Pin *to_pin, + Vertex *to_vertex) override; + private: void makeDivertedPathEnd(Path *after_div, Edge *div_edge, @@ -267,12 +281,6 @@ private: // Return values. PathEnd *&div_end, Path *&after_div_copy); - bool visitEdge(const Pin *from_pin, - Vertex *from_vertex, - Edge *edge, - const Pin *to_pin, - Vertex *to_vertex) override; - void visit(Vertex *) override {} // Not used. void insertUniqueEdgeDiv(Diversion *div); void reportDiversion(const Edge *edge, const TimingArc *div_arc, @@ -286,7 +294,7 @@ private: Slack path_end_slack_; Tag *before_div_tag_; - int before_div_rf_index_; + size_t before_div_rf_index_; Scene *scene_; const MinMax *min_max_; Arrival before_div_arrival_; @@ -445,7 +453,7 @@ PathEnumFaninVisitor::visitFromToPath(const Pin *, bool tag_march = !Tag::matchNoCrpr(to_tag, before_div_tag_); bool crpr = !(!crpr_active_ - || visited_fanins_.find({from_vertex, arc}) == visited_fanins_.end()); + || !visited_fanins_.contains({from_vertex, arc})); debugPrint(debug_, "path_enum", 3, " pruned {}{}{}{}{} {} {}", unique_pins ? "unique_pins " : "", unique_edges ? "unique_edges " : "", same_arc ? "same_arc " : "", diff --git a/search/PathEnum.hh b/search/PathEnum.hh index 8fbab624..bcf856fd 100644 --- a/search/PathEnum.hh +++ b/search/PathEnum.hh @@ -24,14 +24,16 @@ #pragma once +#include #include #include -#include "ContainerHelpers.hh" +#include "Delay.hh" #include "Iterator.hh" -#include "StaState.hh" -#include "SearchClass.hh" +#include "LibertyClass.hh" #include "Path.hh" +#include "SearchClass.hh" +#include "StaState.hh" namespace sta { @@ -67,7 +69,7 @@ public: const StaState *sta); // Insert path ends that are enumerated in slack/arrival order. void insert(PathEnd *path_end); - virtual ~PathEnum(); + ~PathEnum() override; bool hasNext() override; PathEnd *next() override; @@ -85,7 +87,7 @@ private: Path *&after_div_copy); void updatePathHeadDelays(PathSeq &path, Path *after_div); - Arrival divSlack(Path *path, + Arrival divSlack(Path *before_div, Path *after_div, const Edge *div_edge, const TimingArc *div_arc); @@ -99,13 +101,13 @@ private: bool unique_pins_; bool unique_edges_; DiversionQueue div_queue_; - int div_count_; + int div_count_{0}; // Number of paths returned for each endpoint (limit to endpoint_path_count). VertexPathCountMap path_counts_; - bool inserts_pruned_; - PathEnd *next_; + bool inserts_pruned_{false}; + PathEnd *next_{nullptr}; friend class PathEnumFaninVisitor; }; -} // namespace +} // namespace sta diff --git a/search/PathExpanded.cc b/search/PathExpanded.cc index 1f9713a1..bfc082bc 100644 --- a/search/PathExpanded.cc +++ b/search/PathExpanded.cc @@ -24,15 +24,15 @@ #include "PathExpanded.hh" -#include "TimingRole.hh" -#include "PortDirection.hh" -#include "Network.hh" #include "Clock.hh" -#include "Search.hh" -#include "Path.hh" -#include "Latches.hh" #include "Genclks.hh" +#include "Latches.hh" #include "Mode.hh" +#include "Network.hh" +#include "Path.hh" +#include "PortDirection.hh" +#include "Search.hh" +#include "TimingRole.hh" namespace sta { @@ -236,4 +236,4 @@ PathExpanded::latchPaths(// Return values. } } -} // namespace +} // namespace sta diff --git a/search/PathGroup.cc b/search/PathGroup.cc index e2e20a80..6750613c 100644 --- a/search/PathGroup.cc +++ b/search/PathGroup.cc @@ -28,34 +28,35 @@ #include #include #include +#include #include "ContainerHelpers.hh" -#include "StringUtil.hh" -#include "Stats.hh" #include "Debug.hh" -#include "Mutex.hh" -#include "Fuzzy.hh" -#include "MinMax.hh" #include "DispatchQueue.hh" #include "ExceptionPath.hh" -#include "Sdc.hh" -#include "Mode.hh" +#include "Fuzzy.hh" #include "Graph.hh" +#include "MinMax.hh" +#include "Mode.hh" +#include "Mutex.hh" #include "PathEnd.hh" -#include "Tag.hh" -#include "Scene.hh" -#include "Search.hh" -#include "VisitPathEnds.hh" #include "PathEnum.hh" +#include "Scene.hh" +#include "Sdc.hh" +#include "Search.hh" +#include "Stats.hh" +#include "StringUtil.hh" +#include "Tag.hh" +#include "VisitPathEnds.hh" namespace sta { -int PathGroup::group_path_count_max = std::numeric_limits::max(); +size_t PathGroup::group_path_count_max = std::numeric_limits::max(); PathGroup * PathGroup::makePathGroupSlack(std::string_view name, - int group_path_count, - int endpoint_path_count, + size_t group_path_count, + size_t endpoint_path_count, bool unique_pins, bool unique_edges, float slack_min, @@ -69,8 +70,8 @@ PathGroup::makePathGroupSlack(std::string_view name, PathGroup * PathGroup::makePathGroupArrival(std::string_view name, - int group_path_count, - int endpoint_path_count, + size_t group_path_count, + size_t endpoint_path_count, bool unique_pins, bool unique_edges, const MinMax *min_max, @@ -82,8 +83,8 @@ PathGroup::makePathGroupArrival(std::string_view name, } PathGroup::PathGroup(std::string_view name, - int group_path_count, - int endpoint_path_count, + size_t group_path_count, + size_t endpoint_path_count, bool unique_pins, bool unique_edges, float slack_min, @@ -180,7 +181,7 @@ PathGroup::insert(PathEnd *path_end) path_ends_.push_back(path_end); path_end->setPathGroup(this); if (group_path_count_ != group_path_count_max - && path_ends_.size() > static_cast(group_path_count_) * 2) + && path_ends_.size() > group_path_count_ * 2) prune(); } @@ -190,13 +191,12 @@ PathGroup::prune() sort(); VertexPathCountMap path_counts; size_t end_count = 0; - for (unsigned i = 0; i < path_ends_.size(); i++) { - PathEnd *path_end = path_ends_[i]; + for (PathEnd *path_end : path_ends_) { Vertex *vertex = path_end->vertex(sta_); // Squish up to endpoint_path_count path ends per vertex // up to the front of path_ends_. - if (end_count < static_cast(group_path_count_) - && path_counts[vertex] < static_cast(endpoint_path_count_)) { + if (end_count < group_path_count_ + && path_counts[vertex] < endpoint_path_count_) { path_ends_[end_count++] = path_end; path_counts[vertex]++; } @@ -225,7 +225,7 @@ PathGroup::pushEnds(PathEndSeq &path_ends) void PathGroup::ensureSortedMaxPaths() { - if (path_ends_.size() > static_cast(group_path_count_)) + if (path_ends_.size() > group_path_count_) prune(); else sort(); @@ -247,8 +247,8 @@ PathGroup::clear() //////////////////////////////////////////////////////////////// -PathGroups::PathGroups(int group_path_count, - int endpoint_path_count, +PathGroups::PathGroups(size_t group_path_count, + size_t endpoint_path_count, bool unique_pins, bool unique_edges, float slack_min, @@ -262,7 +262,7 @@ PathGroups::PathGroups(int group_path_count, bool clk_gating_hold, bool unconstrained, const Mode *mode) : - StaState(mode), + StaState(mode->sta()), mode_(mode), group_path_count_(group_path_count), endpoint_path_count_(endpoint_path_count), @@ -286,8 +286,8 @@ PathGroups::PathGroups(int group_path_count, } void -PathGroups::makeGroups(int group_path_count, - int endpoint_path_count, +PathGroups::makeGroups(size_t group_path_count, + size_t endpoint_path_count, bool unique_pins, bool unique_edges, float slack_min, @@ -299,7 +299,7 @@ PathGroups::makeGroups(int group_path_count, bool unconstrained, const MinMax *min_max) { - int mm_index = min_max->index(); + size_t mm_index = min_max->index(); if (setup_hold) { const Sdc *sdc = mode_->sdc(); for (const auto& [name, group] : sdc->groupPaths()) { @@ -425,7 +425,7 @@ PathGroups::pathGroups(const PathEnd *path_end) const PathGroup *path_group = nullptr; ExceptionPathSeq group_paths = search_->groupPathsTo(path_end); const MinMax *min_max = path_end->minMax(this); - int mm_index = min_max->index(); + size_t mm_index = min_max->index(); if (path_end->isUnconstrained()) path_group = unconstrained_[mm_index]; // GroupPaths have precedence. @@ -488,9 +488,9 @@ PathGroups::pathGroupNames(const PathEnd *path_end, // GroupPaths have precedence. for (ExceptionPath *group_path : group_paths) { if (group_path->isDefault()) - group_names.push_back(std::string(path_delay_group_name_)); + group_names.emplace_back(path_delay_group_name_); else - group_names.push_back(std::string(group_path->name())); + group_names.emplace_back(group_path->name()); } } else if (path_end->isCheck() || path_end->isLatchCheck()) { @@ -545,7 +545,7 @@ void PathGroups::pushEnds(PathEndSeq &path_ends) { for (const MinMax *min_max : MinMax::range()) { - int mm_index = min_max->index(); + size_t mm_index = min_max->index(); for (std::string &group_name : pathGroupNames()) { PathGroup *path_group = findPathGroup(group_name, min_max); if (path_group) @@ -592,7 +592,7 @@ PathGroups::pushUnconstrainedPathEnds(PathEndSeq &path_ends, { std::set groups; for (const MinMax *mm : min_max->range()) { - int mm_index = mm->index(); + size_t mm_index = mm->index(); PathGroup *group = unconstrained_[mm_index]; if (group // For multiple scene path APs use the same group. @@ -719,7 +719,7 @@ MakePathEnds1::vertexEnd(Vertex *) class MakePathEndsAll : public PathEndVisitor { public: - MakePathEndsAll(int endpoint_path_count, + MakePathEndsAll(size_t endpoint_path_count, PathGroups *path_groups); MakePathEndsAll(const MakePathEndsAll&) = default; ~MakePathEndsAll() override; @@ -731,7 +731,7 @@ private: void visitPathEnd(PathEnd *path_end, PathGroup *group); - int endpoint_path_count_; + size_t endpoint_path_count_; PathGroups *path_groups_; const StaState *sta_; PathGroupEndsMap ends_; @@ -739,7 +739,7 @@ private: PathEndNoCrprLess path_no_crpr_less_; }; -MakePathEndsAll::MakePathEndsAll(int endpoint_path_count, +MakePathEndsAll::MakePathEndsAll(size_t endpoint_path_count, PathGroups *path_groups) : endpoint_path_count_(endpoint_path_count), path_groups_(path_groups), @@ -789,7 +789,7 @@ MakePathEndsAll::vertexEnd(Vertex *) sort(ends, less_); PathEndNoCrprSet unique_ends(path_no_crpr_less_); auto end_iter = ends->begin(); - int n = 0; + size_t n = 0; while (end_iter != ends->end() && n < endpoint_path_count_) { PathEnd *path_end = *end_iter++; @@ -827,8 +827,8 @@ MakePathEndsAll::vertexEnd(Vertex *) void PathGroups::makeGroupPathEnds(ExceptionTo *to, - int group_path_count, - int endpoint_path_count, + size_t group_path_count, + size_t endpoint_path_count, bool unique_pins, bool unique_edges, const SceneSeq &scenes, @@ -843,7 +843,7 @@ PathGroups::makeGroupPathEnds(ExceptionTo *to, makeGroupPathEnds(to, scenes, min_max, &make_path_ends); for (const MinMax *path_min_max : MinMax::range()) { - int mm_index = path_min_max->index(); + size_t mm_index = path_min_max->index(); for (const Mode *mode : Scene::modes(scenes)) { const Sdc *sdc = mode->sdc(); for (const auto& [name, groups] : sdc->groupPaths()) { @@ -882,8 +882,8 @@ PathGroups::makeGroupPathEnds(ExceptionTo *to, void PathGroups::enumPathEnds(PathGroup *group, - int group_path_count, - int endpoint_path_count, + size_t group_path_count, + size_t endpoint_path_count, bool unique_pins, bool unique_edges, bool cmp_slack) @@ -900,7 +900,7 @@ PathGroups::enumPathEnds(PathGroup *group, group->clear(); // Parallel path enumeratation to find the endpoint_path_count/max path ends. - for (int n = 0; path_enum.hasNext() && n < group_path_count; n++) { + for (size_t n = 0; path_enum.hasNext() && n < group_path_count; n++) { PathEnd *end = path_enum.next(); if (group->saveable(end)) group->insert(end); @@ -954,7 +954,7 @@ public: const MinMaxAll *min_max, const StaState *sta); MakeEndpointPathEnds(const MakeEndpointPathEnds &make_path_ends); - ~MakeEndpointPathEnds(); + ~MakeEndpointPathEnds() override; VertexVisitor *copy() const override; void visit(Vertex *vertex) override; @@ -1032,4 +1032,4 @@ PathGroups::makeGroupPathEnds(VertexSet &endpoints, } } -} // namespace +} // namespace sta diff --git a/search/PocvMode.cc b/search/PocvMode.cc index 7e7b28a5..46c262e5 100644 --- a/search/PocvMode.cc +++ b/search/PocvMode.cc @@ -1,5 +1,5 @@ // OpenSTA, Static Timing Analyzer -// Copyright (c) 2025, Parallax Software, Inc. +// Copyright (c) 2026, 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 @@ -45,4 +45,4 @@ findPocvMode(std::string_view mode_name) return pocv_mode_map.find(mode_name, PocvMode::scalar); } -} // namespace +} // namespace sta diff --git a/search/Property.cc b/search/Property.cc index 067298d7..322cf00c 100644 --- a/search/Property.cc +++ b/search/Property.cc @@ -26,24 +26,25 @@ #include #include +#include -#include "Format.hh" -#include "StringUtil.hh" -#include "MinMax.hh" -#include "Transition.hh" -#include "Units.hh" -#include "TimingArc.hh" -#include "Liberty.hh" -#include "PortDirection.hh" -#include "Network.hh" -#include "Graph.hh" #include "Clock.hh" -#include "Scene.hh" +#include "Format.hh" +#include "Graph.hh" +#include "Liberty.hh" +#include "MinMax.hh" +#include "Network.hh" +#include "Path.hh" #include "PathEnd.hh" #include "PathExpanded.hh" -#include "Path.hh" -#include "power/Power.hh" +#include "PortDirection.hh" +#include "Scene.hh" #include "Sta.hh" +#include "StringUtil.hh" +#include "TimingArc.hh" +#include "Transition.hh" +#include "Units.hh" +#include "power/Power.hh" namespace sta { @@ -52,8 +53,7 @@ class PropertyUnknown : public Exception public: PropertyUnknown(std::string_view type, std::string_view property); - virtual ~PropertyUnknown() {} - virtual const char *what() const noexcept; + const char *what() const noexcept override; private: std::string msg_; @@ -61,7 +61,6 @@ private: PropertyUnknown::PropertyUnknown(std::string_view type, std::string_view property) : - Exception(), msg_(sta::format("{} objects do not have a {} property.", type, property)) { } @@ -79,8 +78,7 @@ class PropertyTypeWrong : public Exception public: PropertyTypeWrong(const std::string &accessor, const std::string &type); - virtual ~PropertyTypeWrong() {} - virtual const char *what() const noexcept; + const char *what() const noexcept override; private: std::string msg_; @@ -88,7 +86,6 @@ private: PropertyTypeWrong::PropertyTypeWrong(const std::string &accessor, const std::string &type) : - Exception(), msg_(sta::format("property accessor {} is only valid for {} properties.", accessor, type)) { @@ -714,7 +711,7 @@ Properties::getProperty(const LibertyCell *cell, Network *network = sta_->cmdNetwork(); LibertyLibrary *lib = cell->libertyLibrary(); std::string lib_name = lib->name(); - std::string cell_name = cell->name(); + const std::string& cell_name = cell->name(); std::string full_name = lib_name + network->pathDivider() + cell_name; return PropertyValue(full_name); } @@ -893,14 +890,14 @@ Properties::getProperty(const LibertyPort *port, MinMax::max(), sta_); return delayPropertyValue(delay); } - else { + else { PropertyValue value = registry_liberty_port_.getProperty(port, property, "liberty_port", sta_); if (value.type() != PropertyValue::Type::none) return value; else throw PropertyUnknown("liberty port", property); - } + } } //////////////////////////////////////////////////////////////// @@ -1266,70 +1263,70 @@ Properties::capacitancePropertyValue(float cap) void Properties::defineProperty(std::string_view property, - PropertyRegistry::PropertyHandler handler) + PropertyRegistry::PropertyHandler &handler) { registry_library_.defineProperty(property, handler); } void Properties::defineProperty(std::string_view property, - PropertyRegistry::PropertyHandler handler) + PropertyRegistry::PropertyHandler &handler) { registry_liberty_library_.defineProperty(property, handler); } void Properties::defineProperty(std::string_view property, - PropertyRegistry::PropertyHandler handler) + PropertyRegistry::PropertyHandler &handler) { registry_cell_.defineProperty(property, handler); } void Properties::defineProperty(std::string_view property, - PropertyRegistry::PropertyHandler handler) + PropertyRegistry::PropertyHandler &handler) { registry_liberty_cell_.defineProperty(property, handler); } void Properties::defineProperty(std::string_view property, - PropertyRegistry::PropertyHandler handler) + PropertyRegistry::PropertyHandler &handler) { registry_port_.defineProperty(property, handler); } void Properties::defineProperty(std::string_view property, - PropertyRegistry::PropertyHandler handler) + PropertyRegistry::PropertyHandler &handler) { registry_liberty_port_.defineProperty(property, handler); } void Properties::defineProperty(std::string_view property, - PropertyRegistry::PropertyHandler handler) + PropertyRegistry::PropertyHandler &handler) { registry_instance_.defineProperty(property, handler); } void Properties::defineProperty(std::string_view property, - PropertyRegistry::PropertyHandler handler) + PropertyRegistry::PropertyHandler &handler) { registry_pin_.defineProperty(property, handler); } void Properties::defineProperty(std::string_view property, - PropertyRegistry::PropertyHandler handler) + PropertyRegistry::PropertyHandler &handler) { registry_net_.defineProperty(property, handler); } void Properties::defineProperty(std::string_view property, - PropertyRegistry::PropertyHandler handler) + PropertyRegistry::PropertyHandler &handler) { registry_clock_.defineProperty(property, handler); } @@ -1356,7 +1353,7 @@ void PropertyRegistry::defineProperty(std::string_view property, PropertyHandler handler) { - registry_[std::string(property)] = handler; + registry_[std::string(property)] = std::move(std::move(std::move(std::move(std::move(std::move(std::move(std::move(std::move(std::move(handler)))))))))); } -} // namespace +} // namespace sta diff --git a/search/ReportPath.cc b/search/ReportPath.cc index 0602c978..01027f35 100644 --- a/search/ReportPath.cc +++ b/search/ReportPath.cc @@ -22,46 +22,46 @@ // // This notice may not be removed or altered from any source distribution. +#include "ReportPath.hh" + #include // reverse #include #include -#include "ReportPath.hh" - +#include "ArcDelayCalc.hh" +#include "CheckMaxSkews.hh" +#include "CheckMinPeriods.hh" +#include "CheckMinPulseWidths.hh" +#include "ClkInfo.hh" #include "ContainerHelpers.hh" -#include "Format.hh" -#include "Report.hh" #include "Error.hh" -#include "StringUtil.hh" +#include "ExceptionPath.hh" +#include "Format.hh" #include "Fuzzy.hh" -#include "Units.hh" +#include "Genclks.hh" +#include "Graph.hh" +#include "GraphDelayCalc.hh" +#include "InputDrive.hh" +#include "Latches.hh" +#include "Liberty.hh" +#include "Mode.hh" +#include "Network.hh" +#include "Parasitics.hh" +#include "Path.hh" +#include "PathExpanded.hh" +#include "PathGroup.hh" +#include "PortDelay.hh" +#include "PortDirection.hh" +#include "Report.hh" +#include "Scene.hh" +#include "Sdc.hh" +#include "Search.hh" +#include "StringUtil.hh" +#include "Tag.hh" +#include "TimingArc.hh" #include "TimingRole.hh" #include "Transition.hh" -#include "TimingArc.hh" -#include "Liberty.hh" -#include "PortDirection.hh" -#include "Network.hh" -#include "Graph.hh" -#include "PortDelay.hh" -#include "ExceptionPath.hh" -#include "InputDrive.hh" -#include "Sdc.hh" -#include "Parasitics.hh" -#include "ArcDelayCalc.hh" -#include "GraphDelayCalc.hh" -#include "ClkInfo.hh" -#include "Tag.hh" -#include "PathGroup.hh" -#include "CheckMinPulseWidths.hh" -#include "CheckMinPeriods.hh" -#include "CheckMaxSkews.hh" -#include "Path.hh" -#include "Search.hh" -#include "PathExpanded.hh" -#include "Latches.hh" -#include "Scene.hh" -#include "Mode.hh" -#include "Genclks.hh" +#include "Units.hh" #include "Variables.hh" namespace sta { @@ -96,8 +96,7 @@ ReportField::ReportField(std::string_view name, } ReportField::~ReportField() -{ -} += default; void ReportField::setProperties(std::string_view title, @@ -125,11 +124,7 @@ ReportField::setEnabled(bool enabled) //////////////////////////////////////////////////////////////// ReportPath::ReportPath(StaState *sta) : - StaState(sta), - format_(ReportPathFormat::full), - no_split_(false), - start_end_pt_width_(80), - field_width_extra_(5) + StaState(sta) { makeFields(); setDigits(2); @@ -365,7 +360,6 @@ ReportPath::reportPathEndHeader() const void ReportPath::reportPathEndFooter() const { - std::string header; switch (format_) { case ReportPathFormat::full: case ReportPathFormat::full_clock: @@ -2476,7 +2470,7 @@ ReportPath::reportPathLine(const Path *path, void ReportPath::reportRequired(const PathEnd *end, - std::string margin_msg) const + const std::string& margin_msg) const { Required req_time = end->requiredTimeOffset(this); const EarlyLate *early_late = end->clkEarlyLate(this); @@ -2742,7 +2736,7 @@ ReportPath::reportPath6(const Path *path, Pin *pin = vertex->pin(); Arrival time = delaySum(path1->arrival(), time_offset, this); Delay incr = 0.0; - std::string_view line_case = ""; + std::string_view line_case; bool is_clk_start = path1->vertex(this) == clk_start; bool is_clk = path1->isClock(search_); Instance *inst = network_->instance(pin); @@ -3249,7 +3243,7 @@ ReportPath::reportLine(std::string_view what, else if (field == field_variation_) reportFieldBlank(field, line); else if (field == field_src_attr_) { - if (src_attr != "") + if (!src_attr.empty()) reportField(src_attr, field, line); else reportFieldBlank(field, line); @@ -3597,7 +3591,7 @@ hierPinsThruEdge(const Edge *edge, hierPinsAbove(drvr_pin, network, drvr_hpins); hierPinsAbove(load_pin, network, load_hpins); if (drvr_hpins.empty()) { - std::reverse(load_hpins.begin(), load_hpins.end()); + std::ranges::reverse(load_hpins); return load_hpins; } if (load_hpins.empty()) @@ -3656,4 +3650,4 @@ hierPinsAbove(const Net *net, } } -} // namespace +} // namespace sta diff --git a/search/ReportPath.hh b/search/ReportPath.hh index b3d9bd10..c223a50c 100644 --- a/search/ReportPath.hh +++ b/search/ReportPath.hh @@ -24,16 +24,26 @@ #pragma once +#include #include #include #include -#include "StringUtil.hh" -#include "SearchClass.hh" -#include "PathEnd.hh" -#include "CheckMinPulseWidths.hh" -#include "CheckMinPeriods.hh" #include "CheckMaxSkews.hh" +#include "CheckMinPeriods.hh" +#include "CheckMinPulseWidths.hh" +#include "Clock.hh" +#include "Delay.hh" +#include "GraphClass.hh" +#include "LibertyClass.hh" +#include "MinMax.hh" +#include "Mode.hh" +#include "NetworkClass.hh" +#include "Path.hh" +#include "PathEnd.hh" +#include "Sdc.hh" +#include "SearchClass.hh" +#include "StringUtil.hh" namespace sta { @@ -47,7 +57,7 @@ class ReportPath : public StaState { public: ReportPath(StaState *sta); - virtual ~ReportPath(); + ~ReportPath() override; ReportPathFormat pathFormat() const { return format_; } void setPathFormat(ReportPathFormat format); void setReportFieldOrder(const StringSeq &field_names); @@ -197,7 +207,7 @@ protected: Arrival &borrow, Arrival &time_given_to_startpoint) const; void reportEndpoint(const PathEndDataCheck *end) const; - std::string_view clkNetworkDelayIdealProp(bool is_ideal) const; + std::string_view clkNetworkDelayIdealProp(bool is_prop) const; std::string checkRoleReason(const PathEnd *end) const; std::string checkRoleString(const PathEnd *end) const; @@ -288,13 +298,13 @@ protected: Arrival clk_time, const MinMax *min_max) const ; void reportRequired(const PathEnd *end, - std::string margin_msg) const ; + const std::string& margin_msg) const ; void reportSlack(const PathEnd *end) const ; void reportSlack(Slack slack) const ; void reportSpaceSlack(const PathEnd *end, - std::string &line) const ; + std::string &result) const ; void reportSpaceSlack(Slack slack, - std::string &line) const ; + std::string &result) const ; void reportSrcPathArrival(const PathEnd *end, const PathExpanded &expanded) const ; void reportPath(const PathEnd *end, @@ -386,38 +396,38 @@ protected: const EarlyLate *early_late) const; void reportDashLineTotal() const; void reportDescription(std::string_view what, - std::string &result) const; + std::string &line) const; void reportDescription(std::string_view what, bool first_field, bool last_field, - std::string &result) const; + std::string &line) const; void reportFieldTime(float value, ReportField *field, - std::string &result) const; + std::string &line) const; void reportSpaceFieldTime(float value, - std::string &result) const; + std::string &line) const; void reportSpaceFieldDelay(const Delay &value, const EarlyLate *early_late, - std::string &result) const; + std::string &line) const; void reportFieldDelayMinus(const Delay &value, const EarlyLate *early_late, const ReportField *field, - std::string &result) const; + std::string &line) const; void reportTotalDelay(const Delay &value, const EarlyLate *early_late, - std::string &result) const; + std::string &line) const; void reportFieldDelay(const Delay &value, const EarlyLate *early_late, const ReportField *field, - std::string &result) const; + std::string &line) const; void reportField(float value, const ReportField *field, - std::string &result) const; + std::string &line) const; void reportField(std::string_view value, const ReportField *field, - std::string &result) const; + std::string &line) const; void reportFieldBlank(const ReportField *field, - std::string &result) const; + std::string &line) const; void reportDashLine() const; void reportDashLine(int line_width) const; void reportBlankLine() const; @@ -475,15 +485,15 @@ protected: const MinMax *min_max) const; // Path options. - ReportPathFormat format_; + ReportPathFormat format_{ReportPathFormat::full}; ReportFieldSeq fields_; bool report_input_pin_; bool report_hier_pins_; bool report_net_; - bool no_split_; + bool no_split_{false}; int digits_; - size_t start_end_pt_width_; + size_t start_end_pt_width_{80}; ReportField *field_description_; ReportField *field_total_; @@ -500,7 +510,7 @@ protected: std::string plus_zero_; std::string minus_zero_; - int field_width_extra_; + int field_width_extra_{5}; static constexpr float field_blank_ = -1; static const float field_skip_; }; @@ -538,4 +548,4 @@ protected: std::string blank_; }; -} // namespace +} // namespace sta diff --git a/search/Scene.cc b/search/Scene.cc index 0bd27aa3..404ac409 100644 --- a/search/Scene.cc +++ b/search/Scene.cc @@ -25,9 +25,9 @@ #include "Scene.hh" #include "ContainerHelpers.hh" +#include "Mode.hh" #include "Parasitics.hh" #include "Sdc.hh" -#include "Mode.hh" namespace sta { @@ -134,7 +134,7 @@ Scene::libertyLibraries(const MinMax *min_max) const return liberty_[min_max->index()]; } -int +size_t Scene::libertyIndex(const MinMax *min_max) const { return index_ * MinMax::index_count + min_max->index(); @@ -184,4 +184,4 @@ Scene::modesSorted(const SceneSeq &scenes) return modes; } -} // namespace +} // namespace sta diff --git a/search/Search.cc b/search/Search.cc index 246d5dd6..2fc617fa 100644 --- a/search/Search.cc +++ b/search/Search.cc @@ -24,56 +24,61 @@ #include "Search.hh" +#include +#include #include -#include "ContainerHelpers.hh" -#include "Mutex.hh" -#include "Report.hh" -#include "Debug.hh" -#include "Stats.hh" -#include "Fuzzy.hh" -#include "TimingRole.hh" -#include "FuncExpr.hh" -#include "TimingArc.hh" -#include "Sequential.hh" -#include "Units.hh" -#include "Liberty.hh" -#include "Network.hh" -#include "PortDirection.hh" -#include "Graph.hh" -#include "GraphCmp.hh" -#include "PortDelay.hh" -#include "Clock.hh" -#include "CycleAccting.hh" -#include "ExceptionPath.hh" -#include "DataCheck.hh" -#include "Sdc.hh" -#include "Mode.hh" -#include "SearchPred.hh" -#include "Levelize.hh" #include "Bfs.hh" -#include "Sim.hh" -#include "Path.hh" #include "ClkInfo.hh" -#include "Tag.hh" -#include "TagGroup.hh" +#include "Clock.hh" +#include "ContainerHelpers.hh" +#include "Crpr.hh" +#include "DataCheck.hh" +#include "Debug.hh" +#include "Delay.hh" +#include "ExceptionPath.hh" +#include "Fuzzy.hh" +#include "GatedClk.hh" +#include "Genclks.hh" +#include "Graph.hh" +#include "GraphClass.hh" +#include "Latches.hh" +#include "Levelize.hh" +#include "Liberty.hh" +#include "LibertyClass.hh" +#include "MinMax.hh" +#include "Mode.hh" +#include "Mutex.hh" +#include "Network.hh" +#include "NetworkClass.hh" +#include "Path.hh" #include "PathEnd.hh" #include "PathGroup.hh" -#include "VisitPathEnds.hh" -#include "GatedClk.hh" -#include "WorstSlack.hh" -#include "Latches.hh" -#include "Crpr.hh" -#include "Genclks.hh" +#include "PortDelay.hh" +#include "PortDirection.hh" +#include "Report.hh" +#include "Scene.hh" +#include "Sdc.hh" +#include "SdcClass.hh" +#include "SearchClass.hh" +#include "SearchPred.hh" +#include "Stats.hh" +#include "StringUtil.hh" +#include "Tag.hh" +#include "TagGroup.hh" +#include "TimingArc.hh" +#include "TimingRole.hh" #include "Variables.hh" +#include "VertexVisitor.hh" +#include "VisitPathEnds.hh" +#include "WorstSlack.hh" namespace sta { //////////////////////////////////////////////////////////////// EvalPred::EvalPred(const StaState *sta) : - SearchPred0(sta), - search_thru_latches_(true) + SearchPred0(sta) { } @@ -227,62 +232,40 @@ SearchAdj::searchTo(const Vertex * /* to_vertex */, Search::Search(StaState *sta) : StaState(sta), - unconstrained_paths_(false), - crpr_path_pruning_enabled_(true), - crpr_approx_missing_requireds_(true), search_thru_(new SearchThru(this)), search_adj_(new SearchAdj(nullptr, this)), eval_pred_(new EvalPred(this)), - arrivals_exist_(false), - arrivals_seeded_(false), invalid_arrivals_(makeVertexSet(this)), arrival_iter_(new BfsFwdIterator(BfsIndex::arrival, nullptr, this)), arrival_visitor_(new ArrivalVisitor(this)), - requireds_exist_(false), - requireds_seeded_(false), invalid_requireds_(makeVertexSet(this)), required_iter_(new BfsBkwdIterator(BfsIndex::required, search_adj_, this)), - tns_exists_(false), invalid_tns_(makeVertexSet(this)), - worst_slacks_(nullptr), clk_info_set_(new ClkInfoSet(ClkInfoLess(this))), - tag_capacity_(128), tags_(new Tag *[tag_capacity_]), tag_set_(new TagSet(tag_capacity_, TagHash(this), TagEqual(this))), - tag_next_(0), - tag_group_capacity_(tag_capacity_), tag_groups_(new TagGroup *[tag_group_capacity_]), tag_group_set_(new TagGroupSet(tag_group_capacity_)), - tag_group_next_(0), - pending_latch_outputs_(makeVertexSet(this)), pending_clk_endpoints_(makeVertexSet(this)), endpoints_(makeVertexSet(this)), - endpoints_initialized_(false), invalid_endpoints_(makeVertexSet(this)), - have_filter_(false), - filter_from_(nullptr), - filter_thrus_(nullptr), - filter_to_(nullptr), filtered_arrivals_(makeVertexSet(this)), - found_downstream_clk_pins_(false), - postpone_latch_outputs_(false), - visit_path_ends_(new VisitPathEnds(this)), gated_clk_(new GatedClk(this)), check_crpr_(new CheckCrpr(this)) @@ -714,18 +697,16 @@ class SeedFaninsThruHierPin : public HierPinThruVisitor public: SeedFaninsThruHierPin(Graph *graph, Search *search); - -protected: void visit(const Pin *drvr, const Pin *load) override; +protected: Graph *graph_; Search *search_; }; SeedFaninsThruHierPin::SeedFaninsThruHierPin(Graph *graph, Search *search) : - HierPinThruVisitor(), graph_(graph), search_(search) { @@ -1556,7 +1537,6 @@ Search::seedClkArrival(const Pin *pin, // Propagated pin overrides latency on clk. if (sdc->isPropagatedClock(pin)) { latency = 0.0; - latency_exists = false; is_propagated = true; } } @@ -2689,7 +2669,7 @@ Search::findTagGroup(TagGroupBldr *tag_bldr) if (tag_group_next_ == tag_group_capacity_) { TagGroupIndex tag_capacity = tag_group_capacity_ * 2; TagGroup **tag_groups = new TagGroup *[tag_capacity]; - memcpy(tag_groups, tag_groups_, tag_group_capacity_ * sizeof(TagGroup *)); + std::copy_n(tag_groups_.load(), tag_group_capacity_, tag_groups); tag_groups_prev_.push_back(tag_groups_); tag_groups_ = tag_groups; tag_group_capacity_ = tag_capacity; @@ -2952,7 +2932,7 @@ Search::findTag(Scene *scene, if (tag_next_ == tag_capacity_) { TagIndex tag_capacity = tag_capacity_ * 2; Tag **tags = new Tag *[tag_capacity]; - memcpy(tags, tags_, tag_capacity_ * sizeof(Tag *)); + std::copy_n(tags_.load(), tag_capacity_, tags); tags_prev_.push_back(tags_); tags_ = tags; tag_capacity_ = tag_capacity; @@ -3396,12 +3376,6 @@ Search::seedRequiredEnqueueFanin(Vertex *vertex) //////////////////////////////////////////////////////////////// -RequiredCmp::RequiredCmp() : - have_requireds_(false) -{ - requireds_.reserve(10); -} - void RequiredCmp::requiredsInit(Vertex *vertex, const StaState *sta) diff --git a/search/Search.i b/search/Search.i index 0e65d2f1..bf038a42 100644 --- a/search/Search.i +++ b/search/Search.i @@ -535,11 +535,11 @@ report_clk_latency(ConstClockSeq clks, void report_min_pulse_width_checks(const Net *net, size_t max_count, - bool violations, + bool violators, bool verbose, const SceneSeq scenes) { - return Sta::sta()->reportMinPulseWidthChecks(net, max_count, violations, + return Sta::sta()->reportMinPulseWidthChecks(net, max_count, violators, verbose, scenes); } @@ -548,11 +548,11 @@ report_min_pulse_width_checks(const Net *net, void report_min_period_checks(const Net *net, size_t max_count, - bool violations, + bool violators, bool verbose, const SceneSeq scenes) { - Sta::sta()->reportMinPeriodChecks(net, max_count, violations, verbose, scenes); + Sta::sta()->reportMinPeriodChecks(net, max_count, violators, verbose, scenes); } //////////////////////////////////////////////////////////////// @@ -1113,7 +1113,7 @@ void levelize() { Sta *sta = Sta::sta(); - sta->levelize()->levelize(); + sta->levelize()->findLevels(); } %} // inline diff --git a/search/SearchPred.cc b/search/SearchPred.cc index 803bcf54..77279374 100644 --- a/search/SearchPred.cc +++ b/search/SearchPred.cc @@ -24,17 +24,17 @@ #include "SearchPred.hh" +#include "Graph.hh" +#include "Latches.hh" +#include "Levelize.hh" +#include "Liberty.hh" +#include "Mode.hh" +#include "Network.hh" +#include "Sdc.hh" +#include "Search.hh" +#include "Sim.hh" #include "TimingArc.hh" #include "TimingRole.hh" -#include "Liberty.hh" -#include "Network.hh" -#include "Graph.hh" -#include "Sdc.hh" -#include "Mode.hh" -#include "Levelize.hh" -#include "Search.hh" -#include "Latches.hh" -#include "Sim.hh" #include "Variables.hh" namespace sta { @@ -198,7 +198,7 @@ bool isClkEnd(Vertex *vertex, const Mode *mode) { - Graph *graph = mode->graph(); + Graph *graph = mode->sta()->graph(); ClkTreeSearchPred pred(graph); VertexOutEdgeIterator edge_iter(vertex, graph); while (edge_iter.hasNext()) { @@ -223,7 +223,7 @@ searchThru(const Edge *edge, const TimingArc *arc, const Mode *mode) { - const Graph *graph = mode->graph(); + const Graph *graph = mode->sta()->graph(); const RiseFall *from_rf = arc->fromEdge()->asRiseFall(); const RiseFall *to_rf = arc->toEdge()->asRiseFall(); // Ignore transitions other than rise/fall. @@ -323,4 +323,4 @@ hasFanout(Vertex *vertex, return false; } -} // namespace +} // namespace sta diff --git a/search/Sim.cc b/search/Sim.cc index f2fd6531..58f9adea 100644 --- a/search/Sim.cc +++ b/search/Sim.cc @@ -54,12 +54,7 @@ findDrvrPin(const Pin *pin, Sim::Sim(StaState *sta) : StaState(sta), - mode_(nullptr), - observer_(nullptr), - valid_(false), - incremental_(false), const_func_pins_(network_), - const_func_pins_valid_(false), invalid_insts_(network_), invalid_drvr_pins_(network_), invalid_load_pins_(network_), @@ -179,7 +174,7 @@ logicNot(LogicValue value) static LogicValue logic_not[5] = {LogicValue::one, LogicValue::zero, LogicValue::unknown, LogicValue::unknown, LogicValue::unknown}; - return logic_not[int(value)]; + return logic_not[static_cast(value)]; } void @@ -726,7 +721,7 @@ Sim::functionSense(const Instance *inst, const Pin *from_pin, const Pin *to_pin) { - if (isConstant((from_pin))) + if (isConstant(from_pin)) return TimingSense::none; else { LibertyPort *from_port = network_->libertyPort(from_pin); @@ -867,7 +862,7 @@ Sim::isDisabledMode(Edge *edge, { // Default values. is_disabled = false; - disable_cond = 0; + disable_cond = nullptr; TimingArcSet *arc_set = edge->timingArcSet(); const std::string &mode_name = arc_set->modeName(); const std::string &mode_value = arc_set->modeValue(); diff --git a/search/Sim.hh b/search/Sim.hh index 337f5546..5edd90f2 100644 --- a/search/Sim.hh +++ b/search/Sim.hh @@ -24,17 +24,18 @@ #pragma once -#include #include +#include #include #include -#include "StaConfig.hh" // CUDD -#include "NetworkClass.hh" +#include "Bdd.hh" #include "GraphClass.hh" +#include "LibertyClass.hh" +#include "Mode.hh" +#include "NetworkClass.hh" #include "SdcClass.hh" #include "StaState.hh" -#include "Bdd.hh" namespace sta { @@ -51,8 +52,8 @@ class Sim : public StaState { public: Sim(StaState *sta); - virtual ~Sim(); - virtual void copyState(const StaState *sta); + ~Sim() override; + void copyState(const StaState *sta) override; void clear(); void setMode(Mode *mode); // Set the observer for simulation value changes. @@ -165,10 +166,10 @@ protected: DdNode *funcBddSim(const FuncExpr *expr, const Instance *inst); - Mode *mode_; - SimObserver *observer_; - bool valid_; - bool incremental_; + Mode *mode_{nullptr}; + SimObserver *observer_{nullptr}; + bool valid_{false}; + bool incremental_{false}; // Constants propagated by Sim.cc SimValueMap sim_value_map_; EdgeDisabledCondSet edge_disabled_cond_set_; @@ -176,7 +177,7 @@ protected: // Cache of pins that have constant functions (tie high and tie low // cell instances). PinSet const_func_pins_; - bool const_func_pins_valid_; + bool const_func_pins_valid_{false}; // Instances that require incremental constant propagation. InstanceSet invalid_insts_; // Driver pins waiting to propagate constant to loads. @@ -194,10 +195,9 @@ class SimObserver : public StaState { public: SimObserver(StaState *sta); - virtual ~SimObserver() {} virtual void valueChangeAfter(const Pin *pin) = 0; virtual void faninEdgesChangeAfter(const Pin *pin) = 0; virtual void fanoutEdgesChangeAfter(const Pin *pin) = 0; }; -} // namespace +} // namespace sta diff --git a/search/Sta.cc b/search/Sta.cc index d8bc2b4d..0b4fbcf3 100644 --- a/search/Sta.cc +++ b/search/Sta.cc @@ -25,73 +25,90 @@ #include "Sta.hh" #include -#include +#include #include -#include "Machine.hh" -#include "Format.hh" -#include "ContainerHelpers.hh" -#include "DispatchQueue.hh" -#include "ReportTcl.hh" -#include "Debug.hh" -#include "Stats.hh" -#include "Fuzzy.hh" -#include "Units.hh" -#include "PatternMatch.hh" -#include "TimingArc.hh" -#include "FuncExpr.hh" -#include "EquivCells.hh" -#include "Liberty.hh" -#include "liberty/LibertyReader.hh" -#include "LibertyWriter.hh" -#include "SdcNetwork.hh" -#include "MakeConcreteNetwork.hh" -#include "PortDirection.hh" -#include "VerilogReader.hh" -#include "Graph.hh" -#include "GraphCmp.hh" -#include "Sdc.hh" -#include "Mode.hh" -#include "Variables.hh" -#include "sdc/WriteSdc.hh" -#include "ExceptionPath.hh" -#include "Parasitics.hh" -#include "parasitics/SpefReader.hh" -#include "parasitics/ReportParasiticAnnotation.hh" -#include "DelayCalc.hh" #include "ArcDelayCalc.hh" +#include "CheckCapacitances.hh" +#include "CheckFanouts.hh" +#include "CheckMaxSkews.hh" +#include "CheckMinPeriods.hh" +#include "CheckMinPulseWidths.hh" +#include "CheckSlews.hh" +#include "CheckTiming.hh" +#include "CircuitSim.hh" +#include "ClkInfo.hh" +#include "ClkLatency.hh" +#include "ClkNetwork.hh" +#include "ClkSkew.hh" +#include "ContainerHelpers.hh" +#include "Debug.hh" +#include "Delay.hh" +#include "DelayCalc.hh" +#include "DelayNormal.hh" +#include "DelayScalar.hh" +#include "DelaySkewNormal.hh" +#include "DispatchQueue.hh" +#include "EquivCells.hh" +#include "ExceptionPath.hh" +#include "FindRegister.hh" +#include "Format.hh" +#include "FuncExpr.hh" +#include "Fuzzy.hh" +#include "Genclks.hh" +#include "Graph.hh" +#include "GraphClass.hh" +#include "GraphCmp.hh" #include "GraphDelayCalc.hh" +#include "Latches.hh" +#include "Levelize.hh" +#include "Liberty.hh" +#include "LibertyClass.hh" +#include "LibertyWriter.hh" +#include "Machine.hh" +#include "MakeConcreteNetwork.hh" +#include "MakeTimingModel.hh" +#include "MinMax.hh" +#include "Mode.hh" +#include "Network.hh" +#include "NetworkClass.hh" +#include "Parasitics.hh" +#include "PathExpanded.hh" +#include "PathGroup.hh" +#include "PatternMatch.hh" +#include "PocvMode.hh" +#include "PortDirection.hh" +#include "PowerClass.hh" +#include "ReportPath.hh" +#include "ReportTcl.hh" +#include "RiseFallMinMaxDelay.hh" +#include "Scene.hh" +#include "Sdc.hh" +#include "SdcClass.hh" +#include "SdcNetwork.hh" +#include "Search.hh" +#include "SearchClass.hh" +#include "SearchPred.hh" +#include "Sim.hh" +#include "Stats.hh" +#include "StringUtil.hh" +#include "TagGroup.hh" +#include "TimingArc.hh" +#include "TimingRole.hh" +#include "Units.hh" +#include "Variables.hh" +#include "VerilogReader.hh" +#include "VisitPathEnds.hh" +#include "Wireload.hh" +#include "liberty/LibertyReader.hh" +#include "parasitics/ConcreteParasitics.hh" +#include "parasitics/ReportParasiticAnnotation.hh" +#include "parasitics/SpefReader.hh" +#include "power/Power.hh" +#include "sdc/WriteSdc.hh" #include "sdf/SdfReader.hh" #include "sdf/SdfWriter.hh" -#include "Levelize.hh" -#include "Sim.hh" -#include "ClkInfo.hh" -#include "TagGroup.hh" -#include "Search.hh" -#include "Latches.hh" -#include "PathGroup.hh" -#include "CheckTiming.hh" -#include "CheckSlews.hh" -#include "CheckFanouts.hh" -#include "CheckCapacitances.hh" -#include "CheckMinPulseWidths.hh" -#include "CheckMinPeriods.hh" -#include "CheckMaxSkews.hh" -#include "ClkSkew.hh" -#include "ClkLatency.hh" -#include "FindRegister.hh" -#include "ReportPath.hh" -#include "Genclks.hh" -#include "ClkNetwork.hh" -#include "power/Power.hh" -#include "VisitPathEnds.hh" -#include "PathExpanded.hh" -#include "MakeTimingModel.hh" -#include "parasitics/ConcreteParasitics.hh" #include "spice/WritePathSpice.hh" -#include "DelayScalar.hh" -#include "DelayNormal.hh" -#include "DelaySkewNormal.hh" namespace sta { @@ -128,7 +145,6 @@ private: }; StaDelayCalcObserver::StaDelayCalcObserver(Search *search) : - DelayCalcObserver(), search_(search) { } @@ -262,30 +278,6 @@ deleteAllMemory() //////////////////////////////////////////////////////////////// -// Singleton used by TCL commands. -Sta *Sta::sta_; - -Sta::Sta() : - StaState(), - cmd_scene_(nullptr), - current_instance_(nullptr), - verilog_reader_(nullptr), - check_timing_(nullptr), - check_slews_(nullptr), - check_fanouts_(nullptr), - check_capacitances_(nullptr), - check_min_pulse_widths_(nullptr), - check_min_periods_(nullptr), - check_max_skews_(nullptr), - clk_skews_(nullptr), - report_path_(nullptr), - power_(nullptr), - update_genclks_(false), - equiv_cells_(nullptr), - properties_(this) -{ -} - void Sta::makeComponents() { @@ -964,7 +956,7 @@ Sta::setDriveCell(const LibertyLibrary *library, const LibertyCell *cell, const Port *port, const LibertyPort *from_port, - float *from_slews, + const DriveCellSlews &from_slews, const LibertyPort *to_port, const RiseFallBoth *rf, const MinMaxAll *min_max, @@ -1077,7 +1069,7 @@ Sta::setWireloadSelection(WireloadSelection *selection, void Sta::setSlewLimit(Clock *clk, const RiseFallBoth *rf, - const PathClkOrData clk_data, + PathClkOrData clk_data, const MinMax *min_max, float slew, Sdc *sdc) @@ -1381,18 +1373,18 @@ Sta::removeClockUncertainty(Clock *from_clk, } ClockGroups * -Sta::makeClockGroups(const std::string &name, +Sta::makeClockGroups(std::string_view name, bool logically_exclusive, bool physically_exclusive, bool asynchronous, bool allow_paths, - std::string comment, + std::string_view comment, Sdc *sdc) { ClockGroups *groups = sdc->makeClockGroups(name, logically_exclusive, physically_exclusive, asynchronous, allow_paths, - std::move(comment)); + comment); search_->requiredsInvalid(); return groups; } @@ -2482,9 +2474,9 @@ Sta::setClkThruTristateEnabled(bool enable) void Sta::makeDefaultScene() { - const char *name = "default"; + std::string name("default"); StringSeq scene_names; - scene_names.push_back(name); + scene_names.emplace_back(name); Parasitics *parasitics = makeConcreteParasitics(name, ""); Mode *mode = new Mode(name, 0, this); @@ -3232,8 +3224,8 @@ public: EndpointPathEndVisitor(std::string_view path_group_name, const MinMax *min_max, const StaState *sta); - PathEndVisitor *copy() const; - void visit(PathEnd *path_end); + PathEndVisitor *copy() const override; + void visit(PathEnd *path_end) override; Slack slack() const { return slack_; } private: @@ -3337,7 +3329,7 @@ Sta::reportDelaysWrtClks(const Pin *pin, bool report_variance, int digits, bool find_required, - PathDelayFunc get_path_delay) + const PathDelayFunc &get_path_delay) { ensureGraph(); Vertex *vertex, *bidir_vertex; @@ -3356,7 +3348,7 @@ Sta::reportDelaysWrtClks(Vertex *vertex, bool report_variance, int digits, bool find_required, - PathDelayFunc get_path_delay) + const PathDelayFunc &get_path_delay) { if (find_required) findRequired(vertex); @@ -3382,7 +3374,7 @@ Sta::reportDelaysWrtClks(Vertex *vertex, const Scene *scene, bool report_variance, int digits, - PathDelayFunc get_path_delay) + const PathDelayFunc &get_path_delay) { RiseFallMinMaxDelay delays = findDelaysWrtClks(vertex, clk_edge, scene, get_path_delay); @@ -3406,7 +3398,7 @@ RiseFallMinMaxDelay Sta::findDelaysWrtClks(Vertex *vertex, const ClockEdge *clk_edge, const Scene *scene, - PathDelayFunc get_path_delay) + const PathDelayFunc &get_path_delay) { RiseFallMinMaxDelay delays; VertexPathIterator path_iter(vertex, scene, nullptr, nullptr, this); @@ -3458,7 +3450,7 @@ private: const Clock *clk_; bool include_port_paths_; StaState *sta_; - float min_period_; + float min_period_{0.0}; }; MinPeriodEndVisitor::MinPeriodEndVisitor(const Clock *clk, @@ -3466,8 +3458,7 @@ MinPeriodEndVisitor::MinPeriodEndVisitor(const Clock *clk, StaState *sta) : clk_(clk), include_port_paths_(include_port_paths), - sta_(sta), - min_period_(0) + sta_(sta) { } @@ -3584,7 +3575,7 @@ Sta::worstSlack(const Scene *scene, Vertex *&worst_vertex) { searchPreamble(); - return search_->worstSlack(scene, min_max, worst_slack, worst_vertex); + search_->worstSlack(scene, min_max, worst_slack, worst_vertex); } //////////////////////////////////////////////////////////////// @@ -3645,7 +3636,7 @@ Sta::setIncrementalDelayTolerance(float tol) graph_delay_calc_->setIncrementalDelayTolerance(tol); } -const ArcDelay +ArcDelay Sta::arcDelay(Edge *edge, TimingArc *arc, DcalcAPIndex ap_index) @@ -4275,7 +4266,7 @@ void Sta::deleteParasitics() { Parasitics *parasitics_default = findParasitics("default"); - for (auto [name, parasitics] : parasitics_name_map_) { + for (auto &[name, parasitics] : parasitics_name_map_) { if (parasitics != parasitics_default) delete parasitics; } @@ -4291,11 +4282,11 @@ Sta::deleteParasitics() } Parasitics * -Sta::makeConcreteParasitics(std::string name, - std::string filename) +Sta::makeConcreteParasitics(std::string_view name, + std::string_view filename) { Parasitics *parasitics = new ConcreteParasitics(name, filename, this); - parasitics_name_map_[name] = parasitics; + parasitics_name_map_[std::string(name)] = parasitics; return parasitics; } @@ -5083,56 +5074,56 @@ Sta::clockDomains(const Pin *pin, InstanceSet Sta::findRegisterInstances(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode) { findRegisterPreamble(mode); - return findRegInstances(clks, clk_rf, edge_triggered, latches, mode, this); + return findRegInstances(clks, clk_rf, registers, latches, mode, this); } PinSet Sta::findRegisterDataPins(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode) { findRegisterPreamble(mode); - return findRegDataPins(clks, clk_rf, edge_triggered, latches, mode, this); + return findRegDataPins(clks, clk_rf, registers, latches, mode, this); } PinSet Sta::findRegisterClkPins(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode) { findRegisterPreamble(mode); - return findRegClkPins(clks, clk_rf, edge_triggered, latches, mode, this); + return findRegClkPins(clks, clk_rf, registers, latches, mode, this); } PinSet Sta::findRegisterAsyncPins(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode) { findRegisterPreamble(mode); - return findRegAsyncPins(clks, clk_rf, edge_triggered, latches, mode, this); + return findRegAsyncPins(clks, clk_rf, registers, latches, mode, this); } PinSet Sta::findRegisterOutputPins(ClockSet *clks, const RiseFallBoth *clk_rf, - bool edge_triggered, + bool registers, bool latches, const Mode *mode) { findRegisterPreamble(mode); - return findRegOutputPins(clks, clk_rf, edge_triggered, latches, mode, this); + return findRegOutputPins(clks, clk_rf, registers, latches, mode, this); } void @@ -5708,7 +5699,6 @@ Sta::checkFanout(const Pin *pin, float &slack) { FanoutCheck check = check_fanouts_->check(pin, mode, min_max); - pin = check.pin(); fanout = check.fanout(); limit = check.limit(); slack = check.slack(); @@ -5801,7 +5791,6 @@ Sta::checkCapacitance(const Pin *pin, const Scene *&scene) { CapacitanceCheck check = check_capacitances_->check(pin, scenes, min_max); - pin = check.pin(); capacitance = check.capacitance(); limit = check.limit(); slack = check.slack(); diff --git a/search/StaState.cc b/search/StaState.cc index 661c02c9..ea673b38 100644 --- a/search/StaState.cc +++ b/search/StaState.cc @@ -28,14 +28,14 @@ #include "ContainerHelpers.hh" #include "DispatchQueue.hh" -#include "Units.hh" -#include "Network.hh" -#include "Variables.hh" -#include "Sdc.hh" #include "Graph.hh" -#include "TimingArc.hh" #include "Mode.hh" +#include "Network.hh" #include "Scene.hh" +#include "Sdc.hh" +#include "TimingArc.hh" +#include "Units.hh" +#include "Variables.hh" namespace sta { @@ -160,11 +160,11 @@ StaState::dcalcAnalysisPtCount() const return MinMax::index_count * scenes_.size(); } -const SceneSet +SceneSet StaState::scenesSet() { return Scene::sceneSet(scenes_); } -} // namespace +} // namespace sta diff --git a/search/Tag.cc b/search/Tag.cc index 9e5113e4..8dffce4a 100644 --- a/search/Tag.cc +++ b/search/Tag.cc @@ -24,16 +24,16 @@ #include "Tag.hh" -#include "Report.hh" -#include "Network.hh" -#include "Clock.hh" -#include "PortDelay.hh" -#include "ExceptionPath.hh" -#include "Sdc.hh" -#include "Graph.hh" -#include "Scene.hh" -#include "Search.hh" #include "ClkInfo.hh" +#include "Clock.hh" +#include "ExceptionPath.hh" +#include "Graph.hh" +#include "Network.hh" +#include "PortDelay.hh" +#include "Report.hh" +#include "Scene.hh" +#include "Sdc.hh" +#include "Search.hh" namespace sta { @@ -53,8 +53,6 @@ Tag::Tag(Scene *scene, states_(states), index_(index), is_clk_(is_clk), - is_filter_(false), - is_loop_(false), is_segment_start_(is_segment_start), own_states_(own_states), rf_index_(rf->index()), @@ -681,4 +679,4 @@ TagMatchEqual::operator()(const Tag *tag1, return Tag::match(tag1, tag2, match_crpr_clk_pin_, sta_); } -} // namespace +} // namespace sta diff --git a/search/Tag.hh b/search/Tag.hh index b989c644..006e8865 100644 --- a/search/Tag.hh +++ b/search/Tag.hh @@ -24,11 +24,15 @@ #pragma once -#include "Transition.hh" +#include +#include + +#include "NetworkClass.hh" +#include "Scene.hh" #include "SdcClass.hh" #include "SearchClass.hh" -#include "Path.hh" -#include "Scene.hh" +#include "StaState.hh" +#include "Transition.hh" namespace sta { @@ -71,7 +75,7 @@ public: const ClockEdge *clkEdge() const; const Clock *clock() const; const Pin *clkSrc() const; - int rfIndex() const { return rf_index_; } + size_t rfIndex() const { return rf_index_; } const RiseFall *transition() const; const MinMax *minMax() const; int minMaxIndex() const { return min_max_index_; } @@ -95,7 +99,7 @@ public: const StaState *sta); static int matchCmp(const Tag *tag1, const Tag *tag2, - bool match_clk_clk_pin, + bool match_crpr_clk_pin, const StaState *sta); static bool match(const Tag *tag1, const Tag *tag2, @@ -134,11 +138,11 @@ private: size_t match_hash_; TagIndex index_; bool is_clk_:1; - bool is_filter_:1; - bool is_loop_:1; - bool is_segment_start_:1; + bool is_filter_:1 {false}; + bool is_loop_:1 {false}; + bool is_segment_start_:1 {false}; // Indicates that states_ is owned by the tag. - bool own_states_:1; + bool own_states_:1 {false}; unsigned int rf_index_:RiseFall::index_bit_count; unsigned int min_max_index_:MinMax::index_bit_count; }; @@ -182,4 +186,4 @@ private: const StaState *sta_; }; -} // namespace +} // namespace sta diff --git a/search/TagGroup.cc b/search/TagGroup.cc index 85fc29a5..e7afc9c5 100644 --- a/search/TagGroup.cc +++ b/search/TagGroup.cc @@ -24,14 +24,14 @@ #include "TagGroup.hh" -#include "Report.hh" +#include "ClkInfo.hh" #include "Debug.hh" #include "Graph.hh" -#include "ClkInfo.hh" -#include "Tag.hh" +#include "Path.hh" +#include "Report.hh" #include "Scene.hh" #include "Search.hh" -#include "Path.hh" +#include "Tag.hh" namespace sta { @@ -152,11 +152,6 @@ TagGroupBldr::TagGroupBldr(bool match_crpr_clk_pin, path_index_map_(TagMatchLess(match_crpr_clk_pin, sta)), paths_(default_path_count_), - has_clk_tag_(false), - has_genclk_src_tag_(false), - has_filter_tag_(false), - has_loop_tag_(false), - has_propagated_clk_(false), sta_(sta) { } diff --git a/search/TagGroup.hh b/search/TagGroup.hh index 972b3e73..2865186a 100644 --- a/search/TagGroup.hh +++ b/search/TagGroup.hh @@ -25,11 +25,13 @@ #pragma once #include +#include -#include "MinMax.hh" -#include "Transition.hh" +#include "Delay.hh" #include "GraphClass.hh" +#include "LibertyClass.hh" #include "SearchClass.hh" +#include "StaState.hh" #include "Tag.hh" namespace sta { @@ -89,7 +91,7 @@ protected: class TagGroupHash { public: - size_t operator()(const TagGroup *tag) const; + size_t operator()(const TagGroup *group) const; }; class TagGroupEqual @@ -151,11 +153,11 @@ protected: int default_path_count_; PathIndexMap path_index_map_; std::vector paths_; - bool has_clk_tag_; - bool has_genclk_src_tag_; - bool has_filter_tag_; - bool has_loop_tag_; - bool has_propagated_clk_; + bool has_clk_tag_{false}; + bool has_genclk_src_tag_{false}; + bool has_filter_tag_{false}; + bool has_loop_tag_{false}; + bool has_propagated_clk_{false}; const StaState *sta_; }; @@ -163,4 +165,4 @@ void pathIndexMapReport(const PathIndexMap *path_index_map, const StaState *sta); -} // namespace +} // namespace sta diff --git a/search/VertexVisitor.cc b/search/VertexVisitor.cc index fc04c892..c622c286 100644 --- a/search/VertexVisitor.cc +++ b/search/VertexVisitor.cc @@ -47,4 +47,4 @@ VertexPinCollector::visit(Vertex *vertex) pins_.insert(vertex->pin()); } -} // namespace +} // namespace sta diff --git a/search/VisitPathEnds.cc b/search/VisitPathEnds.cc index 4a668d9b..3a420aad 100644 --- a/search/VisitPathEnds.cc +++ b/search/VisitPathEnds.cc @@ -24,24 +24,24 @@ #include "VisitPathEnds.hh" -#include "Debug.hh" -#include "Liberty.hh" -#include "Network.hh" -#include "TimingArc.hh" -#include "ExceptionPath.hh" -#include "PortDelay.hh" -#include "Sdc.hh" -#include "Mode.hh" -#include "Graph.hh" #include "ClkInfo.hh" -#include "Tag.hh" +#include "Debug.hh" +#include "ExceptionPath.hh" +#include "GatedClk.hh" +#include "Graph.hh" +#include "Liberty.hh" +#include "Mode.hh" +#include "Network.hh" #include "Path.hh" #include "PathEnd.hh" -#include "Search.hh" -#include "GatedClk.hh" -#include "Sim.hh" -#include "Variables.hh" +#include "PortDelay.hh" #include "Scene.hh" +#include "Sdc.hh" +#include "Search.hh" +#include "Sim.hh" +#include "Tag.hh" +#include "TimingArc.hh" +#include "Variables.hh" namespace sta { @@ -562,7 +562,7 @@ VisitPathEnds::visitDataCheckEnd1(DataCheck *check, if (sdc->sameClockGroup(src_clk, tgt_clk) && !sdc->clkStopPropagation(from_pin, tgt_clk) // False paths and path delays override. - && (exception == 0 + && (exception == nullptr || exception->isFilter() || exception->isGroupPath() || exception->isMultiCycle()) @@ -650,4 +650,4 @@ VisitPathEnds::exceptionTo(const Path *path, min_max, false, false, path->sdc(this)); } -} // namespace +} // namespace sta diff --git a/search/WorstSlack.cc b/search/WorstSlack.cc index a58efb64..769319b9 100644 --- a/search/WorstSlack.cc +++ b/search/WorstSlack.cc @@ -28,9 +28,9 @@ #include "ContainerHelpers.hh" #include "Debug.hh" -#include "Report.hh" -#include "Mutex.hh" #include "Graph.hh" +#include "Mutex.hh" +#include "Report.hh" #include "Scene.hh" #include "Search.hh" @@ -96,12 +96,9 @@ WorstSlacks::worstSlackNotifyBefore(Vertex *vertex) WorstSlack::WorstSlack(StaState *sta) : StaState(sta), slack_init_(MinMax::min()->initValue()), - worst_vertex_(nullptr), worst_slack_(slack_init_), slack_threshold_(slack_init_), - queue_(new VertexSet(VertexIdLess(graph_))), - min_queue_size_(10), - max_queue_size_(20) + queue_(new VertexSet(VertexIdLess(graph_))) { } @@ -110,12 +107,9 @@ WorstSlack::~WorstSlack() { delete queue_; } WorstSlack::WorstSlack(const WorstSlack &worst_slack) : StaState(worst_slack), slack_init_(MinMax::min()->initValue()), - worst_vertex_(nullptr), worst_slack_(slack_init_), slack_threshold_(slack_init_), - queue_(new VertexSet(VertexIdLess(graph_))), - min_queue_size_(10), - max_queue_size_(20) + queue_(new VertexSet(VertexIdLess(graph_))) { } @@ -168,7 +162,7 @@ WorstSlack::initQueue(PathAPIndex path_ap_index) setWorstSlack(vertex, slack); if (delayLessEqual(slack, slack_threshold_, this)) queue_->insert(vertex); - int queue_size = queue_->size(); + size_t queue_size = queue_->size(); if (queue_size >= max_queue_size_) sortQueue(path_ap_index); } @@ -181,7 +175,7 @@ WorstSlack::initQueue(PathAPIndex path_ap_index) void WorstSlack::sortQueue(PathAPIndex path_ap_index) { - if (queue_->size() > 0) { + if (!queue_->empty()) { debugPrint(debug_, "wns", 3, "sort queue"); VertexSeq vertices; @@ -191,8 +185,8 @@ WorstSlack::sortQueue(PathAPIndex path_ap_index) WnsSlackLess slack_less(path_ap_index, this); sort(vertices, slack_less); - int vertex_count = vertices.size(); - int threshold_index = std::min(min_queue_size_, vertex_count - 1); + size_t vertex_count = vertices.size(); + size_t threshold_index = std::min(min_queue_size_, vertex_count - 1); Vertex *threshold_vertex = vertices[threshold_index]; slack_threshold_ = search_->wnsSlack(threshold_vertex, path_ap_index); debugPrint(debug_, "wns", 3, "threshold {}", diff --git a/search/WorstSlack.hh b/search/WorstSlack.hh index de3b0372..89141a98 100644 --- a/search/WorstSlack.hh +++ b/search/WorstSlack.hh @@ -27,8 +27,9 @@ #include #include -#include "MinMax.hh" +#include "Delay.hh" #include "GraphClass.hh" +#include "MinMax.hh" #include "SearchClass.hh" #include "StaState.hh" @@ -79,7 +80,7 @@ class WorstSlack : public StaState { public: WorstSlack(StaState *sta); - ~WorstSlack(); + ~WorstSlack() override; WorstSlack(const WorstSlack &); void worstSlack(PathAPIndex path_ap_index, // Return values. @@ -102,16 +103,16 @@ protected: Slack slack_init_; // Vertex with the worst slack. // When nullptr the worst slack is unknown but in the queue. - Vertex *worst_vertex_; + Vertex *worst_vertex_{nullptr}; Slack worst_slack_; Slack slack_threshold_; // Vertices with slack < threshold_ VertexSet *queue_; // Queue is sorted and pruned to min_queue_size_ vertices when it // reaches max_queue_size_. - int min_queue_size_; - int max_queue_size_; + size_t min_queue_size_{10}; + size_t max_queue_size_{20}; std::mutex lock_; }; -} // namespace +} // namespace sta diff --git a/spice/WritePathSpice.cc b/spice/WritePathSpice.cc index 9b3ecb00..842b2620 100644 --- a/spice/WritePathSpice.cc +++ b/spice/WritePathSpice.cc @@ -24,35 +24,36 @@ #include "WritePathSpice.hh" +#include #include #include #include #include "Debug.hh" #include "Error.hh" -#include "Report.hh" #include "Format.hh" -#include "StringUtil.hh" #include "FuncExpr.hh" -#include "Units.hh" -#include "Sequential.hh" -#include "Liberty.hh" -#include "TimingArc.hh" -#include "TableModel.hh" -#include "PortDirection.hh" -#include "Network.hh" #include "Graph.hh" -#include "Sdc.hh" +#include "Liberty.hh" +#include "Network.hh" #include "Parasitics.hh" #include "Path.hh" #include "PathExpanded.hh" +#include "PortDirection.hh" +#include "Report.hh" +#include "Sdc.hh" +#include "Sequential.hh" #include "StaState.hh" -#include "search/Sim.hh" +#include "StringUtil.hh" +#include "TableModel.hh" +#include "TimingArc.hh" +#include "Units.hh" #include "WriteSpice.hh" +#include "search/Sim.hh" namespace sta { -typedef int Stage; +using Stage = int; //////////////////////////////////////////////////////////////// @@ -138,7 +139,7 @@ private: const Path *path_; PathExpanded path_expanded_; // Input clock waveform cycles. - int clk_cycle_count_; + int clk_cycle_count_{3}; InstanceSet written_insts_; @@ -184,7 +185,6 @@ WritePathSpice::WritePathSpice(const Path *path, path->scene(sta), path->minMax(sta), sta), path_(path), path_expanded_(sta), - clk_cycle_count_(3), written_insts_(network_) { initPowerGnd(); @@ -269,13 +269,11 @@ WritePathSpice::pathMaxTime() Edge *edge = edge_iter.next(); Vertex *load = edge->to(graph_); float load_slew = railToRailSlew(findSlew(load, rf, nullptr), rf); - if (load_slew > path_max_slew) - path_max_slew = load_slew; + path_max_slew = std::max(load_slew, path_max_slew); } } float path_max_time = delayAsFloat(path->arrival()) + path_max_slew * 2.0; - if (path_max_time > max_time) - max_time = path_max_time; + max_time = std::max(path_max_time, max_time); } return max_time; } @@ -756,4 +754,4 @@ WritePathSpice::stageLibertyCell(Stage stage) return network_->libertyPort(pin)->libertyCell(); } -} // namespace +} // namespace sta diff --git a/spice/WritePathSpice.hh b/spice/WritePathSpice.hh index aa22e4fc..fd574278 100644 --- a/spice/WritePathSpice.hh +++ b/spice/WritePathSpice.hh @@ -50,4 +50,4 @@ writePathSpice(const Path *path, CircuitSim ckt_sim, StaState *sta); -} // namespace +} // namespace sta diff --git a/spice/WriteSpice.cc b/spice/WriteSpice.cc index 1823080c..6d3f9395 100644 --- a/spice/WriteSpice.cc +++ b/spice/WriteSpice.cc @@ -30,26 +30,25 @@ #include #include -#include "cudd.h" - +#include "Bdd.hh" +#include "Clock.hh" #include "ContainerHelpers.hh" #include "Debug.hh" -#include "Units.hh" -#include "TableModel.hh" -#include "TimingRole.hh" #include "FuncExpr.hh" -#include "Sequential.hh" -#include "PortDirection.hh" -#include "TimingArc.hh" -#include "Liberty.hh" -#include "Network.hh" #include "Graph.hh" -#include "search/Sim.hh" -#include "Clock.hh" -#include "Path.hh" -#include "Bdd.hh" -#include "Sdc.hh" +#include "Liberty.hh" #include "Mode.hh" +#include "Network.hh" +#include "Path.hh" +#include "PortDirection.hh" +#include "Sdc.hh" +#include "Sequential.hh" +#include "TableModel.hh" +#include "TimingArc.hh" +#include "TimingRole.hh" +#include "Units.hh" +#include "cudd.h" +#include "search/Sim.hh" namespace sta { @@ -78,10 +77,6 @@ WriteSpice::WriteSpice(std::string_view spice_filename, scene_(scene), min_max_(min_max), default_library_(network_->defaultLibertyLibrary()), - short_ckt_resistance_(.0001), - cap_index_(1), - res_index_(1), - volt_index_(1), bdd_(sta), parasitics_(scene->parasitics(min_max)) { diff --git a/spice/WriteSpice.hh b/spice/WriteSpice.hh index 2ac35b33..5230b72b 100644 --- a/spice/WriteSpice.hh +++ b/spice/WriteSpice.hh @@ -25,19 +25,19 @@ #pragma once #include +#include #include #include -#include #include -#include "Format.hh" -#include "StaState.hh" -#include "StringUtil.hh" -#include "Liberty.hh" -#include "GraphClass.hh" -#include "Parasitics.hh" #include "Bdd.hh" #include "CircuitSim.hh" +#include "Format.hh" +#include "GraphClass.hh" +#include "Liberty.hh" +#include "Parasitics.hh" +#include "StaState.hh" +#include "StringUtil.hh" namespace sta { @@ -96,7 +96,7 @@ protected: const NetSet &coupling_nets); void writeParasiticNetwork(const Pin *drvr_pin, const Parasitic *parasitic, - const NetSet &aggressor_nets); + const NetSet &coupling_nets); void writePiElmore(const Pin *drvr_pin, const Parasitic *parasitic); void writeNullParasitic(const Pin *drvr_pin); @@ -181,12 +181,12 @@ protected: float gnd_voltage_; float max_time_; // Resistance to use to simulate a short circuit between spice nodes. - float short_ckt_resistance_; + float short_ckt_resistance_{0.0001F}; // Input clock waveform cycles. // Sequential device numbers. - int cap_index_; - int res_index_; - int volt_index_; + int cap_index_{1}; + int res_index_{1}; + int volt_index_{1}; CellSpicePortNames cell_spice_port_names_; Bdd bdd_; Parasitics *parasitics_; diff --git a/spice/Xyce.cc b/spice/Xyce.cc index 35bf668a..2dfbe30f 100644 --- a/spice/Xyce.cc +++ b/spice/Xyce.cc @@ -77,4 +77,4 @@ readXyceCsv(const char *csv_filename, throw FileNotReadable(csv_filename); } -} // namespace +} // namespace sta diff --git a/spice/Xyce.hh b/spice/Xyce.hh index 84cf4f34..9d3d09a3 100644 --- a/spice/Xyce.hh +++ b/spice/Xyce.hh @@ -40,4 +40,4 @@ readXyceCsv(const char *csv_filename, StringSeq &titles, WaveformSeq &waveforms); -} // namespace +} // namespace sta diff --git a/tcl/StaTclTypes.i b/tcl/StaTclTypes.i index afbc74f5..26d5443d 100644 --- a/tcl/StaTclTypes.i +++ b/tcl/StaTclTypes.i @@ -258,7 +258,7 @@ setPtrTclList(SET_TYPE *set, //////////////////////////////////////////////////////////////// -} // namespace +} // namespace sta using namespace sta; diff --git a/tcl/TclTypeHelpers.cc b/tcl/TclTypeHelpers.cc index bcd4f264..d9a50a41 100644 --- a/tcl/TclTypeHelpers.cc +++ b/tcl/TclTypeHelpers.cc @@ -41,8 +41,8 @@ tclListStringSeq(Tcl_Obj *const source, if (Tcl_ListObjGetElements(interp, source, &argc, &argv) == TCL_OK) { for (int i = 0; i < argc; i++) { Tcl_Size length; - const char *str = Tcl_GetStringFromObj(argv[i], &length); - seq.push_back(str); + const char *arg = Tcl_GetStringFromObj(argv[i], &length); + seq.emplace_back(arg); } } return seq; @@ -59,8 +59,8 @@ tclListStringSeqPtr(Tcl_Obj *const source, StringSeq *seq = new StringSeq; for (int i = 0; i < argc; i++) { Tcl_Size length; - const char *str = Tcl_GetStringFromObj(argv[i], &length); - seq->push_back(str); + const char *arg = Tcl_GetStringFromObj(argv[i], &length); + seq->emplace_back(arg); } return seq; } @@ -79,8 +79,8 @@ tclListStringSet(Tcl_Obj *const source, StringSet *set = new StringSet; for (int i = 0; i < argc; i++) { Tcl_Size length; - const char *str = Tcl_GetStringFromObj(argv[i], &length); - set->insert(str); + const char *arg = Tcl_GetStringFromObj(argv[i], &length); + set->insert(arg); } return set; } @@ -102,42 +102,6 @@ tclArgError(Tcl_Interp *interp, } } -void -objectListNext(const char *list, - const char *type, - // Return values. - bool &type_match, - const char *&next) -{ - // Default return values (failure). - type_match = false; - next = nullptr; - // _hexaddress_p_type - const char *s = list; - char ch = *s++; - if (ch == '_') { - while (*s && isxdigit(*s)) - s++; - if ((s - list - 1) == sizeof(void*) * 2 - && *s && *s++ == '_' - && *s && *s++ == 'p' - && *s && *s++ == '_') { - const char *t = type; - while (*s && *s != ' ') { - if (*s != *t) - return; - s++; - t++; - } - type_match = true; - if (*s) - next = s + 1; - else - next = nullptr; - } - } -} - Tcl_Obj * tclArcDcalcArg(ArcDcalcArg &gate, Tcl_Interp *interp) @@ -204,4 +168,4 @@ arcDcalcArgTcl(Tcl_Obj *obj, return ArcDcalcArg(); } -} // namespace +} // namespace sta diff --git a/util/Debug.cc b/util/Debug.cc index 016dc1b5..6cb3f899 100644 --- a/util/Debug.cc +++ b/util/Debug.cc @@ -32,9 +32,7 @@ namespace sta { bool debug_on = false; Debug::Debug(Report *report) : - report_(report), - debug_on_(false), - stats_level_(0) + report_(report) { } @@ -81,4 +79,4 @@ Debug::setLevel(std::string_view what, } } -} // namespace +} // namespace sta diff --git a/util/DispatchQueue.cc b/util/DispatchQueue.cc index 4e828c23..5347a07a 100644 --- a/util/DispatchQueue.cc +++ b/util/DispatchQueue.cc @@ -30,9 +30,9 @@ DispatchQueue::terminateThreads() cv_.notify_all(); // Wait for threads to finish before we exit - for(size_t i = 0; i < threads_.size(); i++) { - if (threads_[i].joinable()) { - threads_[i].join(); + for (auto &thread : threads_) { + if (thread.joinable()) { + thread.join(); } } quit_ = false; @@ -95,10 +95,10 @@ DispatchQueue::dispatch_thread_handler(size_t i) do { // Wait until we have data or a quit signal - cv_.wait(lock, [this] { return (q_.size() || quit_); } ); + cv_.wait(lock, [this] { return (!q_.empty() || quit_); } ); //after wait, we own the lock - if(!quit_ && q_.size()) { + if (!quit_ && !q_.empty()) { auto op = std::move(q_.front()); q_.pop(); @@ -112,4 +112,4 @@ DispatchQueue::dispatch_thread_handler(size_t i) } while (!quit_); } -} // namespace +} // namespace sta diff --git a/util/Error.cc b/util/Error.cc index 3278d0fe..2ca81a1d 100644 --- a/util/Error.cc +++ b/util/Error.cc @@ -24,22 +24,16 @@ #include "Error.hh" -#include #include +#include #include "Format.hh" #include "StringUtil.hh" namespace sta { -Exception::Exception() : - std::exception() -{ -} - ExceptionMsg::ExceptionMsg(const std::string &msg, - const bool suppressed) : - Exception(), + bool suppressed) : msg_(msg), suppressed_(suppressed) { @@ -53,7 +47,6 @@ ExceptionMsg::what() const noexcept ExceptionLine::ExceptionLine(const std::string &filename, int line) : - Exception(), filename_(filename), line_(line) { @@ -81,4 +74,4 @@ FileNotWritable::what() const noexcept return msg_.c_str(); } -} // namespace +} // namespace sta diff --git a/util/FlexDisableRegister.hh b/util/FlexDisableRegister.hh index 64983ba7..52943946 100644 --- a/util/FlexDisableRegister.hh +++ b/util/FlexDisableRegister.hh @@ -3,4 +3,3 @@ #if !(YY_FLEX_MAJOR_VERSION >= 2 && YY_FLEX_MINOR_VERSION >= 6) && __cplusplus > 199711L #define register #endif - diff --git a/util/Fuzzy.cc b/util/Fuzzy.cc index 0308bc9a..b04a3577 100644 --- a/util/Fuzzy.cc +++ b/util/Fuzzy.cc @@ -89,4 +89,4 @@ fuzzyInf(float value) || fuzzyEqual(value, -INF); } -} // namespace +} // namespace sta diff --git a/util/Hash.cc b/util/Hash.cc index 49b49798..8c86b1c6 100644 --- a/util/Hash.cc +++ b/util/Hash.cc @@ -35,4 +35,4 @@ hashString(std::string_view str) return hash; } -} // namespace +} // namespace sta diff --git a/util/Machine.cc b/util/Machine.cc deleted file mode 100644 index 07e14182..00000000 --- a/util/Machine.cc +++ /dev/null @@ -1,33 +0,0 @@ -// OpenSTA, Static Timing Analyzer -// Copyright (c) 2026, 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 . -// -// The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. -// -// Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// This notice may not be removed or altered from any source distribution. - -#if defined(_WIN32) - #include "MachineWin32.cc" -#elif defined(__APPLE__) - #include "MachineApple.cc" -#elif defined(__linux__) - #include "MachineLinux.cc" -#else - #include "MachineUnknown.cc" -#endif diff --git a/util/MachineApple.cc b/util/MachineApple.cc index 220df772..e1de87f4 100644 --- a/util/MachineApple.cc +++ b/util/MachineApple.cc @@ -24,12 +24,12 @@ #include "Machine.hh" -#include -#include -#include -#include +#include +#include #include +#include #include +#include #include "StaConfig.hh" #include "StringUtil.hh" @@ -85,4 +85,4 @@ memoryUsage() return rusage.ru_maxrss; } -} // namespace +} // namespace sta diff --git a/util/MachineLinux.cc b/util/MachineLinux.cc index 7be581f6..ff7079ff 100644 --- a/util/MachineLinux.cc +++ b/util/MachineLinux.cc @@ -24,16 +24,16 @@ #include "Machine.hh" -#include -#include -#include -#include +#include +#include #include +#include #include +#include +#include "Format.hh" #include "StaConfig.hh" #include "StringUtil.hh" -#include "Format.hh" namespace sta { @@ -105,4 +105,4 @@ memoryUsage() return memory; } -} // namespace +} // namespace sta diff --git a/util/MachineUnknown.cc b/util/MachineUnknown.cc index 0a28118b..069e4a95 100644 --- a/util/MachineUnknown.cc +++ b/util/MachineUnknown.cc @@ -61,4 +61,4 @@ memoryUsage() return 0; } -} // namespace +} // namespace sta diff --git a/util/MachineWin32.cc b/util/MachineWin32.cc index 3fec862f..2c2c36bf 100644 --- a/util/MachineWin32.cc +++ b/util/MachineWin32.cc @@ -24,7 +24,8 @@ #include "Machine.hh" -#include +#include +#include #include // GetSystemInfo namespace sta { @@ -35,7 +36,7 @@ int vsnprint(char *str, size_t size, const char *fmt, - va_list args) + const va_list args) { // Copy args before using them because consumption is destructive. va_list args_copy1; @@ -109,4 +110,4 @@ memoryUsage() return 0; } -} // namespace +} // namespace sta diff --git a/util/MinMax.cc b/util/MinMax.cc index 299d3157..4cb0179d 100644 --- a/util/MinMax.cc +++ b/util/MinMax.cc @@ -52,10 +52,10 @@ compareMax(float value1, const MinMax MinMax::min_("min", 0, INF, std::numeric_limits::max(), compareMin); const MinMax MinMax::max_("max", 1, -INF, std::numeric_limits::min(), compareMax); const std::array MinMax::range_{&min_, &max_}; -const std::array MinMax::range_index_{min_.index(), max_.index()}; +const std::array MinMax::range_index_{min_.index(), max_.index()}; -MinMax::MinMax(const char *name, - int index, +MinMax::MinMax(std::string_view name, + size_t index, float init_value, int init_value_int, bool (*compare)(float value1, float value2)) : @@ -86,7 +86,7 @@ MinMax::opposite() const } const MinMax * -MinMax::find(const char *min_max) +MinMax::find(std::string_view min_max) { if (stringEqual(min_max, "min") || stringEqual(min_max, "early")) @@ -99,7 +99,7 @@ MinMax::find(const char *min_max) } const MinMax * -MinMax::find(int index) +MinMax::find(size_t index) { if (index == min_.index()) return &min_; @@ -133,10 +133,10 @@ const MinMaxAll MinMaxAll::max_("max", 1, {MinMax::max()}, {MinMax::max()->index const MinMaxAll MinMaxAll::all_("all", 2, {MinMax::min(), MinMax::max()}, {MinMax::min()->index(), MinMax::max()->index()}); -MinMaxAll::MinMaxAll(const char *name, - int index, - std::vector range, - std::vector range_index) : +MinMaxAll::MinMaxAll(std::string_view name, + size_t index, + const std::vector &range, + const std::vector &range_index) : name_(name), index_(index), range_(range), @@ -182,4 +182,4 @@ MinMaxAll::find(const char *min_max) return nullptr; } -} // namespace +} // namespace sta diff --git a/util/PatternMatch.cc b/util/PatternMatch.cc index c4f15237..a2eb42d0 100644 --- a/util/PatternMatch.cc +++ b/util/PatternMatch.cc @@ -23,6 +23,7 @@ // This notice may not be removed or altered from any source distribution. #include "PatternMatch.hh" + #include #include @@ -114,15 +115,14 @@ PatternMatch::matchNoCase(std::string_view str) const if (regexp_) { std::string buf(str); const char *cstr = buf.c_str(); - return Tcl_RegExpExec(0, regexp_, cstr, cstr) == 1; + return Tcl_RegExpExec(nullptr, regexp_, cstr, cstr) == 1; } return patternMatchNoCase(pattern_, str, nocase_); } //////////////////////////////////////////////////////////////// -RegexpCompileError::RegexpCompileError(std::string_view pattern) : - Exception() +RegexpCompileError::RegexpCompileError(std::string_view pattern) { error_ = "TCL failed to compile regular expression '"; error_.append(pattern.data(), pattern.size()); @@ -205,4 +205,4 @@ patternWildcards(std::string_view pattern) return pattern.find_first_of("*?") != std::string_view::npos; } -} // namespace +} // namespace sta diff --git a/util/Report.cc b/util/Report.cc index ca6bc077..b802738b 100644 --- a/util/Report.cc +++ b/util/Report.cc @@ -29,26 +29,18 @@ #include // strlen #include "Error.hh" -#include "Machine.hh" #include "Format.hh" +#include "Machine.hh" namespace sta { Report *Report::default_ = nullptr; -Report::Report() : - log_stream_(nullptr), - redirect_stream_(nullptr), - redirect_to_string_(false), - buffer_size_(1000), - buffer_(new char[buffer_size_]), - buffer_length_(0) +Report::Report() { default_ = this; } -Report::~Report() { delete[] buffer_; } - size_t Report::printConsole(const char *buffer, size_t length) @@ -97,64 +89,6 @@ Report::reportLine(const std::string &line) //////////////////////////////////////////////////////////////// -void -Report::printToBuffer(const char *fmt, - ...) -{ - va_list args; - va_start(args, fmt); - printToBuffer(fmt, args); - va_end(args); -} - -void -Report::printToBuffer(const char *fmt, - va_list args) -{ - buffer_length_ = 0; - printToBufferAppend(fmt, args); -} - -void -Report::printToBufferAppend(const char *fmt, - ...) -{ - va_list args; - va_start(args, fmt); - printToBufferAppend(fmt, args); - va_end(args); -} - -void -Report::printToBufferAppend(const char *fmt, - va_list args) -{ - // Copy args in case we need to grow the buffer. - va_list args_copy; - va_copy(args_copy, args); - size_t length = - vsnprint(buffer_ + buffer_length_, buffer_size_ - buffer_length_, fmt, args); - if (length >= buffer_size_ - buffer_length_) { - buffer_size_ = buffer_length_ + length * 2; - char *new_buffer = new char[buffer_size_]; - strncpy(new_buffer, buffer_, buffer_length_); - delete[] buffer_; - buffer_ = new_buffer; - length = vsnprint(buffer_ + buffer_length_, buffer_size_ - buffer_length_, fmt, - args_copy); - } - buffer_length_ += length; - va_end(args_copy); -} - -void -Report::printBufferLine() -{ - printLine(buffer_, buffer_length_); -} - -//////////////////////////////////////////////////////////////// - void reportThrowExceptionMsg(const std::string &msg, bool suppressed) diff --git a/util/ReportStd.cc b/util/ReportStd.cc index bcf73c2d..d8f499e8 100644 --- a/util/ReportStd.cc +++ b/util/ReportStd.cc @@ -24,8 +24,8 @@ #include "ReportStd.hh" -#include #include +#include #include "Report.hh" @@ -35,7 +35,7 @@ namespace sta { class ReportStd : public Report { public: - ReportStd(); + ReportStd() = default; protected: size_t printConsole(const char *buffer, size_t length) override; @@ -48,11 +48,6 @@ makeReportStd() return new ReportStd; } -ReportStd::ReportStd() : - Report() -{ -} - size_t ReportStd::printConsole(const char *buffer, size_t length) { @@ -65,4 +60,4 @@ ReportStd::printErrorConsole(const char *buffer, size_t length) return fwrite(buffer, sizeof(char), length, stderr); } -} // namespace +} // namespace sta diff --git a/util/ReportTcl.cc b/util/ReportTcl.cc index e782c23c..d5fd5383 100644 --- a/util/ReportTcl.cc +++ b/util/ReportTcl.cc @@ -82,6 +82,7 @@ static int encapCloseProc(ClientData instanceData, Tcl_Interp *interp); static int encapSeekProc(ClientData instanceData, + // NOLINTNEXTLINE(google-runtime-int) // Tcl_DriverSeekProc offset long offset, int seekMode, int *errorCodePtr); @@ -90,43 +91,36 @@ encapSeekProc(ClientData instanceData, } // extern "C" Tcl_ChannelType tcl_encap_type_stdout = { - const_cast("file"), - TCL_CHANNEL_VERSION_5, + .typeName = "file", + .version = TCL_CHANNEL_VERSION_5, #if TCL_MAJOR_VERSION < 9 - encapCloseProc, + .closeProc = encapCloseProc, #else - nullptr, // closeProc unused + .closeProc = nullptr, // closeProc unused #endif - encapInputProc, - encapOutputProc, + .inputProc = encapInputProc, + .outputProc = encapOutputProc, #if TCL_MAJOR_VERSION < 9 - encapSeekProc, + .seekProc = encapSeekProc, #else - nullptr, // seekProc unused + .seekProc = nullptr, // seekProc unused #endif - encapSetOptionProc, - encapGetOptionProc, - encapWatchProc, - encapGetHandleProc, - encapClose2Proc, - encapBlockModeProc, - nullptr, // flushProc - nullptr, // handlerProc - nullptr, // wideSeekProc - nullptr, // threadActionProc - nullptr // truncateProc + .setOptionProc = encapSetOptionProc, + .getOptionProc = encapGetOptionProc, + .watchProc = encapWatchProc, + .getHandleProc = encapGetHandleProc, + .close2Proc = encapClose2Proc, + .blockModeProc = encapBlockModeProc, + .flushProc = nullptr, + .handlerProc = nullptr, + .wideSeekProc = nullptr, + .threadActionProc = nullptr, + .truncateProc = nullptr, }; //////////////////////////////////////////////////////////////// -ReportTcl::ReportTcl() : - Report(), interp_(nullptr), - tcl_stdout_(nullptr), - tcl_stderr_(nullptr), - tcl_encap_stdout_(nullptr), - tcl_encap_stderr_(nullptr) -{ -} +ReportTcl::ReportTcl() = default; ReportTcl::~ReportTcl() { @@ -324,6 +318,7 @@ encapCloseProc(ClientData instanceData, static int encapSeekProc(ClientData, + // NOLINTNEXTLINE(google-runtime-int) // Tcl_DriverSeekProc offset long, int, int *) diff --git a/util/RiseFallMinMax.cc b/util/RiseFallMinMax.cc index 0284e883..774fd560 100644 --- a/util/RiseFallMinMax.cc +++ b/util/RiseFallMinMax.cc @@ -34,17 +34,16 @@ RiseFallMinMax::RiseFallMinMax() void RiseFallMinMax::clear() { - for (int rf_index = 0; rf_indexvalues_[rf_index][mm_index]; exists_[rf_index][mm_index] = rfmm->exists_[rf_index][mm_index]; } @@ -154,8 +153,8 @@ RiseFallMinMax::setValue(const RiseFall *rf, void RiseFallMinMax::setValues(RiseFallMinMax *values) { - for (int rf_index = 0 ; rf_index < RiseFall::index_count ; rf_index++) { - for (int mm_index = 0; mm_index < MinMax::index_count; mm_index++) { + for (size_t rf_index = 0 ; rf_index < RiseFall::index_count ; rf_index++) { + for (size_t mm_index = 0; mm_index < MinMax::index_count; mm_index++) { values_[rf_index][mm_index] = values->values_[rf_index][mm_index]; exists_[rf_index][mm_index] = values->exists_[rf_index][mm_index]; } @@ -206,8 +205,8 @@ RiseFallMinMax::maxValue(// Return values { max_value = MinMax::max()->initValue(); exists = false; - for (int rf_index = 0 ; rf_index < RiseFall::index_count ; rf_index++) { - for (int mm_index = 0; mm_index < MinMax::index_count; mm_index++) { + for (size_t rf_index = 0 ; rf_index < RiseFall::index_count ; rf_index++) { + for (size_t mm_index = 0; mm_index < MinMax::index_count; mm_index++) { if (exists_[rf_index][mm_index]) { max_value = std::max(max_value, values_[rf_index][mm_index]); exists = true; @@ -219,9 +218,9 @@ RiseFallMinMax::maxValue(// Return values bool RiseFallMinMax::empty() const { - for (int rf_index = 0 ; rf_index < RiseFall::index_count ; rf_index++) { - for (int mm_index = 0; mm_index < MinMax::index_count; mm_index++) { - if (exists_[rf_index][mm_index]) + for (auto rf_exists : exists_) { + for (size_t mm_index = 0; mm_index < MinMax::index_count; mm_index++) { + if (rf_exists[mm_index]) return false; } } @@ -258,8 +257,8 @@ RiseFallMinMax::mergeWith(RiseFallMinMax *rfmm) bool RiseFallMinMax::equal(const RiseFallMinMax *values) const { - for (int rf_index = 0 ; rf_index < RiseFall::index_count ; rf_index++) { - for (int mm_index = 0; mm_index < MinMax::index_count; mm_index++) { + for (size_t rf_index = 0 ; rf_index < RiseFall::index_count ; rf_index++) { + for (size_t mm_index = 0; mm_index < MinMax::index_count; mm_index++) { bool exists1 = exists_[rf_index][mm_index]; bool exists2 = values->exists_[rf_index][mm_index]; if (exists1 != exists2) @@ -284,8 +283,8 @@ RiseFallMinMax::isOneValue(float &value) const { if (exists_[0][0]) { value = values_[0][0]; - for (int rf_index = 0 ; rf_index < RiseFall::index_count ; rf_index++) { - for (int mm_index=0; mm_indexindex(); + size_t mm_index = min_max->index(); if (exists_[0][mm_index]) { value = values_[0][mm_index]; - for (int rf_index = 0 ; rf_index < RiseFall::index_count ; rf_index++) { + for (size_t rf_index = 0 ; rf_index < RiseFall::index_count ; rf_index++) { if (!exists_[rf_index][mm_index] || values_[rf_index][mm_index] != value) return false; @@ -316,4 +315,4 @@ RiseFallMinMax::isOneValue(const MinMax *min_max, return false; } -} // namespace +} // namespace sta diff --git a/util/RiseFallMinMaxDelay.cc b/util/RiseFallMinMaxDelay.cc index 70cac609..3bef6573 100644 --- a/util/RiseFallMinMaxDelay.cc +++ b/util/RiseFallMinMaxDelay.cc @@ -28,21 +28,19 @@ namespace sta { RiseFallMinMaxDelay::RiseFallMinMaxDelay() { - for (int rf_index = 0; rf_indexindex()]; } -} // namespace +} // namespace sta diff --git a/util/Stats.cc b/util/Stats.cc index 07fb62a1..bda5b110 100644 --- a/util/Stats.cc +++ b/util/Stats.cc @@ -24,19 +24,15 @@ #include "Stats.hh" -#include "Machine.hh" -#include "StringUtil.hh" -#include "Report.hh" #include "Debug.hh" +#include "Machine.hh" +#include "Report.hh" +#include "StringUtil.hh" namespace sta { Stats::Stats(Debug *debug, Report *report) : - elapsed_begin_(0.0), - user_begin_(0.0), - system_begin_(0.0), - memory_begin_(0), debug_(debug), report_(report) { diff --git a/util/StringUtil.cc b/util/StringUtil.cc index c070cb6e..808365cd 100644 --- a/util/StringUtil.cc +++ b/util/StringUtil.cc @@ -1,5 +1,5 @@ // OpenSTA, Static Timing Analyzer -// Copyright (c) 2025, Parallax Software, Inc. +// Copyright (c) 2026, 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 @@ -78,7 +78,7 @@ stringFloat(const std::string &str) void trimRight(std::string &str) { - str.erase(str.find_last_not_of(" ") + 1); + str.erase(str.find_last_not_of(' ') + 1); } StringSeq @@ -98,4 +98,4 @@ parseTokens(const std::string &text, return tokens; } -} // namespace +} // namespace sta diff --git a/util/Transition.cc b/util/Transition.cc index 4318366d..25d872f9 100644 --- a/util/Transition.cc +++ b/util/Transition.cc @@ -33,11 +33,11 @@ namespace sta { const RiseFall RiseFall::rise_("rise", "^", 0); const RiseFall RiseFall::fall_("fall", "v", 1); const std::array RiseFall::range_{&rise_, &fall_}; -const std::array RiseFall::range_index_{rise_.index(), fall_.index()}; +const std::array RiseFall::range_index_{rise_.index(), fall_.index()}; RiseFall::RiseFall(std::string_view name, std::string_view short_name, - int sdf_triple_index) : + size_t sdf_triple_index) : name_(name), short_name_(short_name), sdf_triple_index_(sdf_triple_index) @@ -63,17 +63,17 @@ RiseFall::opposite() const } const RiseFall * -RiseFall::find(std::string_view rf_str) +RiseFall::find(std::string_view rf_name) { - if (rf_str == rise_.name() || rf_str == rise_.shortName()) + if (rf_name == rise_.name() || rf_name == rise_.shortName()) return &rise_; - if (rf_str == fall_.name() || rf_str == fall_.shortName()) + if (rf_name == fall_.name() || rf_name == fall_.shortName()) return &fall_; return nullptr; } const RiseFall * -RiseFall::find(int index) +RiseFall::find(size_t index) { if (index == rise_.index()) return &rise_; @@ -127,10 +127,10 @@ const RiseFallBoth RiseFallBoth::rise_fall_("rise_fall", "rf", 2, RiseFallBoth::RiseFallBoth(std::string_view name, std::string_view short_name, - int sdf_triple_index, + size_t sdf_triple_index, const RiseFall *as_rise_fall, - std::vector range, - std::vector range_index) : + const std::vector &range, + const std::vector &range_index) : name_(name), short_name_(short_name), sdf_triple_index_(sdf_triple_index), @@ -150,13 +150,13 @@ RiseFallBoth::to_string(bool use_short) const } const RiseFallBoth * -RiseFallBoth::find(std::string_view name) +RiseFallBoth::find(std::string_view rf_name) { - if (name == rise_.name()) + if (rf_name == rise_.name()) return &rise_; - if (name == fall_.name()) + if (rf_name == fall_.name()) return &fall_; - if (name == rise_fall_.name()) + if (rf_name == rise_fall_.name()) return &rise_fall_; return nullptr; } @@ -181,7 +181,7 @@ RiseFallBoth::matches(const Transition *tr) const //////////////////////////////////////////////////////////////// TransitionMap Transition::transition_map_; -int Transition::max_index_ = 0; +size_t Transition::max_index_ = 0; // Sdf triple order defined on Sdf 3.0 spec, pg 3-17. const Transition Transition::rise_{ "^", "01", RiseFall::rise(), 0}; @@ -196,12 +196,12 @@ const Transition Transition::tr_1X_{"1X", "1X", RiseFall::fall(), 8}; const Transition Transition::tr_X0_{"X0", "X0", RiseFall::fall(), 9}; const Transition Transition::tr_XZ_{"XZ", "XZ", nullptr, 10}; const Transition Transition::tr_ZX_{"ZX", "ZX", nullptr, 11}; -const Transition Transition::rise_fall_{"*", "**", nullptr, -1}; +const Transition Transition::rise_fall_{"*", "**", nullptr, 12}; Transition::Transition(std::string_view name, std::string_view init_final, const RiseFall *as_rise_fall, - int sdf_triple_index) : + size_t sdf_triple_index) : name_(name), init_final_(init_final), as_rise_fall_(as_rise_fall), @@ -219,9 +219,9 @@ Transition::matches(const Transition *tr) const } const Transition * -Transition::find(std::string_view tr_str) +Transition::find(std::string_view tr_name) { - return findStringKey(transition_map_, tr_str); + return findStringKey(transition_map_, tr_name); } const RiseFallBoth * @@ -230,4 +230,4 @@ Transition::asRiseFallBoth() const return reinterpret_cast(as_rise_fall_); } -} // namespace +} // namespace sta diff --git a/util/Util.i b/util/Util.i index c34ba4a8..5d143054 100644 --- a/util/Util.i +++ b/util/Util.i @@ -27,14 +27,14 @@ %{ +#include "Error.hh" +#include "Fuzzy.hh" +#include "Report.hh" #include "Sta.hh" #include "StaConfig.hh" // STA_VERSION #include "Stats.hh" -#include "Report.hh" -#include "Error.hh" -#include "Fuzzy.hh" -#include "Units.hh" #include "StringUtil.hh" +#include "Units.hh" using namespace sta; @@ -263,23 +263,6 @@ object_type(const char *obj) return &obj[1 + sizeof(void*) * 2 + 3]; } -bool -is_object_list(const char *list, - const char *type) -{ - const char *s = list; - while (s) { - bool type_match; - const char *next; - objectListNext(s, type, type_match, next); - if (type_match) - s = next; - else - return false; - } - return true; -} - //////////////////////////////////////////////////////////////// // // Units diff --git a/util/gzstream.hh b/util/gzstream.hh index 26e85352..26b16174 100644 --- a/util/gzstream.hh +++ b/util/gzstream.hh @@ -211,4 +211,4 @@ public: } }; -} // namespace GZSTREAM_NAMESPACE +} // namespace gzstream diff --git a/verilog/Verilog.i b/verilog/Verilog.i index 3a60be30..82647cff 100644 --- a/verilog/Verilog.i +++ b/verilog/Verilog.i @@ -25,8 +25,8 @@ %module verilog %{ -#include "VerilogWriter.hh" #include "Sta.hh" +#include "VerilogWriter.hh" %} %inline %{ diff --git a/verilog/VerilogParse.yy b/verilog/VerilogParse.yy index 9bd7f162..3103c3be 100644 --- a/verilog/VerilogParse.yy +++ b/verilog/VerilogParse.yy @@ -25,7 +25,6 @@ %{ #include #include -#include #include "Report.hh" #include "PortDirection.hh" @@ -50,6 +49,31 @@ sta::VerilogParse::error(const location_type &loc, %} +%code requires { +#include +#include + +namespace sta { +class PortDirection; +class VerilogAssign; +class VerilogAttr; +class VerilogAttrEntry; +class VerilogAttrStmt; +class VerilogDclArg; +class VerilogNet; +class VerilogReader; +class VerilogScanner; +class VerilogStmt; + +using VerilogAttrEntrySeq = std::vector; +using VerilogAttrSeq = std::vector; +using VerilogAttrStmtSeq = std::vector; +using VerilogDclArgSeq = std::vector; +using VerilogNetSeq = std::vector; +using VerilogStmtSeq = std::vector; +} +} + %require "3.2" %skeleton "lalr1.cc" %debug @@ -109,13 +133,13 @@ modules: module: attr_instance_seq MODULE ID ';' stmts ENDMODULE - { reader->makeModule(std::move($3), new sta::VerilogNetSeq,$5, $1, loc_line(@2));} + { reader->makeModule($3, new sta::VerilogNetSeq,$5, $1, loc_line(@2));} | attr_instance_seq MODULE ID '(' ')' ';' stmts ENDMODULE - { reader->makeModule(std::move($3), new sta::VerilogNetSeq,$7, $1, loc_line(@2));} + { reader->makeModule($3, new sta::VerilogNetSeq,$7, $1, loc_line(@2));} | attr_instance_seq MODULE ID '(' port_list ')' ';' stmts ENDMODULE - { reader->makeModule(std::move($3), $5, $8, $1, loc_line(@2)); } + { reader->makeModule($3, $5, $8, $1, loc_line(@2)); } | attr_instance_seq MODULE ID '(' port_dcls ')' ';' stmts ENDMODULE - { reader->makeModule(std::move($3), $5, $8, $1, loc_line(@2)); } + { reader->makeModule($3, $5, $8, $1, loc_line(@2)); } ; port_list: @@ -130,9 +154,9 @@ port_list: port: port_expr | '.' ID '(' ')' - { $$ = reader->makeNetNamedPortRefScalar(std::move($2), nullptr);} + { $$ = reader->makeNetNamedPortRefScalar($2, nullptr);} | '.' ID '(' port_expr ')' - { $$ = reader->makeNetNamedPortRefScalar(std::move($2), $4);} + { $$ = reader->makeNetNamedPortRefScalar($2, $4);} ; port_expr: @@ -332,9 +356,9 @@ dcl_args: dcl_arg: ID - { $$ = reader->makeDclArg(std::move($1)); } + { $$ = reader->makeDclArg($1); } | net_assignment - { $$ = reader->makeDclArg(std::move($1)); } + { $$ = reader->makeDclArg($1); } ; continuous_assign: @@ -363,9 +387,9 @@ net_assign_lhs: instance: attr_instance_seq ID ID '(' inst_pins ')' ';' - { $$ = reader->makeModuleInst(std::move($2), std::move($3), $5, $1, loc_line(@2)); } + { $$ = reader->makeModuleInst($2, $3, $5, $1, loc_line(@2)); } | attr_instance_seq ID parameter_values ID '(' inst_pins ')' ';' - { $$ = reader->makeModuleInst(std::move($2), std::move($4), $6, $1, loc_line(@2)); } + { $$ = reader->makeModuleInst($2, $4, $6, $1, loc_line(@2)); } ; parameter_values: @@ -411,23 +435,23 @@ inst_named_pins: inst_named_pin: // Scalar port. '.' ID '(' ')' - { $$ = reader->makeNetNamedPortRefScalarNet(std::move($2)); } + { $$ = reader->makeNetNamedPortRefScalarNet($2); } | '.' ID '(' ID ')' - { $$ = reader->makeNetNamedPortRefScalarNet(std::move($2), std::move($4)); } + { $$ = reader->makeNetNamedPortRefScalarNet($2, $4); } | '.' ID '(' ID '[' INT ']' ')' - { $$ = reader->makeNetNamedPortRefBitSelect(std::move($2), std::move($4), $6); } + { $$ = reader->makeNetNamedPortRefBitSelect($2, $4, $6); } | '.' ID '(' named_pin_net_expr ')' - { $$ = reader->makeNetNamedPortRefScalar(std::move($2), $4); } + { $$ = reader->makeNetNamedPortRefScalar($2, $4); } // Bus port bit select. | '.' ID '[' INT ']' '(' ')' - { $$ = reader->makeNetNamedPortRefBit(std::move($2), $4, nullptr); } + { $$ = reader->makeNetNamedPortRefBit($2, $4, nullptr); } | '.' ID '[' INT ']' '(' net_expr ')' - { $$ = reader->makeNetNamedPortRefBit(std::move($2), $4, $7); } + { $$ = reader->makeNetNamedPortRefBit($2, $4, $7); } // Bus port part select. | '.' ID '[' INT ':' INT ']' '(' ')' - { $$ = reader->makeNetNamedPortRefPart(std::move($2), $4, $6, nullptr); } + { $$ = reader->makeNetNamedPortRefPart($2, $4, $6, nullptr); } | '.' ID '[' INT ':' INT ']' '(' net_expr ')' - { $$ = reader->makeNetNamedPortRefPart(std::move($2), $4, $6, $9); } + { $$ = reader->makeNetNamedPortRefPart($2, $4, $6, $9); } ; named_pin_net_expr: @@ -444,22 +468,22 @@ net_named: net_scalar: ID - { $$ = reader->makeNetScalar(std::move($1)); } + { $$ = reader->makeNetScalar($1); } ; net_bit_select: ID '[' INT ']' - { $$ = reader->makeNetBitSelect(std::move($1), $3); } + { $$ = reader->makeNetBitSelect($1, $3); } ; net_part_select: ID '[' INT ':' INT ']' - { $$ = reader->makeNetPartSelect(std::move($1), $3, $5); } + { $$ = reader->makeNetPartSelect($1, $3, $5); } ; net_constant: CONSTANT - { $$ = reader->makeNetConstant(std::move($1), loc_line(@1)); } + { $$ = reader->makeNetConstant($1, loc_line(@1)); } ; net_expr_concat: @@ -507,16 +531,16 @@ attr_specs: attr_spec: ID - { $$ = new sta::VerilogAttrEntry(std::move($1), "1"); } + { $$ = new sta::VerilogAttrEntry($1, "1"); } | ID '=' attr_spec_value - { $$ = new sta::VerilogAttrEntry(std::move($1), std::move($3)); } + { $$ = new sta::VerilogAttrEntry($1, $3); } ; attr_spec_value: CONSTANT - { $$ = std::move($1); } + { $$ = $1; } | STRING - { $$ = std::move($1); } + { $$ = $1; } | INT { $$ = std::to_string($1); } ; diff --git a/verilog/VerilogReader.cc b/verilog/VerilogReader.cc index 68f99b62..263acb4a 100644 --- a/verilog/VerilogReader.cc +++ b/verilog/VerilogReader.cc @@ -24,30 +24,31 @@ #include "VerilogReader.hh" +#include #include #include #include #include "ContainerHelpers.hh" -#include "Zlib.hh" #include "Debug.hh" -#include "Report.hh" #include "Error.hh" -#include "Stats.hh" #include "Liberty.hh" -#include "PortDirection.hh" #include "Network.hh" -#include "VerilogNamespace.hh" +#include "PortDirection.hh" +#include "Report.hh" +#include "Stats.hh" #include "StringUtil.hh" +#include "VerilogNamespace.hh" +#include "Zlib.hh" #include "verilog/VerilogReaderPvt.hh" #include "verilog/VerilogScanner.hh" namespace sta { -using VerilogConstant10 = unsigned long long; +using VerilogConstant10 = std::uint64_t; static std::string -verilogBusBitName(const std::string &bus_name, +verilogBusBitName(std::string_view bus_name, int index); static int hierarchyLevel(Net *net, @@ -111,8 +112,6 @@ VerilogReader::VerilogReader(NetworkReader *network) : report_(network->report()), debug_(network->debug()), network_(network), - library_(nullptr), - black_box_index_(0), zero_net_name_("zero_"), one_net_name_("one_") { @@ -168,13 +167,13 @@ VerilogReader::module(Cell *cell) } void -VerilogReader::makeModule(std::string &&module_vname, +VerilogReader::makeModule(std::string_view module_vname, VerilogNetSeq *ports, VerilogStmtSeq *stmts, VerilogAttrStmtSeq *attr_stmts, int line) { - const std::string module_name = moduleVerilogToSta(std::move(module_vname)); + const std::string module_name = moduleVerilogToSta(module_vname); Cell *cell = network_->findCell(library_, module_name); if (cell) { VerilogModule *module = module_map_[cell]; @@ -199,7 +198,7 @@ VerilogReader::makeModule(std::string &&module_vname, } void -VerilogReader::makeModule(std::string &&module_vname, +VerilogReader::makeModule(std::string_view module_vname, VerilogStmtSeq *port_dcls, VerilogStmtSeq *stmts, VerilogAttrStmtSeq *attr_stmts, @@ -219,7 +218,7 @@ VerilogReader::makeModule(std::string &&module_vname, } } delete port_dcls; - makeModule(std::move(module_vname), ports, stmts, attr_stmts, line); + makeModule(module_vname, ports, stmts, attr_stmts, line); } void @@ -371,9 +370,9 @@ VerilogReader::makeDclBus(PortDirection *dir, } VerilogDclArg * -VerilogReader::makeDclArg(std::string &&net_vname) +VerilogReader::makeDclArg(std::string_view net_vname) { - const std::string net_name = netVerilogToSta(std::move(net_vname)); + const std::string net_name = netVerilogToSta(net_vname); VerilogDclArg *dcl = new VerilogDclArg(net_name); return dcl; } @@ -385,36 +384,36 @@ VerilogReader::makeDclArg(VerilogAssign *assign) } VerilogNetPartSelect * -VerilogReader::makeNetPartSelect(std::string &&net_vname, +VerilogReader::makeNetPartSelect(std::string_view net_vname, int from_index, int to_index) { - const std::string net_name = netVerilogToSta(std::move(net_vname)); + const std::string net_name = netVerilogToSta(net_vname); VerilogNetPartSelect *select = new VerilogNetPartSelect(net_name, from_index, to_index); return select; } VerilogNetConstant * -VerilogReader::makeNetConstant(std::string &&constant, +VerilogReader::makeNetConstant(std::string_view constant, int line) { - return new VerilogNetConstant(std::move(constant), this, line); + return new VerilogNetConstant(constant, this, line); } VerilogNetScalar * -VerilogReader::makeNetScalar(std::string &&net_vname) +VerilogReader::makeNetScalar(std::string_view net_vname) { - const std::string net_name = netVerilogToSta(std::move(net_vname)); + const std::string net_name = netVerilogToSta(net_vname); VerilogNetScalar *scalar = new VerilogNetScalar(net_name); return scalar; } VerilogNetBitSelect * -VerilogReader::makeNetBitSelect(std::string &&net_vname, +VerilogReader::makeNetBitSelect(std::string_view net_vname, int index) { - const std::string net_name = netVerilogToSta(std::move(net_vname)); + const std::string net_name = netVerilogToSta(net_vname); VerilogNetBitSelect *select = new VerilogNetBitSelect(net_name, index); return select; } @@ -428,14 +427,14 @@ VerilogReader::makeAssign(VerilogNet *lhs, } VerilogInst * -VerilogReader::makeModuleInst(std::string &&module_vname, - std::string &&inst_vname, +VerilogReader::makeModuleInst(std::string_view module_vname, + std::string_view inst_vname, VerilogNetSeq *pins, VerilogAttrStmtSeq *attr_stmts, - const int line) + int line) { - const std::string module_name = moduleVerilogToSta(std::move(module_vname)); - const std::string inst_name = instanceVerilogToSta(std::move(inst_vname)); + const std::string module_name = moduleVerilogToSta(module_vname); + const std::string inst_name = instanceVerilogToSta(inst_vname); Cell *cell = network_->findAnyCell(module_name); LibertyCell *liberty_cell = nullptr; if (cell) @@ -443,7 +442,7 @@ VerilogReader::makeModuleInst(std::string &&module_vname, // Instances of liberty with scalar ports are special cased // to reduce the memory footprint of the verilog parser. if (liberty_cell && hasScalarNamedPortRefs(liberty_cell, pins)) { - const int port_count = liberty_cell->portBitCount(); + int port_count = liberty_cell->portBitCount(); StringSeq net_names(port_count); for (VerilogNet *vnet : *pins) { VerilogNetPortRefScalarNet *vpin = @@ -476,7 +475,7 @@ bool VerilogReader::hasScalarNamedPortRefs(LibertyCell *liberty_cell, VerilogNetSeq *pins) { - if (pins && pins->size() > 0 && (*pins)[0]->isNamedPortRef()) { + if (pins && !pins->empty() && (*pins)[0]->isNamedPortRef()) { for (VerilogNet *vpin : *pins) { std::string_view port_name = vpin->name(); LibertyPort *port = liberty_cell->findLibertyPort(port_name); @@ -494,62 +493,62 @@ VerilogReader::hasScalarNamedPortRefs(LibertyCell *liberty_cell, } VerilogNetPortRef * -VerilogReader::makeNetNamedPortRefScalarNet(std::string &&port_vname) +VerilogReader::makeNetNamedPortRefScalarNet(std::string_view port_vname) { - const std::string port_name = portVerilogToSta(std::move(port_vname)); + const std::string port_name = portVerilogToSta(port_vname); VerilogNetPortRef *ref = new VerilogNetPortRefScalarNet(port_name); return ref; } VerilogNetPortRef * -VerilogReader::makeNetNamedPortRefScalarNet(std::string &&port_vname, - std::string &&net_vname) +VerilogReader::makeNetNamedPortRefScalarNet(std::string_view port_vname, + std::string_view net_vname) { - const std::string port_name = portVerilogToSta(std::move(port_vname)); - const std::string net_name = netVerilogToSta(std::move(net_vname)); + const std::string port_name = portVerilogToSta(port_vname); + const std::string net_name = netVerilogToSta(net_vname); VerilogNetPortRef *ref = new VerilogNetPortRefScalarNet(port_name, net_name); return ref; } VerilogNetPortRef * -VerilogReader::makeNetNamedPortRefBitSelect(std::string &&port_vname, - std::string &&bus_vname, +VerilogReader::makeNetNamedPortRefBitSelect(std::string_view port_vname, + std::string_view bus_vname, int index) { - const std::string bus_name = portVerilogToSta(std::move(bus_vname)); + const std::string bus_name = portVerilogToSta(bus_vname); const std::string net_name = verilogBusBitName(bus_name, index); - const std::string port_name = portVerilogToSta(std::move(port_vname)); + const std::string port_name = portVerilogToSta(port_vname); VerilogNetPortRef *ref = new VerilogNetPortRefScalarNet(port_name, net_name); return ref; } VerilogNetPortRef * -VerilogReader::makeNetNamedPortRefScalar(std::string &&port_vname, +VerilogReader::makeNetNamedPortRefScalar(std::string_view port_vname, VerilogNet *net) { - const std::string port_name = portVerilogToSta(std::move(port_vname)); + const std::string port_name = portVerilogToSta(port_vname); VerilogNetPortRef *ref = new VerilogNetPortRefScalar(port_name, net); return ref; } VerilogNetPortRef * -VerilogReader::makeNetNamedPortRefBit(std::string &&port_vname, +VerilogReader::makeNetNamedPortRefBit(std::string_view port_vname, int index, VerilogNet *net) { - const std::string port_name = portVerilogToSta(std::move(port_vname)); + const std::string port_name = portVerilogToSta(port_vname); VerilogNetPortRef *ref = new VerilogNetPortRefBit(port_name, index, net); return ref; } VerilogNetPortRef * -VerilogReader::makeNetNamedPortRefPart(std::string &&port_vname, +VerilogReader::makeNetNamedPortRefPart(std::string_view port_vname, int from_index, int to_index, VerilogNet *net) { - const std::string port_name = portVerilogToSta(std::move(port_vname)); + const std::string port_name = portVerilogToSta(port_vname); VerilogNetPortRef *ref = new VerilogNetPortRefPart(port_name, from_index, to_index, net); return ref; @@ -563,11 +562,11 @@ VerilogReader::makeNetConcat(VerilogNetSeq *nets) //////////////////////////////////////////////////////////////// -VerilogModule::VerilogModule(const std::string &name, +VerilogModule::VerilogModule(std::string_view name, VerilogNetSeq *ports, VerilogStmtSeq *stmts, VerilogAttrStmtSeq *attr_stmts, - const std::string &filename, + std::string_view filename, int line, VerilogReader *reader) : VerilogStmt(line), @@ -679,9 +678,9 @@ VerilogStmt::VerilogStmt(int line) : { } -VerilogInst::VerilogInst(const std::string &inst_name, +VerilogInst::VerilogInst(std::string_view inst_name, VerilogAttrStmtSeq *attr_stmts, - const int line) : + int line) : VerilogStmt(line), inst_name_(inst_name), attr_stmts_(attr_stmts) @@ -700,8 +699,8 @@ VerilogInst::setInstanceName(const std::string &inst_name) inst_name_ = inst_name; } -VerilogModuleInst::VerilogModuleInst(const std::string &module_name, - const std::string &inst_name, +VerilogModuleInst::VerilogModuleInst(std::string_view module_name, + std::string_view inst_name, VerilogNetSeq *pins, VerilogAttrStmtSeq *attr_stmts, int line) : @@ -724,23 +723,21 @@ VerilogModuleInst::~VerilogModuleInst() bool VerilogModuleInst::hasPins() { - return pins_ && pins_->size() > 0; + return pins_ && !pins_->empty(); } bool VerilogModuleInst::namedPins() { - return pins_ && pins_->size() > 0 && (*pins_)[0]->isNamedPortRef(); + return pins_ && !pins_->empty() && (*pins_)[0]->isNamedPortRef(); } VerilogLibertyInst::VerilogLibertyInst(LibertyCell *cell, - const std::string &inst_name, + std::string_view inst_name, const StringSeq &net_names, VerilogAttrStmtSeq *attr_stmts, - const int line) : - VerilogInst(inst_name, - attr_stmts, - line), + int line) : + VerilogInst(inst_name, attr_stmts, line), cell_(cell), net_names_(net_names) { @@ -795,10 +792,7 @@ VerilogDclBus::VerilogDclBus(PortDirection *dir, VerilogDclArgSeq *args, VerilogAttrStmtSeq *attr_stmts, int line) : - VerilogDcl(dir, - args, - attr_stmts, - line), + VerilogDcl(dir, args, attr_stmts, line), from_index_(from_index), to_index_(to_index) { @@ -810,10 +804,7 @@ VerilogDclBus::VerilogDclBus(PortDirection *dir, VerilogDclArg *arg, VerilogAttrStmtSeq *attr_stmts, int line) : - VerilogDcl(dir, - arg, - attr_stmts, - line), + VerilogDcl(dir, arg, attr_stmts, line), from_index_(from_index), to_index_(to_index) { @@ -825,7 +816,7 @@ VerilogDclBus::size() const return std::abs(to_index_ - from_index_) + 1; } -VerilogDclArg::VerilogDclArg(const std::string &net_name) : +VerilogDclArg::VerilogDclArg(std::string_view net_name) : net_name_(net_name), assign_(nullptr) { @@ -887,12 +878,11 @@ public: protected: std::string name_; - bool has_next_; + bool has_next_{true}; }; VerilogOneNetNameIterator::VerilogOneNetNameIterator(const std::string &name) : - name_(name), - has_next_(true) + name_(name) { } @@ -912,7 +902,7 @@ VerilogOneNetNameIterator::next() class VerilogBusNetNameIterator : public VerilogNetNameIterator { public: - VerilogBusNetNameIterator(const std::string bus_name, + VerilogBusNetNameIterator(std::string_view bus_name, int from_index, int to_index); bool hasNext() override; @@ -926,7 +916,7 @@ protected: std::string bit_name_; }; -VerilogBusNetNameIterator::VerilogBusNetNameIterator(const std::string bus_name, +VerilogBusNetNameIterator::VerilogBusNetNameIterator(std::string_view bus_name, int from_index, int to_index) : bus_name_(bus_name), @@ -955,7 +945,7 @@ VerilogBusNetNameIterator::next() } static std::string -verilogBusBitName(const std::string &bus_name, +verilogBusBitName(std::string_view bus_name, int index) { return sta::format("{}[{}]", bus_name, index); @@ -1015,7 +1005,7 @@ private: VerilogReader *reader_; VerilogNetSeq *nets_; VerilogNetSeq::iterator net_iter_; - VerilogNetNameIterator *net_name_iter_; + VerilogNetNameIterator *net_name_iter_{nullptr}; }; VerilogNetConcatNameIterator::VerilogNetConcatNameIterator(VerilogNetSeq *nets, @@ -1024,8 +1014,7 @@ VerilogNetConcatNameIterator::VerilogNetConcatNameIterator(VerilogNetSeq *nets, module_(module), reader_(reader), nets_(nets), - net_iter_(nets->begin()), - net_name_iter_(nullptr) + net_iter_(nets->begin()) { if (net_iter_ != nets_->end()) { VerilogNet *net = *net_iter_++; @@ -1066,15 +1055,13 @@ VerilogNetConcatNameIterator::next() const std::string VerilogNetUnnamed::null_; -VerilogNetNamed::VerilogNetNamed(const std::string &name) : +VerilogNetNamed::VerilogNetNamed(std::string_view name) : VerilogNet(), name_(name) { } -VerilogNetNamed::~VerilogNetNamed() {} - -VerilogNetScalar::VerilogNetScalar(const std::string &name) : +VerilogNetScalar::VerilogNetScalar(std::string_view name) : VerilogNetNamed(name) { } @@ -1119,7 +1106,7 @@ VerilogNetScalar::nameIterator(VerilogModule *module, return verilogNetScalarNameIterator(name_, module); } -VerilogNetBitSelect::VerilogNetBitSelect(const std::string &name, +VerilogNetBitSelect::VerilogNetBitSelect(std::string_view name, int index) : VerilogNetNamed(verilogBusBitName(name, index)), @@ -1140,7 +1127,7 @@ VerilogNetBitSelect::nameIterator(VerilogModule *, return new VerilogOneNetNameIterator(name_); } -VerilogNetPartSelect::VerilogNetPartSelect(const std::string &name, +VerilogNetPartSelect::VerilogNetPartSelect(std::string_view name, int from_index, int to_index) : VerilogNetNamed(name), @@ -1165,7 +1152,7 @@ VerilogNetPartSelect::nameIterator(VerilogModule *, return new VerilogBusNetNameIterator(name_, from_index_, to_index_); } -VerilogNetConstant::VerilogNetConstant(std::string constant, +VerilogNetConstant::VerilogNetConstant(std::string_view constant, VerilogReader *reader, int line) { @@ -1173,13 +1160,13 @@ VerilogNetConstant::VerilogNetConstant(std::string constant, } void -VerilogNetConstant::parseConstant(const std::string &constant, +VerilogNetConstant::parseConstant(std::string_view constant, VerilogReader *reader, int line) { // Find constant size. size_t csize_end = constant.find('\''); - std::string csize = constant.substr(0, csize_end); + std::string csize(constant.substr(0, csize_end)); // Read the constant size. size_t size = std::stol(csize); @@ -1214,7 +1201,7 @@ VerilogNetConstant::parseConstant(const std::string &constant, } void -VerilogNetConstant::parseConstant(const std::string &constant, +VerilogNetConstant::parseConstant(std::string_view constant, size_t base_idx, int base, int digit_bit_count) @@ -1243,30 +1230,31 @@ VerilogNetConstant::parseConstant(const std::string &constant, } void -VerilogNetConstant::parseConstant10(const std::string &constant, - size_t base_idx, - VerilogReader *reader, - int line) +VerilogNetConstant::parseConstant10(std::string_view constant, + size_t base_idx, + VerilogReader *reader, + int line) { // Copy the constant skipping underscores. - std::string tmp; + std::string constant1; for (size_t i = base_idx + 1; i < constant.size(); i++) { char ch = constant.at(i); if (ch != '_') - tmp += ch; + constant1 += ch; } size_t size = value_->size(); - size_t length = tmp.size(); + size_t length = constant1.size(); const std::string &constant10_max = reader->constant10Max(); size_t max_length = constant10_max.size(); - if (length > max_length || (length == max_length && tmp > constant10_max)) + if (length > max_length + || (length == max_length && constant1 > constant10_max)) reader->warn(1397, reader->filename(), line, "base 10 constant greater than {} not supported.", constant10_max); else { size_t *end = nullptr; - VerilogConstant10 value = std::stoull(tmp, end, 10); + VerilogConstant10 value = std::stoull(constant1, end, 10); VerilogConstant10 mask = 1; for (size_t bit = 0; bit < size; bit++) { (*value_)[bit] = (value & mask) != 0; @@ -1318,18 +1306,18 @@ VerilogNetConcat::nameIterator(VerilogModule *module, return new VerilogNetConcatNameIterator(nets_, module, reader); } -VerilogNetPortRef::VerilogNetPortRef(const std::string &name) : +VerilogNetPortRef::VerilogNetPortRef(std::string_view name) : VerilogNetScalar(name) { } -VerilogNetPortRefScalarNet::VerilogNetPortRefScalarNet(const std::string &name) : +VerilogNetPortRefScalarNet::VerilogNetPortRefScalarNet(std::string_view name) : VerilogNetPortRef(name) { } -VerilogNetPortRefScalarNet::VerilogNetPortRefScalarNet(const std::string &name, - const std::string &net_name) : +VerilogNetPortRefScalarNet::VerilogNetPortRefScalarNet(std::string_view name, + std::string_view net_name) : VerilogNetPortRef(name), net_name_(net_name) { @@ -1356,7 +1344,7 @@ VerilogNetPortRefScalarNet::nameIterator(VerilogModule *module, return verilogNetScalarNameIterator(net_name_, module); } -VerilogNetPortRefScalar::VerilogNetPortRefScalar(const std::string &name, +VerilogNetPortRefScalar::VerilogNetPortRefScalar(std::string_view name, VerilogNet *net) : VerilogNetPortRef(name), net_(net) @@ -1384,7 +1372,7 @@ VerilogNetPortRefScalar::nameIterator(VerilogModule *module, return new VerilogNullNetNameIterator(); } -VerilogNetPortRefBit::VerilogNetPortRefBit(const std::string &name, +VerilogNetPortRefBit::VerilogNetPortRefBit(std::string_view name, int index, VerilogNet *net) : VerilogNetPortRefScalar(name, @@ -1394,13 +1382,11 @@ VerilogNetPortRefBit::VerilogNetPortRefBit(const std::string &name, { } -VerilogNetPortRefPart::VerilogNetPortRefPart(const std::string &name, +VerilogNetPortRefPart::VerilogNetPortRefPart(std::string_view name, int from_index, int to_index, VerilogNet *net) : - VerilogNetPortRefBit(name, - from_index, - net), + VerilogNetPortRefBit(name, from_index, net), to_index_(to_index) { } @@ -1411,25 +1397,13 @@ VerilogNetPortRefPart::name() const return name_; } -VerilogAttrEntry::VerilogAttrEntry(const std::string &key, - const std::string &value) : +VerilogAttrEntry::VerilogAttrEntry(std::string_view key, + std::string_view value) : key_(key), value_(value) { } -std::string -VerilogAttrEntry::key() -{ - return key_; -} - -std::string -VerilogAttrEntry::value() -{ - return value_; -} - VerilogAttrStmt::VerilogAttrStmt(VerilogAttrEntrySeq *attrs) : attrs_(attrs) { diff --git a/verilog/VerilogReaderPvt.hh b/verilog/VerilogReaderPvt.hh index fc5381f8..c425a387 100644 --- a/verilog/VerilogReaderPvt.hh +++ b/verilog/VerilogReaderPvt.hh @@ -24,11 +24,13 @@ #pragma once -#include -#include #include +#include +#include +#include #include "StringUtil.hh" +#include "VerilogReader.hh" namespace sta { @@ -39,7 +41,7 @@ class VerilogStmt { public: VerilogStmt(int line); - virtual ~VerilogStmt() {} + virtual ~VerilogStmt() = default; virtual bool isInstance() const { return false; } virtual bool isModuleInst() const { return false; } virtual bool isLibertyInst() const { return false; } @@ -54,11 +56,11 @@ private: class VerilogModule : public VerilogStmt { public: - VerilogModule(const std::string &name, + VerilogModule(std::string_view name, VerilogNetSeq *ports, VerilogStmtSeq *stmts, VerilogAttrStmtSeq *attr_stmts, - const std::string &filename, + std::string_view filename, int line, VerilogReader *reader); ~VerilogModule() override; @@ -97,10 +99,10 @@ public: VerilogDclArg *arg, VerilogAttrStmtSeq *attr_stmts, int line); - virtual ~VerilogDcl(); + ~VerilogDcl() override; const std::string &portName(); virtual bool isBus() const { return false; } - virtual bool isDeclaration() const { return true; } + bool isDeclaration() const override { return true; } VerilogDclArgSeq *args() const { return args_; } void appendArg(VerilogDclArg *arg); PortDirection *direction() const { return dir_; } @@ -142,7 +144,7 @@ private: class VerilogDclArg { public: - VerilogDclArg(const std::string &net_name); + VerilogDclArg(std::string_view net_name); VerilogDclArg(VerilogAssign *assign); ~VerilogDclArg(); const std::string &netName(); @@ -174,9 +176,9 @@ private: class VerilogInst : public VerilogStmt { public: - VerilogInst(const std::string &inst_name, + VerilogInst(std::string_view inst_name, VerilogAttrStmtSeq *attr_stmts, - const int line); + int line); ~VerilogInst() override; bool isInstance() const override { return true; } const std::string &instanceName() const { return inst_name_; } @@ -191,11 +193,11 @@ private: class VerilogModuleInst : public VerilogInst { public: - VerilogModuleInst(const std::string &module_name, - const std::string &inst_name, + VerilogModuleInst(std::string_view module_name, + std::string_view inst_name, VerilogNetSeq *pins, VerilogAttrStmtSeq *attr_stmts, - const int line); + int line); ~VerilogModuleInst() override; bool isModuleInst() const override { return true; } const std::string &moduleName() const { return module_name_; } @@ -215,10 +217,10 @@ class VerilogLibertyInst : public VerilogInst { public: VerilogLibertyInst(LibertyCell *cell, - const std::string &inst_name, + std::string_view inst_name, const StringSeq &net_names, VerilogAttrStmtSeq *attr_stmts, - const int line); + int line); bool isLibertyInst() const override { return true; } LibertyCell *cell() const { return cell_; } const StringSeq &netNames() const { return net_names_; } @@ -232,8 +234,7 @@ private: class VerilogNet { public: - VerilogNet() {} - virtual ~VerilogNet() {} + virtual ~VerilogNet() = default; virtual bool isNamed() const = 0; virtual const std::string &name() const = 0; virtual bool isNamedPortRef() { return false; } @@ -246,7 +247,6 @@ public: class VerilogNetUnnamed : public VerilogNet { public: - VerilogNetUnnamed() {} bool isNamed() const override { return false; } const std::string &name() const override { return null_; } @@ -257,8 +257,7 @@ private: class VerilogNetNamed : public VerilogNet { public: - VerilogNetNamed(const std::string &name); - ~VerilogNetNamed() override; + VerilogNetNamed(std::string_view name); bool isNamed() const override { return true; } virtual bool isScalar() const = 0; const std::string &name() const override { return name_; } @@ -271,7 +270,7 @@ protected: class VerilogNetScalar : public VerilogNetNamed { public: - VerilogNetScalar(const std::string &name); + VerilogNetScalar(std::string_view name); bool isScalar() const override { return true; } int size(VerilogModule *module) override; VerilogNetNameIterator *nameIterator(VerilogModule *module, @@ -281,7 +280,7 @@ public: class VerilogNetBitSelect : public VerilogNetNamed { public: - VerilogNetBitSelect(const std::string &name, + VerilogNetBitSelect(std::string_view name, int index); int index() { return index_; } bool isScalar() const override { return false; } @@ -295,7 +294,7 @@ private: class VerilogNetPartSelect : public VerilogNetNamed { public: - VerilogNetPartSelect(const std::string &name, + VerilogNetPartSelect(std::string_view name, int from_index, int to_index); bool isScalar() const override { return false; } @@ -313,7 +312,7 @@ private: class VerilogNetConstant : public VerilogNetUnnamed { public: - VerilogNetConstant(std::string constant, + VerilogNetConstant(std::string_view constant, VerilogReader *reader, int line); ~VerilogNetConstant() override; @@ -322,14 +321,14 @@ public: VerilogReader *reader) override; private: - void parseConstant(const std::string &constant, + void parseConstant(std::string_view constant, VerilogReader *reader, int line); - void parseConstant(const std::string &constant, + void parseConstant(std::string_view constant, size_t base_idx, int base, int digit_bit_count); - void parseConstant10(const std::string &constant, + void parseConstant10(std::string_view constant, size_t base_idx, VerilogReader *reader, int line); @@ -354,7 +353,7 @@ private: class VerilogNetPortRef : public VerilogNetScalar { public: - VerilogNetPortRef(const std::string &name); + VerilogNetPortRef(std::string_view name); bool isNamedPortRef() override { return true; } virtual bool hasNet() = 0; }; @@ -366,9 +365,9 @@ public: class VerilogNetPortRefScalarNet : public VerilogNetPortRef { public: - VerilogNetPortRefScalarNet(const std::string &name); - VerilogNetPortRefScalarNet(const std::string &name, - const std::string &net_name); + VerilogNetPortRefScalarNet(std::string_view name); + VerilogNetPortRefScalarNet(std::string_view name, + std::string_view net_name); bool isScalar() const override { return true; } bool isNamedPortRefScalarNet() const override { return true; } int size(VerilogModule *module) override; @@ -385,7 +384,7 @@ private: class VerilogNetPortRefScalar : public VerilogNetPortRef { public: - VerilogNetPortRefScalar(const std::string &name, + VerilogNetPortRefScalar(std::string_view name, VerilogNet *net); ~VerilogNetPortRefScalar() override; bool isScalar() const override { return true; } @@ -401,7 +400,7 @@ private: class VerilogNetPortRefBit : public VerilogNetPortRefScalar { public: - VerilogNetPortRefBit(const std::string &name, + VerilogNetPortRefBit(std::string_view name, int index, VerilogNet *net); const std::string &name() const override { return bit_name_; } @@ -413,7 +412,7 @@ private: class VerilogNetPortRefPart : public VerilogNetPortRefBit { public: - VerilogNetPortRefPart(const std::string &name, + VerilogNetPortRefPart(std::string_view name, int from_index, int to_index, VerilogNet *net); @@ -433,8 +432,8 @@ class VerilogAttrStmt { public: VerilogAttrStmt(VerilogAttrEntrySeq *attrs); - VerilogAttrEntrySeq *attrs(); virtual ~VerilogAttrStmt(); + VerilogAttrEntrySeq *attrs(); private: VerilogAttrEntrySeq *attrs_; @@ -443,15 +442,14 @@ private: class VerilogAttrEntry { public: - VerilogAttrEntry(const std::string &key, - const std::string &value); - virtual std::string key(); - virtual std::string value(); - virtual ~VerilogAttrEntry() = default; + VerilogAttrEntry(std::string_view key, + std::string_view value); + const std::string &key() const { return key_; } + const std::string &value() const { return value_; } private: std::string key_; std::string value_; }; -} // namespace +} // namespace sta diff --git a/verilog/VerilogScanner.hh b/verilog/VerilogScanner.hh index 3c0c5d61..092c7285 100644 --- a/verilog/VerilogScanner.hh +++ b/verilog/VerilogScanner.hh @@ -39,6 +39,7 @@ namespace sta { class Report; +class VerilogReader; class VerilogScanner : public VerilogFlexLexer { @@ -46,9 +47,7 @@ public: VerilogScanner(std::istream *stream, std::string_view filename, Report *report); - virtual ~VerilogScanner() {} - - virtual int lex(VerilogParse::semantic_type *const yylval, + virtual int lex(VerilogParse::semantic_type *yylval, VerilogParse::location_type *yylloc); // YY_DECL defined in VerilogLex.ll // Method body created by flex in VerilogLex.cc @@ -65,4 +64,4 @@ private: std::string token_; }; -} // namespace +} // namespace sta diff --git a/verilog/VerilogWriter.cc b/verilog/VerilogWriter.cc index 49ecedf3..4f5e5fc6 100644 --- a/verilog/VerilogWriter.cc +++ b/verilog/VerilogWriter.cc @@ -33,11 +33,11 @@ #include "Error.hh" #include "Format.hh" #include "Liberty.hh" -#include "PortDirection.hh" #include "Network.hh" #include "NetworkCmp.hh" -#include "VerilogNamespace.hh" #include "ParseBus.hh" +#include "PortDirection.hh" +#include "VerilogNamespace.hh" namespace sta { @@ -84,7 +84,7 @@ protected: CellSet remove_cells_; FILE *stream_; Network *network_; - int unconnected_net_index_; + int unconnected_net_index_{1}; }; void @@ -115,8 +115,7 @@ VerilogWriter::VerilogWriter(const char *filename, include_pwr_gnd_(include_pwr_gnd), remove_cells_(network), stream_(stream), - network_(network), - unconnected_net_index_(1) + network_(network) { if (remove_cells) { for(Cell *lib_cell : *remove_cells) @@ -515,4 +514,4 @@ VerilogWriter::findPortNCcount(const Instance *inst, return nc_count; } -} // namespace +} // namespace sta