diff --git a/DRAMSys/simulator/resources/configs/mcconfigs/fifo.xml b/DRAMSys/simulator/resources/configs/mcconfigs/fifo.xml index 2048948f..86322a2f 100644 --- a/DRAMSys/simulator/resources/configs/mcconfigs/fifo.xml +++ b/DRAMSys/simulator/resources/configs/mcconfigs/fifo.xml @@ -11,4 +11,5 @@ + diff --git a/DRAMSys/simulator/resources/configs/mcconfigs/fifoStrict.xml b/DRAMSys/simulator/resources/configs/mcconfigs/fifoStrict.xml index 164f89f6..9ca4b1b4 100644 --- a/DRAMSys/simulator/resources/configs/mcconfigs/fifoStrict.xml +++ b/DRAMSys/simulator/resources/configs/mcconfigs/fifoStrict.xml @@ -10,6 +10,7 @@ - + + diff --git a/DRAMSys/simulator/resources/configs/mcconfigs/fr_fcfs.xml b/DRAMSys/simulator/resources/configs/mcconfigs/fr_fcfs.xml index 50532f62..b0dc6ba4 100644 --- a/DRAMSys/simulator/resources/configs/mcconfigs/fr_fcfs.xml +++ b/DRAMSys/simulator/resources/configs/mcconfigs/fr_fcfs.xml @@ -11,12 +11,6 @@ - + diff --git a/DRAMSys/simulator/resources/configs/mcconfigs/par_bs.xml b/DRAMSys/simulator/resources/configs/mcconfigs/par_bs.xml index 24418246..a919e8c3 100644 --- a/DRAMSys/simulator/resources/configs/mcconfigs/par_bs.xml +++ b/DRAMSys/simulator/resources/configs/mcconfigs/par_bs.xml @@ -11,5 +11,6 @@ + diff --git a/DRAMSys/simulator/resources/configs/memspecs/WideIO.xml b/DRAMSys/simulator/resources/configs/memspecs/wideio.xml similarity index 100% rename from DRAMSys/simulator/resources/configs/memspecs/WideIO.xml rename to DRAMSys/simulator/resources/configs/memspecs/wideio.xml diff --git a/DRAMSys/simulator/resources/configs/simulator/ddr3.xml b/DRAMSys/simulator/resources/configs/simulator/ddr3.xml new file mode 100644 index 00000000..cc8f9de5 --- /dev/null +++ b/DRAMSys/simulator/resources/configs/simulator/ddr3.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/DRAMSys/simulator/resources/configs/simulator/wideio.xml b/DRAMSys/simulator/resources/configs/simulator/wideio.xml new file mode 100644 index 00000000..607db393 --- /dev/null +++ b/DRAMSys/simulator/resources/configs/simulator/wideio.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/DRAMSys/simulator/resources/configs/thermalsim/config.xml b/DRAMSys/simulator/resources/configs/thermalsim/config.xml new file mode 100644 index 00000000..9c71f8c6 --- /dev/null +++ b/DRAMSys/simulator/resources/configs/thermalsim/config.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/DRAMSys/simulator/resources/resources.pri b/DRAMSys/simulator/resources/resources.pri index 1d6ffe46..2a29a7d0 100644 --- a/DRAMSys/simulator/resources/resources.pri +++ b/DRAMSys/simulator/resources/resources.pri @@ -6,6 +6,9 @@ OTHER_FILES += resources/simulations/sim-batch.xml OTHER_FILES += resources/simulations/ddr3-example.xml OTHER_FILES += resources/simulations/ddr3-single-device.xml +# Simulator Configuration: +OTHER_FILES += + # scripts OTHER_FILES += resources/scripts/address_scrambler.pl OTHER_FILES += resources/scripts/createTraceDB.sql @@ -68,7 +71,7 @@ OTHER_FILES += resources/configs/mcconfigs/par_bs.xml OTHER_FILES += resources/configs/memspecs/memspec.dtd OTHER_FILES += resources/configs/memspecs/MatzesWideIO.xml OTHER_FILES += resources/configs/memspecs/DDR4.xml -OTHER_FILES += resources/configs/memspecs/WideIO.xml +OTHER_FILES += OTHER_FILES += resources/configs/memspecs/MatzesWideIO-short.xml OTHER_FILES += resources/configs/memspecs/MICRON_1Gb_DDR3-1600_8bit_G.xml OTHER_FILES += resources/configs/memspecs/JEDEC_256Mb_WIDEIO_SDR-200_128bit.xml @@ -131,3 +134,9 @@ OTHER_FILES += resources/configs/thermalsim/mem.flp OTHER_FILES += resources/configs/thermalsim/powerInfo.xml OTHER_FILES += resources/configs/thermalsim/stack.stk +DISTFILES += \ + $$PWD/configs/thermalsim/config.xml \ + $$PWD/configs/simulator/wideio.xml \ + $$PWD/configs/simulator/ddr3.xml \ + $$PWD/configs/memspecs/wideio.xml + diff --git a/DRAMSys/simulator/resources/simulations/ddr3-example.xml b/DRAMSys/simulator/resources/simulations/ddr3-example.xml index 643716ef..9c921124 100644 --- a/DRAMSys/simulator/resources/simulations/ddr3-example.xml +++ b/DRAMSys/simulator/resources/simulations/ddr3-example.xml @@ -1,32 +1,10 @@ - - - - - - - - - - - - - - - - - - - - - - @@ -50,12 +28,12 @@ - + - ddr3_example.stl + _128x128_64-Pixelgroesse_scram.stl diff --git a/DRAMSys/simulator/resources/simulations/ddr3-single-device.xml b/DRAMSys/simulator/resources/simulations/ddr3-single-device.xml index e6653583..5181342a 100644 --- a/DRAMSys/simulator/resources/simulations/ddr3-single-device.xml +++ b/DRAMSys/simulator/resources/simulations/ddr3-single-device.xml @@ -1,32 +1,10 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/DRAMSys/simulator/resources/simulations/sim-batch.xml b/DRAMSys/simulator/resources/simulations/sim-batch.xml index 0752914c..84ed962b 100644 --- a/DRAMSys/simulator/resources/simulations/sim-batch.xml +++ b/DRAMSys/simulator/resources/simulations/sim-batch.xml @@ -1,39 +1,15 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + diff --git a/DRAMSys/simulator/src/common/Utils.cpp b/DRAMSys/simulator/src/common/Utils.cpp index a791071b..e5b09fee 100644 --- a/DRAMSys/simulator/src/common/Utils.cpp +++ b/DRAMSys/simulator/src/common/Utils.cpp @@ -44,7 +44,6 @@ using namespace std; using namespace tinyxml2; - bool TimeInterval::timeIsInInterval(sc_time time) { return (start < time && time < end); diff --git a/DRAMSys/simulator/src/common/Utils.h b/DRAMSys/simulator/src/common/Utils.h index 1de06366..c8c8d85e 100644 --- a/DRAMSys/simulator/src/common/Utils.h +++ b/DRAMSys/simulator/src/common/Utils.h @@ -48,6 +48,15 @@ #include "dramExtension.h" #include "third_party/tinyxml2/tinyxml2.h" + +#define DEF_SINGLETON( NAME ) \ +public: \ + static NAME& getInstance() \ + { \ + static NAME _instance; \ + return _instance; \ + } + //TODO : move to timing specific header sc_time getDistance(sc_time a, sc_time b); diff --git a/DRAMSys/simulator/src/common/xmlAddressdecoder.cpp b/DRAMSys/simulator/src/common/xmlAddressdecoder.cpp index 24c3c356..ae790ea8 100644 --- a/DRAMSys/simulator/src/common/xmlAddressdecoder.cpp +++ b/DRAMSys/simulator/src/common/xmlAddressdecoder.cpp @@ -44,32 +44,44 @@ using namespace std; using namespace tinyxml2; -tinyxml2::XMLElement* xmlAddressDecoder::addressmapping = NULL; +//tinyxml2::XMLElement* xmlAddressDecoder::addressmapping = NULL; +//xmlAddressDecoder* xmlAddressDecoder::decoder = NULL; + +xmlAddressDecoder::xmlAddressDecoder() +{ + addressmapping = NULL; +} xmlAddressDecoder::xmlAddressDecoder(string addressConfigURI) { - tinyxml2::XMLDocument doc; - - loadXML(addressConfigURI, doc); - xmlAddressDecoder(doc.FirstChildElement("dramconfig")->FirstChildElement("addressmap")); - + setConfiguration(addressConfigURI); } xmlAddressDecoder::xmlAddressDecoder(XMLElement* addressmap) { - tinyxml2::XMLDocument doc; - string xmlNodeName(addressmap->Name()); - if( xmlNodeName != "addressmapping") - reportFatal("AddressDecorder", "addressmap node expected"); + setConfiguration(addressmap); +} - if(addressmap->Attribute("src")) +void xmlAddressDecoder::setConfiguration(std::string addressConfigURI) +{ + tinyxml2::XMLDocument doc; + loadXML(addressConfigURI, doc); + setConfiguration(doc.RootElement()); +} + +void xmlAddressDecoder::setConfiguration(tinyxml2::XMLElement* addressMap) +{ + tinyxml2::XMLDocument doc; + string xmlNodeName(addressMap->Name()); + + if( xmlNodeName != "addressmapping") { - string src(addressmap->Attribute("src")); - loadXML(src, doc); - addressmap = (doc.FirstChildElement("addressmapping")); + reportFatal("AddressDecorder", "addressmap node expected"); } - for(XMLElement* child = addressmap->FirstChildElement(); child != NULL; child = child->NextSiblingElement()) + for(XMLElement* child = addressMap->FirstChildElement(); + child != NULL; + child = child->NextSiblingElement()) { int from; int to; @@ -80,10 +92,10 @@ xmlAddressDecoder::xmlAddressDecoder(XMLElement* addressmap) shifts[child->Name()] = from; masks[child->Name()] = pow(2.0, to + 1.0) - pow(2.0, from + 0.0); amount[child->Name()] = pow(2.0, to - from + 1.0); - //std::cout << child->Name() << " XXXX " << pow(2.0, to - from + 1.0) <(pair.second)< #include +#include "Utils.h" #include "third_party/tinyxml2/tinyxml2.h" struct DecodedAddress @@ -62,35 +63,27 @@ struct DecodedAddress class xmlAddressDecoder { - public: - - static tinyxml2::XMLElement* addressmapping; - static inline xmlAddressDecoder& getInstance() - { - static xmlAddressDecoder decoder(xmlAddressDecoder::addressmapping); - return decoder; - } - - static inline void Initialize(tinyxml2::XMLElement* mapping) - { - addressmapping = mapping; - xmlAddressDecoder::getInstance(); - addressmapping = NULL; - } - - DecodedAddress decodeAddress(sc_dt::uint64 addr); - sc_dt::uint64 encodeAddress(DecodedAddress n); - - - void print(); private: + + xmlAddressDecoder(); xmlAddressDecoder(std::string URI); xmlAddressDecoder(tinyxml2::XMLElement* addressMap); std::map masks; std::map shifts; + tinyxml2::XMLElement* addressmapping; + public: + DEF_SINGLETON(xmlAddressDecoder); + + DecodedAddress decodeAddress(sc_dt::uint64 addr); + sc_dt::uint64 encodeAddress(DecodedAddress n); + + void setConfiguration(std::string url); + void setConfiguration(tinyxml2::XMLElement* addressMap); + void print(); + std::map amount; }; diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp index 594a746b..289682d5 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp +++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp @@ -133,6 +133,8 @@ void Configuration::setParameter(std::string name, std::string value) ReorderBuffer = string2bool(value); //SimConfig------------------------------------------------ + else if(name == "SimulationName") + SimulationName = value; else if(name == "DatabaseRecording") DatabaseRecording = string2bool(value); else if(name == "PowerAnalysis") @@ -264,6 +266,9 @@ unsigned int Configuration::getBytesPerBurst() // offset of the N-byte-wide memory module (DIMM) (a single data word // or burst element has N bytes. N = 2^(# bits for byte offset)). unsigned int burstElementSizeInBytes = xmlAddressDecoder::getInstance().amount["bytes"]; + cout << "burstElementSizeInBytes:" << burstElementSizeInBytes << endl; + cout << "bytesPerBurst:" << bytesPerBurst << endl; + cout << "BurstLength:" << memSpec.BurstLength << endl; assert(bytesPerBurst == (burstElementSizeInBytes * memSpec.BurstLength)); } diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.h b/DRAMSys/simulator/src/controller/core/configuration/Configuration.h index 53437269..29b8d41a 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.h +++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.h @@ -50,18 +50,14 @@ DEFINE_ENUM_CLASS_WITH_STRING_CONVERSIONS(StorageMode, (NoStorage)(Store)(ErrorM enum class EPowerDownMode{NoPowerDown, Staggered, TimeoutPDN, TimeoutSREF}; -struct Configuration +struct Configuration { static std::string memspecUri; static std::string mcconfigUri; - static inline Configuration& getInstance() - { - static Configuration configuration; - return configuration; - } + DEF_SINGLETON(Configuration); - //MCConfig + // MCConfig: bool BankwiseLogic = false; bool OpenPagePolicy = true; unsigned int MaxNrOfTransactions = 8; @@ -72,7 +68,8 @@ struct Configuration bool ReadWriteGrouping = false; bool ReorderBuffer = false; - //SimConfig + // SimConfig + std::string SimulationName = "default"; bool DatabaseRecording = true; bool PowerAnalysis = false; bool EnableWindowing = false; @@ -86,7 +83,7 @@ struct Configuration unsigned int NumberOfDevicesOnDIMM = 1; bool CheckTLM2Protocol = false; - //MemSpec(from DRAM-Power XML) + // MemSpec (from DRAM-Power XML) MemSpec memSpec; void setParameter(std::string name, std::string value); diff --git a/DRAMSys/simulator/src/controller/core/configuration/ConfigurationLoader.cpp b/DRAMSys/simulator/src/controller/core/configuration/ConfigurationLoader.cpp index f948c8db..d717e2d0 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/ConfigurationLoader.cpp +++ b/DRAMSys/simulator/src/controller/core/configuration/ConfigurationLoader.cpp @@ -107,13 +107,6 @@ void ConfigurationLoader::loadMemSpec(Configuration& config, string memspecUri) void ConfigurationLoader::loadMemSpec(Configuration& config, XMLElement* memspec) { - XMLDocument doc; - - string src(memspec->Attribute("src")); - config.memspecUri = src; - loadXML(src, doc); - memspec = doc.FirstChildElement("memspec"); - config.memSpec.MemoryId = queryStringParameter(memspec, "memoryId"); config.memSpec.MemoryType = queryStringParameter(memspec, "memoryType"); diff --git a/DRAMSys/simulator/src/controller/core/configuration/ConfigurationLoader.h b/DRAMSys/simulator/src/controller/core/configuration/ConfigurationLoader.h index 9c319129..d9cf1bc8 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/ConfigurationLoader.h +++ b/DRAMSys/simulator/src/controller/core/configuration/ConfigurationLoader.h @@ -45,7 +45,8 @@ class ConfigurationLoader { public: - static void loadMCConfig(Configuration& config, std::string mcconfigUri); + + static void loadMCConfig(Configuration& config, std::string amconfigUri); static void loadMCConfig(Configuration& config, tinyxml2::XMLElement* mcconfig); static void loadSimConfig(Configuration& config, std::string simconfigUri); diff --git a/DRAMSys/simulator/src/simulation/dramSys.cpp b/DRAMSys/simulator/src/simulation/dramSys.cpp index 12058f97..98e7412c 100644 --- a/DRAMSys/simulator/src/simulation/dramSys.cpp +++ b/DRAMSys/simulator/src/simulation/dramSys.cpp @@ -53,38 +53,59 @@ using namespace std; -dramSys::dramSys(sc_module_name __attribute__((unused)) name, +DRAMSys::DRAMSys(sc_module_name __attribute__((unused)) name, + string pathToResources, string memspec, string mcconfig, - string amconfig) + string amconfig, + string simconfig, + string thermalconfig) { logo(); SC_THREAD(stop); - // TODO: - - cout << memspec << endl; - cout << mcconfig << endl; - cout << amconfig << endl; - // The xmlAddressDecoder MUST be initialized before calling the // ConfigurationLoader because some information from the xmlAddressDecoder // is needed to assure the coherence of the configuration. - xmlAddressDecoder::Initialize(setup.addressmapping); + xmlAddressDecoder::getInstance().setConfiguration(pathToResources + + "configs/amconfigs/" + + amconfig); xmlAddressDecoder::getInstance().print(); - ConfigurationLoader::loadMCConfig(Configuration::getInstance(), setup.mcconfig); - ConfigurationLoader::loadMemSpec(Configuration::getInstance(), setup.memspec); - ConfigurationLoader::loadSimConfig(Configuration::getInstance(), setup.simconfig); - ConfigurationLoader::loadTemperatureSimConfig(Configuration::getInstance(), setup.thermalsimconfig); + // Setup the memory controller with the propriate xml file + ConfigurationLoader::loadMCConfig(Configuration::getInstance(), + pathToResources + + "configs/mcconfigs/" + + mcconfig); - instantiateModules(traceName, setup.pathToResources); + ConfigurationLoader::loadMemSpec(Configuration::getInstance(), + pathToResources + + "configs/memspecs/" + + memspec); + + ConfigurationLoader::loadSimConfig(Configuration::getInstance(), + pathToResources + + "configs/simulator/" + + simconfig); + + ConfigurationLoader::loadTemperatureSimConfig(Configuration::getInstance(), + pathToResources + + "configs/thermalsim/" + + thermalconfig); + + // Instantiate all internal DRAMSys modules: + instantiateModules(Configuration::getInstance().SimulationName, + pathToResources); + + // Connect all internal DRAMSys modules: bindSockets(); - setupDebugManager(traceName); + + // Setup the debug manager: + setupDebugManager(Configuration::getInstance().SimulationName); } -void dramSys::logo() +void DRAMSys::logo() { #define REDTXT(s) string(("\033[0;31m"+string((s))+"\033[0m")) #define BOLDBLUETXT(s) string(("\033[1;34m"+string((s))+"\033[0m")) @@ -92,15 +113,18 @@ void dramSys::logo() cout << REDTXT(" |||") << endl; cout << REDTXT(" +---+ Microelectronic Systems") << endl; cout << REDTXT("=| |= Design Research Group") << endl; - cout << REDTXT("=| |= ") << BOLDBLUETXT("University of Kaiserslautern") << endl; + cout << REDTXT("=| |= ") << BOLDBLUETXT("University of Kaiserslautern") + << endl; cout << REDTXT(" +---+ ") << endl; - cout << REDTXT(" ||| ") << "DRAMSys - Approximately-Timed TLM Models for DDR and Wide I/0 DRAM -" << endl; + cout << REDTXT(" ||| ") << "DRAMSys -" + << " Approximately-Timed TLM Models for DDR and Wide I/0 DRAM -" + << endl; cout << endl; #undef REDTXT #undef BOLDBLUETXT } -void dramSys::setupDebugManager(const string& traceName) +void DRAMSys::setupDebugManager(const string& traceName) { auto& dbg = DebugManager::getInstance(); dbg.writeToConsole = true; @@ -109,21 +133,35 @@ void dramSys::setupDebugManager(const string& traceName) dbg.openDebugFile(traceName + ".txt"); } -void dramSys::setupTlmRecorders(const string &traceName, const string &pathToResources) +void DRAMSys::setupTlmRecorders(const string &traceName, + const string &pathToResources) { // Create TLM Recorders, one per channel. - for (size_t i = 0; i < Configuration::getInstance().NumberOfMemChannels; i++) { - std::string sqlScriptURI = pathToResources + string("scripts/createTraceDB.sql"); - std::string dbName = traceName + string("_channel") + std::to_string(i) + ".tdb"; + for (size_t i = 0; + i < Configuration::getInstance().NumberOfMemChannels; + i++) + { + std::string sqlScriptURI = pathToResources + + string("scripts/createTraceDB.sql"); + + std::string dbName = traceName + + string("_channel") + + std::to_string(i) + + ".tdb"; + std::string recorderName = "tlmRecorder" + std::to_string(i); - TlmRecorder *tlmRecorder = new TlmRecorder(recorderName.c_str(), sqlScriptURI.c_str(), dbName.c_str(), Configuration::getInstance().DatabaseRecording); + TlmRecorder *tlmRecorder = + new TlmRecorder(recorderName.c_str(), + sqlScriptURI.c_str(), + dbName.c_str(), + Configuration::getInstance().DatabaseRecording); tlmRecorder->recordMCconfig(Configuration::getInstance().mcconfigUri); tlmRecorder->recordMemspec(Configuration::getInstance().memspecUri); tlmRecorders.push_back(tlmRecorder); - std::string traceNames = "FOO"; /// TODO + std::string traceNames = "FOO"; // TODO //for (size_t i = 0; i < devices.size(); i++) { // traceNames.append(devices[i].trace); // if (i == devices.size() - 1) @@ -134,20 +172,25 @@ void dramSys::setupTlmRecorders(const string &traceName, const string &pathToRes } } -void dramSys::instantiateModules(const string &traceName, const string &pathToResources) +void DRAMSys::instantiateModules(const string &traceName, + const string &pathToResources) { // The first call to getInstance() creates the Temperature Controller. // The same instance will be accessed by all other modules. TemperatureController::getInstance(); - // Create and properly initialize TLM recorders. They need to be ready before creating some modules. + // Create and properly initialize TLM recorders. + // They need to be ready before creating some modules. setupTlmRecorders(traceName, pathToResources); arbiter = new Arbiter("arbiter"); arbiter->setTlmRecorders(tlmRecorders); - for (size_t i = 0; i < Configuration::getInstance().NumberOfMemChannels; i++) { + for (size_t i = 0; + i < Configuration::getInstance().NumberOfMemChannels; + i++) + { std::string str = "controller" + std::to_string(i); Controller *controller = new Controller(str.c_str(), tlmRecorders[i]); controllers.push_back(controller); @@ -158,80 +201,103 @@ void dramSys::instantiateModules(const string &traceName, const string &pathToRe dram->setDramController(controllers[i]); drams.push_back(dram); - if(Configuration::getInstance().CheckTLM2Protocol) { + if(Configuration::getInstance().CheckTLM2Protocol) + { str = "TLMCheckerController"+ std::to_string(i); - tlm_utils::tlm2_base_protocol_checker<> * controllerTlmChecker = new tlm_utils::tlm2_base_protocol_checker<>(str.c_str()); + tlm_utils::tlm2_base_protocol_checker<> * controllerTlmChecker = + new tlm_utils::tlm2_base_protocol_checker<>(str.c_str()); controllersTlmCheckers.push_back(controllerTlmChecker); } } } -void dramSys::bindSockets() +void DRAMSys::bindSockets() { tSocket.bind(arbiter->tSocket); - if(Configuration::getInstance().CheckTLM2Protocol) { + if(Configuration::getInstance().CheckTLM2Protocol) + { - for (size_t i = 0; i < Configuration::getInstance().NumberOfMemChannels; i++) { + for (size_t i = 0; + i < Configuration::getInstance().NumberOfMemChannels; + i++) + { arbiter->iSocket.bind(controllersTlmCheckers[i]->target_socket); - controllersTlmCheckers[i]->initiator_socket.bind(controllers[i]->tSocket); + controllersTlmCheckers[i]->initiator_socket.bind( + controllers[i]->tSocket); controllers[i]->iSocket.bind(drams[i]->tSocket); } - } else { - for (size_t i = 0; i < Configuration::getInstance().NumberOfMemChannels; i++) { + } + else + { + for (size_t i = 0; + i < Configuration::getInstance().NumberOfMemChannels; + i++) + { arbiter->iSocket.bind(controllers[i]->tSocket); controllers[i]->iSocket.bind(drams[i]->tSocket); } } } -dramSys::~dramSys() +DRAMSys::~DRAMSys() { delete arbiter; - for (auto controller : controllers) { + for (auto controller : controllers) + { delete controller; } - for (auto dram : drams) { + for (auto dram : drams) + { delete dram; } - for (auto rec : tlmRecorders) { + for (auto rec : tlmRecorders) + { delete rec; } - for (auto tlmChecker : controllersTlmCheckers) { + for (auto tlmChecker : controllersTlmCheckers) + { delete tlmChecker; } } -void dramSys::stop() +void DRAMSys::stop() { wait(terminateSimulation); unsigned int pending_payloads = 0; - do { + do + { pending_payloads = 0; - for (auto controller : controllers) { + for (auto controller : controllers) + { pending_payloads += controller->getTotalNumberOfPayloadsInSystem(); } wait(sc_time(200, SC_NS)); - } while(pending_payloads != 0); + } + while(pending_payloads != 0); - for (auto controller : controllers) { + for (auto controller : controllers) + { controller->terminateSimulation(); } + wait(sc_time(200, SC_NS)); - for (auto rec : tlmRecorders) { + + for (auto rec : tlmRecorders) + { rec->closeConnection(); } sc_stop(); } -void dramSys::report(string message) +void DRAMSys::report(string message) { DebugManager::getInstance().printDebugMessage(this->name(), message); cout << message << endl; diff --git a/DRAMSys/simulator/src/simulation/dramSys.h b/DRAMSys/simulator/src/simulation/dramSys.h index f7e8e5b8..0e093b4e 100644 --- a/DRAMSys/simulator/src/simulation/dramSys.h +++ b/DRAMSys/simulator/src/simulation/dramSys.h @@ -50,74 +50,23 @@ #include "../common/third_party/tinyxml2/tinyxml2.h" #include "../common/tlm2_base_protocol_checker.h" - -struct DramSetup - -{ - tinyxml2::XMLElement* memspec; - tinyxml2::XMLElement* mcconfig; - tinyxml2::XMLElement* simconfig; - tinyxml2::XMLElement* addressmapping; - tinyxml2::XMLElement* thermalsimconfig; - - string pathToResources; - - DramSetup() : memspec(NULL), - mcconfig(NULL), - simconfig(NULL), - addressmapping(NULL), - thermalsimconfig(NULL) - { - } - - DramSetup(tinyxml2::XMLElement* memspec, - tinyxml2::XMLElement* mcconfig, - tinyxml2::XMLElement* simconfig, - tinyxml2::XMLElement* addressmapping, - tinyxml2::XMLElement *tsc) : - memspec(memspec), - mcconfig(mcconfig), - simconfig(simconfig), - addressmapping(addressmapping), - thermalsimconfig(tsc) - { - } -}; - -struct Device -{ - std::string trace; - unsigned int clkMhz; - unsigned int burstLength; - - Device():trace("empty.stl"), burstLength(0) - { - } - - Device(std::string trace, - unsigned int clkMhz, - unsigned int burstLength = 8) : - trace(trace), - clkMhz (clkMhz), - burstLength(burstLength) - { - } -}; - -class dramSys: public sc_module +class DRAMSys: public sc_module { public: - tlm_utils::multi_passthrough_target_socket tSocket; + tlm_utils::multi_passthrough_target_socket tSocket; sc_event terminateSimulation; - SC_HAS_PROCESS(dramSys); - dramSys(sc_module_name name, + SC_HAS_PROCESS(DRAMSys); + DRAMSys(sc_module_name name, + string pathToResources, string memspec, string mcconfig, - string amconfig); + string amconfig, + string simconfig, + string thermalconfig); - ~dramSys(); + ~DRAMSys(); void stop(); void logo(); @@ -125,7 +74,7 @@ public: private: std::string traceName; - DramSetup setup; + //DramSetup setup; //TLM 2.0 Protocol Checkers std::vector*> controllersTlmCheckers; diff --git a/DRAMSys/simulator/src/simulation/main.cpp b/DRAMSys/simulator/src/simulation/main.cpp index 0f802619..5fb07b81 100644 --- a/DRAMSys/simulator/src/simulation/main.cpp +++ b/DRAMSys/simulator/src/simulation/main.cpp @@ -43,6 +43,8 @@ //XXX //#include "SimulationManager.h" #include "dramSys.h" +#include "ExampleInitiator.h" + using namespace std; @@ -65,7 +67,8 @@ int sc_main(int argc, char **argv) sc_set_time_resolution(1, SC_PS); // Get path of resources: - resources = pathOfFile(argv[0]) + string("/../../DRAMSys/simulator/resources/"); + resources = pathOfFile(argv[0]) + + string("/../../DRAMSys/simulator/resources/"); string simulationToRun; if(argc > 1) @@ -74,10 +77,23 @@ int sc_main(int argc, char **argv) simulationToRun = resources + "simulations/sim-batch.xml"; - dramSys dramSystem("dramSystem", - "../../DRAMSys/simulator/resources/memspec/WideIO.xml", - "../../DRAMSys/simulator/resources/fifoStrict.xml", - "../../DRAMSys/simulator/resources/am_wideio.xml"); + DRAMSys dramSystem("dramSystem", + "../../DRAMSys/simulator/resources/", + "wideio.xml", + "fifoStrict.xml", + "am_wideio.xml", + "wideio.xml", + "config.xml"); + + ExampleInitiator trageGenerator("traceGenerator"); + + trageGenerator.socket.bind(dramSystem.tSocket); + + SC_REPORT_INFO("sc_main", "Start of Simulation"); + + sc_core::sc_start(); + + SC_REPORT_INFO("sc_main", "End of Simulation"); return 0; }