merged conflicts

This commit is contained in:
Janik Schlemminger
2014-09-03 10:37:39 +02:00
15 changed files with 189 additions and 111 deletions

View File

@@ -39,7 +39,6 @@ SOURCES += \
../src/common/TlmRecorder.cpp \
../src/common/dramExtension.cpp \
../src/common/DebugManager.cpp \
../src/controller/core/configuration/MemSpecLoader.cpp \
../src/controller/core/configuration/Configuration.cpp \
../src/controller/core/powerdown/PowerDownManagerTimeout.cpp \
../src/controller/core/powerdown/PowerDownManagerBankwise.cpp \
@@ -71,7 +70,8 @@ SOURCES += \
../src/simulation/main.cpp \
../src/controller/core/RowBufferStates.cpp \
../src/controller/scheduler/Scheduler.cpp \
../src/controller/scheduler/readwritegrouper.cpp
../src/controller/scheduler/readwritegrouper.cpp \
../src/controller/core/configuration/ConfigurationLoader.cpp
HEADERS += \
../src/common/third_party/tinyxml2.h \
@@ -82,7 +82,6 @@ HEADERS += \
../src/common/protocol.h \
../src/common/dramExtension.h \
../src/common/DebugManager.h \
../src/controller/core/configuration/MemSpecLoader.h \
../src/controller/core/configuration/Configuration.h \
../src/controller/core/powerdown/PowerDownManagerTimeout.h \
../src/controller/core/powerdown/PowerDownManagerBankwise.h \
@@ -129,4 +128,5 @@ HEADERS += \
../src/simulation/TlmPacketGenerator.h \
../src/simulation/StlPlayer.h \
../src/simulation/TracePlayerListener.h
../src/controller/core/configuration/ConfigurationLoader.h

View File

@@ -1,14 +1,12 @@
<memspec>
<memconfig>
<parameter id="bankwiseLogic" type="bool" value="0" />
<parameter id="openPagePolicy" type="bool" value="1" />
<parameter id="adaptiveOpenPagePolicy" type="bool" value="0" />
<parameter id="refreshAwareScheduling" type="bool" value="1" />
<parameter id="maxNrOfTransactionsInDram" type="uint" value="50" />
<parameter id="scheduler" type="string" value="FR_FCFS" />
<parameter id="capsize" type="uint" value="5" />
<parameter id="powerDownMode" type="string" value="Staggered" />
<parameter id="powerDownTimeout" type="uint" value="100" />
<parameter id="databaseRecordingEnabled" type="bool" value="1" />
</memconfig>
</memspec>
<memconfig>
<BankwiseLogic value="0"/>
<OpenPagePolicy value="1" />
<AdaptiveOpenPagePolicy value="0" />
<RefreshAwareScheduling value="1" />
<MaxNrOfTransactions value="50" />
<Scheduler value="FR_FCFS" />
<Capsize value="5" />
<PowerDownMode value="Staggered" />
<PowerDownTimeout value="100" />
<DatabaseRecordingEnabled value="1" />
</memconfig>

View File

@@ -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>

View File

@@ -96,7 +96,7 @@ double queryDoubleParameter(XMLElement* node, string name)
bool queryBoolParameter(XMLElement* node, string name)
{
bool result;
XMLElement* element;
XMLElement* element;// = node->FirstChildElement("parameter");
for (element = node->FirstChildElement("parameter"); element != NULL;
element = element->NextSiblingElement("parameter"))
{

View File

@@ -6,21 +6,95 @@
*/
#include "Configuration.h"
#include "MemSpecLoader.h"
#include "ConfigurationLoader.h"
#include "boost/lexical_cast.hpp"
using namespace std;
namespace core{
string Configuration::memspecUri = "";
string Configuration::memconfigUri = "";
Configuration::Configuration()
{
MemSpecLoader loader;
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 == "NoPowerDown")
return PowerDownMode::NoPowerDown;
else 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
{
SC_REPORT_FATAL("Configuration", ("Parameter " + name + " not defined in Configuration").c_str());
throw;
}
}
void Configuration::setParameters(std::map<std::string, std::string> parameterMap)
{
for(auto item : parameterMap)
{
setParameter(item.first, item.second);
}
}
} /* namespace core */

View File

@@ -12,10 +12,9 @@
#include <string>
#include "MemSpec.h"
namespace core{
enum class PowerDownMode{Staggered, TimeoutPDN, TimeoutSREF};
enum class PowerDownMode{NoPowerDown, Staggered, TimeoutPDN, TimeoutSREF};
struct Configuration
@@ -29,7 +28,7 @@ struct Configuration
return configuration;
}
//MemConfiguration
//MemConfig
bool BankwiseLogic = false;
bool OpenPagePolicy = true;
bool AdaptiveOpenPagePolicy = false;
@@ -37,17 +36,21 @@ struct Configuration
unsigned int MaxNrOfTransactions = 50;
std::string Scheduler;
unsigned int Capsize = 5;
sc_time powerDownTimeout = 3*memSpec.clk;
PowerDownMode powerDownMode;
sc_time getPowerDownTimeout(){return powerDownTimeoutInClk*memSpec.clk;}
PowerDownMode powerDownMode = PowerDownMode::Staggered;
//Memory Specification (from DRAM Power XML)
//SimConfig
bool databaseRecordingEnabled = true;
//MemSpec(from DRAM-Power XML)
MemSpec memSpec;
//Simulation Configuration
bool databaseRecordingEnabled = true;
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 */

View File

@@ -5,7 +5,7 @@
* Author: jonny
*/
#include "MemSpecLoader.h"
#include "ConfigurationLoader.h"
#include "MemSpec.h"
#include "../TimingCalculation.h"
@@ -14,51 +14,46 @@ using namespace std;
namespace core {
void MemSpecLoader::loadConfiguration(Configuration& config, string memspecUri, string memconfigUri)
void ConfigurationLoader::loadSimConfig(Configuration& config, string simconfigUri)
{
tinyxml2::XMLDocument doc;
loadXML(simconfigUri, doc);
XMLElement* simconfig = doc.FirstChildElement("simconfig");
loadConfig(config, simconfig);
}
void ConfigurationLoader::loadMemConfig(Configuration& config, string memconfigUri)
{
tinyxml2::XMLDocument doc;
loadXML(memconfigUri, doc);
XMLElement* memconfig = doc.FirstChildElement("memconfig");
loadConfig(config, memconfig);
}
void ConfigurationLoader::loadConfig(Configuration& config, XMLElement* configNode)
{
XMLElement* element;
for (element = configNode->FirstChildElement(); element != NULL;
element = element->NextSiblingElement())
{
config.setParameter(element->Name(), element->Attribute("value"));
}
}
void ConfigurationLoader::loadMemSpec(Configuration& config, string memspecUri)
{
tinyxml2::XMLDocument doc;
loadXML(memspecUri, doc);
XMLElement* memspec = doc.FirstChildElement("memspec");
loadMemSpec(config, memspec);
loadXML(memconfigUri, doc);
XMLElement* memconfig = doc.FirstChildElement("memspec");
loadMemConfig(config, memconfig);
}
void MemSpecLoader::loadMemConfig(Configuration& config, XMLElement* memconfig)
{
//MemConfiguration
XMLElement* configuration = memconfig->FirstChildElement("memconfig");
config.BankwiseLogic = queryBoolParameter(configuration, "bankwiseLogic");
config.OpenPagePolicy = queryBoolParameter(configuration, "openPagePolicy");
config.AdaptiveOpenPagePolicy = queryBoolParameter(configuration, "adaptiveOpenPagePolicy");
config.RefreshAwareScheduling = queryBoolParameter(configuration, "refreshAwareScheduling");
config.MaxNrOfTransactions = queryUIntParameter(configuration, "maxNrOfTransactionsInDram");
config.Scheduler = queryStringParameter(configuration, "scheduler");
config.Capsize = queryUIntParameter(configuration, "capsize");
string mode = queryStringParameter(configuration, "powerDownMode");
if (mode.compare("Staggered") == 0)
{
config.powerDownMode = PowerDownMode::Staggered;
}
else if (mode.compare("TimeoutPDN") == 0)
{
config.powerDownMode = PowerDownMode::TimeoutPDN;
}
else if (mode.compare("TimeoutSREF") == 0)
{
config.powerDownMode = PowerDownMode::TimeoutSREF;
}
config.powerDownTimeout = queryUIntParameter(configuration, "powerDownTimeout") * config.memSpec.clk;
config.databaseRecordingEnabled = queryBoolParameter(configuration, "databaseRecordingEnabled");
}
void MemSpecLoader::loadMemSpec(Configuration& config, XMLElement* memspec)
void ConfigurationLoader::loadMemSpec(Configuration& config, XMLElement* memspec)
{
config.memSpec.MemoryId = queryStringParameter(memspec, "memoryId");
config.memSpec.MemoryType = queryStringParameter(memspec, "memoryType");
@@ -77,9 +72,9 @@ void MemSpecLoader::loadMemSpec(Configuration& config, XMLElement* memspec)
}
}
void MemSpecLoader::loadDDR4(Configuration& config, XMLElement* memspec)
void ConfigurationLoader::loadDDR4(Configuration& config, XMLElement* memspec)
{
//MemSpecification
//MemArchitecture
XMLElement* architecture = memspec->FirstChildElement("memarchitecturespec");
config.memSpec.NumberOfBanks = queryUIntParameter(architecture, "nbrOfBanks");
@@ -126,7 +121,7 @@ void MemSpecLoader::loadDDR4(Configuration& config, XMLElement* memspec)
}
}
void MemSpecLoader::loadWideIO(Configuration& config, XMLElement* memspec)
void ConfigurationLoader::loadWideIO(Configuration& config, XMLElement* memspec)
{
//MemSpecification
XMLElement* architecture = memspec->FirstChildElement("memarchitecturespec");

View File

@@ -0,0 +1,38 @@
/*
* ConfigurationLoader.h
*
* Created on: Apr 7, 2014
* Author: jonny
*/
#ifndef CONFIGURATIONLOADER_H_
#define CONFIGURATIONLOADER_H_
#include <string>
#include "../../../common/third_party/tinyxml2.h"
#include "../../../common/Utils.h"
#include "Configuration.h"
namespace core {
class ConfigurationLoader
{
public:
static void loadMemConfig(Configuration& config, std::string memconfigUri);
static void loadSimConfig(Configuration& config, std::string simconfigUri);
static void loadMemSpec(Configuration& config, std::string memspecUri);
static void loadMemSpec(Configuration& config, tinyxml2::XMLElement* memspec);
private:
ConfigurationLoader(){}
static void loadConfig(Configuration& config, tinyxml2::XMLElement* configNode);
//specific loader
static void loadDDR4(Configuration& config, tinyxml2::XMLElement* memspec);
static void loadWideIO(Configuration& config, tinyxml2::XMLElement* memspec);
};
} /* namespace core */
#endif /* CONFIGURATIONLOADER_H_ */

View File

@@ -11,6 +11,7 @@
#include <systemc.h>
#include <map>
#include "../../../common/dramExtension.h"
namespace core{
struct RefreshTiming

View File

@@ -1,32 +0,0 @@
/*
* MemSpecLoader.h
*
* Created on: Apr 7, 2014
* Author: jonny
*/
#ifndef MEMSPECLOADER_H_
#define MEMSPECLOADER_H_
#include <string>
#include "../../../common/third_party/tinyxml2.h"
#include "../../../common/Utils.h"
#include "Configuration.h"
namespace core {
class MemSpecLoader
{
public:
void loadConfiguration(Configuration& config, std::string memspecUri, std::string memconfigUri);
private:
void loadMemConfig(Configuration& config, tinyxml2::XMLElement* memspec);
void loadMemSpec(Configuration& config, tinyxml2::XMLElement* memspec);
void loadDDR4(Configuration& config, tinyxml2::XMLElement* memspec);
void loadWideIO(Configuration& config, tinyxml2::XMLElement* memspec);
};
} /* namespace core */
#endif /* MEMSPECLOADER_H_ */

View File

@@ -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)]);
}
}

View File

@@ -29,8 +29,6 @@ private:
bool collidesWithStrobeCommand(ScheduledCommand& write, ScheduledCommand& strobeCommand) const;
const Configuration& config;
ControllerState& state;
};
} /* namespace controller */

View File

@@ -10,6 +10,7 @@
#include "../common/DebugManager.h"
#include "../common/xmlAddressdecoder.h"
#include "../controller/core/ControllerCore.h"
#include "../controller/core/configuration/ConfigurationLoader.h"
#include <stdlib.h>
#include <iostream>
#include <fstream>
@@ -28,9 +29,12 @@ Simulation::Simulation(sc_module_name /*name*/, string pathToResources, string t
xmlAddressDecoder::addressConfigURI = pathToResources + string("configs/amconfigs/") + setup.addressmapping;
Configuration::memconfigUri = pathToResources + string("configs/memconfigs/") + setup.memconfig;
//Configuration::memconfigUri = pathToResources + string("configs/memconfigs/") + setup.memconfig;
Configuration::memspecUri = pathToResources + string("configs/memspecs/") + setup.memspec;
ConfigurationLoader::loadMemConfig(Configuration::getInstance(), pathToResources + string("configs/memconfigs/") + setup.memconfig);
ConfigurationLoader::loadMemSpec(Configuration::getInstance(), pathToResources + string("configs/memspecs/") + setup.memspec);
setupTlmRecorder(traceName, pathToResources, setup, devices);
instantiateModules(pathToResources, devices);
bindSockets();

View File

@@ -81,8 +81,8 @@ void TracePlayer<BUSWIDTH>::printDebugMessage(std::string message)
DebugManager::getInstance().printDebugMessage(this->name(), message);
}
//todo move
template<unsigned int BUSWIDTH>
//TODO: this doesn't depend on the tracePlayer, move it somewhere
void TracePlayer<BUSWIDTH>::setDataPointer(gp* payload, unsigned char * dataElement)
{
//check if payload takes ownership

View File

@@ -31,7 +31,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/");