diff --git a/DRAMSys/simulator/resources/simulations/ddr3-example.xml b/DRAMSys/simulator/resources/simulations/ddr3-example.xml
index f4793a45..0df2e1c7 100644
--- a/DRAMSys/simulator/resources/simulations/ddr3-example.xml
+++ b/DRAMSys/simulator/resources/simulations/ddr3-example.xml
@@ -4,8 +4,7 @@
-
-
+
diff --git a/DRAMSys/simulator/resources/simulations/sim-batch.xml b/DRAMSys/simulator/resources/simulations/sim-batch.xml
index b356d01c..aaaba0a9 100644
--- a/DRAMSys/simulator/resources/simulations/sim-batch.xml
+++ b/DRAMSys/simulator/resources/simulations/sim-batch.xml
@@ -4,8 +4,7 @@
-
-
+
diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp
index 4959d5a7..975cc7a0 100644
--- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp
+++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp
@@ -136,25 +136,28 @@ void Configuration::setParameter(std::string name, std::string value)
DatabaseRecording = string2bool(value);
else if(name == "PowerAnalysis")
PowerAnalysis = string2bool(value);
- else if (name == "PowerWindowSize")
- PowerWindowSize = std::stod(value.c_str());
- else if (name == "PowerWindowUnit")
- PowerWindowUnit = string2TimeUnit(value);
+ else if (name == "NumberOfTimeWindows") {
+ if(string2int(value) < 1) {
+ SC_REPORT_FATAL("Configuration", ("Invalid value for parameter " + name + ". This parameter must be at least one.").c_str());
+ throw;
+ }
+ NumberOfTimeWindows = string2int(value);
+ }
else if(name == "Debug")
Debug = string2bool(value);
else if (name == "NumberOfTracePlayers")
NumberOfTracePlayers = string2int(value);
else if (name == "NumberOfMemChannels") {
NumberOfMemChannels = string2int(value);
- unsigned int maxNumberofMemChannels = xmlAddressDecoder::getInstance().amount["channel"];
- if (NumberOfMemChannels > maxNumberofMemChannels) {
+ unsigned int maxNumberofMemChannels = xmlAddressDecoder::getInstance().amount["channel"];
+ if (NumberOfMemChannels > maxNumberofMemChannels) {
SC_REPORT_FATAL("Configuration", ("Invalid value for parameter "
+ name
+ ". Value is out of range. The maximum value according to "
+ "the address mapping configuration file is "
+ std::to_string(maxNumberofMemChannels) + ".").c_str());
throw;
- }
+ }
}
else if (name == "ControllerCoreDisableRefresh")
ControllerCoreDisableRefresh = string2bool(value);
diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.h b/DRAMSys/simulator/src/controller/core/configuration/Configuration.h
index e6abb2ae..450e7bde 100644
--- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.h
+++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.h
@@ -75,8 +75,8 @@ struct Configuration
//SimConfig
bool DatabaseRecording = true;
bool PowerAnalysis = false;
- double PowerWindowSize;
- enum sc_time_unit PowerWindowUnit;
+ sc_time TraceLength;
+ unsigned int NumberOfTimeWindows;
bool Debug = false;
unsigned int NumberOfTracePlayers = 1;
unsigned int NumberOfMemChannels = 1;
diff --git a/DRAMSys/simulator/src/simulation/Dram.h b/DRAMSys/simulator/src/simulation/Dram.h
index ed5152b0..47c7625e 100644
--- a/DRAMSys/simulator/src/simulation/Dram.h
+++ b/DRAMSys/simulator/src/simulation/Dram.h
@@ -67,9 +67,7 @@ struct Dram : sc_module
// Power Model related
bool powerAnalysis = Configuration::getInstance().PowerAnalysis;
- double pWindowSize = Configuration::getInstance().PowerWindowSize;
- enum sc_time_unit pWindowUnit = Configuration::getInstance().PowerWindowUnit;
- sc_time powerWindowSize = sc_time(pWindowSize, pWindowUnit);
+ sc_time powerWindowSize = Configuration::getInstance().TraceLength/Configuration::getInstance().NumberOfTimeWindows;
libDRAMPower *DRAMPower;
double totalEnergy = 0;
double sumOfEnergyWindows = 0;
@@ -230,10 +228,10 @@ struct Dram : sc_module
double currentAveragePower = 0;
double currentTotalEnergy = 0;
- do
- {
+ do {
DRAMPower->updateCounters(false);
DRAMPower->calcEnergy();
+
currentTotalEnergy = DRAMPower->getEnergy().total_energy - totalEnergy;
currentAveragePower = currentTotalEnergy/powerWindowSize.value();
tlmRecorder->recordPower(sc_time_stamp(),currentAveragePower);
diff --git a/DRAMSys/simulator/src/simulation/Simulation.cpp b/DRAMSys/simulator/src/simulation/Simulation.cpp
index d889e233..750439db 100644
--- a/DRAMSys/simulator/src/simulation/Simulation.cpp
+++ b/DRAMSys/simulator/src/simulation/Simulation.cpp
@@ -121,11 +121,15 @@ void Simulation::instantiateModules(const string &traceName, const string &pathT
// or if you simply dont care about the data the normal StlPlayer is used.
if(Configuration::getInstance().ErrorStoreMode == ErrorStorageMode::NoStorage)
{
- player = new StlPlayer<>(playerStr.c_str(), pathToResources + string("traces/") + devices[i].trace, devices[i].clkMhz, this);
+ StlPlayer<> *newPlayer = new StlPlayer<>(playerStr.c_str(), pathToResources + string("traces/") + devices[i].trace, devices[i].clkMhz, this);
+ player = newPlayer;
+ newPlayer->getTraceLength(pathToResources + string("traces/") + devices[i].trace);
}
else
{
- player = new StlDataPlayer<>(playerStr.c_str(), pathToResources + string("traces/") + devices[i].trace, devices[i].clkMhz, this);
+ StlDataPlayer<> *newPlayer = new StlDataPlayer<>(playerStr.c_str(), pathToResources + string("traces/") + devices[i].trace, devices[i].clkMhz, this);
+ player = newPlayer;
+ newPlayer->getTraceLength(pathToResources + string("traces/") + devices[i].trace);
}
players.push_back(player);
}
@@ -177,7 +181,7 @@ Simulation::~Simulation()
}
for (auto rec : tlmRecorders) {
- delete rec;
+ delete rec;
}
}
@@ -189,7 +193,7 @@ void Simulation::start()
report(" -> memspec: \t\t" + Configuration::getInstance().memSpec.MemoryId);
cout << endl;
simulationStartTime = clock();
-
+
for (auto player : players) {
player->nextPayload();
}
diff --git a/DRAMSys/simulator/src/simulation/StlDataPlayer.h b/DRAMSys/simulator/src/simulation/StlDataPlayer.h
index d4b55638..06c253d7 100644
--- a/DRAMSys/simulator/src/simulation/StlDataPlayer.h
+++ b/DRAMSys/simulator/src/simulation/StlDataPlayer.h
@@ -134,6 +134,50 @@ public:
}
}
+ void getTraceLength(string pathToTrace)
+ {
+ ifstream newFile;
+ newFile.open(pathToTrace);
+ if(newFile.is_open()) {
+ newFile.seekg(-1,ios_base::end);// go to one spot before the EOF
+ char ch;
+ newFile.get(ch);
+
+ if(ch == file.eof())
+ SC_REPORT_FATAL(0, (string("Empty Trace ") + pathToTrace).c_str());
+
+ if(ch == '\n')
+ newFile.seekg(-2,ios_base::end);
+
+ bool keepLooping = true;
+ while(keepLooping) {
+
+ newFile.get(ch); // Get current byte's data
+
+ if((int)newFile.tellg() <= 1) { // If the data was at or before the 0th byte
+ newFile.seekg(0); // The first line is the last line
+ keepLooping = false; // So stop there
+ }
+ else if(ch == '\n') { // If the data was a newline
+ keepLooping = false; // Stop at the current position.
+ }
+ else { // If the data was neither a newline nor at the 0 byte
+ newFile.seekg(-2,ios_base::cur); // Move to the front of that data, then to the front of the data before it
+ }
+ }
+
+ string lastLine;
+ getline(newFile,lastLine); // Read the current line
+ std::istringstream iss(lastLine);
+ string time;
+ iss >> time;
+ Configuration::getInstance().TraceLength = std::stoull(time.c_str())*clk;
+ newFile.close();
+ }
+
+ }
+
+
private:
ifstream file;
unsigned int burstlength;
diff --git a/DRAMSys/simulator/src/simulation/StlPlayer.h b/DRAMSys/simulator/src/simulation/StlPlayer.h
index 918eae84..92038aad 100644
--- a/DRAMSys/simulator/src/simulation/StlPlayer.h
+++ b/DRAMSys/simulator/src/simulation/StlPlayer.h
@@ -120,6 +120,52 @@ public:
}
}
+
+
+ void getTraceLength(string pathToTrace)
+ {
+ ifstream newFile;
+ newFile.open(pathToTrace);
+ if(newFile.is_open()) {
+ newFile.seekg(-1,ios_base::end);// go to one spot before the EOF
+ char ch;
+ newFile.get(ch);
+
+ if(ch == file.eof())
+ SC_REPORT_FATAL(0, (string("Empty Trace ") + pathToTrace).c_str());
+
+ if(ch == '\n')
+ newFile.seekg(-2,ios_base::end);
+
+ bool keepLooping = true;
+ while(keepLooping) {
+
+ newFile.get(ch); // Get current byte's data
+
+ if((int)newFile.tellg() <= 1) { // If the data was at or before the 0th byte
+ newFile.seekg(0); // The first line is the last line
+ keepLooping = false; // So stop there
+ }
+ else if(ch == '\n') { // If the data was a newline
+ keepLooping = false; // Stop at the current position.
+ }
+ else { // If the data was neither a newline nor at the 0 byte
+ newFile.seekg(-2,ios_base::cur); // Move to the front of that data, then to the front of the data before it
+ }
+ }
+
+ string lastLine;
+ getline(newFile,lastLine); // Read the current line
+ std::istringstream iss(lastLine);
+ string time;
+ iss >> time;
+ Configuration::getInstance().TraceLength = std::stoull(time.c_str())*clk;
+ newFile.close();
+ }
+
+ }
+
+
private:
ifstream file;
unsigned int burstlength;
diff --git a/README.md b/README.md
index 84a10c31..8e841423 100644
--- a/README.md
+++ b/README.md
@@ -319,8 +319,7 @@ The DRAMSys' main configuration file is presented below.
-
-
+
@@ -419,8 +418,7 @@ The XML code below shows a typic configuration:
-
-
+
@@ -532,15 +530,8 @@ Below are listed the configuration sections and configuration fields.
- *PowerAnalysis* (boolean)
- "1": enables live power analysis with the DRAMPower tool
- "0": disables power analysis
- - *PowerWindowSize* (double)
- - Size of the time window used to evaluate averate power consumption
- - *PowerWindowUnit* (string)
- - "s": seconds
- - "ms": millisecond
- - "us": microseconds
- - "ns": nanoseconds
- - "ps": picoseconds
- - "fs": femtoseconds
+ - *NumberOfTimeWindows* (int)
+ - number of time windows used to evaluate average bandwidth and average power consumption
- *NumberOfTracePlayers* (unsigned int)
- Number of trace players
- *NumberOfMemChannels* (unsigned int)