changed scheduler interface. Fixed bug with terminateSimulation
This commit is contained in:
@@ -20,45 +20,64 @@ using namespace std;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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) :
|
||||
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);
|
||||
|
||||
setupTlmRecorder(traceName, pathToResources, setup, devices);
|
||||
instantiateModules(pathToResources, devices);
|
||||
bindSockets();
|
||||
setupDebugManager(traceName);
|
||||
calculateNumberOfTransaction(devices, pathToResources);
|
||||
}
|
||||
|
||||
|
||||
void Simulation::setupDebugManager(const string& traceName)
|
||||
{
|
||||
auto& dbg = DebugManager::getInstance();
|
||||
|
||||
dbg.addToWhiteList(controller->name());
|
||||
dbg.addToWhiteList(player2->name());
|
||||
dbg.addToWhiteList(player1->name());
|
||||
dbg.addToWhiteList(this->name());
|
||||
dbg.addToWhiteList(TlmRecorder::senderName);
|
||||
dbg.addToWhiteList(ControllerCore::senderName);
|
||||
dbg.addToWhiteList(PowerDownManagerBankwise::senderName);
|
||||
|
||||
dbg.writeToConsole = true;
|
||||
dbg.writeToFile = true;
|
||||
if(dbg.writeToFile)
|
||||
dbg.openDebugFile(traceName + ".txt");
|
||||
}
|
||||
|
||||
void Simulation::setupTlmRecorder(const string &traceName, const string &pathToResources, const DramSetup &setup, const std::vector<Device> &devices)
|
||||
{
|
||||
if(Configuration::getInstance().databaseRecordingEnabled)
|
||||
{
|
||||
TlmRecorder::recordingEnabled = true;
|
||||
TlmRecorder::dbName = traceName;
|
||||
TlmRecorder::sqlScriptURI = pathToResources + string("scripts/createTraceDB.sql");
|
||||
TlmRecorder::getInstance().recordMemconfig(setup.memconfig);
|
||||
TlmRecorder::getInstance().recordMemspec(setup.memspec);
|
||||
TlmRecorder::getInstance().recordTracenames(devices[0].trace + "," + devices[1].trace + "," + devices[2].trace + "," + devices[3].trace);
|
||||
}
|
||||
else
|
||||
{
|
||||
TlmRecorder::recordingEnabled = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Simulation::instantiateModules(const string &pathToResources, const std::vector<Device>& devices)
|
||||
{
|
||||
dram = new Dram<>("dram");
|
||||
arbiter = new Arbiter<NumberOfTracePlayers, 128>("arbiter");
|
||||
controller = new Controller<>("controller");
|
||||
@@ -67,23 +86,24 @@ Simulation::Simulation(sc_module_name name, string pathToResources, string trace
|
||||
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);
|
||||
}
|
||||
|
||||
void Simulation::bindSockets()
|
||||
{
|
||||
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);
|
||||
|
||||
void Simulation::calculateNumberOfTransaction(std::vector<Device> devices, string pathToResources)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -129,9 +149,8 @@ void Simulation::stop()
|
||||
{
|
||||
wait(terminateSimulation);
|
||||
report("\nTerminating simulation");
|
||||
wait(sc_time(50, SC_NS));
|
||||
controller->terminateSimulation();
|
||||
wait(sc_time(50, SC_NS));
|
||||
wait(sc_time(200, SC_NS));
|
||||
TlmRecorder::getInstance().closeConnection();
|
||||
sc_stop();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user