From 99cfd40dc7a383a823ac1f73024fd6ff96d1d7ce Mon Sep 17 00:00:00 2001 From: "Felipe S. Prado" Date: Mon, 29 Aug 2016 17:47:28 +0200 Subject: [PATCH 1/2] TLM 2.0 Protocol Checking --- .../resources/configs/memconfigs/par_bs.xml | 0 .../resources/simulations/sim-batch.xml | 1 + .../core/configuration/Configuration.cpp | 2 + .../core/configuration/Configuration.h | 1 + .../simulator/src/simulation/Simulation.cpp | 66 ++++++++++++++++--- DRAMSys/simulator/src/simulation/Simulation.h | 3 + DRAMSys/tests/error/sim-batch.xml | 1 + DRAMSys/tests/simple/sim-batch.xml | 1 + README.md | 7 +- 9 files changed, 72 insertions(+), 10 deletions(-) create mode 100644 DRAMSys/simulator/resources/configs/memconfigs/par_bs.xml diff --git a/DRAMSys/simulator/resources/configs/memconfigs/par_bs.xml b/DRAMSys/simulator/resources/configs/memconfigs/par_bs.xml new file mode 100644 index 00000000..e69de29b diff --git a/DRAMSys/simulator/resources/simulations/sim-batch.xml b/DRAMSys/simulator/resources/simulations/sim-batch.xml index 06d1807c..73ca12b6 100644 --- a/DRAMSys/simulator/resources/simulations/sim-batch.xml +++ b/DRAMSys/simulator/resources/simulations/sim-batch.xml @@ -12,6 +12,7 @@ + diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp index 241c264f..a4170649 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp +++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp @@ -170,6 +170,8 @@ void Configuration::setParameter(std::string name, std::string value) SimulationProgressBar = string2bool(value); else if(name == "NumberOfDevicesOnDIMM") NumberOfDevicesOnDIMM = string2int(value); + else if(name == "CheckTLM2Protocol") + CheckTLM2Protocol = string2bool(value); // Specification for ErrorChipSeed, ErrorCSVFile path and StoreMode else if(name == "ErrorChipSeed") ErrorChipSeed = string2int(value); diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.h b/DRAMSys/simulator/src/controller/core/configuration/Configuration.h index 1bb478b2..01d6383a 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.h +++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.h @@ -85,6 +85,7 @@ struct Configuration bool ThermalSimulation = false; bool SimulationProgressBar = false; unsigned int NumberOfDevicesOnDIMM = 1; + bool CheckTLM2Protocol = false; //MemSpec(from DRAM-Power XML) MemSpec memSpec; diff --git a/DRAMSys/simulator/src/simulation/Simulation.cpp b/DRAMSys/simulator/src/simulation/Simulation.cpp index db6709e6..c66a5ac0 100644 --- a/DRAMSys/simulator/src/simulation/Simulation.cpp +++ b/DRAMSys/simulator/src/simulation/Simulation.cpp @@ -118,6 +118,11 @@ void Simulation::instantiateModules(const string &traceName, const string &pathT #if USE_EXAMPLE_INITIATOR init = new ExampleInitiator("init"); + if(Configuration::getInstance().CheckTLM2Protocol) { + string str = "tlmChecker"+ std::to_string(tlmCheckers.size()); + tlm_utils::tlm2_base_protocol_checker<32> *tlmChecker = new tlm_utils::tlm2_base_protocol_checker<32>(str.c_str()); + tlmCheckers.push_back(tlmChecker); + } #else for (size_t i = 0; i < Configuration::getInstance().NumberOfTracePlayers; i++) { std::string playerStr = "tracePlayer" + std::to_string(i); @@ -147,10 +152,14 @@ void Simulation::instantiateModules(const string &traceName, const string &pathT totalTransactions += player->getNumberOfLines(pathToResources + string("traces/") + devices[i].trace); } players.push_back(player); + + if(Configuration::getInstance().CheckTLM2Protocol) { + string str = "tlmChecker"+ std::to_string(tlmCheckers.size()); + tlm_utils::tlm2_base_protocol_checker<32> *tlmChecker = new tlm_utils::tlm2_base_protocol_checker<32>(str.c_str()); + tlmCheckers.push_back(tlmChecker); + } } - remainingTransactions = totalTransactions; - #endif /* USE_EXAMPLE_INITIATOR */ // Create and properly initialize TLM recorders. They need to be ready before creating some modules. @@ -170,22 +179,55 @@ void Simulation::instantiateModules(const string &traceName, const string &pathT dram->setTlmRecorder(tlmRecorders[i]); dram->setDramController(controllers[i]); drams.push_back(dram); + + if(Configuration::getInstance().CheckTLM2Protocol) { + str = "tlmChecker"+ std::to_string(tlmCheckers.size()); + tlm_utils::tlm2_base_protocol_checker<32> *tlmChecker = new tlm_utils::tlm2_base_protocol_checker<32>(str.c_str()); + tlmCheckers.push_back(tlmChecker); + } } } void Simulation::bindSockets() { #if USE_EXAMPLE_INITIATOR - init->socket.bind(arbiter->tSocket); -#else - for (auto player : players) { - player->iSocket.bind(arbiter->tSocket); + if(Configuration::getInstance().CheckTLM2Protocol) { + init->socket.bind(tlmCheckers[0]->target_socket); + tlmCheckers[0]->initiator_socket.bind(arbiter->tSocket); + + for (size_t i = 0; i < Configuration::getInstance().NumberOfMemChannels; i++) { + arbiter->iSocket.bind(tlmCheckers[i+1]->target_socket); + tlmCheckers[i+1]->initiator_socket.bind(controllers[i]->tSocket); + controllers[i]->iSocket.bind(drams[i]->tSocket); + } } + else { + init->socket.bind(arbiter->tSocket); + +#else + if(Configuration::getInstance().CheckTLM2Protocol) { + for (size_t i = 0; i < players.size(); i++) { + players[i]->iSocket.bind(tlmCheckers[i]->target_socket); + tlmCheckers[i]->initiator_socket.bind(arbiter->tSocket); + } + + for (size_t i = 0; i < Configuration::getInstance().NumberOfMemChannels; i++) { + arbiter->iSocket.bind(tlmCheckers[i+players.size()]->target_socket); + tlmCheckers[i+players.size()]->initiator_socket.bind(controllers[i]->tSocket); + controllers[i]->iSocket.bind(drams[i]->tSocket); + } + } + else { + for (auto player : players) { + player->iSocket.bind(arbiter->tSocket); + } + #endif - for (size_t i = 0; i < Configuration::getInstance().NumberOfMemChannels; i++) { - arbiter->iSocket.bind(controllers[i]->tSocket); - controllers[i]->iSocket.bind(drams[i]->tSocket); + for (size_t i = 0; i < Configuration::getInstance().NumberOfMemChannels; i++) { + arbiter->iSocket.bind(controllers[i]->tSocket); + controllers[i]->iSocket.bind(drams[i]->tSocket); + } } } @@ -195,6 +237,8 @@ Simulation::~Simulation() delete player; } + delete init; + delete arbiter; for (auto controller : controllers) { @@ -208,6 +252,10 @@ Simulation::~Simulation() for (auto rec : tlmRecorders) { delete rec; } + + for (auto tlmChecker : tlmCheckers) { + delete tlmChecker; + } } void Simulation::start() diff --git a/DRAMSys/simulator/src/simulation/Simulation.h b/DRAMSys/simulator/src/simulation/Simulation.h index 29d39584..e5e62b99 100644 --- a/DRAMSys/simulator/src/simulation/Simulation.h +++ b/DRAMSys/simulator/src/simulation/Simulation.h @@ -52,6 +52,7 @@ #include "../controller/Controller.h" #include "../common/third_party/tinyxml2/tinyxml2.h" #include "ExampleInitiator.h" +#include "../common/tlm2_base_protocol_checker.h" struct DramSetup { @@ -99,6 +100,8 @@ private: // A vector of pointers to all trace player (devices which acquire the bus // and initiate transactions targeting the memory) std::vector players; + //TLM 2.0 Protocol Checkers + std::vector*> tlmCheckers; // All transactions pass through the same arbiter ExampleInitiator *init; Arbiter *arbiter; diff --git a/DRAMSys/tests/error/sim-batch.xml b/DRAMSys/tests/error/sim-batch.xml index 31ee9130..7b741534 100644 --- a/DRAMSys/tests/error/sim-batch.xml +++ b/DRAMSys/tests/error/sim-batch.xml @@ -12,6 +12,7 @@ + diff --git a/DRAMSys/tests/simple/sim-batch.xml b/DRAMSys/tests/simple/sim-batch.xml index a439c09c..f7efc847 100644 --- a/DRAMSys/tests/simple/sim-batch.xml +++ b/DRAMSys/tests/simple/sim-batch.xml @@ -12,6 +12,7 @@ + diff --git a/README.md b/README.md index d2330084..4712faa9 100644 --- a/README.md +++ b/README.md @@ -406,6 +406,7 @@ The DRAMSys' main configuration file is presented below. + @@ -508,7 +509,8 @@ The XML code below shows a typic configuration: - + + @@ -636,6 +638,9 @@ Below are listed the configuration sections and configuration fields. - "0": disables the simulation progress bar - *NumberOfDevicesOnDIMM* (unsigned int) - Number of devices on dual inline memory module + - *CheckTLM2Protocol* (boolean) + - "1": enables the TLM 2.0 Protocol Checking + - "0": disables the TLM 2.0 Protocol Checking - **Temperature Simulator Configuration** - *TemperatureScale* (string) From c1854e4398ae059ef761f95ebd6732fee65a3de4 Mon Sep 17 00:00:00 2001 From: "Felipe S. Prado" Date: Thu, 1 Sep 2016 15:34:03 +0200 Subject: [PATCH 2/2] Example initiator and TLM checkers --- .../resources/configs/memconfigs/par_bs.xml | 15 +++++++ DRAMSys/simulator/resources/resources.pri | 3 +- .../simulator/src/simulation/Simulation.cpp | 45 ++++++++++--------- DRAMSys/simulator/src/simulation/Simulation.h | 11 +++-- 4 files changed, 49 insertions(+), 25 deletions(-) diff --git a/DRAMSys/simulator/resources/configs/memconfigs/par_bs.xml b/DRAMSys/simulator/resources/configs/memconfigs/par_bs.xml index e69de29b..65be1936 100644 --- a/DRAMSys/simulator/resources/configs/memconfigs/par_bs.xml +++ b/DRAMSys/simulator/resources/configs/memconfigs/par_bs.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/DRAMSys/simulator/resources/resources.pri b/DRAMSys/simulator/resources/resources.pri index 70a57f47..3f2dc9ce 100644 --- a/DRAMSys/simulator/resources/resources.pri +++ b/DRAMSys/simulator/resources/resources.pri @@ -2,7 +2,7 @@ # "DRAMSys/simulator/simulator.pro" # simulation files -OTHER_FILES += resources/simulations/sim-batch.xml +OTHER_FILES += resources/simulations/sim-batch.xml OTHER_FILES += resources/simulations/ddr3-example.xml # scripts @@ -58,6 +58,7 @@ OTHER_FILES += resources/configs/memconfigs/_old/grouper.xml OTHER_FILES += resources/configs/memconfigs/_old/par_bs.xml OTHER_FILES += resources/configs/memconfigs/_old/fr_fcfs_bankwise.xml OTHER_FILES += resources/configs/memconfigs/fr_fcfs.xml +OTHER_FILES += resources/configs/memconfigs/par_bs.xml # memspecs OTHER_FILES += resources/configs/memspecs/memspec.dtd diff --git a/DRAMSys/simulator/src/simulation/Simulation.cpp b/DRAMSys/simulator/src/simulation/Simulation.cpp index c66a5ac0..7311ab08 100644 --- a/DRAMSys/simulator/src/simulation/Simulation.cpp +++ b/DRAMSys/simulator/src/simulation/Simulation.cpp @@ -51,8 +51,6 @@ #include "../simulation/TemperatureController.h" #include "../controller/Controller.h" -#define USE_EXAMPLE_INITIATOR 0 - using namespace std; Simulation::Simulation(sc_module_name __attribute__((unused)) name, string pathToResources, string traceName, DramSetup setup, @@ -119,9 +117,8 @@ void Simulation::instantiateModules(const string &traceName, const string &pathT #if USE_EXAMPLE_INITIATOR init = new ExampleInitiator("init"); if(Configuration::getInstance().CheckTLM2Protocol) { - string str = "tlmChecker"+ std::to_string(tlmCheckers.size()); - tlm_utils::tlm2_base_protocol_checker<32> *tlmChecker = new tlm_utils::tlm2_base_protocol_checker<32>(str.c_str()); - tlmCheckers.push_back(tlmChecker); + string str = "ExampleInitiatorTLMChecker"; + exampleInitiatorTlmChecker = new tlm_utils::tlm2_base_protocol_checker<>(str.c_str()); } #else for (size_t i = 0; i < Configuration::getInstance().NumberOfTracePlayers; i++) { @@ -154,9 +151,9 @@ void Simulation::instantiateModules(const string &traceName, const string &pathT players.push_back(player); if(Configuration::getInstance().CheckTLM2Protocol) { - string str = "tlmChecker"+ std::to_string(tlmCheckers.size()); - tlm_utils::tlm2_base_protocol_checker<32> *tlmChecker = new tlm_utils::tlm2_base_protocol_checker<32>(str.c_str()); - tlmCheckers.push_back(tlmChecker); + string str = "TLMCheckerPlayer"+ std::to_string(i); + tlm_utils::tlm2_base_protocol_checker<> * playerTlmChecker = new tlm_utils::tlm2_base_protocol_checker<>(str.c_str()); + playersTlmCheckers.push_back(playerTlmChecker); } } remainingTransactions = totalTransactions; @@ -181,9 +178,9 @@ void Simulation::instantiateModules(const string &traceName, const string &pathT drams.push_back(dram); if(Configuration::getInstance().CheckTLM2Protocol) { - str = "tlmChecker"+ std::to_string(tlmCheckers.size()); - tlm_utils::tlm2_base_protocol_checker<32> *tlmChecker = new tlm_utils::tlm2_base_protocol_checker<32>(str.c_str()); - tlmCheckers.push_back(tlmChecker); + str = "TLMCheckerController"+ std::to_string(i); + tlm_utils::tlm2_base_protocol_checker<> * controllerTlmChecker = new tlm_utils::tlm2_base_protocol_checker<>(str.c_str()); + controllersTlmCheckers.push_back(controllerTlmChecker); } } } @@ -192,12 +189,12 @@ void Simulation::bindSockets() { #if USE_EXAMPLE_INITIATOR if(Configuration::getInstance().CheckTLM2Protocol) { - init->socket.bind(tlmCheckers[0]->target_socket); - tlmCheckers[0]->initiator_socket.bind(arbiter->tSocket); + init->socket.bind(exampleInitiatorTlmChecker->target_socket); + exampleInitiatorTlmChecker->initiator_socket.bind(arbiter->tSocket); for (size_t i = 0; i < Configuration::getInstance().NumberOfMemChannels; i++) { - arbiter->iSocket.bind(tlmCheckers[i+1]->target_socket); - tlmCheckers[i+1]->initiator_socket.bind(controllers[i]->tSocket); + arbiter->iSocket.bind(controllersTlmCheckers[i]->target_socket); + controllersTlmCheckers[i]->initiator_socket.bind(controllers[i]->tSocket); controllers[i]->iSocket.bind(drams[i]->tSocket); } } @@ -207,13 +204,13 @@ void Simulation::bindSockets() #else if(Configuration::getInstance().CheckTLM2Protocol) { for (size_t i = 0; i < players.size(); i++) { - players[i]->iSocket.bind(tlmCheckers[i]->target_socket); - tlmCheckers[i]->initiator_socket.bind(arbiter->tSocket); + players[i]->iSocket.bind(playersTlmCheckers[i]->target_socket); + playersTlmCheckers[i]->initiator_socket.bind(arbiter->tSocket); } for (size_t i = 0; i < Configuration::getInstance().NumberOfMemChannels; i++) { - arbiter->iSocket.bind(tlmCheckers[i+players.size()]->target_socket); - tlmCheckers[i+players.size()]->initiator_socket.bind(controllers[i]->tSocket); + arbiter->iSocket.bind(controllersTlmCheckers[i]->target_socket); + controllersTlmCheckers[i]->initiator_socket.bind(controllers[i]->tSocket); controllers[i]->iSocket.bind(drams[i]->tSocket); } } @@ -237,7 +234,10 @@ Simulation::~Simulation() delete player; } +#if USE_EXAMPLE_INITIATOR delete init; + delete exampleInitiatorTlmChecker; +#endif delete arbiter; @@ -253,7 +253,11 @@ Simulation::~Simulation() delete rec; } - for (auto tlmChecker : tlmCheckers) { + for (auto tlmChecker : playersTlmCheckers) { + delete tlmChecker; + } + + for (auto tlmChecker : controllersTlmCheckers) { delete tlmChecker; } } @@ -327,4 +331,3 @@ void Simulation::report(string message) DebugManager::getInstance().printDebugMessage(this->name(), message); cout << message << endl; } - diff --git a/DRAMSys/simulator/src/simulation/Simulation.h b/DRAMSys/simulator/src/simulation/Simulation.h index e5e62b99..e9091dc5 100644 --- a/DRAMSys/simulator/src/simulation/Simulation.h +++ b/DRAMSys/simulator/src/simulation/Simulation.h @@ -54,6 +54,8 @@ #include "ExampleInitiator.h" #include "../common/tlm2_base_protocol_checker.h" +#define USE_EXAMPLE_INITIATOR 0 + struct DramSetup { DramSetup():memspec(NULL),memconfig(NULL),simconfig(NULL),addressmapping(NULL), thermalsimconfig(NULL) {} @@ -101,9 +103,13 @@ private: // and initiate transactions targeting the memory) std::vector players; //TLM 2.0 Protocol Checkers - std::vector*> tlmCheckers; - // All transactions pass through the same arbiter + std::vector*> playersTlmCheckers; + std::vector*> controllersTlmCheckers; +#if USE_EXAMPLE_INITIATOR ExampleInitiator *init; + tlm_utils::tlm2_base_protocol_checker<>* exampleInitiatorTlmChecker; +#endif + // All transactions pass through the same arbiter Arbiter *arbiter; // Each DRAM unit has a controller std::vector controllers; @@ -126,4 +132,3 @@ private: }; #endif /* SIMULATIONMANAGER_H_ */ -