old code removed
This commit is contained in:
@@ -42,8 +42,6 @@
|
||||
#include "dramExtensions.h"
|
||||
#include <sstream>
|
||||
|
||||
|
||||
using namespace tinyxml2;
|
||||
using namespace tlm;
|
||||
|
||||
bool TimeInterval::timeIsInInterval(sc_time time)
|
||||
@@ -78,25 +76,6 @@ std::string phaseNameToString(tlm_phase phase)
|
||||
return str;
|
||||
}
|
||||
|
||||
unsigned int queryUIntParameter(XMLElement *node, std::string name)
|
||||
{
|
||||
int result = 0;
|
||||
XMLElement *element;
|
||||
for (element = node->FirstChildElement("parameter"); element != NULL;
|
||||
element = element->NextSiblingElement("parameter")) {
|
||||
if (element->Attribute("id") == name) {
|
||||
sc_assert(!strcmp(element->Attribute("type"), "uint"));
|
||||
XMLError __attribute__((unused)) error = element->QueryIntAttribute("value",
|
||||
&result);
|
||||
sc_assert(!error);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
reportFatal("Query XML", "Parameter '" + name + "' does not exist.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
unsigned int uIntParameter(nlohmann::json obj, std::string name)
|
||||
{
|
||||
@@ -111,39 +90,6 @@ unsigned int uIntParameter(nlohmann::json obj, std::string name)
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool parameterExists(tinyxml2::XMLElement *node, std::string name)
|
||||
{
|
||||
XMLElement *element;
|
||||
for (element = node->FirstChildElement("parameter"); element != NULL;
|
||||
element = element->NextSiblingElement("parameter")) {
|
||||
if (element->Attribute("id") == name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
double queryDoubleParameter(XMLElement *node, std::string name)
|
||||
{
|
||||
double result = 0;
|
||||
XMLElement *element;
|
||||
for (element = node->FirstChildElement("parameter"); element != NULL;
|
||||
element = element->NextSiblingElement("parameter")) {
|
||||
if (element->Attribute("id") == name) {
|
||||
sc_assert(!strcmp(element->Attribute("type"), "double"));
|
||||
XMLError __attribute__((unused)) error = element->QueryDoubleAttribute("value",
|
||||
&result);
|
||||
sc_assert(!error);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
reportFatal("Query XML", "Parameter '" + name + "' does not exist.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
double doubleParameter(nlohmann::json obj, std::string name)
|
||||
{
|
||||
|
||||
@@ -159,39 +105,6 @@ double doubleParameter(nlohmann::json obj, std::string name)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
bool queryBoolParameter(XMLElement *node, std::string name)
|
||||
{
|
||||
bool result = false;
|
||||
XMLElement *element;// = node->FirstChildElement("parameter");
|
||||
for (element = node->FirstChildElement("parameter"); element != NULL;
|
||||
element = element->NextSiblingElement("parameter")) {
|
||||
if (element->Attribute("id") == name) {
|
||||
sc_assert(!strcmp(element->Attribute("type"), "bool"));
|
||||
XMLError __attribute__((unused)) error = element->QueryBoolAttribute("value",
|
||||
&result);
|
||||
sc_assert(!error);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
reportFatal("Query XML", "Parameter '" + name + "' does not exist.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string queryStringParameter(XMLElement *node, std::string name)
|
||||
{
|
||||
XMLElement *element;
|
||||
for (element = node->FirstChildElement("parameter"); element != NULL;
|
||||
element = element->NextSiblingElement("parameter")) {
|
||||
if (element->Attribute("id") == name) {
|
||||
return element->Attribute("value");
|
||||
}
|
||||
}
|
||||
|
||||
reportFatal("Query XML", "Parameter '" + name + "' does not exist.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string stringParameter(nlohmann::json obj)
|
||||
@@ -206,63 +119,6 @@ std::string stringParameter(nlohmann::json obj)
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string errorToString(XMLError error)
|
||||
{
|
||||
switch (error) {
|
||||
case XML_NO_ERROR:
|
||||
return "no error";
|
||||
case XML_NO_ATTRIBUTE:
|
||||
return "NO_ATTRIBUTE";
|
||||
case XML_WRONG_ATTRIBUTE_TYPE:
|
||||
return "WRONG_ATTRIBUTE_TYPE";
|
||||
case XML_ERROR_FILE_NOT_FOUND:
|
||||
return "FILE_NOT_FOUND";
|
||||
case XML_ERROR_FILE_COULD_NOT_BE_OPENED:
|
||||
return "FILE_COULD_NOT_BE_OPENED";
|
||||
case XML_ERROR_FILE_READ_ERROR:
|
||||
return "FILE_READ_ERROR";
|
||||
case XML_ERROR_ELEMENT_MISMATCH:
|
||||
return "ERROR_ELEMENT_MISMATCH";
|
||||
case XML_ERROR_PARSING_ELEMENT:
|
||||
return "ERROR_PARSING_ELEMENT";
|
||||
case XML_ERROR_PARSING_ATTRIBUTE:
|
||||
return "ERROR_PARSING_ATTRIBUTE";
|
||||
case XML_ERROR_IDENTIFYING_TAG:
|
||||
return "ERROR_IDENTIFYING_TAG";
|
||||
case XML_ERROR_PARSING_TEXT:
|
||||
return "ERROR_PARSING_TEXT";
|
||||
case XML_ERROR_PARSING_CDATA:
|
||||
return "ERROR_PARSING_CDATA";
|
||||
case XML_ERROR_PARSING_COMMENT:
|
||||
return "ERROR_PARSING_COMMENT";
|
||||
case XML_ERROR_PARSING_DECLARATION:
|
||||
return "ERROR_PARSING_DECLARATION";
|
||||
case XML_ERROR_PARSING_UNKNOWN:
|
||||
return "ERROR_PARSING_UNKNOWN";
|
||||
case XML_ERROR_EMPTY_DOCUMENT:
|
||||
return "ERROR_EMPTY_DOCUMENT";
|
||||
case XML_ERROR_MISMATCHED_ELEMENT:
|
||||
return "ERROR_MISMATCHED_ELEMENT";
|
||||
case XML_ERROR_PARSING:
|
||||
return "ERROR_PARSING";
|
||||
case XML_CAN_NOT_CONVERT_TEXT:
|
||||
return "CAN_NOT_CONVERT_TEXT";
|
||||
case XML_NO_TEXT_NODE:
|
||||
return "NO_TEXT_NODE";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
void loadXML(std::string uri, XMLDocument &doc)
|
||||
{
|
||||
XMLError error = doc.LoadFile(uri.c_str());
|
||||
|
||||
if (error) {
|
||||
reportFatal("Configuration", "Error loading xml from: " + uri + " "
|
||||
+ errorToString(error));
|
||||
}
|
||||
}
|
||||
|
||||
std::string loadTextFileContents(std::string filename)
|
||||
{
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
#include <tlm.h>
|
||||
#include <iomanip>
|
||||
#include "dramExtensions.h"
|
||||
#include "third_party/tinyxml2/tinyxml2.h"
|
||||
#include "../common/third_party/nlohmann/single_include/nlohmann/json.hpp"
|
||||
|
||||
#define DEF_SINGLETON( NAME ) \
|
||||
@@ -137,16 +136,9 @@ void reportFatal(std::string sender, std::string message);
|
||||
std::string phaseNameToString(tlm::tlm_phase phase);
|
||||
|
||||
|
||||
//TODO : Move to other source specific to xml
|
||||
//TODO : Move to other source specific
|
||||
std::string getFileName(std::string uri);
|
||||
bool parameterExists(tinyxml2::XMLElement *node, std::string name);
|
||||
std::string loadTextFileContents(std::string filename);
|
||||
void loadXML(std::string uri, tinyxml2::XMLDocument &doc);
|
||||
unsigned int queryUIntParameter(tinyxml2::XMLElement *node, std::string name);
|
||||
std::string queryStringParameter(tinyxml2::XMLElement *node, std::string name);
|
||||
bool queryBoolParameter(tinyxml2::XMLElement *node, std::string name);
|
||||
double queryDoubleParameter(tinyxml2::XMLElement *node, std::string name);
|
||||
|
||||
|
||||
unsigned int uIntParameter(nlohmann::json obj, std::string name);
|
||||
double doubleParameter(nlohmann::json obj, std::string name);
|
||||
|
||||
@@ -88,7 +88,7 @@ struct Configuration
|
||||
bool useMalloc = false;
|
||||
unsigned long long int addressOffset = 0;
|
||||
|
||||
// MemSpec (from DRAM-Power XML)
|
||||
// MemSpec (from DRAM-Power)
|
||||
MemSpec *memSpec;
|
||||
|
||||
void setParameter(std::string name, std::string value);
|
||||
|
||||
@@ -47,10 +47,8 @@
|
||||
#include "memspec/MemSpecGDDR5X.h"
|
||||
#include "memspec/MemSpecGDDR6.h"
|
||||
|
||||
using namespace tinyxml2;
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
||||
void ConfigurationLoader::loadSimConfig(Configuration &config,
|
||||
std::string simconfigUri)
|
||||
{
|
||||
@@ -70,28 +68,6 @@ void ConfigurationLoader::loadTemperatureSimConfig(Configuration &config,
|
||||
|
||||
}
|
||||
|
||||
void ConfigurationLoader::loadTemperatureSimConfig(Configuration &config,
|
||||
XMLElement *thermalsimconfig)
|
||||
{
|
||||
if (thermalsimconfig->Attribute("src")) {
|
||||
// Configuration is inside another a file
|
||||
std::string uri(thermalsimconfig->Attribute("src"));
|
||||
loadConfigFromUri(config, uri, "thermalsimconfig");
|
||||
} else {
|
||||
loadConfig(config, thermalsimconfig);
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigurationLoader::loadConfig(Configuration &config,
|
||||
XMLElement *configNode)
|
||||
{
|
||||
XMLElement *element;
|
||||
for (element = configNode->FirstChildElement(); element != NULL;
|
||||
element = element->NextSiblingElement()) {
|
||||
config.setParameter(element->Name(), element->Attribute("value"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigurationLoader::loadConfigJson(Configuration &config,
|
||||
json::object_t *configNode)
|
||||
@@ -102,14 +78,6 @@ void ConfigurationLoader::loadConfigJson(Configuration &config,
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigurationLoader::loadConfigFromUri(Configuration &config,
|
||||
std::string uri, std::string first_element)
|
||||
{
|
||||
tinyxml2::XMLDocument doc;
|
||||
loadXML(uri, doc);
|
||||
XMLElement *e = doc.FirstChildElement(first_element.c_str());
|
||||
loadConfig(config, e);
|
||||
}
|
||||
|
||||
void ConfigurationLoader::loadMCConfig(Configuration &config,
|
||||
std::string mcconfigUri)
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#define CONFIGURATIONLOADER_H
|
||||
|
||||
#include <string>
|
||||
#include "../common/third_party/tinyxml2/tinyxml2.h"
|
||||
#include "../common/third_party/nlohmann/single_include/nlohmann/json.hpp"
|
||||
#include "../common/utils.h"
|
||||
#include "Configuration.h"
|
||||
@@ -59,14 +58,10 @@ public:
|
||||
|
||||
static void loadTemperatureSimConfig(Configuration &config,
|
||||
std::string simconfigUri);
|
||||
static void loadTemperatureSimConfig(Configuration &config,
|
||||
tinyxml2::XMLElement *simconfig);
|
||||
private:
|
||||
ConfigurationLoader() {}
|
||||
static void loadConfigJson(Configuration &config, nlohmann::json::object_t *configNode);
|
||||
static void loadConfig(Configuration &config, tinyxml2::XMLElement *configNode);
|
||||
static void loadConfigFromUri(Configuration &config, std::string uri,
|
||||
std::string first_element);
|
||||
|
||||
// Loads common config of DRAMs
|
||||
static void loadCommons(Configuration &config, nlohmann::json::object_t *memspec);
|
||||
// Load specific config
|
||||
|
||||
@@ -40,9 +40,7 @@
|
||||
#include <systemc.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "../common/DebugManager.h"
|
||||
#include "../common/third_party/tinyxml2/tinyxml2.h"
|
||||
#include "../common/utils.h"
|
||||
|
||||
struct TemperatureSimConfig
|
||||
|
||||
@@ -54,13 +54,8 @@ Setup::Setup(std::string uri,
|
||||
// Load all sub-configuration JSON files
|
||||
|
||||
memspec = simulationdoc["simulation"]["memspec"];
|
||||
|
||||
mcconfig = simulationdoc["simulation"]["mcconfig"];
|
||||
|
||||
amconfig = simulationdoc["simulation"]["addressmapping"];
|
||||
|
||||
simconfig = simulationdoc["simulation"]["simconfig"];
|
||||
|
||||
thermalconfig = simulationdoc["simulation"]["thermalconfig"];
|
||||
|
||||
}
|
||||
|
||||
@@ -61,34 +61,34 @@ int sc_main(int argc, char **argv)
|
||||
sc_set_time_resolution(1, SC_PS);
|
||||
|
||||
|
||||
std::string SimulationXML;
|
||||
// Run only with default config (ddr-example.xml):
|
||||
std::string SimulationJSON;
|
||||
// Run only with default config (ddr3-example.json):
|
||||
if (argc == 1) {
|
||||
// Get path of resources:
|
||||
resources = pathOfFile(argv[0])
|
||||
+ std::string("/../DRAMSys/library/resources/");
|
||||
SimulationXML = resources + "simulations/ddr3-example.xml";
|
||||
SimulationJSON = resources + "simulations/ddr3-example.json";
|
||||
}
|
||||
// Run with specific config but default resource folders:
|
||||
else if (argc == 2) {
|
||||
// Get path of resources:
|
||||
resources = pathOfFile(argv[0])
|
||||
+ std::string("/../DRAMSys/library/resources/");
|
||||
SimulationXML = argv[1];
|
||||
SimulationJSON = argv[1];
|
||||
}
|
||||
// Run with spefific config and specific resource folder:
|
||||
else if (argc == 3) {
|
||||
SimulationXML = argv[1];
|
||||
SimulationJSON = argv[1];
|
||||
resources = argv[2];
|
||||
}
|
||||
|
||||
std::vector<TracePlayer *> players;
|
||||
|
||||
// Instantiate DRAMSys:
|
||||
DRAMSys *dramSys = new DRAMSys("DRAMSys", SimulationXML, resources);
|
||||
DRAMSys *dramSys = new DRAMSys("DRAMSys", SimulationJSON, resources);
|
||||
|
||||
// Instantiate STL Players:
|
||||
TraceSetup *ts = new TraceSetup(SimulationXML, resources, &players);
|
||||
TraceSetup *ts = new TraceSetup(SimulationJSON, resources, &players);
|
||||
|
||||
// Bind STL Players with DRAMSys:
|
||||
for (size_t i = 0; i < players.size(); i++) {
|
||||
|
||||
Reference in New Issue
Block a user