From 4de69821e630576f40c55a26355ed1064c6a233c Mon Sep 17 00:00:00 2001 From: Andreas Hansson Date: Fri, 24 Jan 2014 15:29:30 -0600 Subject: sim: Expose the current voltage for each object as a stat --- src/sim/voltage_domain.cc | 12 ++++++++++++ src/sim/voltage_domain.hh | 7 +++++++ 2 files changed, 19 insertions(+) (limited to 'src') diff --git a/src/sim/voltage_domain.cc b/src/sim/voltage_domain.cc index 43848d68a..461e672ea 100644 --- a/src/sim/voltage_domain.cc +++ b/src/sim/voltage_domain.cc @@ -61,6 +61,18 @@ VoltageDomain::voltage(double voltage) "Setting voltage to %f for domain %s\n", _voltage, name()); } +void +VoltageDomain::regStats() +{ + using namespace Stats; + + currentVoltage + .scalar(_voltage) + .name(params()->name + ".voltage") + .desc("Voltage in Volts") + ; +} + VoltageDomain * VoltageDomainParams::create() { diff --git a/src/sim/voltage_domain.hh b/src/sim/voltage_domain.hh index 585ec8d66..b2f6715cf 100644 --- a/src/sim/voltage_domain.hh +++ b/src/sim/voltage_domain.hh @@ -60,6 +60,11 @@ class VoltageDomain : public SimObject */ double _voltage; + /** + * Stat for reporting voltage of the domain + */ + Stats::Value currentVoltage; + public: typedef VoltageDomainParams Params; @@ -79,6 +84,8 @@ class VoltageDomain : public SimObject */ void voltage(double voltage); + void regStats(); + }; #endif -- cgit v1.2.3