Files
OpenSTA/include/sta/PowerClass.hh
T

102 lines
2.6 KiB
C++
Raw Normal View History

2020-07-31 09:42:24 -07:00
// OpenSTA, Static Timing Analyzer
2026-03-10 13:21:17 -07:00
// Copyright (c) 2026, Parallax Software, Inc.
2020-07-31 09:42:24 -07:00
//
// 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
2022-01-04 10:17:08 -07:00
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2020-07-31 09:42:24 -07:00
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
2022-01-04 10:17:08 -07:00
// along with this program. If not, see <https://www.gnu.org/licenses/>.
2025-01-21 18:54:33 -07:00
//
// 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.
2020-07-31 09:42:24 -07:00
#pragma once
2026-01-03 16:59:35 -08:00
#include <utility>
2026-04-15 09:38:10 -07:00
#include <vector>
2026-01-03 16:59:35 -08:00
2020-07-31 09:42:24 -07:00
namespace sta {
2024-02-27 10:00:48 -07:00
class Power;
2026-04-15 09:38:10 -07:00
class Instance;
2024-02-27 10:00:48 -07:00
2020-07-31 09:42:24 -07:00
enum class PwrActivityOrigin
{
global,
input,
user,
2023-10-21 17:16:39 -07:00
vcd,
2024-09-23 18:04:26 -07:00
saif,
2020-07-31 09:42:24 -07:00
propagated,
clock,
constant,
unknown
};
class PwrActivity
{
public:
2026-04-13 14:58:16 -07:00
PwrActivity() = default;
2025-01-17 13:02:13 -07:00
PwrActivity(float density,
2026-01-03 16:59:35 -08:00
float duty,
PwrActivityOrigin origin);
2025-06-25 07:56:26 -07:00
void init();
2025-01-17 13:02:13 -07:00
float density() const { return density_; }
void setDensity(float density);
2020-07-31 09:42:24 -07:00
float duty() const { return duty_; }
void setDuty(float duty);
PwrActivityOrigin origin() const { return origin_; }
2023-11-10 09:59:50 -07:00
void setOrigin(PwrActivityOrigin origin);
2026-03-28 19:13:35 -07:00
const std::string &originName() const;
2025-01-17 13:02:13 -07:00
void set(float density,
2026-01-03 16:59:35 -08:00
float duty,
PwrActivityOrigin origin);
2020-07-31 09:42:24 -07:00
bool isSet() const;
private:
2020-11-02 17:22:49 -08:00
void check();
2026-04-13 14:58:16 -07:00
float density_{0.0}; // transitions / second
float duty_{0.0}; // probability signal is high
PwrActivityOrigin origin_{PwrActivityOrigin::unknown};
2020-11-02 17:22:49 -08:00
2025-01-17 13:02:13 -07:00
static constexpr float min_density = 1E-10;
2020-07-31 09:42:24 -07:00
};
class PowerResult
{
public:
2026-04-13 14:58:16 -07:00
PowerResult() = default;
2020-07-31 09:42:24 -07:00
void clear();
float internal() const { return internal_; }
float switching() const { return switching_; }
float leakage() const { return leakage_; }
2020-07-31 09:42:24 -07:00
float total() const;
void incr(PowerResult &result);
void incrInternal(float pwr);
void incrSwitching(float pwr);
void incrLeakage(float pwr);
2020-07-31 09:42:24 -07:00
private:
2026-04-13 14:58:16 -07:00
float internal_{0.0};
float switching_{0.0};
float leakage_{0.0};
2020-07-31 09:42:24 -07:00
};
2026-01-03 16:59:35 -08:00
using InstPower = std::pair<const Instance*, PowerResult>;
using InstPowers = std::vector<InstPower>;
2026-04-13 14:58:16 -07:00
} // namespace sta