splitting config and memspec
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
|
||||
|
||||
<trace-setup id="media">
|
||||
<device clkMhz="800">mediabench-fractal_32.stl</device>
|
||||
<device clkMhz="800">chstone-sha_32.stl</device>
|
||||
</trace-setup>
|
||||
|
||||
</trace-setups>
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
@@ -37,17 +37,21 @@ struct Configuration
|
||||
unsigned int MaxNrOfTransactions = 50;
|
||||
std::string Scheduler;
|
||||
unsigned int Capsize = 5;
|
||||
sc_time powerDownTimeout = 3*memSpec.clk;
|
||||
PowerDownMode powerDownMode;
|
||||
|
||||
//Memory Specification (from DRAM Power XML)
|
||||
MemSpec memSpec;
|
||||
sc_time getPowerDownTimeout(){return powerDownTimeoutInClk*memSpec.clk;}
|
||||
PowerDownMode powerDownMode = PowerDownMode::Staggered;
|
||||
|
||||
//Simulation Configuration
|
||||
bool databaseRecordingEnabled = true;
|
||||
|
||||
//Memory Specification (from DRAM Power XML)
|
||||
MemSpec memSpec;
|
||||
|
||||
void setParameter(std::string name, std::string value);
|
||||
void setParameters(std::map<std::string, std::string> parameterMap);
|
||||
|
||||
private:
|
||||
Configuration();
|
||||
unsigned int powerDownTimeoutInClk = 3;
|
||||
};
|
||||
|
||||
} /* namespace core */
|
||||
|
||||
@@ -53,7 +53,7 @@ void MemSpecLoader::loadMemConfig(Configuration& config, XMLElement* memconfig)
|
||||
{
|
||||
config.powerDownMode = PowerDownMode::TimeoutSREF;
|
||||
}
|
||||
config.powerDownTimeout = queryUIntParameter(configuration, "powerDownTimeout") * config.memSpec.clk;
|
||||
config.setParameter("PowerDownTimeout", queryStringParameter(configuration, "powerDownTimeout"));
|
||||
|
||||
config.databaseRecordingEnabled = queryBoolParameter(configuration, "databaseRecordingEnabled");
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ PowerDownManagerTimeout::~PowerDownManagerTimeout()
|
||||
|
||||
void PowerDownManagerTimeout::sleep(Bank bank, sc_time time)
|
||||
{
|
||||
if(canSleep() && !isInPowerDown() && (time - controller.state.getLastScheduledCommand().getEnd()) >= Configuration::getInstance().powerDownTimeout)
|
||||
if(canSleep() && !isInPowerDown() && (time - controller.state.getLastScheduledCommand().getEnd()) >= Configuration::getInstance().getPowerDownTimeout())
|
||||
{
|
||||
PowerDownState newState;
|
||||
if(Configuration::getInstance().powerDownMode == PowerDownMode::TimeoutPDN)
|
||||
@@ -106,7 +106,7 @@ void PowerDownManagerTimeout::triggerSleep(Bank /*bank*/, sc_time time)
|
||||
{
|
||||
if(canSleep() && !isInPowerDown())
|
||||
{
|
||||
controller.wrapper.send(PDNTrigger, time + controller.config.powerDownTimeout, powerDownPayloads[Bank(0)]);
|
||||
controller.wrapper.send(PDNTrigger, time + controller.config.getPowerDownTimeout(), powerDownPayloads[Bank(0)]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ int main(int argc, char **argv)
|
||||
|
||||
int sc_main(int argc, char **argv)
|
||||
{
|
||||
cout<<"hello"<<endl;
|
||||
sc_set_time_resolution(1, SC_PS);
|
||||
resources = pathOfFile(argv[0]) + string("/../resources/");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user