From 63efee64bfefb7dffa6636b3092fdd644069a097 Mon Sep 17 00:00:00 2001 From: James Cherry Date: Mon, 13 Apr 2026 14:58:16 -0700 Subject: [PATCH] tidy round1 --- .clang-tidy | 77 ++++++ .cursor/rules/cpp-coding-standards.mdc | 26 ++ CMakeLists.txt | 2 +- app/StaMain.cc | 2 +- dcalc/ArcDcalcWaveforms.cc | 2 +- dcalc/ArcDcalcWaveforms.hh | 2 +- dcalc/ArcDelayCalc.cc | 4 +- dcalc/Arnoldi.hh | 2 +- dcalc/ArnoldiDelayCalc.cc | 2 +- dcalc/ArnoldiDelayCalc.hh | 2 +- dcalc/ArnoldiReduce.hh | 2 +- dcalc/CcsCeffDelayCalc.hh | 2 +- dcalc/Delay.cc | 22 +- dcalc/DelayCalc.cc | 2 +- dcalc/DelayCalcBase.cc | 2 +- dcalc/DelayCalcBase.hh | 2 +- dcalc/DelayNormal.cc | 4 +- dcalc/DelayScalar.cc | 4 +- dcalc/DelaySkewNormal.cc | 4 +- dcalc/DmpCeff.hh | 2 +- dcalc/DmpDelayCalc.cc | 2 +- dcalc/DmpDelayCalc.hh | 2 +- dcalc/FindRoot.cc | 2 +- dcalc/FindRoot.hh | 2 +- dcalc/GraphDelayCalc.cc | 2 +- dcalc/LumpedCapDelayCalc.cc | 2 +- dcalc/LumpedCapDelayCalc.hh | 2 +- dcalc/NetCaps.cc | 2 +- dcalc/NetCaps.hh | 2 +- dcalc/ParallelDelayCalc.cc | 2 +- dcalc/ParallelDelayCalc.hh | 2 +- dcalc/PrimaDelayCalc.hh | 2 +- dcalc/UnitDelayCalc.cc | 2 +- dcalc/UnitDelayCalc.hh | 2 +- doc/StaApi.txt | 5 +- graph/Graph.cc | 2 +- include/sta/ArcDelayCalc.hh | 5 +- include/sta/Bdd.hh | 4 +- include/sta/Bfs.hh | 10 +- include/sta/CircuitSim.hh | 2 +- include/sta/ClkNetwork.hh | 8 +- include/sta/Clock.hh | 6 +- include/sta/ClockGatingCheck.hh | 2 +- include/sta/ClockGroups.hh | 6 +- include/sta/ClockInsertion.hh | 2 +- include/sta/ClockLatency.hh | 2 +- include/sta/ConcreteLibrary.hh | 8 +- include/sta/ConcreteNetwork.hh | 8 +- include/sta/ContainerHelpers.hh | 70 ++--- include/sta/CycleAccting.hh | 2 +- include/sta/DataCheck.hh | 2 +- include/sta/Debug.hh | 6 +- include/sta/Delay.hh | 20 +- include/sta/DelayCalc.hh | 2 +- include/sta/DelayNormal.hh | 4 +- include/sta/DelayScalar.hh | 4 +- include/sta/DelaySkewNormal.hh | 4 +- include/sta/DeratingFactors.hh | 2 +- include/sta/DisabledPorts.hh | 2 +- include/sta/DispatchQueue.hh | 6 +- include/sta/EnumNameMap.hh | 7 +- include/sta/EquivCells.hh | 2 +- include/sta/Error.hh | 5 +- include/sta/ExceptionPath.hh | 43 ++-- include/sta/FilterObjects.hh | 5 +- include/sta/FuncExpr.hh | 2 +- include/sta/Fuzzy.hh | 2 +- include/sta/Graph.hh | 8 +- include/sta/GraphClass.hh | 2 +- include/sta/GraphCmp.hh | 2 +- include/sta/GraphDelayCalc.hh | 9 +- include/sta/Hash.hh | 2 +- include/sta/HpinDrvrLoad.hh | 5 +- include/sta/InputDrive.hh | 2 +- include/sta/InternalPower.hh | 2 +- include/sta/Iterator.hh | 4 +- include/sta/LeakagePower.hh | 2 +- include/sta/Liberty.hh | 270 ++++++++++---------- include/sta/LibertyClass.hh | 12 +- include/sta/LibertyWriter.hh | 2 +- include/sta/LinearModel.hh | 8 +- include/sta/Machine.hh | 8 +- include/sta/MakeConcreteNetwork.hh | 2 +- include/sta/MinMax.hh | 46 ++-- include/sta/MinMaxValues.hh | 2 +- include/sta/Mode.hh | 18 +- include/sta/Mutex.hh | 4 +- include/sta/Network.hh | 22 +- include/sta/NetworkClass.hh | 2 +- include/sta/NetworkCmp.hh | 2 +- include/sta/ObjectId.hh | 2 +- include/sta/ObjectTable.hh | 14 +- include/sta/Parasitics.hh | 3 +- include/sta/ParasiticsClass.hh | 2 +- include/sta/ParseBus.hh | 22 +- include/sta/Path.hh | 5 +- include/sta/PathEnd.hh | 271 ++++++++++---------- include/sta/PathExpanded.hh | 2 +- include/sta/PathGroup.hh | 52 ++-- include/sta/PatternMatch.hh | 6 +- include/sta/PinPair.hh | 2 +- include/sta/PocvMode.hh | 4 +- include/sta/PortDelay.hh | 2 +- include/sta/PortDirection.hh | 8 +- include/sta/PortExtCap.hh | 2 +- include/sta/PowerClass.hh | 18 +- include/sta/Property.hh | 29 +-- include/sta/Report.hh | 26 +- include/sta/ReportStd.hh | 2 +- include/sta/ReportTcl.hh | 14 +- include/sta/RiseFallMinMax.hh | 2 +- include/sta/RiseFallMinMaxDelay.hh | 2 +- include/sta/RiseFallValues.hh | 2 +- include/sta/Scene.hh | 4 +- include/sta/Sdc.hh | 33 ++- include/sta/SdcClass.hh | 2 +- include/sta/SdcCmdComment.hh | 8 +- include/sta/SdcNetwork.hh | 2 +- include/sta/Search.hh | 165 ++++++------ include/sta/SearchClass.hh | 2 +- include/sta/SearchPred.hh | 4 +- include/sta/Sequential.hh | 2 +- include/sta/Sta.hh | 75 +++--- include/sta/StaMain.hh | 2 +- include/sta/StaState.hh | 6 +- include/sta/Stats.hh | 10 +- include/sta/StringUtil.hh | 29 +-- include/sta/TableModel.hh | 29 +-- include/sta/TclTypeHelpers.hh | 2 +- include/sta/TimingArc.hh | 20 +- include/sta/TimingModel.hh | 4 +- include/sta/TimingRole.hh | 2 +- include/sta/Transition.hh | 68 ++--- include/sta/Units.hh | 6 +- include/sta/Variables.hh | 2 +- include/sta/VectorMap.hh | 19 +- include/sta/VerilogNamespace.hh | 2 +- include/sta/VerilogReader.hh | 36 +-- include/sta/VerilogWriter.hh | 2 +- include/sta/VertexId.hh | 2 +- include/sta/VertexVisitor.hh | 10 +- include/sta/VisitPathEnds.hh | 4 +- include/sta/Wireload.hh | 4 +- liberty/EquivCells.cc | 23 +- liberty/FuncExpr.cc | 9 +- liberty/InternalPower.cc | 9 +- liberty/LeakagePower.cc | 3 +- liberty/LibExprLex.ll | 2 +- liberty/LibExprReader.cc | 4 +- liberty/LibExprReader.hh | 2 +- liberty/LibExprReaderPvt.hh | 4 +- liberty/LibExprScanner.hh | 6 +- liberty/Liberty.cc | 326 ++++++++---------------- liberty/Liberty.i | 1 - liberty/LibertyBuilder.cc | 44 ++-- liberty/LibertyBuilder.hh | 25 +- liberty/LibertyExt.cc | 287 --------------------- liberty/LibertyLex.ll | 2 +- liberty/LibertyParser.cc | 24 +- liberty/LibertyParser.hh | 13 +- liberty/LibertyReader.cc | 189 +++++++------- liberty/LibertyReader.hh | 2 +- liberty/LibertyReaderPvt.hh | 88 +++---- liberty/LibertyScanner.hh | 8 +- liberty/LibertyWriter.cc | 9 +- liberty/LinearModel.cc | 10 +- liberty/Sequential.cc | 4 +- liberty/TableModel.cc | 79 +++--- liberty/TimingArc.cc | 65 +++-- liberty/TimingModel.cc | 4 +- liberty/TimingRole.cc | 4 +- liberty/Units.cc | 14 +- liberty/Wireload.cc | 12 +- network/ConcreteLibrary.cc | 6 +- network/ConcreteNetwork.cc | 2 +- network/HpinDrvrLoad.cc | 2 +- network/Network.cc | 2 +- network/NetworkCmp.cc | 2 +- network/ParseBus.cc | 2 +- network/PortDirection.cc | 4 +- network/SdcNetwork.cc | 2 +- network/VerilogNamespace.cc | 2 +- parasitics/ConcreteParasitics.cc | 6 +- parasitics/ConcreteParasitics.hh | 8 +- parasitics/ConcreteParasiticsPvt.hh | 2 +- parasitics/EstimateParasitics.cc | 2 +- parasitics/EstimateParasitics.hh | 2 +- parasitics/ReduceParasitics.cc | 2 +- parasitics/ReduceParasitics.hh | 2 +- parasitics/ReportParasiticAnnotation.hh | 2 +- parasitics/SpefNamespace.cc | 2 +- parasitics/SpefNamespace.hh | 2 +- parasitics/SpefReader.cc | 2 - parasitics/SpefReader.hh | 2 +- parasitics/SpefReaderPvt.hh | 4 +- parasitics/SpefScanner.hh | 4 +- power/Power.cc | 136 +++++----- power/Power.hh | 23 +- power/ReportPower.hh | 2 +- power/SaifReader.hh | 2 +- power/SaifReaderPvt.hh | 2 +- power/SaifScanner.hh | 4 +- power/VcdParse.hh | 4 +- power/VcdReader.hh | 2 +- sdc/Clock.cc | 6 +- sdc/ClockGatingCheck.cc | 2 +- sdc/ClockGroups.cc | 8 +- sdc/ClockInsertion.cc | 2 +- sdc/ClockLatency.cc | 2 +- sdc/CycleAccting.cc | 2 +- sdc/DataCheck.cc | 2 +- sdc/DeratingFactors.cc | 2 +- sdc/ExceptionPath.cc | 14 +- sdc/FilterObjects.cc | 139 +++++++--- sdc/InputDrive.cc | 2 +- sdc/PinPair.cc | 2 +- sdc/PortDelay.cc | 2 +- sdc/PortExtCap.cc | 2 +- sdc/Sdc.cc | 143 +++++------ sdc/SdcCmdComment.cc | 21 +- sdc/Variables.cc | 2 +- sdc/WriteSdc.cc | 4 +- sdc/WriteSdc.hh | 2 +- sdc/WriteSdcPvt.hh | 2 +- sdf/ReportAnnotation.hh | 2 +- sdf/SdfReader.hh | 2 +- sdf/SdfReaderPvt.hh | 2 +- sdf/SdfScanner.hh | 4 +- sdf/SdfWriter.cc | 2 +- sdf/SdfWriter.hh | 2 +- search/Bdd.cc | 9 +- search/Bfs.cc | 17 +- search/CheckCapacitances.cc | 40 +-- search/CheckCapacitances.hh | 14 +- search/CheckFanouts.cc | 25 +- search/CheckFanouts.hh | 7 +- search/CheckMaxSkews.cc | 19 +- search/CheckMaxSkews.hh | 14 +- search/CheckMinPeriods.cc | 16 +- search/CheckMinPeriods.hh | 12 +- search/CheckMinPulseWidths.cc | 28 +- search/CheckMinPulseWidths.hh | 12 +- search/CheckSlews.cc | 31 ++- search/CheckSlews.hh | 18 +- search/CheckTiming.cc | 47 ++-- search/CheckTiming.hh | 22 +- search/ClkDelays.hh | 9 +- search/ClkInfo.cc | 12 +- search/ClkInfo.hh | 19 +- search/ClkLatency.cc | 12 +- search/ClkLatency.hh | 11 +- search/ClkNetwork.cc | 15 +- search/ClkSkew.cc | 40 ++- search/ClkSkew.hh | 18 +- search/Crpr.cc | 22 +- search/Crpr.hh | 14 +- search/FindRegister.cc | 119 ++++----- search/FindRegister.hh | 14 +- search/GatedClk.cc | 10 +- search/GatedClk.hh | 10 +- search/Genclks.cc | 76 +++--- search/Genclks.hh | 16 +- search/Latches.cc | 28 +- search/Latches.hh | 9 +- search/Levelize.cc | 27 +- search/Levelize.hh | 24 +- search/MakeTimingModel.cc | 56 ++-- search/MakeTimingModel.hh | 2 +- search/MakeTimingModelPvt.hh | 17 +- search/Mode.cc | 18 +- search/Path.cc | 29 ++- search/PathEnd.cc | 68 +++-- search/PathEnum.cc | 50 ++-- search/PathEnum.hh | 20 +- search/PathExpanded.cc | 14 +- search/PathGroup.cc | 94 +++---- search/PocvMode.cc | 4 +- search/Property.cc | 65 +++-- search/ReportPath.cc | 82 +++--- search/ReportPath.hh | 62 +++-- search/Scene.cc | 6 +- search/Search.cc | 116 ++++----- search/Search.i | 10 +- search/SearchPred.cc | 24 +- search/Sim.cc | 11 +- search/Sim.hh | 26 +- search/Sta.cc | 225 ++++++++-------- search/StaState.cc | 14 +- search/Tag.cc | 22 +- search/Tag.hh | 24 +- search/TagGroup.cc | 13 +- search/TagGroup.hh | 20 +- search/VertexVisitor.cc | 2 +- search/VisitPathEnds.cc | 32 +-- search/WorstSlack.cc | 22 +- search/WorstSlack.hh | 13 +- spice/WritePathSpice.cc | 2 +- spice/WritePathSpice.hh | 2 +- spice/Xyce.cc | 2 +- spice/Xyce.hh | 2 +- tcl/StaTclTypes.i | 2 +- tcl/TclTypeHelpers.cc | 2 +- util/Debug.cc | 6 +- util/DispatchQueue.cc | 12 +- util/Error.cc | 11 +- util/Fuzzy.cc | 2 +- util/Hash.cc | 2 +- util/MachineApple.cc | 10 +- util/MachineLinux.cc | 12 +- util/MachineUnknown.cc | 2 +- util/MachineWin32.cc | 6 +- util/MinMax.cc | 20 +- util/PatternMatch.cc | 8 +- util/Report.cc | 70 +---- util/ReportStd.cc | 11 +- util/ReportTcl.cc | 49 ++-- util/RiseFallMinMax.cc | 38 +-- util/RiseFallMinMaxDelay.cc | 10 +- util/RiseFallValues.cc | 2 +- util/Stats.cc | 10 +- util/StringUtil.cc | 6 +- util/Transition.cc | 38 +-- util/Util.i | 8 +- verilog/VerilogParse.yy | 53 ++-- verilog/VerilogReader.cc | 179 ++++++------- verilog/VerilogReaderPvt.hh | 64 +++-- verilog/VerilogScanner.hh | 4 +- verilog/VerilogWriter.cc | 2 +- 328 files changed, 3030 insertions(+), 3441 deletions(-) create mode 100644 .clang-tidy delete mode 100644 liberty/LibertyExt.cc diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 00000000..19aed656 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,77 @@ +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-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)/.*' + +# Bison-generated parser headers (build/{Liberty,Verilog,...}Parse.hh); gzstream (e.g. util/gzstream.hh). +ExcludeHeaderFilterRegex: '.*/(gzstream\.h(?:h)?|(?: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/CMakeLists.txt b/CMakeLists.txt index b9308293..33bc1ede 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 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..6de6bdb6 100644 --- a/dcalc/ArcDcalcWaveforms.cc +++ b/dcalc/ArcDcalcWaveforms.cc @@ -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..38000cd0 100644 --- a/dcalc/ArcDelayCalc.cc +++ b/dcalc/ArcDelayCalc.cc @@ -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), @@ -305,4 +305,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..73fc26b2 100644 --- a/dcalc/Arnoldi.hh +++ b/dcalc/Arnoldi.hh @@ -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..efacb54a 100644 --- a/dcalc/ArnoldiDelayCalc.cc +++ b/dcalc/ArnoldiDelayCalc.cc @@ -1488,4 +1488,4 @@ ArnoldiDelayCalc::ar1_ceff_delay(delay_work *D, } } -} // namespace +} // 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.hh b/dcalc/ArnoldiReduce.hh index aed95e52..0ee70c84 100644 --- a/dcalc/ArnoldiReduce.hh +++ b/dcalc/ArnoldiReduce.hh @@ -120,4 +120,4 @@ protected: int order; }; -} // namespace +} // namespace sta diff --git a/dcalc/CcsCeffDelayCalc.hh b/dcalc/CcsCeffDelayCalc.hh index 665588f8..81fb2450 100644 --- a/dcalc/CcsCeffDelayCalc.hh +++ b/dcalc/CcsCeffDelayCalc.hh @@ -155,4 +155,4 @@ protected: ArcDelayCalc *table_dcalc_; }; -} // namespace +} // namespace sta diff --git a/dcalc/Delay.cc b/dcalc/Delay.cc index 48c867a3..bdec1906 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 @@ -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..3ce3cbc9 100644 --- a/dcalc/DelayCalc.cc +++ b/dcalc/DelayCalc.cc @@ -93,4 +93,4 @@ delayCalcNames() return names; } -} // namespace +} // namespace sta diff --git a/dcalc/DelayCalcBase.cc b/dcalc/DelayCalcBase.cc index 71e2f116..c41eb94f 100644 --- a/dcalc/DelayCalcBase.cc +++ b/dcalc/DelayCalcBase.cc @@ -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..2cfdc650 100644 --- a/dcalc/DelayCalcBase.hh +++ b/dcalc/DelayCalcBase.hh @@ -89,4 +89,4 @@ protected: using ArcDelayCalc::reduceParasitic; }; -} // namespace +} // namespace sta diff --git a/dcalc/DelayNormal.cc b/dcalc/DelayNormal.cc index 2c3cb059..2120bded 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 @@ -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..73f217b4 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 @@ -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..b8c9c8e5 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 @@ -290,4 +290,4 @@ DelayOpsSkewNormal::asStringVariance(const Delay &delay, sta->units()->scalarUnit()->asString(delay.skewness(), digits)); } -} // namespace +} // namespace sta diff --git a/dcalc/DmpCeff.hh b/dcalc/DmpCeff.hh index 065a0026..15f44640 100644 --- a/dcalc/DmpCeff.hh +++ b/dcalc/DmpCeff.hh @@ -101,4 +101,4 @@ private: DmpAlg *dmp_alg_; }; -} // namespace +} // namespace sta diff --git a/dcalc/DmpDelayCalc.cc b/dcalc/DmpDelayCalc.cc index d89b319d..c9c63f5a 100644 --- a/dcalc/DmpDelayCalc.cc +++ b/dcalc/DmpDelayCalc.cc @@ -436,4 +436,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..97e1c62d 100644 --- a/dcalc/FindRoot.cc +++ b/dcalc/FindRoot.cc @@ -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..d0c1921f 100644 --- a/dcalc/FindRoot.hh +++ b/dcalc/FindRoot.hh @@ -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..eddd3235 100644 --- a/dcalc/GraphDelayCalc.cc +++ b/dcalc/GraphDelayCalc.cc @@ -1828,4 +1828,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..936fc77a 100644 --- a/dcalc/LumpedCapDelayCalc.cc +++ b/dcalc/LumpedCapDelayCalc.cc @@ -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..7c7643da 100644 --- a/dcalc/LumpedCapDelayCalc.hh +++ b/dcalc/LumpedCapDelayCalc.hh @@ -84,4 +84,4 @@ protected: ArcDelayCalc * makeLumpedCapDelayCalc(StaState *sta); -} // namespace +} // namespace sta diff --git a/dcalc/NetCaps.cc b/dcalc/NetCaps.cc index 3ca8cd6a..80a7c801 100644 --- a/dcalc/NetCaps.cc +++ b/dcalc/NetCaps.cc @@ -53,4 +53,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..7c09cc66 100644 --- a/dcalc/NetCaps.hh +++ b/dcalc/NetCaps.hh @@ -51,4 +51,4 @@ private: bool has_net_load_; }; -} // namespace +} // namespace sta diff --git a/dcalc/ParallelDelayCalc.cc b/dcalc/ParallelDelayCalc.cc index 38b71c32..1cb7c94e 100644 --- a/dcalc/ParallelDelayCalc.cc +++ b/dcalc/ParallelDelayCalc.cc @@ -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..46d3f826 100644 --- a/dcalc/ParallelDelayCalc.hh +++ b/dcalc/ParallelDelayCalc.hh @@ -47,4 +47,4 @@ protected: const MinMax *min_max); }; -} // namespace +} // namespace sta diff --git a/dcalc/PrimaDelayCalc.hh b/dcalc/PrimaDelayCalc.hh index 086e29ce..a925efdf 100644 --- a/dcalc/PrimaDelayCalc.hh +++ b/dcalc/PrimaDelayCalc.hh @@ -263,4 +263,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..fa92605c 100644 --- a/graph/Graph.cc +++ b/graph/Graph.cc @@ -1580,4 +1580,4 @@ VertexIdLess::operator()(const Vertex *vertex1, } -} // namespace +} // namespace sta diff --git a/include/sta/ArcDelayCalc.hh b/include/sta/ArcDelayCalc.hh index 85e656d1..b21d524c 100644 --- a/include/sta/ArcDelayCalc.hh +++ b/include/sta/ArcDelayCalc.hh @@ -63,7 +63,7 @@ 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, @@ -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..0cc101bf 100644 --- a/include/sta/Bdd.hh +++ b/include/sta/Bdd.hh @@ -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..10c90f17 100644 --- a/include/sta/Bfs.hh +++ b/include/sta/Bfs.hh @@ -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/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..1d25b57c 100644 --- a/include/sta/ClkNetwork.hh +++ b/include/sta/ClkNetwork.hh @@ -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..aae3e58b 100644 --- a/include/sta/Clock.hh +++ b/include/sta/Clock.hh @@ -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, @@ -291,4 +291,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..dad7bdeb 100644 --- a/include/sta/ClockGatingCheck.hh +++ b/include/sta/ClockGatingCheck.hh @@ -42,4 +42,4 @@ private: LogicValue active_value_; }; -} // namespace +} // namespace sta diff --git a/include/sta/ClockGroups.hh b/include/sta/ClockGroups.hh index 63765088..f725b6e9 100644 --- a/include/sta/ClockGroups.hh +++ b/include/sta/ClockGroups.hh @@ -34,12 +34,12 @@ 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..256e7dbe 100644 --- a/include/sta/ClockInsertion.hh +++ b/include/sta/ClockInsertion.hh @@ -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..87ddb3b7 100644 --- a/include/sta/ClockLatency.hh +++ b/include/sta/ClockLatency.hh @@ -61,4 +61,4 @@ private: RiseFallMinMax delays_; }; -} // namespace +} // namespace sta diff --git a/include/sta/ConcreteLibrary.hh b/include/sta/ConcreteLibrary.hh index fc831a99..50182a1e 100644 --- a/include/sta/ConcreteLibrary.hh +++ b/include/sta/ConcreteLibrary.hh @@ -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, + void groupBusPorts(char bus_brkt_left, + char bus_brkt_right, 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: @@ -275,4 +275,4 @@ private: ConcretePort *next_; }; -} // Namespace +} // namespace sta diff --git a/include/sta/ConcreteNetwork.hh b/include/sta/ConcreteNetwork.hh index b3a37793..592a65a6 100644 --- a/include/sta/ConcreteNetwork.hh +++ b/include/sta/ConcreteNetwork.hh @@ -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, @@ -354,7 +354,7 @@ public: void setVertexId(VertexId id); protected: - ~ConcretePin() {} + ~ConcretePin() = default; ConcretePin(ConcreteInstance *instance, ConcretePort *port, ConcreteNet *net); @@ -384,7 +384,7 @@ public: ConcretePin *pin() const { return pin_; } protected: - ~ConcreteTerm() {} + ~ConcreteTerm() = default; ConcreteTerm(ConcretePin *pin, ConcreteNet *net); @@ -432,4 +432,4 @@ protected: friend class ConcreteNetPinIterator; }; -} // namespace +} // namespace sta diff --git a/include/sta/ContainerHelpers.hh b/include/sta/ContainerHelpers.hh index 9c5aeae4..9b1a447a 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::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::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..ca4aa3b8 100644 --- a/include/sta/CycleAccting.hh +++ b/include/sta/CycleAccting.hh @@ -130,4 +130,4 @@ private: bool max_cycles_exceeded_; }; -} // namespace +} // namespace sta diff --git a/include/sta/DataCheck.hh b/include/sta/DataCheck.hh index a1bb30ee..e96e067c 100644 --- a/include/sta/DataCheck.hh +++ b/include/sta/DataCheck.hh @@ -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..0bc4be1d 100644 --- a/include/sta/Debug.hh +++ b/include/sta/Debug.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..983e6889 100644 --- a/include/sta/Delay.hh +++ b/include/sta/Delay.hh @@ -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 value) 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..a068a6da 100644 --- a/include/sta/DeratingFactors.hh +++ b/include/sta/DeratingFactors.hh @@ -117,4 +117,4 @@ public: DeratingFactorsNet(); }; -} // namespace +} // namespace sta diff --git a/include/sta/DisabledPorts.hh b/include/sta/DisabledPorts.hh index 20ea6a18..5628d85c 100644 --- a/include/sta/DisabledPorts.hh +++ b/include/sta/DisabledPorts.hh @@ -111,4 +111,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..9baa0099 100644 --- a/include/sta/DispatchQueue.hh +++ b/include/sta/DispatchQueue.hh @@ -18,10 +18,10 @@ 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..7459e315 100644 --- a/include/sta/Error.hh +++ b/include/sta/Error.hh @@ -36,7 +36,6 @@ class Exception : public std::exception { public: Exception(); - virtual ~Exception() {} const char *what() const noexcept override = 0; }; @@ -44,7 +43,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 +92,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..07987e94 100644 --- a/include/sta/ExceptionPath.hh +++ b/include/sta/ExceptionPath.hh @@ -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(); @@ -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, @@ -308,7 +308,7 @@ public: 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 +327,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; } @@ -386,7 +386,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 +512,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 +538,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 +547,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); @@ -620,7 +620,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, @@ -678,7 +677,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 +697,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..3de0dd84 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" @@ -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..93db8d68 100644 --- a/include/sta/FuncExpr.hh +++ b/include/sta/FuncExpr.hh @@ -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..2d3024a7 100644 --- a/include/sta/Graph.hh +++ b/include/sta/Graph.hh @@ -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); @@ -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); @@ -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..bb030924 100644 --- a/include/sta/GraphClass.hh +++ b/include/sta/GraphClass.hh @@ -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..add7530a 100644 --- a/include/sta/GraphCmp.hh +++ b/include/sta/GraphCmp.hh @@ -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..5d2ae509 100644 --- a/include/sta/GraphDelayCalc.hh +++ b/include/sta/GraphDelayCalc.hh @@ -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. @@ -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; @@ -359,4 +358,4 @@ private: std::vector net_caps_; }; -} // namespace +} // namespace sta diff --git a/include/sta/Hash.hh b/include/sta/Hash.hh index 6f87d56c..ce68f03a 100644 --- a/include/sta/Hash.hh +++ b/include/sta/Hash.hh @@ -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..a5dbdf2d 100644 --- a/include/sta/InputDrive.hh +++ b/include/sta/InputDrive.hh @@ -116,4 +116,4 @@ private: 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..17f547ad 100644 --- a/include/sta/LibertyClass.hh +++ b/include/sta/LibertyClass.hh @@ -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..5d5c8686 100644 --- a/include/sta/MinMax.hh +++ b/include/sta/MinMax.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..6b2fcc9b 100644 --- a/include/sta/MinMaxValues.hh +++ b/include/sta/MinMaxValues.hh @@ -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..05eee68b 100644 --- a/include/sta/Network.hh +++ b/include/sta/Network.hh @@ -94,7 +94,7 @@ class Network : public StaState { public: Network(); - virtual ~Network(); + ~Network() override; virtual void clear(); // Linking the hierarchy creates the instance/pin/net network hierarchy. @@ -501,7 +501,7 @@ class NetworkEdit : public Network { public: NetworkEdit(); - virtual bool isEditable() const { return true; } + 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,9 +611,8 @@ 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, @@ -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..0e72ff24 100644 --- a/include/sta/NetworkClass.hh +++ b/include/sta/NetworkClass.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..7b4bfccf 100644 --- a/include/sta/Parasitics.hh +++ b/include/sta/Parasitics.hh @@ -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; @@ -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..81b37957 100644 --- a/include/sta/Path.hh +++ b/include/sta/Path.hh @@ -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..2e252922 100644 --- a/include/sta/PathEnd.hh +++ b/include/sta/PathEnd.hh @@ -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..b6c8ba2b 100644 --- a/include/sta/PathExpanded.hh +++ b/include/sta/PathExpanded.hh @@ -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..2d743fee 100644 --- a/include/sta/PathGroup.hh +++ b/include/sta/PathGroup.hh @@ -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..3657cd4c 100644 --- a/include/sta/PortDelay.hh +++ b/include/sta/PortDelay.hh @@ -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..d1c0d694 100644 --- a/include/sta/PortExtCap.hh +++ b/include/sta/PortExtCap.hh @@ -76,4 +76,4 @@ private: FanoutValues fanout_; }; -} // namespace +} // namespace sta diff --git a/include/sta/PowerClass.hh b/include/sta/PowerClass.hh index b3f2a6df..a3425631 100644 --- a/include/sta/PowerClass.hh +++ b/include/sta/PowerClass.hh @@ -47,7 +47,7 @@ enum class PwrActivityOrigin class PwrActivity { public: - PwrActivity(); + PwrActivity() = default; PwrActivity(float density, float duty, PwrActivityOrigin origin); @@ -67,9 +67,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 +77,7 @@ private: class PowerResult { public: - PowerResult(); + PowerResult() = default; void clear(); float internal() const { return internal_; } float switching() const { return switching_; } @@ -89,12 +89,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..afb71765 100644 --- a/include/sta/Property.hh +++ b/include/sta/Property.hh @@ -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..068a206a 100644 --- a/include/sta/Report.hh +++ b/include/sta/Report.hh @@ -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..0fd3975a 100644 --- a/include/sta/RiseFallMinMaxDelay.hh +++ b/include/sta/RiseFallMinMaxDelay.hh @@ -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..a43a4cb4 100644 --- a/include/sta/Scene.hh +++ b/include/sta/Scene.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..cea05abf 100644 --- a/include/sta/Sdc.hh +++ b/include/sta/Sdc.hh @@ -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>; @@ -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(); @@ -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..a22fee1e 100644 --- a/include/sta/SdcClass.hh +++ b/include/sta/SdcClass.hh @@ -133,4 +133,4 @@ constexpr int timing_derate_type_count = 3; enum class TimingDerateCellType { cell_delay, cell_check }; constexpr int timing_derate_cell_type_count = 2; -} // namespace +} // 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..d23d18da 100644 --- a/include/sta/SdcNetwork.hh +++ b/include/sta/SdcNetwork.hh @@ -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..ec1fbdbc 100644 --- a/include/sta/Search.hh +++ b/include/sta/Search.hh @@ -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,14 @@ 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 +// NOLINTNEXTLINE(misc-multiple-inheritance) +class PathVisitor : public VertexVisitor, + public StaState { public: // Uses search->evalPred() for search predicate. @@ -704,9 +706,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 +755,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 +766,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 +816,6 @@ protected: class RequiredCmp { public: - RequiredCmp(); void requiredsInit(Vertex *vertex, const StaState *sta); void requiredSet(size_t path_index, @@ -827,8 +828,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 +838,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..47f29563 100644 --- a/include/sta/SearchClass.hh +++ b/include/sta/SearchClass.hh @@ -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..ab6b8dd3 100644 --- a/include/sta/SearchPred.hh +++ b/include/sta/SearchPred.hh @@ -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 32d60093..9da0e830 100644 --- a/include/sta/Sta.hh +++ b/include/sta/Sta.hh @@ -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); @@ -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, @@ -1151,9 +1150,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, @@ -1187,8 +1186,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 @@ -1518,23 +1517,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, @@ -1608,30 +1607,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..7d5fdbf0 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,11 +25,11 @@ #pragma once #include +#include #include #include #include #include -#include // for strncasecmp #include #include @@ -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..46984d49 100644 --- a/include/sta/TableModel.hh +++ b/include/sta/TableModel.hh @@ -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..995b425f 100644 --- a/include/sta/TclTypeHelpers.hh +++ b/include/sta/TclTypeHelpers.hh @@ -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..d9553830 100644 --- a/include/sta/TimingArc.hh +++ b/include/sta/TimingArc.hh @@ -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..a5bf2a1f 100644 --- a/include/sta/Variables.hh +++ b/include/sta/Variables.hh @@ -97,4 +97,4 @@ private: float pocv_quantile_; }; -} // namespace +} // namespace sta diff --git a/include/sta/VectorMap.hh b/include/sta/VectorMap.hh index b78f76cf..2273e3ab 100644 --- a/include/sta/VectorMap.hh +++ b/include/sta/VectorMap.hh @@ -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..c004f629 100644 --- a/include/sta/VerilogNamespace.hh +++ b/include/sta/VerilogNamespace.hh @@ -47,4 +47,4 @@ netVerilogToSta(std::string_view sta_name); std::string portVerilogToSta(std::string_view sta_name); -} // namespace +} // namespace sta diff --git a/include/sta/VerilogReader.hh b/include/sta/VerilogReader.hh index b28e0f23..4a94269c 100644 --- a/include/sta/VerilogReader.hh +++ b/include/sta/VerilogReader.hh @@ -104,12 +104,12 @@ public: ~VerilogReader(); bool read(std::string_view filename); - void makeModule(std::string &&module_name, + void makeModule(std::string_view module_name, VerilogNetSeq *ports, VerilogStmtSeq *stmts, VerilogAttrStmtSeq *attr_stmts, int line); - void makeModule(std::string &&module_name, + void makeModule(std::string_view module_name, VerilogStmtSeq *port_dcls, VerilogStmtSeq *stmts, VerilogAttrStmtSeq *attr_stmts, @@ -122,7 +122,7 @@ public: VerilogDclArg *arg, VerilogAttrStmtSeq *attr_stmts, int line); - VerilogDclArg *makeDclArg(std::string &&net_name); + VerilogDclArg *makeDclArg(std::string_view net_name); VerilogDclArg*makeDclArg(VerilogAssign *assign); VerilogDclBus *makeDclBus(PortDirection *dir, int from_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_name, + std::string_view inst_name, 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_name, + std::string_view net_name); + VerilogNetPortRef *makeNetNamedPortRefBitSelect(std::string_view port_name, + std::string_view bus_name, int index); - VerilogNetPortRef *makeNetNamedPortRefScalar(std::string &&port_name, + VerilogNetPortRef *makeNetNamedPortRefScalar(std::string_view port_name, VerilogNet *net); - VerilogNetPortRef *makeNetNamedPortRefBit(std::string &&port_name, + VerilogNetPortRef *makeNetNamedPortRefBit(std::string_view port_name, int index, VerilogNet *net); - VerilogNetPortRef *makeNetNamedPortRefPart(std::string &&port_name, + VerilogNetPortRef *makeNetNamedPortRefPart(std::string_view port_name, 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); 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..c7c8e981 100644 --- a/include/sta/VertexVisitor.hh +++ b/include/sta/VertexVisitor.hh @@ -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..ad52fbf7 100644 --- a/include/sta/VisitPathEnds.hh +++ b/include/sta/VisitPathEnds.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 1817a7a2..bdccfcbd 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,10 +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 &scale : scales_) { + for (size_t pvt = 0; pvt < scale_factor_pvt_count; pvt++) { + for (size_t rf_index : RiseFall::rangeIndex()) { + scale[pvt][rf_index] = 0.0; } } } @@ -3096,7 +2993,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 +3001,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 +3009,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 +3017,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 +3032,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 +3068,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 +3076,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 +3085,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..3273cb69 100644 --- a/network/ConcreteLibrary.cc +++ b/network/ConcreteLibrary.cc @@ -351,8 +351,8 @@ BusPort::addBusBit(ConcretePort *port, } void -ConcreteCell::groupBusPorts(const char bus_brkt_left, - const char bus_brkt_right, +ConcreteCell::groupBusPorts(char bus_brkt_left, + char bus_brkt_right, std::function port_msb_first) { const char bus_brkts_left[2]{bus_brkt_left, '\0'}; @@ -625,4 +625,4 @@ ConcreteCellPortBitIterator::findNext() next_ = nullptr; } -} // namespace +} // namespace sta diff --git a/network/ConcreteNetwork.cc b/network/ConcreteNetwork.cc index 44cc8a0a..dba9d286 100644 --- a/network/ConcreteNetwork.cc +++ b/network/ConcreteNetwork.cc @@ -2125,4 +2125,4 @@ ConcreteBindingTbl::ensureBinding(Net *proto_net, return net; } -} // namespace +} // namespace sta diff --git a/network/HpinDrvrLoad.cc b/network/HpinDrvrLoad.cc index ab76900d..032b0ff3 100644 --- a/network/HpinDrvrLoad.cc +++ b/network/HpinDrvrLoad.cc @@ -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..0252c801 100644 --- a/network/Network.cc +++ b/network/Network.cc @@ -2040,4 +2040,4 @@ NetSet::NetSet(const Network *network) : { } -} // namespace +} // namespace sta diff --git a/network/NetworkCmp.cc b/network/NetworkCmp.cc index cda43af7..2d75bb01 100644 --- a/network/NetworkCmp.cc +++ b/network/NetworkCmp.cc @@ -137,4 +137,4 @@ sortByPathName(NetSet *set, return nets; } -} // namespace +} // namespace sta diff --git a/network/ParseBus.cc b/network/ParseBus.cc index 7bbab7a0..16300d69 100644 --- a/network/ParseBus.cc +++ b/network/ParseBus.cc @@ -190,4 +190,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..50f95fc0 100644 --- a/network/SdcNetwork.cc +++ b/network/SdcNetwork.cc @@ -1271,4 +1271,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..e0094688 100644 --- a/network/VerilogNamespace.cc +++ b/network/VerilogNamespace.cc @@ -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..27d74bf6 100644 --- a/parasitics/ConcreteParasitics.cc +++ b/parasitics/ConcreteParasitics.cc @@ -752,8 +752,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), @@ -1439,4 +1439,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..e866e8e7 100644 --- a/parasitics/ConcreteParasitics.hh +++ b/parasitics/ConcreteParasitics.hh @@ -50,10 +50,10 @@ using ConcreteParasiticNetworkMap = std::mapsetCouplingCapFactor(coupling_cap_factor); } -SpefReader::~SpefReader() {} - bool SpefReader::read() { diff --git a/parasitics/SpefReader.hh b/parasitics/SpefReader.hh index d07e8a63..f1187e1d 100644 --- a/parasitics/SpefReader.hh +++ b/parasitics/SpefReader.hh @@ -55,4 +55,4 @@ readSpefFile(std::string_view filename, Parasitics *parasirics, StaState *sta); -} // namespace +} // namespace sta diff --git a/parasitics/SpefReaderPvt.hh b/parasitics/SpefReaderPvt.hh index 272d7ef1..9ba21cde 100644 --- a/parasitics/SpefReaderPvt.hh +++ b/parasitics/SpefReaderPvt.hh @@ -58,7 +58,7 @@ public: const MinMaxAll *min_max, Parasitics *parasitics, StaState *sta); - virtual ~SpefReader(); + virtual ~SpefReader() = default; bool read(); char divider() const { return divider_; } void setDivider(char divider); @@ -181,4 +181,4 @@ private: SpefTriple *c1_; }; -} // namespace +} // namespace sta diff --git a/parasitics/SpefScanner.hh b/parasitics/SpefScanner.hh index c87a43c0..58e64025 100644 --- a/parasitics/SpefScanner.hh +++ b/parasitics/SpefScanner.hh @@ -46,8 +46,6 @@ public: std::string_view filename, SpefReader *reader, Report *report); - virtual ~SpefScanner() {} - virtual int lex(SpefParse::semantic_type *const yylval, SpefParse::location_type *yylloc); // YY_DECL defined in SpefLex.ll @@ -66,4 +64,4 @@ private: std::string token_; }; -} // namespace +} // namespace sta diff --git a/power/Power.cc b/power/Power.cc index 78d9adce..114d802e 100644 --- a/power/Power.cc +++ b/power/Power.cc @@ -26,38 +26,53 @@ #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 "search/Levelize.hh" +#include "search/Sim.hh" // Related liberty not supported: // library @@ -90,16 +105,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 +405,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 +511,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; @@ -564,14 +570,15 @@ ActivitySrchPred::searchTo(const Vertex *, //////////////////////////////////////////////////////////////// +// NOLINTNEXTLINE(misc-multiple-inheritance) class PropActivityVisitor : public VertexVisitor, StaState { 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 +590,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 +602,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 +1450,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 +1796,6 @@ Power::powerInvalid() //////////////////////////////////////////////////////////////// -PowerResult::PowerResult() : - internal_(0.0), - switching_(0.0), - leakage_(0.0) -{ -} - void PowerResult::clear() { @@ -1863,13 +1848,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..9bb72e65 100644 --- a/power/Power.hh +++ b/power/Power.hh @@ -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/ReportPower.hh b/power/ReportPower.hh index 0486f8d7..4d905e88 100644 --- a/power/ReportPower.hh +++ b/power/ReportPower.hh @@ -90,4 +90,4 @@ private: int digits); }; -} // namespace +} // namespace sta 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 af8722a6..6443dfa9 100644 --- a/power/SaifReaderPvt.hh +++ b/power/SaifReaderPvt.hh @@ -84,4 +84,4 @@ private: Power *power_; }; -} // namespace +} // namespace sta diff --git a/power/SaifScanner.hh b/power/SaifScanner.hh index 0fa4a805..945ddc6a 100644 --- a/power/SaifScanner.hh +++ b/power/SaifScanner.hh @@ -44,8 +44,6 @@ public: const std::string &filename, SaifReader *reader, Report *report); - virtual ~SaifScanner() {} - virtual int lex(SaifParse::semantic_type *const yylval, SaifParse::location_type *yylloc); // YY_DECL defined in SaifLex.ll @@ -63,4 +61,4 @@ private: std::string token_; }; -} // namespace +} // namespace sta diff --git a/power/VcdParse.hh b/power/VcdParse.hh index 69a3f7d0..82702222 100644 --- a/power/VcdParse.hh +++ b/power/VcdParse.hh @@ -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.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..1772b60f 100644 --- a/sdc/Clock.cc +++ b/sdc/Clock.cc @@ -244,7 +244,7 @@ Clock::removeSlew() void Clock::setSlewLimit(const RiseFallBoth *rf, - const PathClkOrData clk_data, + PathClkOrData clk_data, const MinMax *min_max, float slew) { @@ -253,7 +253,7 @@ Clock::setSlewLimit(const RiseFallBoth *rf, void Clock::slewLimit(const RiseFall *rf, - const PathClkOrData clk_data, + PathClkOrData clk_data, const MinMax *min_max, // Return values. float &slew, @@ -714,4 +714,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..96d134d3 100644 --- a/sdc/ClockGatingCheck.cc +++ b/sdc/ClockGatingCheck.cc @@ -37,4 +37,4 @@ 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..8f4b4b32 100644 --- a/sdc/CycleAccting.cc +++ b/sdc/CycleAccting.cc @@ -429,4 +429,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..dbba2422 100644 --- a/sdc/DataCheck.cc +++ b/sdc/DataCheck.cc @@ -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..f5534cee 100644 --- a/sdc/DeratingFactors.cc +++ b/sdc/DeratingFactors.cc @@ -217,4 +217,4 @@ DeratingFactorsNet::DeratingFactorsNet() { } -} // namespace +} // namespace sta diff --git a/sdc/ExceptionPath.cc b/sdc/ExceptionPath.cc index e3cb2dd5..69ad2b57 100644 --- a/sdc/ExceptionPath.cc +++ b/sdc/ExceptionPath.cc @@ -524,7 +524,7 @@ PathDelay::to_string(const Network *network) const fromThruToString(network)); } -const char * +std::string_view PathDelay::typeString() const { return "Path"; @@ -604,7 +604,7 @@ FalsePath::tighterThan(ExceptionPath *) const return false; } -const char * +std::string_view FalsePath::typeString() const { return "False"; @@ -633,7 +633,7 @@ LoopPath::LoopPath(ExceptionThruSeq *thrus, { } -const char * +std::string_view LoopPath::typeString() const { return "Loop"; @@ -726,7 +726,7 @@ MultiCyclePath::to_string(const Network *network) const fromThruToString(network)); } -const char * +std::string_view MultiCyclePath::typeString() const { return "Multicycle"; @@ -759,7 +759,7 @@ FilterPath::FilterPath(ExceptionFrom *from, { } -const char * +std::string_view FilterPath::typeString() const { return "Filter"; @@ -831,7 +831,7 @@ GroupPath::~GroupPath() { } -const char * +std::string_view GroupPath::typeString() const { return "Group"; @@ -2465,4 +2465,4 @@ deletePinPairsThruHierPin(const Pin *hpin, visitDrvrLoadsThruHierPin(hpin, network, &visitor); } -} // namespace +} // namespace sta diff --git a/sdc/FilterObjects.cc b/sdc/FilterObjects.cc index 45e59997..cf303377 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,19 +24,32 @@ #include "FilterObjects.hh" -#include #include #include +#include #include #include +#include #include #include +#include +#include +#include "Clock.hh" +#include "ContainerHelpers.hh" +#include "Format.hh" +#include "GraphClass.hh" +#include "GraphCmp.hh" +#include "Liberty.hh" +#include "LibertyClass.hh" #include "NetworkClass.hh" #include "Network.hh" +#include "SearchClass.hh" #include "StringUtil.hh" #include "Property.hh" +#include "PathEnd.hh" #include "PatternMatch.hh" +#include "SdcClass.hh" #include "Sta.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); + virtual ~PredicateToken() = 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..1b558b96 100644 --- a/sdc/InputDrive.cc +++ b/sdc/InputDrive.cc @@ -235,4 +235,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..cd6dbba9 100644 --- a/sdc/PortDelay.cc +++ b/sdc/PortDelay.cc @@ -132,4 +132,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..a17f353c 100644 --- a/sdc/PortExtCap.cc +++ b/sdc/PortExtCap.cc @@ -90,4 +90,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..08510aea 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() @@ -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()) @@ -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/SdcCmdComment.cc b/sdc/SdcCmdComment.cc index 083812ad..805bb194 100644 --- a/sdc/SdcCmdComment.cc +++ b/sdc/SdcCmdComment.cc @@ -27,34 +27,15 @@ 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..90534a80 100644 --- a/sdc/Variables.cc +++ b/sdc/Variables.cc @@ -136,4 +136,4 @@ Variables::setPocvQuantile(float quantile) pocv_quantile_ = quantile; } -} // namespace +} // namespace sta diff --git a/sdc/WriteSdc.cc b/sdc/WriteSdc.cc index 3af1de6a..c812c1ea 100644 --- a/sdc/WriteSdc.cc +++ b/sdc/WriteSdc.cc @@ -89,7 +89,7 @@ class WriteSdcObject { public: WriteSdcObject() {} - virtual ~WriteSdcObject() {} + virtual ~WriteSdcObject() = default; virtual void write() const = 0; }; @@ -2860,4 +2860,4 @@ WriteSdc::writeCmdComment(SdcCmdComment *cmd) const 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..ad6b3c58 100644 --- a/sdc/WriteSdcPvt.hh +++ b/sdc/WriteSdcPvt.hh @@ -275,4 +275,4 @@ protected: gzFile stream_; }; -} // namespace +} // namespace sta 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/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..226e3151 100644 --- a/sdf/SdfReaderPvt.hh +++ b/sdf/SdfReaderPvt.hh @@ -230,4 +230,4 @@ private: static const int null_index_ = -1; }; -} // namespace +} // namespace sta diff --git a/sdf/SdfScanner.hh b/sdf/SdfScanner.hh index bcb0c6cd..87fc8587 100644 --- a/sdf/SdfScanner.hh +++ b/sdf/SdfScanner.hh @@ -46,8 +46,6 @@ public: std::string_view filename, SdfReader *reader, Report *report); - virtual ~SdfScanner() {} - virtual int lex(SdfParse::semantic_type *const yylval, SdfParse::location_type *yylloc); // YY_DECL defined in SdfLex.ll @@ -65,4 +63,4 @@ private: std::string token_; }; -} // namespace +} // namespace sta diff --git a/sdf/SdfWriter.cc b/sdf/SdfWriter.cc index 0d750092..7607af78 100644 --- a/sdf/SdfWriter.cc +++ b/sdf/SdfWriter.cc @@ -824,4 +824,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 d13f9700..69b9c28b 100644 --- a/search/Bfs.cc +++ b/search/Bfs.cc @@ -24,14 +24,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 { @@ -68,8 +68,6 @@ BfsIterator::ensureSize() } } -BfsIterator::~BfsIterator() {} - void BfsIterator::clear() { @@ -153,7 +151,6 @@ BfsIterator::visit(Level to_level, } } level_vertices.clear(); - visitor->levelFinished(); } return visit_count; } @@ -169,6 +166,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_) @@ -208,7 +206,6 @@ BfsIterator::visitParallel(Level to_level, } dispatch_queue_->finishTasks(); } - visitor->levelFinished(); level_vertices.clear(); visit_count += vertex_count; } @@ -294,7 +291,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_)) @@ -329,7 +326,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..cb6a7b47 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 { @@ -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..7b3dc2c1 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 { @@ -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..5ba9436a 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 { @@ -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 5302be0a..2219a91d 100644 --- a/search/Levelize.cc +++ b/search/Levelize.cc @@ -29,30 +29,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) + relevelize_from_(makeVertexSet(sta)) { } @@ -106,7 +101,7 @@ Levelize::ensureLevelized() if (levelized_) relevelize(); else - levelize(); + findLevels(); } } @@ -114,7 +109,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 3a30d869..a1b680e8 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,7 +72,7 @@ public: void setObserver(LevelizeObserver *observer); void checkLevels(); // Public for regression testing. - void levelize(); + void findLevels(); protected: void findRoots(); @@ -105,17 +104,17 @@ protected: void deleteLoops(); void reportPath(EdgeSeq &path) const; - 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}; }; // Loops broken by levelization may not necessarily be combinational. @@ -137,10 +136,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 1ace1d08..50d05574 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); @@ -360,7 +355,6 @@ ReportPath::reportPathEndHeader() const void ReportPath::reportPathEndFooter() const { - std::string header; switch (format_) { case ReportPathFormat::full: case ReportPathFormat::full_clock: @@ -2466,7 +2460,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); @@ -2732,7 +2726,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); @@ -3233,7 +3227,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); @@ -3575,7 +3569,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()) @@ -3634,4 +3628,4 @@ hierPinsAbove(const Net *net, } } -} // namespace +} // namespace sta diff --git a/search/ReportPath.hh b/search/ReportPath.hh index 98b7dd23..b8ce652d 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); @@ -195,7 +205,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; @@ -286,13 +296,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, @@ -383,38 +393,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; @@ -472,15 +482,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_; @@ -496,7 +506,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_; }; @@ -534,4 +544,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 f1617670..ae4e4c18 100644 --- a/search/Search.i +++ b/search/Search.i @@ -533,11 +533,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); } @@ -546,11 +546,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); } //////////////////////////////////////////////////////////////// @@ -1111,7 +1111,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 7a47319d..0aca01e0 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() { @@ -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); @@ -3199,8 +3191,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: @@ -3304,7 +3296,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; @@ -3323,7 +3315,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); @@ -3349,7 +3341,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); @@ -3373,7 +3365,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); @@ -3425,7 +3417,7 @@ private: const Clock *clk_; bool include_port_paths_; StaState *sta_; - float min_period_; + float min_period_{0.0}; }; MinPeriodEndVisitor::MinPeriodEndVisitor(const Clock *clk, @@ -3433,8 +3425,7 @@ MinPeriodEndVisitor::MinPeriodEndVisitor(const Clock *clk, StaState *sta) : clk_(clk), include_port_paths_(include_port_paths), - sta_(sta), - min_period_(0) + sta_(sta) { } @@ -3551,7 +3542,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); } //////////////////////////////////////////////////////////////// @@ -3612,7 +3603,7 @@ Sta::setIncrementalDelayTolerance(float tol) graph_delay_calc_->setIncrementalDelayTolerance(tol); } -const ArcDelay +ArcDelay Sta::arcDelay(Edge *edge, TimingArc *arc, DcalcAPIndex ap_index) @@ -4242,7 +4233,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; } @@ -4258,11 +4249,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; } @@ -5050,56 +5041,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 @@ -5675,7 +5666,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(); @@ -5768,7 +5758,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..c414317d 100644 --- a/spice/WritePathSpice.cc +++ b/spice/WritePathSpice.cc @@ -756,4 +756,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/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..913a437f 100644 --- a/tcl/TclTypeHelpers.cc +++ b/tcl/TclTypeHelpers.cc @@ -204,4 +204,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..553bc29a 100644 --- a/util/Error.cc +++ b/util/Error.cc @@ -24,22 +24,20 @@ #include "Error.hh" -#include #include +#include #include "Format.hh" #include "StringUtil.hh" namespace sta { -Exception::Exception() : - std::exception() +Exception::Exception() { } ExceptionMsg::ExceptionMsg(const std::string &msg, - const bool suppressed) : - Exception(), + bool suppressed) : msg_(msg), suppressed_(suppressed) { @@ -53,7 +51,6 @@ ExceptionMsg::what() const noexcept ExceptionLine::ExceptionLine(const std::string &filename, int line) : - Exception(), filename_(filename), line_(line) { @@ -81,4 +78,4 @@ FileNotWritable::what() const noexcept return msg_.c_str(); } -} // namespace +} // namespace sta 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/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..b2def31d 100644 --- a/util/MachineWin32.cc +++ b/util/MachineWin32.cc @@ -24,7 +24,7 @@ #include "Machine.hh" -#include +#include #include // GetSystemInfo namespace sta { @@ -35,7 +35,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 +109,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..6c2566f4 100644 --- a/util/RiseFallMinMax.cc +++ b/util/RiseFallMinMax.cc @@ -34,8 +34,8 @@ 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 +154,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 +206,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,8 +219,8 @@ 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++) { + 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]) return false; } @@ -258,8 +258,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 +284,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 +316,4 @@ RiseFallMinMax::isOneValue(const MinMax *min_max, return false; } -} // namespace +} // namespace sta diff --git a/util/RiseFallMinMaxDelay.cc b/util/RiseFallMinMaxDelay.cc index 70cac609..9614d3b0 100644 --- a/util/RiseFallMinMaxDelay.cc +++ b/util/RiseFallMinMaxDelay.cc @@ -28,8 +28,8 @@ 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..4379982f 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; diff --git a/verilog/VerilogParse.yy b/verilog/VerilogParse.yy index 9bd7f162..c5a1c8cd 100644 --- a/verilog/VerilogParse.yy +++ b/verilog/VerilogParse.yy @@ -25,7 +25,6 @@ %{ #include #include -#include #include "Report.hh" #include "PortDirection.hh" @@ -109,13 +108,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 +129,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 +331,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 +362,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 +410,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 +443,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 +506,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..d9f76747 100644 --- a/verilog/VerilogReader.cc +++ b/verilog/VerilogReader.cc @@ -47,7 +47,7 @@ namespace sta { using VerilogConstant10 = unsigned long long; static std::string -verilogBusBitName(const std::string &bus_name, +verilogBusBitName(std::string_view bus_name, int index); static int hierarchyLevel(Net *net, @@ -168,13 +168,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 +199,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 +219,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 +371,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 +385,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 +428,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 +443,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 = @@ -494,62 +494,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 +563,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 +679,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 +700,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) : @@ -734,13 +734,11 @@ VerilogModuleInst::namedPins() } 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 +793,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 +805,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 +817,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) { @@ -955,7 +947,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); @@ -1066,15 +1058,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 +1109,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 +1130,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 +1155,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 +1163,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 +1204,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 +1233,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 +1309,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 +1347,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 +1375,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 +1385,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 +1400,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..e3569c61 100644 --- a/verilog/VerilogReaderPvt.hh +++ b/verilog/VerilogReaderPvt.hh @@ -25,6 +25,7 @@ #pragma once #include +#include #include #include @@ -39,7 +40,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 +55,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; @@ -142,7 +143,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,7 +175,7 @@ private: class VerilogInst : public VerilogStmt { public: - VerilogInst(const std::string &inst_name, + VerilogInst(std::string_view inst_name, VerilogAttrStmtSeq *attr_stmts, const int line); ~VerilogInst() override; @@ -191,8 +192,8 @@ 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); @@ -215,7 +216,7 @@ 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); @@ -232,8 +233,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; } @@ -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..92b0d395 100644 --- a/verilog/VerilogScanner.hh +++ b/verilog/VerilogScanner.hh @@ -46,8 +46,6 @@ public: VerilogScanner(std::istream *stream, std::string_view filename, Report *report); - virtual ~VerilogScanner() {} - virtual int lex(VerilogParse::semantic_type *const yylval, VerilogParse::location_type *yylloc); // YY_DECL defined in VerilogLex.ll @@ -65,4 +63,4 @@ private: std::string token_; }; -} // namespace +} // namespace sta diff --git a/verilog/VerilogWriter.cc b/verilog/VerilogWriter.cc index 49ecedf3..954c560a 100644 --- a/verilog/VerilogWriter.cc +++ b/verilog/VerilogWriter.cc @@ -515,4 +515,4 @@ VerilogWriter::findPortNCcount(const Instance *inst, return nc_count; } -} // namespace +} // namespace sta