mcconfig loaded from json file
This commit is contained in:
@@ -1 +1,11 @@
|
||||
{"mcconfig": {"PagePolicy": {"@value": "Open"}, "Scheduler": {"@value": "Fifo"}, "RequestBufferSize": {"@value": "8"}, "CmdMux": {"@value": "Strict"}, "RespQueue": {"@value": "Fifo"}, "RefreshPolicy": {"@value": "Rankwise"}, "RefreshMode": {"@value": "1"}, "RefreshMaxPostponed": {"@value": "8"}, "RefreshMaxPulledin": {"@value": "8"}, "PowerDownPolicy": {"@value": "NoPowerDown"}, "PowerDownTimeout": {"@value": "100"}}}
|
||||
{"mcconfig": {"PagePolicy": "Open",
|
||||
"Scheduler": "Fifo",
|
||||
"RequestBufferSize": "8",
|
||||
"CmdMux": "Strict",
|
||||
"RespQueue": "Fifo",
|
||||
"RefreshPolicy": "Rankwise",
|
||||
"RefreshMode": "1",
|
||||
"RefreshMaxPostponed": "8",
|
||||
"RefreshMaxPulledin": "8",
|
||||
"PowerDownPolicy": "NoPowerDown",
|
||||
"PowerDownTimeout": "100"}}
|
||||
@@ -1 +1,2 @@
|
||||
{"mcconfig": {"PagePolicy": {"@value": "Open"}, "Scheduler": {"@value": "FrFcfs"}, "RequestBufferSize": {"@value": "8"}, "CmdMux": {"@value": "Oldest"}, "RespQueue": {"@value": "Fifo"}, "RefreshPolicy": {"@value": "Rankwise"}, "RefreshMode": {"@value": "1"}, "RefreshMaxPostponed": {"@value": "8"}, "RefreshMaxPulledin": {"@value": "8"}, "PowerDownPolicy": {"@value": "NoPowerDown"}, "PowerDownTimeout": {"@value": "100"}}}
|
||||
{"mcconfig": {
|
||||
"PagePolicy": "Open", "Scheduler": "FrFcfs", "RequestBufferSize": "8", "CmdMux": "Oldest", "RespQueue": "Fifo", "RefreshPolicy": "Rankwise", "RefreshMode": "1", "RefreshMaxPostponed": "8", "RefreshMaxPulledin": "8", "PowerDownPolicy": "NoPowerDown", "PowerDownTimeout": "100"}}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"mcconfig": {"PagePolicy": {"@value": "Open"}, "Scheduler": {"@value": "FrFcfsGrp"}, "RequestBufferSize": {"@value": "8"}, "CmdMux": {"@value": "Oldest"}, "RespQueue": {"@value": "Fifo"}, "RefreshPolicy": {"@value": "Rankwise"}, "RefreshMode": {"@value": "1"}, "RefreshMaxPostponed": {"@value": "8"}, "RefreshMaxPulledin": {"@value": "8"}, "PowerDownPolicy": {"@value": "NoPowerDown"}, "PowerDownTimeout": {"@value": "100"}}}
|
||||
{"mcconfig": {"PagePolicy": "Open", "Scheduler": "FrFcfsGrp", "RequestBufferSize": "8", "CmdMux": "Oldest", "RespQueue": "Fifo", "RefreshPolicy": "Rankwise", "RefreshMode": "1", "RefreshMaxPostponed": "8", "RefreshMaxPulledin": "8", "PowerDownPolicy": "NoPowerDown", "PowerDownTimeout": "100"}}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<simulation>
|
||||
<!-- Simulation file identifier -->
|
||||
<simulationid id="ddr3-example"></simulationid>
|
||||
<!-- Configuration for the DRAMSys Simulator -->
|
||||
<simconfig src="ddr3.xml" />
|
||||
<!-- Temperature Simulator Configuration -->
|
||||
<thermalconfig src="config.xml" />
|
||||
<!-- Memory Device Specification: Which Device is on the DDR3 DIMM -->
|
||||
<memspec src="MICRON_1Gb_DDR3-1600_8bit_G.xml"></memspec>
|
||||
<!-- Addressmapping Configuration of the Memory Controller -->
|
||||
<addressmapping src="am_ddr3_8x1Gbx8_dimm_p1KB_rbc.xml"></addressmapping>
|
||||
<!-- Memory Controller Configuration: -->
|
||||
<mcconfig src="fifo.json"/>
|
||||
<!--
|
||||
The following trace setup is only used in standalone mode.
|
||||
In library mode e.g. in Platform Architect the trace setup is ignored.
|
||||
-->
|
||||
<tracesetup>
|
||||
<!--
|
||||
This device mimics an image processing application
|
||||
running on an FPGA with 200 Mhz.
|
||||
-->
|
||||
<device clkMhz="800">ddr3_example.stl</device>
|
||||
</tracesetup>
|
||||
</simulation>
|
||||
@@ -48,6 +48,8 @@
|
||||
#include "memspec/MemSpecGDDR6.h"
|
||||
|
||||
using namespace tinyxml2;
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
||||
void ConfigurationLoader::loadSimConfig(Configuration &config,
|
||||
std::string simconfigUri)
|
||||
@@ -100,6 +102,18 @@ void ConfigurationLoader::loadConfig(Configuration &config,
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigurationLoader::loadConfigJson(Configuration &config,
|
||||
json::object_t *configNode)
|
||||
{
|
||||
json j = *configNode;
|
||||
|
||||
for (auto& x : j.items())
|
||||
{
|
||||
config.setParameter(x.key(), x.value());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ConfigurationLoader::loadConfigFromUri(Configuration &config,
|
||||
std::string uri, std::string first_element)
|
||||
{
|
||||
@@ -112,27 +126,12 @@ void ConfigurationLoader::loadConfigFromUri(Configuration &config,
|
||||
void ConfigurationLoader::loadMCConfig(Configuration &config,
|
||||
std::string mcconfigUri)
|
||||
{
|
||||
tinyxml2::XMLDocument doc;
|
||||
config.mcconfigUri = mcconfigUri;
|
||||
loadXML(mcconfigUri, doc);
|
||||
XMLElement *mcconfig = doc.FirstChildElement("mcconfig");
|
||||
loadConfig(config, mcconfig);
|
||||
json doc = json::parse(std::ifstream(mcconfigUri));
|
||||
auto mcconfig = doc["mcconfig"].get_ptr<json::object_t*>();
|
||||
loadConfigJson(config, mcconfig);
|
||||
}
|
||||
|
||||
void ConfigurationLoader::loadMCConfig(Configuration &config,
|
||||
XMLElement *mcconfig)
|
||||
{
|
||||
if (mcconfig->Attribute("src"))
|
||||
{
|
||||
XMLDocument doc;
|
||||
std::string src(mcconfig->Attribute("src"));
|
||||
config.mcconfigUri = src;
|
||||
loadXML(src, doc);
|
||||
loadMCConfig(config, doc.FirstChildElement("mcconfig"));
|
||||
}
|
||||
else
|
||||
loadConfig(config, mcconfig);
|
||||
}
|
||||
|
||||
void ConfigurationLoader::loadMemSpec(Configuration &config, std::string memspecUri)
|
||||
{
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
|
||||
#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"
|
||||
|
||||
@@ -47,8 +48,9 @@ class ConfigurationLoader
|
||||
{
|
||||
public:
|
||||
|
||||
static void loadMCConfig(Configuration &config, std::string amconfigUri);
|
||||
static void loadMCConfig(Configuration &config, tinyxml2::XMLElement *mcconfig);
|
||||
|
||||
static void loadMCConfig(Configuration &config, std::string amconfigUri);
|
||||
|
||||
|
||||
static void loadSimConfig(Configuration &config, std::string simconfigUri);
|
||||
static void loadSimConfig(Configuration &config,
|
||||
@@ -63,6 +65,7 @@ public:
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user