diff --git a/dram/dramSys/dramSys.pro b/dram/dramSys/dramSys.pro index 1b3163b3..3448244c 100644 --- a/dram/dramSys/dramSys.pro +++ b/dram/dramSys/dramSys.pro @@ -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 diff --git a/dram/resources/configs/memconfigs/fr_fcfs.xml b/dram/resources/configs/memconfigs/fr_fcfs.xml index 8aa70731..cce963c7 100644 --- a/dram/resources/configs/memconfigs/fr_fcfs.xml +++ b/dram/resources/configs/memconfigs/fr_fcfs.xml @@ -1,14 +1,12 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/dram/src/common/Utils.cpp b/dram/src/common/Utils.cpp index 0425aef2..96bd6d63 100644 --- a/dram/src/common/Utils.cpp +++ b/dram/src/common/Utils.cpp @@ -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")) { diff --git a/dram/src/controller/core/configuration/Configuration.cpp b/dram/src/controller/core/configuration/Configuration.cpp index c3ba3e73..b8eef538 100644 --- a/dram/src/controller/core/configuration/Configuration.cpp +++ b/dram/src/controller/core/configuration/Configuration.cpp @@ -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 parameterMap) @@ -96,6 +96,5 @@ void Configuration::setParameters(std::map parameterMa } } - } /* namespace core */ diff --git a/dram/src/controller/core/configuration/Configuration.h b/dram/src/controller/core/configuration/Configuration.h index 86214d36..cc4835cc 100644 --- a/dram/src/controller/core/configuration/Configuration.h +++ b/dram/src/controller/core/configuration/Configuration.h @@ -12,10 +12,9 @@ #include #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); diff --git a/dram/src/controller/core/configuration/MemSpecLoader.cpp b/dram/src/controller/core/configuration/ConfigurationLoader.cpp similarity index 76% rename from dram/src/controller/core/configuration/MemSpecLoader.cpp rename to dram/src/controller/core/configuration/ConfigurationLoader.cpp index cb2b9eb9..67611c08 100644 --- a/dram/src/controller/core/configuration/MemSpecLoader.cpp +++ b/dram/src/controller/core/configuration/ConfigurationLoader.cpp @@ -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"); diff --git a/dram/src/controller/core/configuration/ConfigurationLoader.h b/dram/src/controller/core/configuration/ConfigurationLoader.h new file mode 100644 index 00000000..26e18d54 --- /dev/null +++ b/dram/src/controller/core/configuration/ConfigurationLoader.h @@ -0,0 +1,38 @@ +/* + * ConfigurationLoader.h + * + * Created on: Apr 7, 2014 + * Author: jonny + */ + +#ifndef CONFIGURATIONLOADER_H_ +#define CONFIGURATIONLOADER_H_ + +#include +#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_ */ diff --git a/dram/src/controller/core/configuration/MemSpec.h b/dram/src/controller/core/configuration/MemSpec.h index 9a47ce35..5be412e5 100644 --- a/dram/src/controller/core/configuration/MemSpec.h +++ b/dram/src/controller/core/configuration/MemSpec.h @@ -11,6 +11,7 @@ #include #include #include "../../../common/dramExtension.h" + namespace core{ struct RefreshTiming diff --git a/dram/src/controller/core/configuration/MemSpecLoader.h b/dram/src/controller/core/configuration/MemSpecLoader.h deleted file mode 100644 index 7653075e..00000000 --- a/dram/src/controller/core/configuration/MemSpecLoader.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * MemSpecLoader.h - * - * Created on: Apr 7, 2014 - * Author: jonny - */ - -#ifndef MEMSPECLOADER_H_ -#define MEMSPECLOADER_H_ - -#include -#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_ */ diff --git a/dram/src/controller/core/scheduling/checker/WriteChecker.h b/dram/src/controller/core/scheduling/checker/WriteChecker.h index 64dd726e..28ba61d5 100644 --- a/dram/src/controller/core/scheduling/checker/WriteChecker.h +++ b/dram/src/controller/core/scheduling/checker/WriteChecker.h @@ -29,8 +29,6 @@ private: bool collidesWithStrobeCommand(ScheduledCommand& write, ScheduledCommand& strobeCommand) const; const Configuration& config; ControllerState& state; - - }; } /* namespace controller */ diff --git a/dram/src/simulation/Simulation.cpp b/dram/src/simulation/Simulation.cpp index 6f233309..383a77eb 100644 --- a/dram/src/simulation/Simulation.cpp +++ b/dram/src/simulation/Simulation.cpp @@ -10,6 +10,7 @@ #include "../common/DebugManager.h" #include "../common/xmlAddressdecoder.h" #include "../controller/core/ControllerCore.h" +#include "../controller/core/configuration/ConfigurationLoader.h" #include #include #include @@ -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(); diff --git a/dram/src/simulation/TracePlayer.h b/dram/src/simulation/TracePlayer.h index 2fc5edbd..250e51b5 100644 --- a/dram/src/simulation/TracePlayer.h +++ b/dram/src/simulation/TracePlayer.h @@ -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::start() } } +template +void TracePlayer::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 void TracePlayer::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++; - } }