From 636ff65a38cd4389e9995f62a9e35852580c960f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Wed, 17 Feb 2016 13:24:10 -0200 Subject: [PATCH] Added support to single-line comments in STL files (issue#45). Lines which start with '#' will be ignored by trace players. From IP_GFRBM.pdf: STL syntax supports only single line comments. A single-line comment is everything on a line following but not including the first occurrence of the # character and up to, but not including the end of the line. For example: # this is a comment Comments should always begin in a new line. --- .../simulator/src/simulation/Simulation.cpp | 2 +- .../simulator/src/simulation/StlDataPlayer.h | 33 ++++++++---------- DRAMSys/simulator/src/simulation/StlPlayer.h | 34 ++++++++----------- 3 files changed, 31 insertions(+), 38 deletions(-) diff --git a/DRAMSys/simulator/src/simulation/Simulation.cpp b/DRAMSys/simulator/src/simulation/Simulation.cpp index 55bd4c0d..e19496e0 100644 --- a/DRAMSys/simulator/src/simulation/Simulation.cpp +++ b/DRAMSys/simulator/src/simulation/Simulation.cpp @@ -109,7 +109,7 @@ void Simulation::setupTlmRecorders(const string &traceName, const string &pathTo void Simulation::instantiateModules(const string &traceName, const string &pathToResources, const std::vector &devices) { // The first call to getInstance() creates the Temperature Controller. - // The same instance will can be accessed by all other modules. + // The same instance will be accessed by all other modules. TemperatureController::getInstance(); for (size_t i = 0; i < Configuration::getInstance().NumberOfTracePlayers; i++) { diff --git a/DRAMSys/simulator/src/simulation/StlDataPlayer.h b/DRAMSys/simulator/src/simulation/StlDataPlayer.h index fbe6a67a..d4b55638 100644 --- a/DRAMSys/simulator/src/simulation/StlDataPlayer.h +++ b/DRAMSys/simulator/src/simulation/StlDataPlayer.h @@ -49,18 +49,21 @@ template struct StlDataPlayer: public TracePlayer { public: - StlDataPlayer(sc_module_name /*name*/, string pathToTrace, unsigned int clkMhz, - TracePlayerListener* listener); + StlDataPlayer(sc_module_name /*name*/, string pathToTrace, unsigned int clkMhz, TracePlayerListener* listener); + virtual void nextPayload() override { - string line; - while(line.empty() && file) - { + std::string line; + while (line.empty() && file) { std::getline(file, line); + + // Ignore lines which begin with '#' (commented lines) + if (!line.empty() && line.at(0) == '#') { + line.clear(); + } } - if(!file) - { + if(!file) { this->terminate(); return; } @@ -118,26 +121,19 @@ public: dataElement[i] = std::stoi(byteString.c_str(), 0, 16); } } - } - else - { - SC_REPORT_FATAL(0, - (string("Corrupted tracefile, command ") + command + string(" unknown")).c_str()); + } else { + SC_REPORT_FATAL(0, (string("Corrupted tracefile, command ") + command + string(" unknown")).c_str()); } sc_time sendingTime = std::stoull(time.c_str())*clk; - if (sendingTime <= sc_time_stamp()) - { + if (sendingTime <= sc_time_stamp()) { this->payloadEventQueue.notify(*payload, BEGIN_REQ, SC_ZERO_TIME); - } - else - { + } else { this->payloadEventQueue.notify(*payload, BEGIN_REQ, sendingTime - sc_time_stamp()); } } - private: ifstream file; unsigned int burstlength; @@ -164,3 +160,4 @@ StlDataPlayer::StlDataPlayer(sc_module_name /*name*/, string pathToTra } #endif // STLDATAPLAYER_H + diff --git a/DRAMSys/simulator/src/simulation/StlPlayer.h b/DRAMSys/simulator/src/simulation/StlPlayer.h index 355e7e5e..918eae84 100644 --- a/DRAMSys/simulator/src/simulation/StlPlayer.h +++ b/DRAMSys/simulator/src/simulation/StlPlayer.h @@ -49,23 +49,25 @@ template struct StlPlayer: public TracePlayer { public: - StlPlayer(sc_module_name /*name*/, string pathToTrace, unsigned int clkMhz, - TracePlayerListener* listener); + StlPlayer(sc_module_name /*name*/, string pathToTrace, unsigned int clkMhz, TracePlayerListener *listener); + virtual void nextPayload() override { - string line; - while(line.empty() && file) - { + std::string line; + while (line.empty() && file) { std::getline(file, line); + + // Ignore lines which begin with '#' (commented lines) + if (!line.empty() && line.at(0) == '#') { + line.clear(); + } } - if(!file) - { + if(!file) { this->terminate(); return; } - std::istringstream iss(line); string time, command, address; iss >> time >> command >> address; @@ -105,26 +107,19 @@ public: dataElement[i] = std::stoi(byteString.c_str(), 0, 16); } } - } - else - { - SC_REPORT_FATAL(0, - (string("Corrupted tracefile, command ") + command + string(" unknown")).c_str()); + } else { + SC_REPORT_FATAL(0, (string("Corrupted tracefile, command ") + command + string(" unknown")).c_str()); } sc_time sendingTime = std::stoull(time.c_str())*clk; - if (sendingTime <= sc_time_stamp()) - { + if (sendingTime <= sc_time_stamp()) { this->payloadEventQueue.notify(*payload, BEGIN_REQ, SC_ZERO_TIME); - } - else - { + } else { this->payloadEventQueue.notify(*payload, BEGIN_REQ, sendingTime - sc_time_stamp()); } } - private: ifstream file; unsigned int burstlength; @@ -151,3 +146,4 @@ StlPlayer::StlPlayer(sc_module_name /*name*/, string pathToTrace, unsi } #endif // STLPLAYER_H +