power: Add a voltage variable to power expressions
authorAndreas Sandberg <andreas.sandberg@arm.com>
Wed, 5 Apr 2017 15:40:08 +0000 (16:40 +0100)
committerAndreas Sandberg <andreas.sandberg@arm.com>
Thu, 6 Apr 2017 13:35:17 +0000 (13:35 +0000)
There is currently no good way of extracting the current operating
voltage in MathExprPowerModels. This change adds a magic variable,
'voltage', that can be referenced from such expressions to get the
current operating voltage.

Change-Id: Ice3c9a4a221921a542de5da52f83f3f88862d246
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-by: Sascha Bischoff <sascha.bischoff@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/2662
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>

src/sim/power/mathexpr_powermodel.cc

index 13d225ee3d31d75beefe45f054d97528532f93eb..a77e14a084c94a898cfce22eb1be5155940e5062 100644 (file)
@@ -115,8 +115,11 @@ MathExprPowerModel::getStatValue(const std::string &name) const
     using namespace Stats;
 
     // Automatic variables:
-    if (name == "temp")
+    if (name == "temp") {
         return _temp;
+    } else if (name == "voltage") {
+        return clocked_object->voltage();
+    }
 
     // Try to cast the stat, only these are supported right now
     const auto it = stats_map.find(name);