diff --git a/dram/.settings/language.settings.xml b/dram/.settings/language.settings.xml index 26f9f756..d60268a9 100644 --- a/dram/.settings/language.settings.xml +++ b/dram/.settings/language.settings.xml @@ -4,7 +4,7 @@ - + @@ -14,7 +14,7 @@ - + diff --git a/dram/resources/configs/addressConfig.xml b/dram/resources/configs/amconfigs/am_ddr4.xml similarity index 100% rename from dram/resources/configs/addressConfig.xml rename to dram/resources/configs/amconfigs/am_ddr4.xml diff --git a/dram/resources/configs/amconfigs/am_wideio.xml b/dram/resources/configs/amconfigs/am_wideio.xml new file mode 100755 index 00000000..7494e586 --- /dev/null +++ b/dram/resources/configs/amconfigs/am_wideio.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + diff --git a/dram/resources/simulations/first.xml b/dram/resources/simulations/first.xml index 91776355..44906c04 100644 --- a/dram/resources/simulations/first.xml +++ b/dram/resources/simulations/first.xml @@ -1,13 +1,19 @@ MICRON_4Gb_DDR4-1866_8bit_A.xml + am_wideio.xml memconfig.xml - + fifo.xml + fr_fcfs_unaware.xml - + chstone-mips_32.stl + + + chstone-adpcm_32.stl + empty.stl + empty.stl empty.stl diff --git a/dram/src/common/DebugManager.cpp b/dram/src/common/DebugManager.cpp index 2fcad46a..a79c245d 100644 --- a/dram/src/common/DebugManager.cpp +++ b/dram/src/common/DebugManager.cpp @@ -16,7 +16,7 @@ void DebugManager::printDebugMessage(string sender, string message) if (writeToConsole) cout << " at " << sc_time_stamp() << "\t in " << sender << "\t: " << message << endl; - if (writeToFile) + if (writeToFile && debugFile) debugFile << " at " << sc_time_stamp() << " in " << sender << "\t: " << message << "\n"; } #endif @@ -36,7 +36,6 @@ void DebugManager::addToWhiteList(vector senders) DebugManager::DebugManager() : writeToConsole(true), writeToFile(true) { - debugFile.open("debug.txt"); } void DebugManager::setDebugFile(std::string filename) diff --git a/dram/src/common/TlmRecorder.cpp b/dram/src/common/TlmRecorder.cpp index d00a3856..84fb4f2c 100644 --- a/dram/src/common/TlmRecorder.cpp +++ b/dram/src/common/TlmRecorder.cpp @@ -255,6 +255,5 @@ void TlmRecorder::closeConnection() printDebugMessage("tlmPhaseRecorder:\tEnd Recording"); sqlite3_close(db); db = NULL; - std::cout<<"connection closed"< +constexpr const char headline[] = "========================================================="; + template Val getElementFromMap(std::map& m, Key key) { @@ -39,16 +41,19 @@ bool isIn(const T& value, const std::vector& collection) return false; } -static inline void loadbar(unsigned int x, unsigned int n, unsigned int w = 50, unsigned int granularity=1) +static inline void loadbar(unsigned int x, unsigned int n, unsigned int w = 50, unsigned int granularity = 1) { - if ( (x != n) && (x % (n/100*granularity) != 0) ) return; + if ((x != n) && (x % (n / 100 * granularity) != 0)) + return; - float ratio = x/(float)n; - unsigned int c = (ratio * w); - std::cout << std::setw(3) << round(ratio*100) << "% ["; - for (unsigned int x=0; x using namespace std; @@ -22,9 +23,8 @@ MemoryManager::~MemoryManager() delete payload; numberOfFrees++; } - cout << "Memory Manager: Number of allocated payloads: " << numberOfAllocations << std::endl; - cout << "Memory Manager: Number of freed payloads: " << numberOfFrees << std::endl; - + DebugManager::getInstance().printDebugMessage("MemomryManager","Number of allocated payloads: " + to_string(numberOfAllocations)); + DebugManager::getInstance().printDebugMessage("MemomryManager","Number of freed payloads: " + to_string(numberOfFrees)); } gp* MemoryManager::allocate() diff --git a/dram/src/simulation/Simulation.cpp b/dram/src/simulation/Simulation.cpp index f2f6f7ab..77ee2b98 100644 --- a/dram/src/simulation/Simulation.cpp +++ b/dram/src/simulation/Simulation.cpp @@ -20,31 +20,8 @@ using namespace std; namespace simulation { -Simulation::Simulation(string name, string pathToResources, string traceName, DramSetup setup, - std::vector 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; - - //setup dram - dram = new Dram<>("dram"); - arbiter = new Arbiter("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); - - - player1->iSocket.bind(arbiter->tSockets[0]); - player2->iSocket.bind(arbiter->tSockets[1]); - arbiter->iSocket.bind(controller->tSocket); - controller->iSocket.bind(dram->tSocket); - vector whiteList; if (!silent) { @@ -56,7 +33,6 @@ Simulation::Simulation(string name, string pathToResources, string traceName, Dr whiteList.push_back(ControllerCore::senderName); whiteList.push_back(PowerDownManagerBankwise::senderName); } - auto& dbg = DebugManager::getInstance(); dbg.addToWhiteList(whiteList); dbg.setDebugFile(traceName + ".txt"); @@ -65,12 +41,44 @@ Simulation::Simulation(string name, string pathToResources, string traceName, Dr dbg.writeToConsole = false; dbg.writeToFile = false; } +} + +Simulation::Simulation(string name, string pathToResources, string traceName, DramSetup setup, std::vector devices, + bool silent) : + traceName(traceName), senderName(name), dramSetup(setup) + +{ + 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; + + dram = new Dram<>("dram"); + arbiter = new Arbiter("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); + + 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() @@ -80,16 +88,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<start(); player2->start(); - sc_set_stop_mode(SC_STOP_FINISH_DELTA); + player3->start(); + player4->start(); sc_start(); } @@ -97,22 +112,27 @@ void inline Simulation::transactionFinished() { remainingTransactions--; loadbar(totalTransactions - remainingTransactions, totalTransactions); - if(remainingTransactions == 0) + if (remainingTransactions == 0) { + cout<terminateSimulation(); - DebugManager::getInstance().printDebugMessage(senderName, "Terminating simulation"); 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(senderName, message); + cout << message << endl; } unsigned int Simulation::getNumberOfLines(string uri) diff --git a/dram/src/simulation/Simulation.h b/dram/src/simulation/Simulation.h index 87eae6d5..7b1bbd07 100644 --- a/dram/src/simulation/Simulation.h +++ b/dram/src/simulation/Simulation.h @@ -21,9 +21,10 @@ namespace simulation { struct DramSetup { DramSetup():memconfig(""),memspec(""){} - DramSetup(std::string memconfig, std::string memspec) : memconfig(memconfig), memspec(memspec) {} + DramSetup(std::string memconfig, std::string memspec, std::string addressmapping) : memconfig(memconfig), memspec(memspec), addressmapping(addressmapping) {} std::string memconfig; std::string memspec; + std::string addressmapping; }; struct Device @@ -47,22 +48,29 @@ public: void stop(); void inline transactionFinished() override; + constexpr static unsigned int NumberOfTracePlayers = 4; private: - constexpr static unsigned int numberOfTracePlayers = 2; std::string traceName; std::string senderName; + DramSetup dramSetup; + Dram<> *dram; - Arbiter *arbiter; + Arbiter *arbiter; Controller<> *controller; TracePlayer<> *player1; TracePlayer<> *player2; + TracePlayer<> *player3; + TracePlayer<> *player4; unsigned int totalTransactions; unsigned int remainingTransactions; clock_t simulationStartTime; unsigned int getNumberOfLines(string uri); + + void report(std::string message); + void setupDebugManager(bool silent, const string& traceName); }; } /* namespace simulation */ diff --git a/dram/src/simulation/SimulationManager.cpp b/dram/src/simulation/SimulationManager.cpp index ce16d9d9..9599bf95 100644 --- a/dram/src/simulation/SimulationManager.cpp +++ b/dram/src/simulation/SimulationManager.cpp @@ -25,19 +25,47 @@ SimulationManager::~SimulationManager() void SimulationManager::loadSimulationFromXML(string uri) { - simulationName = getFileName(uri); - + cout << "\n\nLoad Simulation-Batch:"< load simulation from .."< parsing simulation object .."< checking paths .."< simulation loaded successfully!\n"<FirstChildElement("memspec")->GetText(); + string addressmappingUri = simulation->FirstChildElement("addressmapping")->GetText(); for (XMLElement* element = simulation->FirstChildElement("memconfigs")->FirstChildElement("memconfig"); element != NULL; element = element->NextSiblingElement("memconfig")) { - dramSetups.push_back(DramSetup(element->GetText(), memspecUri)); + dramSetups.push_back(DramSetup(element->GetText(), memspecUri, addressmappingUri)); } for (XMLElement* element = simulation->FirstChildElement("trace-setups")->FirstChildElement("trace-setup"); element != NULL; @@ -45,23 +73,6 @@ void SimulationManager::loadSimulationFromXML(string uri) { addTraceSetup(element); } - - checkPaths(); -} - -void SimulationManager::runSimulations() -{ - system(string("mkdir " + simulationName).c_str()); - printSimulationBatch(); - int i = 0; - for (auto dramSetup : dramSetups) - { - for (auto traceSetup : traceSetups) - { - i++; - runSimulation(simulationName+"/tpr" + to_string(i) + ".tdb", dramSetup, traceSetup); - } - } } void SimulationManager::checkPaths() @@ -75,7 +86,7 @@ void SimulationManager::runSimulation(string traceName, DramSetup dramSetup, vec int status = 0; if (pid == 0) { - Simulation* simulation = new Simulation("sim", resources, traceName, dramSetup, traceSetup); + Simulation* simulation = new Simulation("sim", resources, traceName, dramSetup, traceSetup, silent); simulation->start(); delete simulation; _Exit(0); @@ -84,27 +95,10 @@ void SimulationManager::runSimulation(string traceName, DramSetup dramSetup, vec waitpid(pid, &status, 0); } -void SimulationManager::printSimulationBatch() -{ - cout << "Simulation Batch:\n##################" << endl; - for (DramSetup& s : dramSetups) - { - cout << s.memspec << " - " << s.memconfig << endl; - } - cout << endl; - for (vector& s : traceSetups) - { - cout << "Simulation:\n"; - for (Device d : s) - cout << "\t(" << d.burstLength << ") " << d.trace << ";" << endl; - cout << endl; - } -} - void SimulationManager::startTraceAnalyzer() { string p = getenv("trace"); - string run_tpr = p + " -f " + simulationName; + string run_tpr = p + " -f " + simulationName + "&"; system(run_tpr.c_str()); } @@ -115,7 +109,34 @@ void SimulationManager::addTraceSetup(tinyxml2::XMLElement* element) { devices.push_back(Device(device->GetText(), device->IntAttribute("bl"))); } - traceSetups.push_back(devices); + while(devices.size()Attribute("id"), devices); +} + +void SimulationManager::report(string message) +{ + //DebugManager::getInstance().printDebugMessage("Simulation Manager", message); + //if (DebugManager::getInstance().writeToConsole == false) + cout << message << endl; +} + +void SimulationManager::printSimulationBatch() +{ + for (DramSetup& s : dramSetups) + { + cout << s.memspec << " - " << s.memconfig << endl; + } + cout << endl; + for (auto& s : traceSetups) + { + cout << "trace-setup " + s.first + ":\n"; + for (Device d : s.second) + cout << "\t(" << d.burstLength << ") " << d.trace << ";" << endl; + cout << endl; + } } } diff --git a/dram/src/simulation/SimulationManager.h b/dram/src/simulation/SimulationManager.h index 122e1e2e..185c4bf9 100644 --- a/dram/src/simulation/SimulationManager.h +++ b/dram/src/simulation/SimulationManager.h @@ -10,6 +10,7 @@ #include #include +#include #include "Simulation.h" #include "../common/third_party/tinyxml2.h" @@ -25,17 +26,21 @@ public: void runSimulations(); void startTraceAnalyzer(); + bool silent = false; private: std::string simulationName; std::vector dramSetups; - std::vector> traceSetups; + std::map> traceSetups; std::string resources; void runSimulation(std::string traceName, DramSetup dramSetup, std::vector traceSetup); void addTraceSetup(tinyxml2::XMLElement* element); + void parseXML(tinyxml2::XMLDocument& doc); void checkPaths(); void printSimulationBatch(); + + void report(std::string message); }; } /* namespace simulation */ diff --git a/dram/src/simulation/main.cpp b/dram/src/simulation/main.cpp index 340881f9..822db596 100644 --- a/dram/src/simulation/main.cpp +++ b/dram/src/simulation/main.cpp @@ -39,6 +39,7 @@ int sc_main(int argc, char **argv) SimulationManager manager(resources); manager.loadSimulationFromXML(resources + "/simulations/" + simulationToRun); + manager.silent = true; manager.runSimulations(); manager.startTraceAnalyzer();