diff --git a/dram/gmon.out b/dram/gmon.out deleted file mode 100644 index f7dfccb0..00000000 Binary files a/dram/gmon.out and /dev/null differ diff --git a/dram/src/common/Utils.cpp b/dram/src/common/Utils.cpp index b8b15d65..68682549 100644 --- a/dram/src/common/Utils.cpp +++ b/dram/src/common/Utils.cpp @@ -3,6 +3,7 @@ #include using namespace std; +using namespace tinyxml2; void reportFatal(std::string sender, std::string message) { @@ -17,3 +18,75 @@ std::string phaseNameToString(tlm::tlm_phase phase) std::string str = oss.str(); return str; } + +unsigned int queryIntParameter(XMLElement* node, string name) { + int result; + XMLElement* element; + for (element = node->FirstChildElement("parameter"); element != NULL; + element = element->NextSiblingElement("parameter")) + { + if (element->Attribute("id") == name) + { + assert(!strcmp(element->Attribute("type"), "uint")); + XMLError error = element->QueryIntAttribute("value", &result); + assert(!error); + return result; + } + } + + std::cout << "error: " + name + " element not found" << endl; + return 0; +} + +double queryDoubleParameter(XMLElement* node, string name) { + double result; + XMLElement* element; + for (element = node->FirstChildElement("parameter"); element != NULL; + element = element->NextSiblingElement("parameter")) + { + if (element->Attribute("id") == name) + { + assert(!strcmp(element->Attribute("type"), "double")); + XMLError error = element->QueryDoubleAttribute("value", &result); + assert(!error); + return result; + } + } + + std::cout << "error: " + name + " element not found" << endl; + return 0; +} + +bool queryBoolParameter(XMLElement* node, string name) { + bool result; + XMLElement* element; + for (element = node->FirstChildElement("parameter"); element != NULL; + element = element->NextSiblingElement("parameter")) + { + if (element->Attribute("id") == name) + { + assert(!strcmp(element->Attribute("type"), "double")); + XMLError error = element->QueryBoolAttribute("value", &result); + assert(!error); + return result; + } + } + + std::cout << "error: " + name + " element not found" << endl; + return 0; +} + +string queryStringParameter(XMLElement* node, string name) { + XMLElement* element; + for (element = node->FirstChildElement("parameter"); element != NULL; + element = element->NextSiblingElement("parameter")) + { + if (element->Attribute("id") == name) + { + return element->Attribute("value"); + } + } + + std::cout << "error: element not found" << endl; + return 0; +} diff --git a/dram/src/common/Utils.h b/dram/src/common/Utils.h index 71c5d4ae..2c73fab6 100644 --- a/dram/src/common/Utils.h +++ b/dram/src/common/Utils.h @@ -14,6 +14,8 @@ #include #include +#include "third_party/tinyxml2.h" + template Val getElementFromMap(std::map& m, Key key) { @@ -39,4 +41,9 @@ bool isIn(const T& value, const std::vector& collection) void reportFatal(std::string sender, std::string message); std::string phaseNameToString(tlm::tlm_phase phase); +unsigned int queryIntParameter(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); + #endif /* UTILS_COMMON_H_ */ diff --git a/dram/src/core/Configuration.h b/dram/src/core/Configuration.h index 3e4224ff..16029e5e 100644 --- a/dram/src/core/Configuration.h +++ b/dram/src/core/Configuration.h @@ -15,9 +15,20 @@ namespace core{ struct Configuration { + static std::string memspecUri; + static std::string memconfigUri; + + Configuration(): NumberOfBanks(8), NumberOfBankGroups(4), Burstlength(2), Timings(NumberOfBanks), BankwiseRefresh(true),BankwisePowerDown(true), nActivate(2) - {} + { + readMemSpec(); + } + + + string MemoryId; + string MemmoryType; + unsigned int NumberOfBanks; unsigned int NumberOfBankGroups; unsigned int Burstlength; @@ -26,9 +37,13 @@ struct Configuration bool BankwiseRefresh; bool BankwisePowerDown; unsigned int nActivate; + + + void readMemSpec(); + void readMemConfig(); }; -} /* namespace controller */ +} /* namespace core */ #endif /* CONFIGURATION_H_ */