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") {
130 }
else if (name==
"clock_period") {
137 warn(
"Failed to find stat '%s'\n", name);
142 const Info *info = it->second;
151 panic(
"Unknown stat type!\n");
161 MathExprPowerModelParams::create()
#define panic(...)
This implements a cprintf based panic() function.
#define fatal(...)
This implements a cprintf based fatal() function.
std::unordered_map< std::string, Stats::Info * > stats_map
static std::stack< std::string > path
void regStats()
Callback to set stat parameters.
double tryEval(const MathExpr &expr) const
Evaluate an expression in the context of this object, set failed if evaluation failed.
list< Info * > & statsList()
Declaration of Statistics objects.
double eval(EvalCallback fn) const
Evaluates the expression.
MathExprPowerModel(const Params *p)
void regStats()
Callback to set stat parameters.
double _temp
Current temperature.
void startup()
startup() is the final initialization call before simulation.
const Params * params() const
MathExprPowerModelParams Params
ClockedObject * clocked_object
The clocked object we belong to.
virtual const std::string name() const
double getStatValue(const std::string &name) const
Get the value for a variable (maps to a stat)
double eval(const MathExpr &expr) const
Evaluate an expression in the context of this object, fatal if evaluation fails.
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)
std::string toStr() const
Prints an ASCII representation of the expression tree.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...