45 #include "params/MathExprPowerModel.hh"
57 assert(path.size() > 2);
58 for (
unsigned i = 0;
i < path.size() - 2;
i++)
71 }
else if (
i->name.find(
".") == std::string::npos) {
78 const bool st_failed =
failed;
81 const bool dyn_failed =
failed;
83 if (st_failed || dyn_failed) {
87 fatal(
"Failed to evaluate power expressions:\n%s%s%s\n",
88 st_failed ?
p->st :
"",
89 st_failed && dyn_failed ?
"\n" :
"",
90 dyn_failed ?
p->dyn :
"");
97 const double value =
tryEval(expr);
111 const double value = expr.
eval(
113 this, std::placeholders::_1)
123 using namespace Stats;
126 if (name ==
"temp") {
128 }
else if (name ==
"voltage") {
135 warn(
"Failed to find stat '%s'\n", name);
140 const Info *info = it->second;
149 panic(
"Unknown stat type!\n");
159 MathExprPowerModelParams::create()
const std::string & name()
std::unordered_map< std::string, Stats::Info * > stats_map
static std::stack< std::string > path
std::string toStr() const
Prints an ASCII representation of the expression tree.
double eval(const MathExpr &expr) const
Evaluate an expression in the context of this object, fatal if evaluation fails.
panic_if(!root,"Invalid expression\n")
void regStats()
Register statistics for this object.
const Params * params() const
list< Info * > & statsList()
Declaration of Statistics objects.
MathExprPowerModel(const Params *p)
void regStats()
Register statistics for this object.
double _temp
Current temperature.
void startup()
startup() is the final initialization call before simulation.
MathExprPowerModelParams Params
ClockedObject * clocked_object
The clocked object we belong to.
virtual const std::string name() const
A PowerModelState is an abstract class used as interface to get power figures out of SimObjects...
void tokenize(vector< string > &v, const string &s, char token, bool ignore)
double tryEval(const MathExpr &expr) const
Evaluate an expression in the context of this object, set failed if evaluation failed.
double getStatValue(const std::string &name) const
Get the value for a variable (maps to a stat)
double eval(EvalCallback fn) const
Evaluates the expression.