powerdown manager. simulation manager introduced

This commit is contained in:
Janik Schlemminger
2014-04-05 12:18:34 +02:00
parent 0e07876071
commit 2145f3b18c
43 changed files with 823 additions and 956 deletions

View File

@@ -0,0 +1,85 @@
/*
* SimulationManager.cpp
*
* Created on: Apr 4, 2014
* Author: jonny
*/
#include "SimulationManager.h"
#include "../common/TlmRecorder.h"
#include "../common/DebugManager.h"
#include "../common/xmlAddressdecoder.h"
#include "../core/ControllerCore.h"
#include <stdlib.h>
#include <iostream>
#include <vector>
using namespace std;
namespace simulation {
SimulationManager::SimulationManager(sc_module_name name, std::string stl1, std::string stl2,
std::string traceName, std::string pathToResources) :
dram("dram"), arbiter("arbiter"), controller("controller"), player1("player1",
pathToResources + string("traces/") + stl1, this), player2("player2",
pathToResources + string("traces/") + stl2, this), traceName(traceName)
{
SC_THREAD(terminationThread);
xmlAddressDecoder::addressConfigURI = pathToResources + string("configs/addressConfig.xml");
TlmRecorder::dbName = traceName;
TlmRecorder::sqlScriptURI = pathToResources + string("scripts/createTraceDB.sql");
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;
whiteList.push_back(controller.name());
whiteList.push_back(player2.name());
whiteList.push_back(player1.name());
whiteList.push_back(TlmRecorder::senderName);
whiteList.push_back(ControllerCore::senderName);
whiteList.push_back(PowerDownManager::senderName);
DebugManager::getInstance().addToWhiteList(whiteList);
}
void SimulationManager::startSimulation()
{
clock_t begin = clock();
cout << "Toplevel: simulation start" << std::endl;
sc_start();
clock_t end = clock();
double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
cout << "Simulation took " << elapsed_secs << " seconds." << endl;
cout << this->name();
string p = getenv("trace");
string run_tpr = p + " " + traceName;
system(run_tpr.c_str());
}
void SimulationManager::tracePlayerFinishedCallback()
{
static int finishedPlayers = 0;
finishedPlayers++;
if (finishedPlayers == numberOfTracePlayers)
{
terminateSimulation.notify();
}
}
void SimulationManager::terminationThread()
{
wait(terminateSimulation);
controller.terminateSimulation();
//waits for the termination of all pending powerdown phases in the dram system
wait(sc_time(50,SC_NS));
TlmRecorder::getInstance().closeConnection();
sc_stop();
}
} /* namespace simulation */