Quick and Dirty XML - Refactoring necessary
This commit is contained in:
@@ -1,21 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
|
||||
<!-- <dramconfig>
|
||||
<addressmap length="29">
|
||||
<channel from="27" to="28" />
|
||||
<row from="14" to="26" />
|
||||
<bank from="11" to="13" />
|
||||
<colum from="4" to="10" />
|
||||
<bytes from="0" to="3" />
|
||||
</addressmap>
|
||||
</dramconfig>
|
||||
-->
|
||||
<dramconfig>
|
||||
<addressmap>
|
||||
<addressmapping>
|
||||
<channel from="27" to="28" />
|
||||
<row from="14" to="26" />
|
||||
<column from="7" to="13" />
|
||||
<bank from="4" to="6" />
|
||||
<bytes from="0" to="3" />
|
||||
</addressmap>
|
||||
</dramconfig>
|
||||
</addressmapping>
|
||||
|
||||
|
||||
@@ -1,20 +1,29 @@
|
||||
<simulation id = "simbatch3">
|
||||
<memspec>WideIO.xml</memspec>
|
||||
|
||||
<addressmapping>am_wideio.xml</addressmapping>
|
||||
|
||||
<memconfigs>
|
||||
<!-- <memconfig>fr_fcfs.xml</memconfig>
|
||||
--> <memconfig>fifo.xml</memconfig>
|
||||
</memconfigs>
|
||||
<trace-setups>
|
||||
<simulation>
|
||||
<simconfig>
|
||||
<Debug value="1" />
|
||||
</simconfig>
|
||||
<memspecs>
|
||||
<memspec src="/home/jonny/git/dram.vp.system/dram/resources/configs/memspecs/WideIO.xml"></memspec>
|
||||
</memspecs>
|
||||
<addressmappings>
|
||||
<addressmapping src="/home/jonny/git/dram.vp.system/dram/resources/configs/amconfigs/am_wideio.xml"></addressmapping>
|
||||
</addressmappings>
|
||||
<memconfigs>
|
||||
<!-- <memconfig>fr_fcfs.xml</memconfig>
|
||||
-->
|
||||
<memconfig src="/home/jonny/git/dram.vp.system/dram/resources/configs/memconfigs/fifo.xml">
|
||||
<!-- <Debug value="1"></Debug>-->
|
||||
</memconfig>
|
||||
</memconfigs>
|
||||
|
||||
<tracesetups>
|
||||
|
||||
|
||||
<trace-setup id="media">
|
||||
<tracesetup id="media">
|
||||
<device clkMhz="800">chstone-sha_32.stl</device>
|
||||
</trace-setup>
|
||||
</tracesetup>
|
||||
|
||||
</trace-setups>
|
||||
</tracesetups>
|
||||
</simulation>
|
||||
|
||||
|
||||
|
||||
@@ -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"<<addressmap->Name()<<endl;
|
||||
string xmlNodeName(addressmap->Name());
|
||||
if( xmlNodeName != "addressmapping")
|
||||
reportFatal("AddressDecorder", "addressmap node expected");
|
||||
|
||||
cout<<addressmap<<endl;
|
||||
if(addressmap->Attribute("src"))
|
||||
{
|
||||
|
||||
|
||||
string src(addressmap->Attribute("src"));
|
||||
std::cout<<src<<endl;
|
||||
loadXML(src, doc);
|
||||
addressmap = (doc.FirstChildElement("addressmapping"));
|
||||
}
|
||||
cout<<addressmap<<endl;
|
||||
|
||||
//tinyxml2::XMLDocument doc2;
|
||||
//loadXML("/home/jonny/git/dram.vp.system/dram/resources/configs/amconfigs/am_wideio.xml", doc2);
|
||||
//XMLElement* addressmap = doc2.FirstChildElement("addressmapping");
|
||||
for(XMLElement* child = addressmap->FirstChildElement(); child != NULL; child = child->NextSiblingElement())
|
||||
{
|
||||
int from;
|
||||
|
||||
@@ -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"<<std::endl;
|
||||
static xmlAddressDecoder decoder(xmlAddressDecoder::addressmapping);
|
||||
return decoder;
|
||||
}
|
||||
|
||||
DecodedAddress decodeAddress(sc_dt::uint64 addr);
|
||||
static inline void Initialize(tinyxml2::XMLElement* mapping)
|
||||
{
|
||||
addressmapping = mapping;
|
||||
//decoder = xmlAddressDecoder(addressmapping);
|
||||
xmlAddressDecoder::getInstance();
|
||||
addressmapping = NULL;
|
||||
}
|
||||
|
||||
DecodedAddress decodeAddress(sc_dt::uint64 addr);
|
||||
private:
|
||||
|
||||
//static xmlAddressDecoder decoder;
|
||||
|
||||
//xmlAddressDecoder();
|
||||
xmlAddressDecoder(std::string URI);
|
||||
xmlAddressDecoder(tinyxml2::XMLElement* addressMap);
|
||||
|
||||
std::map<std::string, sc_dt::uint64> masks;
|
||||
std::map<std::string, unsigned int> shifts;
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -47,6 +47,7 @@ struct Configuration
|
||||
//SimConfig
|
||||
bool DatabaseRecording = true;
|
||||
bool PowerAnalysys = false;
|
||||
bool Debug = false;
|
||||
|
||||
//MemSpec(from DRAM-Power XML)
|
||||
MemSpec memSpec;
|
||||
|
||||
@@ -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"<<src<<endl;
|
||||
loadXML(src, doc);
|
||||
loadMemConfig(config, doc.FirstChildElement("memconfig"));
|
||||
}
|
||||
loadConfig(config, memconfig);
|
||||
}
|
||||
|
||||
void ConfigurationLoader::loadSimConfig(Configuration& config, XMLElement* simconfig)
|
||||
{
|
||||
if(simconfig->Attribute("src"))
|
||||
{
|
||||
|
||||
XMLDocument doc;
|
||||
|
||||
string src(simconfig->Attribute("src"));
|
||||
std::cout<<"inner first"<<src<<endl;
|
||||
loadXML(src, doc);
|
||||
loadSimConfig(config, doc.FirstChildElement("simconfig"));
|
||||
}
|
||||
loadConfig(config, simconfig);
|
||||
}
|
||||
|
||||
void ConfigurationLoader::loadConfig(Configuration& config, XMLElement* configNode)
|
||||
{
|
||||
XMLElement* element;
|
||||
@@ -55,6 +85,18 @@ void ConfigurationLoader::loadMemSpec(Configuration& config, string memspecUri)
|
||||
|
||||
void ConfigurationLoader::loadMemSpec(Configuration& config, XMLElement* memspec)
|
||||
{
|
||||
//if(memspec->Attribute("src"))
|
||||
//{
|
||||
|
||||
XMLDocument doc;
|
||||
|
||||
string src(memspec->Attribute("src"));
|
||||
config.memspecUri = src;
|
||||
std::cout<<"inner first"<<src<<endl;
|
||||
loadXML(src, doc);
|
||||
memspec = doc.FirstChildElement("memspec");
|
||||
//}
|
||||
|
||||
config.memSpec.MemoryId = queryStringParameter(memspec, "memoryId");
|
||||
config.memSpec.MemoryType = queryStringParameter(memspec, "memoryType");
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ class ConfigurationLoader
|
||||
public:
|
||||
static void loadMemConfig(Configuration& config, std::string memconfigUri);
|
||||
static void loadSimConfig(Configuration& config, std::string simconfigUri);
|
||||
static void loadMemConfig(Configuration& config, tinyxml2::XMLElement* memconfig);
|
||||
static void loadSimConfig(Configuration& config,tinyxml2::XMLElement* simconfig);
|
||||
|
||||
static void loadMemSpec(Configuration& config, std::string memspecUri);
|
||||
static void loadMemSpec(Configuration& config, tinyxml2::XMLElement* memspec);
|
||||
|
||||
@@ -27,13 +27,17 @@ Simulation::Simulation(sc_module_name /*name*/, string pathToResources, string t
|
||||
{
|
||||
SC_THREAD(stop);
|
||||
|
||||
xmlAddressDecoder::addressConfigURI = pathToResources + string("configs/amconfigs/") + setup.addressmapping;
|
||||
cout<<setup.addressmapping->Name()<<endl;
|
||||
//xmlAddressDecoder::addressConfigURI = pathToResources + string("configs/amconfigs/") + setup.addressmapping;
|
||||
xmlAddressDecoder::Initialize(setup.addressmapping);
|
||||
|
||||
//Configuration::memconfigUri = pathToResources + string("configs/memconfigs/") + setup.memconfig;
|
||||
Configuration::memspecUri = pathToResources + string("configs/memspecs/") + setup.memspec;
|
||||
|
||||
ConfigurationLoader::loadMemConfig(Configuration::getInstance(), pathToResources + string("configs/memconfigs/") + setup.memconfig);
|
||||
ConfigurationLoader::loadMemSpec(Configuration::getInstance(), pathToResources + string("configs/memspecs/") + setup.memspec);
|
||||
//Configuration::memspecUri = pathToResources + string("configs/memspecs/") + setup.memspec;
|
||||
|
||||
ConfigurationLoader::loadMemConfig(Configuration::getInstance(), setup.memconfig);//pathToResources + string("configs/memconfigs/") + setup.memconfig);
|
||||
ConfigurationLoader::loadMemSpec(Configuration::getInstance(), setup.memspec);//pathToResources + string("configs/memspecs/") + setup.memspec);
|
||||
ConfigurationLoader::loadSimConfig(Configuration::getInstance(), setup.simconfig);
|
||||
|
||||
setupTlmRecorder(traceName, pathToResources, setup, devices);
|
||||
instantiateModules(pathToResources, devices);
|
||||
@@ -70,8 +74,8 @@ void Simulation::setupTlmRecorder(const string &traceName, const string &pathToR
|
||||
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().recordMemconfig(Configuration::getInstance().memconfigUri);
|
||||
TlmRecorder::getInstance().recordMemspec(Configuration::getInstance().memspecUri);
|
||||
TlmRecorder::getInstance().recordTracenames(devices[0].trace + "," + devices[1].trace + "," + devices[2].trace + "," + devices[3].trace);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -17,14 +17,17 @@
|
||||
#include <string>
|
||||
#include <systemc.h>
|
||||
#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
|
||||
|
||||
@@ -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 += "&";
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
struct SimulationBatch
|
||||
{
|
||||
std::string simulationName;
|
||||
//std::string simulationName;
|
||||
|
||||
std::vector<DramSetup> dramSetups;
|
||||
std::map<std::string, std::vector<Device>> traceSetups;
|
||||
@@ -39,7 +39,9 @@ private:
|
||||
std::string resources;
|
||||
std::string exportPath;
|
||||
|
||||
std::vector<SimulationBatch> simulationsBatches;
|
||||
tinyxml2::XMLDocument simulationdoc;
|
||||
|
||||
std::vector<SimulationBatch> simulationBatches;
|
||||
|
||||
void runSimulation(std::string traceName, DramSetup dramSetup, std::vector<Device> traceSetup);
|
||||
void parseSimulationBatch(tinyxml2::XMLElement* simulation);
|
||||
|
||||
@@ -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<<resources<<endl;
|
||||
string simulationToRun;
|
||||
if(argc > 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;
|
||||
|
||||
Reference in New Issue
Block a user