Configuration refactoring

This commit is contained in:
Janik Schlemminger
2014-08-30 19:22:48 +02:00
parent fdc723a1bc
commit 85a574fd5b
12 changed files with 185 additions and 177 deletions

View File

@@ -36,7 +36,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 \
@@ -68,7 +67,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 \
@@ -79,7 +79,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 \
@@ -123,5 +122,6 @@ HEADERS += \
../src/controller/core/RowBufferStates.h \
../src/controller/scheduler/readwritegrouper.h \
../src/simulation/ReorderBuffer.h \
../src/controller/core/configuration/MemSpec.h
../src/controller/core/configuration/MemSpec.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

@@ -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,8 +6,7 @@
*/
#include "Configuration.h"
#include "MemSpecLoader.h"
#include "systemc.h"
#include "ConfigurationLoader.h"
#include "boost/lexical_cast.hpp"
using namespace std;
@@ -15,12 +14,9 @@ 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)
@@ -47,13 +43,14 @@ int string2int(string s)
PowerDownMode string2PDNMode(string s)
{
if(s == "Staggered")
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());
@@ -82,10 +79,13 @@ void Configuration::setParameter(std::string name, std::string value)
powerDownTimeoutInClk = string2int(value);
else if(name == "PowerDownMode")
powerDownMode = string2PDNMode(value);
else if(name == "databaseRecordingEnabled")
else if(name == "DatabaseRecordingEnabled")
databaseRecordingEnabled = string2bool(value);
else
throw "Parameter " + name + " not defined in Configuration";
{
SC_REPORT_FATAL("Configuration", ("Parameter " + name + " not defined in Configuration").c_str());
throw;
}
}
void Configuration::setParameters(std::map<std::string, std::string> parameterMap)
@@ -96,6 +96,5 @@ void Configuration::setParameters(std::map<std::string, std::string> parameterMa
}
}
} /* 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;
@@ -40,10 +39,10 @@ struct Configuration
sc_time getPowerDownTimeout(){return powerDownTimeoutInClk*memSpec.clk;}
PowerDownMode powerDownMode = PowerDownMode::Staggered;
//Simulation Configuration
//SimConfig
bool databaseRecordingEnabled = true;
//Memory Specification (from DRAM Power XML)
//MemSpec(from DRAM-Power XML)
MemSpec memSpec;
void setParameter(std::string name, std::string value);

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.setParameter("PowerDownTimeout", queryStringParameter(configuration, "powerDownTimeout"));
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,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>
@@ -29,9 +30,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

@@ -38,6 +38,7 @@ public:
void start();
private:
void setDataPointer(gp* p, unsigned char * data);
void generateNextPayload();
tlm_sync_enum nb_transport_bw(tlm_generic_payload& payload, tlm_phase& phase, sc_time& bwDelay);
void peqCallback(tlm_generic_payload& payload, const tlm_phase& phase);
@@ -82,82 +83,89 @@ void TracePlayer<BUSWIDTH>::start()
}
}
template<unsigned int BUSWIDTH>
void TracePlayer<BUSWIDTH>::setDataPointer(gp* payload, unsigned char * dataElement)
{
//check if payload takes ownership
payload->set_data_length(16); // TODO: column / burst breite ..... buswidth * burst /8
payload->set_data_ptr(dataElement);
for(int i = 0; i < 16; i++) // TODO: column / burst breite
dataElement[i] = 0;
}
template<unsigned int BUSWIDTH>
void TracePlayer<BUSWIDTH>::generateNextPayload()
{
string line;
if (std::getline(file, line))
string line;
if (!std::getline(file, line))
return;
if(line.empty())
{
generateNextPayload();
return;
}
std::istringstream iss(line);
string time, command, address;
iss >> time >> command >> address;
long parsedAdress = std::stoi(address.c_str(), 0, 16);
gp* payload = memoryManager.allocate();
unsigned char * dataElement = new unsigned char[16]; // TODO: column / burst breite
payload->set_address(parsedAdress);
payload->set_response_status(TLM_INCOMPLETE_RESPONSE);
payload->set_dmi_allowed(false);
payload->set_byte_enable_length(0);
payload->set_streaming_width(burstlenght);
setDataPointer(payload, dataElement);
if (command == "read")
{
payload->set_command(TLM_READ_COMMAND);
}
else if (command == "write")
{
payload->set_command(TLM_WRITE_COMMAND);
// Parse and set data
string data;
iss >> data;
if(!data.empty())
{
if(line.empty())
//cout << "parsing write data: " << data << std::endl;
for(int i = 0; i < 16; i++) // TODO column / burst breite
{
generateNextPayload();
return;
std::string byteString = "0x";
byteString.append(data.substr(2*(i+1), 2));
//cout << byteString << " " << std::stoi(byteString.c_str(), 0, 16) << endl;
dataElement[i] = std::stoi(byteString.c_str(), 0, 16);
}
std::istringstream iss(line);
string time, command, address;
iss >> time >> command >> address;
long parsedAdress = std::stoi(address.c_str(), 0, 16);
}
}
else
{
SC_REPORT_FATAL(0,
(string("Corrupted tracefile, command ") + command + string(" unknown")).c_str());
}
gp* payload = memoryManager.allocate();
payload->set_address(parsedAdress);
sc_time sendingTime = std::stoi(time.c_str())*clk;
GenerationExtension* genExtension = new GenerationExtension(sendingTime);
payload->set_auto_extension(genExtension);
// Set data pointer
unsigned char * dataElement = new unsigned char[16]; // TODO: column / burst breite
payload->set_data_length(16); // TODO: column / burst breite
payload->set_data_ptr(dataElement);
for(int i = 0; i < 16; i++) // TODO: column / burst breite
dataElement[i] = 0;
if (sendingTime <= sc_time_stamp())
{
payloadEventQueue.notify(*payload, BEGIN_REQ, SC_ZERO_TIME);
}
else
{
payloadEventQueue.notify(*payload, BEGIN_REQ, sendingTime - sc_time_stamp());
}
numberOfPendingTransactions++;
if (command == "read")
{
payload->set_command(TLM_READ_COMMAND);
}
else if (command == "write")
{
payload->set_command(TLM_WRITE_COMMAND);
// Parse and set data
string data;
iss >> data;
if(!data.empty())
{
//cout << "parsing write data: " << data << std::endl;
for(int i = 0; i < 16; i++) // TODO column / burst breite
{
std::string byteString = "0x";
byteString.append(data.substr(2*(i+1), 2));
//cout << byteString << " " << std::stoi(byteString.c_str(), 0, 16) << endl;
dataElement[i] = std::stoi(byteString.c_str(), 0, 16);
}
}
}
else
{
SC_REPORT_FATAL(0,
(string("Corrupted tracefile, command ") + command + string(" unknown")).c_str());
}
payload->set_response_status(TLM_INCOMPLETE_RESPONSE);
payload->set_dmi_allowed(false);
payload->set_byte_enable_length(0);
payload->set_streaming_width(burstlenght);
sc_time sendingTime = std::stoi(time.c_str())*clk;
GenerationExtension* genExtension = new GenerationExtension(sendingTime);
payload->set_auto_extension(genExtension);
if (sendingTime <= sc_time_stamp())
{
payloadEventQueue.notify(*payload, BEGIN_REQ, SC_ZERO_TIME);
}
else
{
payloadEventQueue.notify(*payload, BEGIN_REQ, sendingTime - sc_time_stamp());
}
numberOfPendingTransactions++;
}
}