This commit is contained in:
robert
2014-04-13 11:54:01 +02:00
17 changed files with 293 additions and 173 deletions

View File

@@ -20,31 +20,8 @@ using namespace std;
namespace simulation {
Simulation::Simulation(string name, string pathToResources, string traceName, DramSetup setup,
std::vector<Device> devices, bool silent) :
traceName(traceName), senderName(name)
void Simulation::setupDebugManager(bool silent, const string& traceName)
{
xmlAddressDecoder::addressConfigURI = pathToResources + string("configs/addressConfig.xml");
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");
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);
TlmRecorder::getInstance().recordTracenames(devices[0].trace + "," + devices[1].trace);
player1->iSocket.bind(arbiter->tSockets[0]);
player2->iSocket.bind(arbiter->tSockets[1]);
arbiter->iSocket.bind(controller->tSocket);
controller->iSocket.bind(dram->tSocket);
vector<string> whiteList;
if (!silent)
@@ -52,12 +29,11 @@ Simulation::Simulation(string name, string pathToResources, string traceName, Dr
whiteList.push_back(controller->name());
whiteList.push_back(player2->name());
whiteList.push_back(player1->name());
whiteList.push_back(this->senderName);
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");
@@ -66,12 +42,49 @@ Simulation::Simulation(string name, string pathToResources, string traceName, Dr
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)
{
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);
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->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);
setupDebugManager(silent, traceName);
totalTransactions = getNumberOfLines(pathToResources + string("traces/") + devices[0].trace);
totalTransactions += getNumberOfLines(pathToResources + string("traces/") + devices[1].trace);
cout << "Total transactions: " << totalTransactions << endl;
remainingTransactions = totalTransactions;
totalTransactions += getNumberOfLines(pathToResources + string("traces/") + devices[2].trace);
totalTransactions += getNumberOfLines(pathToResources + string("traces/") + devices[3].trace);
remainingTransactions = totalTransactions;
}
Simulation::~Simulation()
@@ -81,15 +94,23 @@ Simulation::~Simulation()
delete controller;
delete player1;
delete player2;
delete player3;
delete player4;
}
void Simulation::start()
{
cout << "Starting simulation:" << endl;
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();
DebugManager::getInstance().printDebugMessage(senderName, "Starting simulation");
player1->start();
player2->start();
player3->start();
player4->start();
sc_set_stop_mode(SC_STOP_FINISH_DELTA);
sc_start();
}
@@ -98,22 +119,29 @@ void inline Simulation::transactionFinished()
{
remainingTransactions--;
loadbar(totalTransactions - remainingTransactions, totalTransactions);
if(remainingTransactions == 0)
if (remainingTransactions == 0)
{
stop();
cout << endl;
terminateSimulation.notify();
}
}
void Simulation::stop()
{
wait(terminateSimulation);
report("\nTerminating simulation");
controller->terminateSimulation();
DebugManager::getInstance().printDebugMessage(senderName, "Terminating simulation");
wait(sc_time(50, SC_NS));
TlmRecorder::getInstance().closeConnection();
sc_stop();
double elapsed_secs = double(clock() - simulationStartTime) / CLOCKS_PER_SEC;
DebugManager::getInstance().printDebugMessage(senderName, "Simulation took " + to_string(elapsed_secs) + " seconds");
cout << "\nSimulation took: " << (elapsed_secs) << endl;
report("Simulation took " + to_string(elapsed_secs) + " seconds");
}
void Simulation::report(string message)
{
DebugManager::getInstance().printDebugMessage(this->name(), message);
cout << message << endl;
}
unsigned int Simulation::getNumberOfLines(string uri)