diff --git a/dram/resources/configs/amconfigs/am_wideio.xml b/dram/resources/configs/amconfigs/am_wideio.xml index fc29d918..781f4d1e 100755 --- a/dram/resources/configs/amconfigs/am_wideio.xml +++ b/dram/resources/configs/amconfigs/am_wideio.xml @@ -1,21 +1,9 @@ - - - - + - - + + diff --git a/dram/resources/simulations/sim-batch.xml b/dram/resources/simulations/sim-batch.xml index dce15a11..0d76672d 100644 --- a/dram/resources/simulations/sim-batch.xml +++ b/dram/resources/simulations/sim-batch.xml @@ -1,20 +1,29 @@ - -WideIO.xml - - am_wideio.xml - - - fifo.xml - - + + + + + + + + + + + + + + + + + + - + chstone-sha_32.stl - + - + diff --git a/dram/src/common/xmlAddressdecoder.cpp b/dram/src/common/xmlAddressdecoder.cpp index 4d1cab11..7771d118 100644 --- a/dram/src/common/xmlAddressdecoder.cpp +++ b/dram/src/common/xmlAddressdecoder.cpp @@ -5,15 +5,43 @@ using namespace std; using namespace tinyxml2; -string xmlAddressDecoder::addressConfigURI = ""; +//string xmlAddressDecoder::addressConfigURI = ""; +//tinyxml2::XMLElement* xmlAddressDecoder::addressMap = NULL; + +tinyxml2::XMLElement* xmlAddressDecoder::addressmapping = NULL; xmlAddressDecoder::xmlAddressDecoder(string addressConfigURI) { tinyxml2::XMLDocument doc; loadXML(addressConfigURI, doc); - tinyxml2::XMLElement* addressmap = doc.FirstChildElement("dramconfig")->FirstChildElement("addressmap"); + xmlAddressDecoder(doc.FirstChildElement("dramconfig")->FirstChildElement("addressmap")); +} + +xmlAddressDecoder::xmlAddressDecoder(XMLElement* addressmap) +{ + tinyxml2::XMLDocument doc; + //std::cout<<"fffffff"<Name()<Name()); + if( xmlNodeName != "addressmapping") + reportFatal("AddressDecorder", "addressmap node expected"); + + cout<Attribute("src")) + { + + + string src(addressmap->Attribute("src")); + std::cout<FirstChildElement(); child != NULL; child = child->NextSiblingElement()) { int from; diff --git a/dram/src/common/xmlAddressdecoder.h b/dram/src/common/xmlAddressdecoder.h index 3cd3d6fe..857114db 100755 --- a/dram/src/common/xmlAddressdecoder.h +++ b/dram/src/common/xmlAddressdecoder.h @@ -38,18 +38,32 @@ class xmlAddressDecoder { public: - static std::string addressConfigURI; - + //static std::string addressConfigURI; + //static tinyxml2::XMLElement* addressmapping; +static tinyxml2::XMLElement* addressmapping; static inline xmlAddressDecoder& getInstance() { - static xmlAddressDecoder decoder(xmlAddressDecoder::addressConfigURI); + //if(decoder==NULL) std::cout<<"ERROR: AddressDecoder has been called before initialization"< masks; std::map shifts; diff --git a/dram/src/controller/core/configuration/Configuration.cpp b/dram/src/controller/core/configuration/Configuration.cpp index 2915a755..bc85232d 100644 --- a/dram/src/controller/core/configuration/Configuration.cpp +++ b/dram/src/controller/core/configuration/Configuration.cpp @@ -14,6 +14,7 @@ using namespace std; namespace core{ string Configuration::memspecUri = ""; +string Configuration::memconfigUri = ""; Configuration::Configuration() { @@ -95,6 +96,8 @@ void Configuration::setParameter(std::string name, std::string value) DatabaseRecording = string2bool(value); else if(name == "PowerAnalysys") PowerAnalysys = string2bool(value); + else if(name == "Debug") + Debug = string2bool(value); else { SC_REPORT_FATAL("Configuration", ("Parameter " + name + " not defined in Configuration").c_str()); diff --git a/dram/src/controller/core/configuration/Configuration.h b/dram/src/controller/core/configuration/Configuration.h index 9487c91f..90b1d3d1 100644 --- a/dram/src/controller/core/configuration/Configuration.h +++ b/dram/src/controller/core/configuration/Configuration.h @@ -47,6 +47,7 @@ struct Configuration //SimConfig bool DatabaseRecording = true; bool PowerAnalysys = false; + bool Debug = false; //MemSpec(from DRAM-Power XML) MemSpec memSpec; diff --git a/dram/src/controller/core/configuration/ConfigurationLoader.cpp b/dram/src/controller/core/configuration/ConfigurationLoader.cpp index 0a5c8686..d373e42b 100644 --- a/dram/src/controller/core/configuration/ConfigurationLoader.cpp +++ b/dram/src/controller/core/configuration/ConfigurationLoader.cpp @@ -33,6 +33,36 @@ void ConfigurationLoader::loadMemConfig(Configuration& config, string memconfigU loadConfig(config, memconfig); } +void ConfigurationLoader::loadMemConfig(Configuration& config, XMLElement* memconfig) +{ + if(memconfig->Attribute("src")) + { + + XMLDocument doc; + + string src(memconfig->Attribute("src")); + std::cout<<"inner first"<Attribute("src")) + { + + XMLDocument doc; + + string src(simconfig->Attribute("src")); + std::cout<<"inner first"<Attribute("src")) + //{ + + XMLDocument doc; + + string src(memspec->Attribute("src")); + config.memspecUri = src; + std::cout<<"inner first"<Name()< #include #include "TracePlayerListener.h" +#include "../common/third_party/tinyxml2.h" struct DramSetup { - DramSetup():memconfig(""),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; + DramSetup():memspec(NULL),memconfig(NULL),simconfig(NULL),addressmapping(NULL){} + DramSetup(tinyxml2::XMLElement* memspec, tinyxml2::XMLElement* memconfig, tinyxml2::XMLElement* simconfig, tinyxml2::XMLElement* addressmapping) + : memspec(memspec), memconfig(memconfig), simconfig(simconfig), addressmapping(addressmapping) {} + tinyxml2::XMLElement* memspec; + tinyxml2::XMLElement* memconfig; + tinyxml2::XMLElement* simconfig; + tinyxml2::XMLElement* addressmapping; }; struct Device diff --git a/dram/src/simulation/SimulationManager.cpp b/dram/src/simulation/SimulationManager.cpp index 9f8d2d30..7cce0f65 100644 --- a/dram/src/simulation/SimulationManager.cpp +++ b/dram/src/simulation/SimulationManager.cpp @@ -24,28 +24,27 @@ SimulationManager::~SimulationManager() void SimulationManager::loadSimulationsFromXML(string uri) { - cout << "\n\nLoad Simulation-Batchs:" << endl; + cout << "\n\nload simulation-batch:" << endl; cout << headline << endl; - cout << "\t-> load simulations .." << endl; exportPath = getFileName(uri); - XMLDocument doc; - loadXML(uri, doc); + + loadXML(uri, simulationdoc); cout << "\t-> parsing simulation objects .." << endl; - for (XMLElement* element = doc.FirstChildElement("simulation"); element != NULL; - element = element->NextSiblingElement("simulation")) - { - parseSimulationBatch(element); - } + XMLElement* simulation = simulationdoc.FirstChildElement("simulation"); + string xmlNodeName(simulation->Name()); + if( xmlNodeName != "simulation") + reportFatal("SimulationManager", "simulation node expected"); + parseSimulationBatch(simulation); - cout << "\t-> checking paths .." << endl; - checkPaths(); + //cout << "\t-> checking paths .." << endl; + //checkPaths(); cout << "\t-> simulation batches loaded successfully!\n" << endl; - for (auto batch : simulationsBatches) + for (auto batch : simulationBatches) { batch.print(); } @@ -53,22 +52,22 @@ void SimulationManager::loadSimulationsFromXML(string uri) void SimulationManager::runSimulations() { - for (auto& batch : simulationsBatches) + for (auto& batch : simulationBatches) { - boost::filesystem::path dir(exportPath + "/" + batch.simulationName); + boost::filesystem::path dir(exportPath);// + "/" + batch.simulationName); boost::filesystem::create_directories(dir); for (auto& dramSetup : batch.dramSetups) { - string memconfig = getFileName(dramSetup.memconfig); - string memspec = getFileName(dramSetup.memspec); - string addressmappig = getFileName(dramSetup.addressmapping); + //string memconfig = getFileName(dramSetup.memconfig); + //string memspec = getFileName(dramSetup.memspec); + //string addressmappig = getFileName(dramSetup.addressmapping); for (auto& traceSetup : batch.traceSetups) { - runSimulation( - exportPath + "/" + batch.simulationName + "/" + traceSetup.first + "-" + memspec + "-" + - memconfig + ".tdb", dramSetup, traceSetup.second); + // string exportname = exportPath + "/" + batch.simulationName + "/" + traceSetup.first + ".tdb"; + string exportname = exportPath + "/" + traceSetup.first + ".tdb"; + runSimulation(exportname, dramSetup, traceSetup.second); } } } @@ -78,34 +77,52 @@ void SimulationManager::parseSimulationBatch(XMLElement* simulation) { SimulationBatch batch; - batch.simulationName = simulation->Attribute("id"); + //batch.simulationName = simulation->Attribute("id"); - string memspecUri; - string addressmappingUri; + //string memspecUri; + //string addressmappingUri; - for (XMLElement* element = simulation->FirstChildElement("memspec"); element != NULL; - element = element->NextSiblingElement("memspec")) + XMLElement* simconfig = simulation->FirstChildElement("simconfig"); + + XMLElement* memspecs = simulation->FirstChildElement("memspecs"); + if(memspecs == NULL) memspecs = simulation; + + XMLElement* addressmappings = simulation->FirstChildElement("addressmappings"); + if(addressmappings == NULL) addressmappings = simulation; + + XMLElement* memconfigs = simulation->FirstChildElement("memconfigs"); + if(memconfigs == NULL) memconfigs = simulation; + + + + for (XMLElement* memspec = memspecs->FirstChildElement("memspec"); memspec != NULL; + memspec = memspec->NextSiblingElement("memspec")) { - memspecUri = element->GetText(); - for (XMLElement* element = simulation->FirstChildElement("addressmapping"); element != NULL; - element = element->NextSiblingElement("addressmapping")) + //memspecUri = element->GetText(); + + for (XMLElement* addressmapping = addressmappings->FirstChildElement("addressmapping"); addressmapping != NULL; + addressmapping = addressmapping->NextSiblingElement("addressmapping")) { - addressmappingUri = element->GetText(); - for (XMLElement* element = simulation->FirstChildElement("memconfigs")->FirstChildElement("memconfig"); - element != NULL; element = element->NextSiblingElement("memconfig")) + // addressmappingUri = element->GetText(); + + for (XMLElement* memconfig = memconfigs->FirstChildElement("memconfig"); + memconfig != NULL; memconfig = memconfig->NextSiblingElement("memconfig")) { - batch.dramSetups.push_back(DramSetup(element->GetText(), memspecUri, addressmappingUri)); + batch.dramSetups.push_back(DramSetup(memspec, memconfig, simconfig, addressmapping)); } } } - for (XMLElement* element = simulation->FirstChildElement("trace-setups")->FirstChildElement("trace-setup"); element != NULL; - element = element->NextSiblingElement("trace-setup")) + XMLElement* tracesetups = simulation->FirstChildElement("tracesetups"); + if(tracesetups == NULL) tracesetups = simulation; + + for (XMLElement* tracesetup = tracesetups->FirstChildElement("tracesetup"); tracesetup != NULL; + tracesetup = tracesetup->NextSiblingElement("tracesetup")) { - addTraceSetup(batch, element); + addTraceSetup(batch, tracesetup); } - simulationsBatches.push_back(batch); + simulationBatches.push_back(batch); } @@ -133,9 +150,9 @@ void SimulationManager::startTraceAnalyzer() { string p = getenv("trace"); string run_tpr = p + " -f "; - for (auto batch : simulationsBatches) + for (auto batch : simulationBatches) { - run_tpr += exportPath + "/" + batch.simulationName + " "; + // run_tpr += exportPath + "/" + batch.simulationName + " "; } run_tpr += "&"; diff --git a/dram/src/simulation/SimulationManager.h b/dram/src/simulation/SimulationManager.h index 5dde2838..966e1731 100644 --- a/dram/src/simulation/SimulationManager.h +++ b/dram/src/simulation/SimulationManager.h @@ -16,7 +16,7 @@ struct SimulationBatch { - std::string simulationName; + //std::string simulationName; std::vector dramSetups; std::map> traceSetups; @@ -39,7 +39,9 @@ private: std::string resources; std::string exportPath; - std::vector simulationsBatches; + tinyxml2::XMLDocument simulationdoc; + + std::vector simulationBatches; void runSimulation(std::string traceName, DramSetup dramSetup, std::vector traceSetup); void parseSimulationBatch(tinyxml2::XMLElement* simulation); diff --git a/dram/src/simulation/main.cpp b/dram/src/simulation/main.cpp index b49f816f..2da7a398 100644 --- a/dram/src/simulation/main.cpp +++ b/dram/src/simulation/main.cpp @@ -34,14 +34,15 @@ int sc_main(int argc, char **argv) sc_set_time_resolution(1, SC_PS); resources = pathOfFile(argv[0]) + string("/../resources/"); + cout< 1) simulationToRun = argv[1]; else - simulationToRun = "sim-batch.xml"; + simulationToRun = resources + "/simulations/sim-batch.xml"; SimulationManager manager(resources); - manager.loadSimulationsFromXML(resources + "/simulations/" + simulationToRun); + manager.loadSimulationsFromXML(simulationToRun); manager.runSimulations(); return 0;