diff --git a/DRAMSys/simulator/src/simulation/Arbiter.h b/DRAMSys/simulator/src/simulation/Arbiter.h
index 79e6aa97..47fb5a1e 100644
--- a/DRAMSys/simulator/src/simulation/Arbiter.h
+++ b/DRAMSys/simulator/src/simulation/Arbiter.h
@@ -236,6 +236,10 @@ private:
void appendDramExtension(int socketId, tlm_generic_payload& payload)
{
+ // Append Generation Extension
+ GenerationExtension* genExtension = new GenerationExtension(sc_time_stamp());
+ payload.set_auto_extension(genExtension);
+
unsigned int burstlength = payload.get_streaming_width();
DecodedAddress decodedAddress = xmlAddressDecoder::getInstance().decodeAddress(payload.get_address());
// Check the valid range of decodedAddress
@@ -274,4 +278,3 @@ private:
};
#endif /* ARBITER_H_ */
-
diff --git a/DRAMSys/simulator/src/simulation/Simulation.cpp b/DRAMSys/simulator/src/simulation/Simulation.cpp
index 71acb46c..34259e92 100644
--- a/DRAMSys/simulator/src/simulation/Simulation.cpp
+++ b/DRAMSys/simulator/src/simulation/Simulation.cpp
@@ -114,51 +114,6 @@ void Simulation::instantiateModules(const string &traceName, const string &pathT
// The same instance will be accessed by all other modules.
TemperatureController::getInstance();
-#if USE_EXAMPLE_INITIATOR
- init = new ExampleInitiator("init");
- if(Configuration::getInstance().CheckTLM2Protocol) {
- 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++) {
- std::string playerStr = "tracePlayer" + std::to_string(i);
- TracePlayer *player;
- sc_time playerClk;
-
- // The clock frequency for the player can be specified in the
- // configuration file like in the example below (200 MHz):
- //
- //
- //
- // chstone-adpcm_32.stl
- //
- //
- //
- // If it is not specified in the configuration, the player will be
- // configured to use the memory clock frequency got from the memory
- // specs.
- if (devices[i].clkMhz == 0)
- playerClk = Configuration::getInstance().memSpec.clk;
- else
- playerClk = FrequencyToClk(devices[i].clkMhz);
-
- player = new StlPlayer(playerStr.c_str(), pathToResources + string("traces/") + devices[i].trace, playerClk, this);
- if(Configuration::getInstance().SimulationProgressBar)
- {
- totalTransactions += player->getNumberOfLines(pathToResources + string("traces/") + devices[i].trace);
- }
- players.push_back(player);
-
- if(Configuration::getInstance().CheckTLM2Protocol) {
- 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;
-#endif /* USE_EXAMPLE_INITIATOR */
-
// Create and properly initialize TLM recorders. They need to be ready before creating some modules.
setupTlmRecorders(traceName, pathToResources, devices);
@@ -187,57 +142,24 @@ void Simulation::instantiateModules(const string &traceName, const string &pathT
void Simulation::bindSockets()
{
-#if USE_EXAMPLE_INITIATOR
- if(Configuration::getInstance().CheckTLM2Protocol) {
- init->socket.bind(exampleInitiatorTlmChecker->target_socket);
- exampleInitiatorTlmChecker->initiator_socket.bind(arbiter->tSocket);
+ tSocket.bind(arbiter->tSocket);
+ if(Configuration::getInstance().CheckTLM2Protocol) {
- 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);
- controllers[i]->iSocket.bind(drams[i]->tSocket);
+ 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);
+ controllers[i]->iSocket.bind(drams[i]->tSocket);
+ }
+ } else {
+ for (size_t i = 0; i < Configuration::getInstance().NumberOfMemChannels; i++) {
+ arbiter->iSocket.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(playersTlmCheckers[i]->target_socket);
- playersTlmCheckers[i]->initiator_socket.bind(arbiter->tSocket);
- }
-
- 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);
- 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);
- }
- }
}
Simulation::~Simulation()
{
- for (auto player : players) {
- delete player;
- }
-
-#if USE_EXAMPLE_INITIATOR
- delete init;
- delete exampleInitiatorTlmChecker;
-#endif
delete arbiter;
@@ -253,40 +175,11 @@ Simulation::~Simulation()
delete rec;
}
- for (auto tlmChecker : playersTlmCheckers) {
- delete tlmChecker;
- }
-
for (auto tlmChecker : controllersTlmCheckers) {
delete tlmChecker;
}
}
-void Simulation::start()
-{
- report("\n\nStarting simulation:");
- report(headline);
- report(" -> setup: \t\t" + getFileName(traceName));
- report(" -> memspec: \t\t" + Configuration::getInstance().memSpec.MemoryId);
- cout << endl;
- simulationStartTime = clock();
-
- for (auto player : players) {
- player->nextPayload();
- }
-
- sc_set_stop_mode(SC_STOP_FINISH_DELTA);
- sc_start();
-}
-
-void inline Simulation::tracePlayerTerminates()
-{
- static unsigned int finishedTracePlayers = 0;
- finishedTracePlayers++;
-
- if (finishedTracePlayers == Configuration::getInstance().NumberOfTracePlayers)
- terminateSimulation.notify();
-}
void Simulation::stop()
{
@@ -316,16 +209,6 @@ void Simulation::stop()
}
-void inline Simulation::transactionFinished()
-{
- remainingTransactions--;
- loadbar(totalTransactions - remainingTransactions, totalTransactions);
- if (remainingTransactions == 0)
- {
- cout << endl;
- }
-}
-
void Simulation::report(string message)
{
DebugManager::getInstance().printDebugMessage(this->name(), message);
diff --git a/DRAMSys/simulator/src/simulation/Simulation.h b/DRAMSys/simulator/src/simulation/Simulation.h
index 0fb8a523..6dc79f94 100644
--- a/DRAMSys/simulator/src/simulation/Simulation.h
+++ b/DRAMSys/simulator/src/simulation/Simulation.h
@@ -44,17 +44,12 @@
#include "Dram.h"
#include "Arbiter.h"
-#include "TracePlayer.h"
#include "TraceGenerator.h"
#include "ReorderBuffer.h"
-#include "TracePlayerListener.h"
-#include "StlPlayer.h"
#include "../controller/Controller.h"
#include "../common/third_party/tinyxml2/tinyxml2.h"
-#include "ExampleInitiator.h"
#include "../common/tlm2_base_protocol_checker.h"
-#define USE_EXAMPLE_INITIATOR 0
struct DramSetup
{
@@ -79,36 +74,28 @@ struct Device
unsigned int burstLength;
};
-class Simulation: public sc_module, public TracePlayerListener
+class Simulation: public sc_module
{
public:
+ tlm_utils::multi_passthrough_target_socket tSocket;
+
+ sc_event terminateSimulation;
+
SC_HAS_PROCESS(Simulation);
Simulation(sc_module_name name, string pathToResources, string traceName, DramSetup setup,
std::vector devices);
~Simulation();
- void start();
void stop();
- virtual void tracePlayerTerminates() override;
- virtual void transactionFinished() override;
private:
std::string traceName;
DramSetup dramSetup;
- sc_event terminateSimulation;
-
- // 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*> 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
@@ -120,9 +107,6 @@ private:
// Transaction Recorders (one per channel). They generate the output databases.
std::vector tlmRecorders;
- unsigned int totalTransactions = 0;
- unsigned int remainingTransactions;
-
clock_t simulationStartTime;
void report(std::string message);
void setupTlmRecorders(const string &traceName, const string &pathToResources, const std::vector &devices);
diff --git a/DRAMSys/simulator/src/simulation/SimulationManager.cpp b/DRAMSys/simulator/src/simulation/SimulationManager.cpp
index 7fd9b47b..d84099d5 100644
--- a/DRAMSys/simulator/src/simulation/SimulationManager.cpp
+++ b/DRAMSys/simulator/src/simulation/SimulationManager.cpp
@@ -50,6 +50,17 @@ SimulationManager::SimulationManager(string resources) : resources(resources)
SimulationManager::~SimulationManager()
{
+ for (auto player : players) {
+ delete player;
+ }
+#if USE_EXAMPLE_INITIATOR
+ delete init;
+ delete exampleInitiatorTlmChecker;
+#endif
+
+ for (auto tlmChecker : playersTlmCheckers) {
+ delete tlmChecker;
+ }
}
void SimulationManager::loadSimulationsFromXML(string uri)
@@ -88,7 +99,9 @@ void SimulationManager::runSimulations()
for (auto& traceSetup : batch.traceSetups)
{
string exportname = exportPath + "/" + traceSetup.first;
- runSimulation(exportname, dramSetup, traceSetup.second);
+ instantiateModules(exportname, dramSetup, traceSetup.second);
+ bindSockets();
+ runSimulation(exportname);
}
}
}
@@ -132,15 +145,106 @@ void SimulationManager::parseSimulationBatch(XMLElement* simulation)
simulationBatches.push_back(batch);
}
-void SimulationManager::runSimulation(string traceName, DramSetup dramSetup, vector traceSetup)
+void SimulationManager::instantiateModules(string traceName, DramSetup dramSetup, vector traceSetup)
+{
+
+ simulation = new Simulation("sim", resources, traceName, dramSetup, traceSetup);
+
+#if USE_EXAMPLE_INITIATOR
+ init = new ExampleInitiator("init");
+ if(Configuration::getInstance().CheckTLM2Protocol) {
+ 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++) {
+ std::string playerStr = "tracePlayer" + std::to_string(i);
+ TracePlayer *player;
+ sc_time playerClk;
+
+ // The clock frequency for the player can be specified in the
+ // configuration file like in the example below (200 MHz):
+ //
+ //
+ //
+ // chstone-adpcm_32.stl
+ //
+ //
+ //
+ // If it is not specified in the configuration, the player will be
+ // configured to use the memory clock frequency got from the memory
+ // specs.
+ if (traceSetup[i].clkMhz == 0)
+ playerClk = Configuration::getInstance().memSpec.clk;
+ else
+ playerClk = FrequencyToClk(traceSetup[i].clkMhz);
+ const string pathToResources = resources;
+ player = new StlPlayer(playerStr.c_str(), pathToResources + string("traces/") + traceSetup[i].trace, playerClk, this);
+ if(Configuration::getInstance().SimulationProgressBar)
+ {
+ totalTransactions += player->getNumberOfLines(pathToResources + string("traces/") + traceSetup[i].trace);
+ }
+ players.push_back(player);
+
+ if(Configuration::getInstance().CheckTLM2Protocol) {
+ 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;
+#endif /* USE_EXAMPLE_INITIATOR */
+}
+
+void SimulationManager::bindSockets()
+{
+#if USE_EXAMPLE_INITIATOR
+ if(Configuration::getInstance().CheckTLM2Protocol) {
+ init->socket.bind(exampleInitiatorTlmChecker->target_socket);
+ exampleInitiatorTlmChecker->initiator_socket.bind(simulation->tSocket);
+
+ }
+ else {
+ init->socket.bind(simulation->tSocket);
+#else
+ if(Configuration::getInstance().CheckTLM2Protocol) {
+ for (size_t i = 0; i < players.size(); i++) {
+ players[i]->iSocket.bind(playersTlmCheckers[i]->target_socket);
+ playersTlmCheckers[i]->initiator_socket.bind(simulation->tSocket);
+ }
+
+ }
+ else {
+ for (auto player : players) {
+ player->iSocket.bind(simulation->tSocket);
+ }
+
+#endif
+ }
+}
+
+void SimulationManager::runSimulation(string traceName)
{
// int pid = fork();
// int status = 0;
// if (pid == 0)
// {
- Simulation* simulation = new Simulation("sim", resources, traceName, dramSetup, traceSetup);
- simulation->start();
- delete simulation;
+
+ report("\n\nStarting simulation:");
+ report(headline);
+ report(" -> setup: \t\t" + getFileName(traceName));
+ report(" -> memspec: \t\t" + Configuration::getInstance().memSpec.MemoryId);
+ cout << endl;
+ //simulationStartTime = clock();
+
+ for (auto player : players) {
+ player->nextPayload();
+ }
+
+ sc_set_stop_mode(SC_STOP_FINISH_DELTA);
+ sc_start();
+
+ delete simulation;
// _Exit(0);
//}
@@ -181,6 +285,23 @@ void SimulationManager::addTraceSetups(SimulationBatch &batch, tinyxml2::XMLElem
}
}
+void inline SimulationManager::tracePlayerTerminates()
+{
+ static unsigned int finishedTracePlayers = 0;
+ finishedTracePlayers++;
+
+ if (finishedTracePlayers == Configuration::getInstance().NumberOfTracePlayers)
+ simulation->terminateSimulation.notify();
+}
+void inline SimulationManager::transactionFinished()
+{
+ remainingTransactions--;
+ loadbar(totalTransactions - remainingTransactions, totalTransactions);
+ if (remainingTransactions == 0)
+ {
+ cout << endl;
+ }
+}
void SimulationManager::report(string message)
{
cout << message << endl;
@@ -196,4 +317,3 @@ void SimulationBatch::print()
cout << endl;
}
}
-
diff --git a/DRAMSys/simulator/src/simulation/SimulationManager.h b/DRAMSys/simulator/src/simulation/SimulationManager.h
index c95a96f2..3d1de351 100644
--- a/DRAMSys/simulator/src/simulation/SimulationManager.h
+++ b/DRAMSys/simulator/src/simulation/SimulationManager.h
@@ -42,40 +42,67 @@
#include
#include