splitting config and memspec
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "Configuration.h"
|
||||
#include "MemSpecLoader.h"
|
||||
#include "systemc.h"
|
||||
#include "boost/lexical_cast.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -21,6 +23,79 @@ Configuration::Configuration()
|
||||
loader.loadConfiguration(*this, Configuration::memspecUri, Configuration::memconfigUri);
|
||||
}
|
||||
|
||||
int string2bool(string s)
|
||||
{
|
||||
try {
|
||||
bool x = boost::lexical_cast<bool>( s );
|
||||
return x;
|
||||
} catch( boost::bad_lexical_cast const& ) {
|
||||
SC_REPORT_FATAL("Configuration", ("Could not convert to bool: " + s).c_str());
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
int string2int(string s)
|
||||
{
|
||||
try {
|
||||
int x = boost::lexical_cast<int>( s );
|
||||
return x;
|
||||
} catch( boost::bad_lexical_cast const& ) {
|
||||
SC_REPORT_FATAL("Configuration", ("Could not convert to int: " + s).c_str());
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
PowerDownMode string2PDNMode(string s)
|
||||
{
|
||||
if(s == "Staggered")
|
||||
return PowerDownMode::Staggered;
|
||||
else if (s == "TimeoutPDN")
|
||||
return PowerDownMode::TimeoutPDN;
|
||||
else if (s == "TimeoutSREF")
|
||||
return PowerDownMode::TimeoutSREF;
|
||||
|
||||
else
|
||||
{
|
||||
SC_REPORT_FATAL("Configuration", ("Unknown PowerDownMode: " + s).c_str());
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Configuration::setParameter(std::string name, std::string value)
|
||||
{
|
||||
if(name == "BankwiseLogic")
|
||||
BankwiseLogic = string2bool(value);
|
||||
else if(name == "OpenPagePolicy")
|
||||
OpenPagePolicy = string2bool(value);
|
||||
else if(name == "AdaptiveOpenPagePolicy")
|
||||
AdaptiveOpenPagePolicy = string2bool(value);
|
||||
else if(name == "RefreshAwareScheduling")
|
||||
RefreshAwareScheduling = string2bool(value);
|
||||
else if(name == "MaxNrOfTransactions")
|
||||
MaxNrOfTransactions = string2int(value);
|
||||
else if(name == "Scheduler")
|
||||
Scheduler = value;
|
||||
else if(name == "Capsize")
|
||||
Capsize = string2int(value);
|
||||
else if(name == "PowerDownTimeout")
|
||||
powerDownTimeoutInClk = string2int(value);
|
||||
else if(name == "PowerDownMode")
|
||||
powerDownMode = string2PDNMode(value);
|
||||
else if(name == "databaseRecordingEnabled")
|
||||
databaseRecordingEnabled = string2bool(value);
|
||||
else
|
||||
throw "Parameter " + name + " not defined in Configuration";
|
||||
}
|
||||
|
||||
void Configuration::setParameters(std::map<std::string, std::string> parameterMap)
|
||||
{
|
||||
for(auto item : parameterMap)
|
||||
{
|
||||
setParameter(item.first, item.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} /* namespace core */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user