changed project structure to qtcreator, added timed out powerdown

This commit is contained in:
robert
2014-05-07 17:22:20 +02:00
parent 00f95b1587
commit c5512389da
114 changed files with 2324 additions and 9246 deletions

View File

@@ -9,7 +9,7 @@
#include "../common/TlmRecorder.h"
#include "../common/DebugManager.h"
#include "../common/xmlAddressdecoder.h"
#include "../core/ControllerCore.h"
#include "../controller/core/ControllerCore.h"
#include <stdlib.h>
#include <iostream>
#include <fstream>
@@ -23,135 +23,135 @@ namespace simulation {
void Simulation::setupDebugManager(bool silent, const string& traceName)
{
vector<string> whiteList;
if (!silent)
{
whiteList.push_back(controller->name());
whiteList.push_back(player2->name());
whiteList.push_back(player1->name());
whiteList.push_back(this->name());
whiteList.push_back(TlmRecorder::senderName);
whiteList.push_back(ControllerCore::senderName);
whiteList.push_back(PowerDownManagerBankwise::senderName);
}
auto& dbg = DebugManager::getInstance();
dbg.addToWhiteList(whiteList);
dbg.setDebugFile(traceName + ".txt");
if (silent)
{
dbg.writeToConsole = false;
dbg.writeToFile = false;
}
vector<string> whiteList;
if (!silent)
{
whiteList.push_back(controller->name());
whiteList.push_back(player2->name());
whiteList.push_back(player1->name());
whiteList.push_back(this->name());
whiteList.push_back(TlmRecorder::senderName);
whiteList.push_back(ControllerCore::senderName);
whiteList.push_back(PowerDownManagerBankwise::senderName);
}
auto& dbg = DebugManager::getInstance();
dbg.addToWhiteList(whiteList);
dbg.setDebugFile(traceName + ".txt");
if (silent)
{
dbg.writeToConsole = false;
dbg.writeToFile = false;
}
}
Simulation::Simulation(sc_module_name name, string pathToResources, string traceName, DramSetup setup,
std::vector<Device> devices, bool silent) :
traceName(traceName), dramSetup(setup)
std::vector<Device> devices, bool silent) :
traceName(traceName), dramSetup(setup)
{
SC_THREAD(stop);
SC_THREAD(stop);
xmlAddressDecoder::addressConfigURI = pathToResources + string("configs/amconfigs/") + setup.addressmapping;
TlmRecorder::dbName = traceName;
TlmRecorder::sqlScriptURI = pathToResources + string("scripts/createTraceDB.sql");
Configuration::memconfigUri = pathToResources + string("configs/memconfigs/") + setup.memconfig;
Configuration::memspecUri = pathToResources + string("configs/memspecs/") + setup.memspec;
TlmRecorder::getInstance().recordMemconfig(setup.memconfig);
TlmRecorder::getInstance().recordMemspec(setup.memspec);
xmlAddressDecoder::addressConfigURI = pathToResources + string("configs/amconfigs/") + setup.addressmapping;
TlmRecorder::dbName = traceName;
TlmRecorder::sqlScriptURI = pathToResources + string("scripts/createTraceDB.sql");
Configuration::memconfigUri = pathToResources + string("configs/memconfigs/") + setup.memconfig;
Configuration::memspecUri = pathToResources + string("configs/memspecs/") + setup.memspec;
TlmRecorder::getInstance().recordMemconfig(setup.memconfig);
TlmRecorder::getInstance().recordMemspec(setup.memspec);
dram = new Dram<>("dram");
arbiter = new Arbiter<NumberOfTracePlayers, 128>("arbiter");
controller = new Controller<>("controller");
dram = new Dram<>("dram");
arbiter = new Arbiter<NumberOfTracePlayers, 128>("arbiter");
controller = new Controller<>("controller");
player1 = new TracePlayer<>("player1", pathToResources + string("traces/") + devices[0].trace, devices[0].burstLength, this);
player2 = new TracePlayer<>("player2", pathToResources + string("traces/") + devices[1].trace, devices[1].burstLength, this);
player3 = new TracePlayer<>("player3", pathToResources + string("traces/") + devices[2].trace, devices[2].burstLength, this);
player4 = new TracePlayer<>("player4", pathToResources + string("traces/") + devices[3].trace, devices[3].burstLength, this);
TlmRecorder::getInstance().recordTracenames(devices[0].trace + "," + devices[1].trace + "," + devices[2].trace + "," + devices[3].trace);
player1 = new TracePlayer<>("player1", pathToResources + string("traces/") + devices[0].trace, devices[0].burstLength, this);
player2 = new TracePlayer<>("player2", pathToResources + string("traces/") + devices[1].trace, devices[1].burstLength, this);
player3 = new TracePlayer<>("player3", pathToResources + string("traces/") + devices[2].trace, devices[2].burstLength, this);
player4 = new TracePlayer<>("player4", pathToResources + string("traces/") + devices[3].trace, devices[3].burstLength, this);
TlmRecorder::getInstance().recordTracenames(devices[0].trace + "," + devices[1].trace + "," + devices[2].trace + "," + devices[3].trace);
player1->iSocket.bind(arbiter->tSockets[0]);
player2->iSocket.bind(arbiter->tSockets[1]);
player3->iSocket.bind(arbiter->tSockets[2]);
player4->iSocket.bind(arbiter->tSockets[3]);
player1->iSocket.bind(arbiter->tSockets[0]);
player2->iSocket.bind(arbiter->tSockets[1]);
player3->iSocket.bind(arbiter->tSockets[2]);
player4->iSocket.bind(arbiter->tSockets[3]);
arbiter->iSocket.bind(controller->tSocket);
controller->iSocket.bind(dram->tSocket);
arbiter->iSocket.bind(controller->tSocket);
controller->iSocket.bind(dram->tSocket);
setupDebugManager(silent, traceName);
setupDebugManager(silent, traceName);
totalTransactions = getNumberOfLines(pathToResources + string("traces/") + devices[0].trace);
totalTransactions += getNumberOfLines(pathToResources + string("traces/") + devices[1].trace);
totalTransactions += getNumberOfLines(pathToResources + string("traces/") + devices[2].trace);
totalTransactions += getNumberOfLines(pathToResources + string("traces/") + devices[3].trace);
totalTransactions = getNumberOfLines(pathToResources + string("traces/") + devices[0].trace);
totalTransactions += getNumberOfLines(pathToResources + string("traces/") + devices[1].trace);
totalTransactions += getNumberOfLines(pathToResources + string("traces/") + devices[2].trace);
totalTransactions += getNumberOfLines(pathToResources + string("traces/") + devices[3].trace);
remainingTransactions = totalTransactions;
remainingTransactions = totalTransactions;
}
Simulation::~Simulation()
{
delete dram;
delete arbiter;
delete controller;
delete player1;
delete player2;
delete player3;
delete player4;
delete dram;
delete arbiter;
delete controller;
delete player1;
delete player2;
delete player3;
delete player4;
}
void Simulation::start()
{
report("\n\nStarting simulation:");
report(headline);
report(" -> setup: \t\t" + getFileName(traceName));
report(" -> memspec: \t\t" + Configuration::getInstance().MemoryId);
report(" -> transactions: \t" + to_string(totalTransactions));
cout << endl;
simulationStartTime = clock();
player1->start();
player2->start();
player3->start();
player4->start();
sc_set_stop_mode(SC_STOP_FINISH_DELTA);
sc_start();
report("\n\nStarting simulation:");
report(headline);
report(" -> setup: \t\t" + getFileName(traceName));
report(" -> memspec: \t\t" + Configuration::getInstance().MemoryId);
report(" -> transactions: \t" + to_string(totalTransactions));
cout << endl;
simulationStartTime = clock();
player1->start();
player2->start();
player3->start();
player4->start();
sc_set_stop_mode(SC_STOP_FINISH_DELTA);
sc_start();
}
void inline Simulation::transactionFinished()
{
remainingTransactions--;
loadbar(totalTransactions - remainingTransactions, totalTransactions);
if (remainingTransactions == 0)
{
cout << endl;
terminateSimulation.notify();
}
remainingTransactions--;
loadbar(totalTransactions - remainingTransactions, totalTransactions);
if (remainingTransactions == 0)
{
cout << endl;
terminateSimulation.notify();
}
}
void Simulation::stop()
{
wait(terminateSimulation);
report("\nTerminating simulation");
wait(sc_time(50, SC_NS));
controller->terminateSimulation();
wait(sc_time(50, SC_NS));
TlmRecorder::getInstance().closeConnection();
sc_stop();
wait(terminateSimulation);
report("\nTerminating simulation");
wait(sc_time(50, SC_NS));
controller->terminateSimulation();
wait(sc_time(50, SC_NS));
TlmRecorder::getInstance().closeConnection();
sc_stop();
double elapsed_secs = double(clock() - simulationStartTime) / CLOCKS_PER_SEC;
report("Simulation took " + to_string(elapsed_secs) + " seconds");
double elapsed_secs = double(clock() - simulationStartTime) / CLOCKS_PER_SEC;
report("Simulation took " + to_string(elapsed_secs) + " seconds");
}
void Simulation::report(string message)
{
DebugManager::getInstance().printDebugMessage(this->name(), message);
cout << message << endl;
DebugManager::getInstance().printDebugMessage(this->name(), message);
cout << message << endl;
}
unsigned int Simulation::getNumberOfLines(string uri)
{
std::ifstream file(uri);
file.unsetf(std::ios_base::skipws); // new lines will be skipped unless we stop it from happening:
// count the newlines with an algorithm specialized for counting:
unsigned lineCount = std::count(std::istream_iterator<char>(file), std::istream_iterator<char>(), '\n');
return lineCount;
std::ifstream file(uri);
file.unsetf(std::ios_base::skipws); // new lines will be skipped unless we stop it from happening:
// count the newlines with an algorithm specialized for counting:
unsigned lineCount = std::count(std::istream_iterator<char>(file), std::istream_iterator<char>(), '\n');
return lineCount;
}
} /* namespace simulation */