diff --git a/include/sta/PowerClass.hh b/include/sta/PowerClass.hh new file mode 100644 index 00000000..706e1f45 --- /dev/null +++ b/include/sta/PowerClass.hh @@ -0,0 +1,73 @@ +// OpenSTA, Static Timing Analyzer +// Copyright (c) 2020, 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 . + +#pragma once + +namespace sta { + +enum class PwrActivityOrigin +{ + global, + input, + user, + propagated, + clock, + constant, + defaulted, + unknown +}; + +class PwrActivity +{ +public: + PwrActivity(); + PwrActivity(float activity, + float duty, + PwrActivityOrigin origin); + float activity() const { return activity_; } + float duty() const { return duty_; } + PwrActivityOrigin origin() { return origin_; } + const char *originName() const; + void set(float activity, + float duty, + PwrActivityOrigin origin); + bool isSet() const; + +private: + // In general activity is per clock cycle, NOT per second. + float activity_; + float duty_; + PwrActivityOrigin origin_; +}; + +class PowerResult +{ +public: + PowerResult(); + void clear(); + float &internal() { return internal_; } + float &switching() { return switching_; } + float &leakage() { return leakage_; } + float total() const; + void incr(PowerResult &result); + +private: + float internal_; + float switching_; + float leakage_; +}; + +} // namespace diff --git a/include/sta/Property.hh b/include/sta/Property.hh index c83f1af1..d4b35bee 100644 --- a/include/sta/Property.hh +++ b/include/sta/Property.hh @@ -22,7 +22,7 @@ #include "NetworkClass.hh" #include "SearchClass.hh" #include "SdcClass.hh" -#include "Power.hh" +#include "PowerClass.hh" namespace sta { diff --git a/include/sta/Sta.hh b/include/sta/Sta.hh index e8b23756..fb3b6172 100644 --- a/include/sta/Sta.hh +++ b/include/sta/Sta.hh @@ -29,6 +29,7 @@ #include "StaState.hh" #include "VertexVisitor.hh" #include "SearchClass.hh" +#include "PowerClass.hh" struct Tcl_Interp; diff --git a/search/Power.cc b/search/Power.cc index 506b10e6..367a8dc3 100644 --- a/search/Power.cc +++ b/search/Power.cc @@ -65,7 +65,7 @@ isPositiveUnate(const LibertyCell *cell, const LibertyPort *from, const LibertyPort *to); -Power::Power(Sta *sta) : +Power::Power(StaState *sta) : StaState(sta), global_activity_{0.0, 0.0, PwrActivityOrigin::unknown}, input_activity_{0.1, 0.5, PwrActivityOrigin::input}, diff --git a/include/sta/Power.hh b/search/Power.hh similarity index 83% rename from include/sta/Power.hh rename to search/Power.hh index c35c16f0..d83a5ddc 100644 --- a/include/sta/Power.hh +++ b/search/Power.hh @@ -16,12 +16,19 @@ #pragma once -#include "Sta.hh" +#include + +#include "UnorderedMap.hh" +#include "Network.hh" +#include "SdcClass.hh" +#include "PowerClass.hh" +#include "StaState.hh" namespace sta { -class PowerResult; -class PwrActivity; +class Sta; +class Corner; +class DcalcAnalysisPt; class PropActivityVisitor; class BfsFwdIterator; @@ -44,47 +51,12 @@ typedef UnorderedMap PwrActivityMap; typedef UnorderedMap PwrSeqActivityMap; -enum class PwrActivityOrigin -{ - global, - input, - user, - propagated, - clock, - constant, - defaulted, - unknown -}; - -class PwrActivity -{ -public: - PwrActivity(); - PwrActivity(float activity, - float duty, - PwrActivityOrigin origin); - float activity() const { return activity_; } - float duty() const { return duty_; } - PwrActivityOrigin origin() { return origin_; } - const char *originName() const; - void set(float activity, - float duty, - PwrActivityOrigin origin); - bool isSet() const; - -private: - // In general activity is per clock cycle, NOT per second. - float activity_; - float duty_; - PwrActivityOrigin origin_; -}; - // The Power class has access to Sta components directly for // convenience but also requires access to the Sta class member functions. class Power : public StaState { public: - Power(Sta *sta); + Power(StaState *sta); void power(const Corner *corner, // Return values. PowerResult &total, @@ -204,21 +176,4 @@ private: friend class PropActivityVisitor; }; -class PowerResult -{ -public: - PowerResult(); - void clear(); - float &internal() { return internal_; } - float &switching() { return switching_; } - float &leakage() { return leakage_; } - float total() const; - void incr(PowerResult &result); - -private: - float internal_; - float switching_; - float leakage_; -}; - } // namespace diff --git a/tcl/StaTcl.i b/tcl/StaTcl.i index 00b46b43..65cd5cce 100644 --- a/tcl/StaTcl.i +++ b/tcl/StaTcl.i @@ -68,7 +68,6 @@ #include "PathEnd.hh" #include "PathGroup.hh" #include "PathAnalysisPt.hh" -#include "Power.hh" #include "Property.hh" #include "WritePathSpice.hh" #include "Search.hh" @@ -78,6 +77,7 @@ #include "search/CheckMinPulseWidths.hh" #include "search/Levelize.hh" #include "search/ReportPath.hh" +#include "search/Power.hh" namespace sta {