Fix some bugs in configuration library
This commit is contained in:
@@ -45,13 +45,11 @@ void to_json(json &j, const AddressMapping &m)
|
||||
json congen = json{};
|
||||
|
||||
congen = json{{"BYTE_BIT", m.byteBits},
|
||||
{"COLUMN_BIT", m.coloumnBits},
|
||||
{"BANKGROUP_BIT", m.bankGroupBits},
|
||||
{"COLUMN_BIT", m.columnBits},
|
||||
{"BANK_BIT", m.bankBits},
|
||||
{"BANKGROUP_BIT", m.bankGroupBits},
|
||||
{"ROW_BIT", m.rowBits},
|
||||
{"CHANNEL_BIT", m.channelBits},
|
||||
{"BYTE_BIT", m.byteBits},
|
||||
{"BANKGROUP_BIT", m.bankGroupBits},
|
||||
{"RANK_BIT", m.rankBits},
|
||||
{"XOR", m.xorBits}};
|
||||
|
||||
@@ -70,9 +68,14 @@ void from_json(const json &j, AddressMapping &m)
|
||||
else
|
||||
congen = j_addressmapping["CONGEN"];
|
||||
|
||||
congen.at("COLUMN_BIT").get_to(m.coloumnBits);
|
||||
congen.at("BANK_BIT").get_to(m.bankBits);
|
||||
congen.at("ROW_BIT").get_to(m.rowBits);
|
||||
if (congen.contains("COLUMN_BIT"))
|
||||
congen.at("COLUMN_BIT").get_to(m.columnBits);
|
||||
|
||||
if (congen.contains("BANK_BIT"))
|
||||
congen.at("BANK_BIT").get_to(m.bankBits);
|
||||
|
||||
if (congen.contains("ROW_BIT"))
|
||||
congen.at("ROW_BIT").get_to(m.rowBits);
|
||||
|
||||
if (congen.contains("RANK_BIT"))
|
||||
congen.at("RANK_BIT").get_to(m.rankBits);
|
||||
|
||||
@@ -58,10 +58,10 @@ void from_json(const json &j, XorPair &x);
|
||||
struct AddressMapping
|
||||
{
|
||||
Optional<std::vector<unsigned int>> byteBits;
|
||||
std::vector<unsigned int> coloumnBits;
|
||||
std::vector<unsigned int> bankBits;
|
||||
Optional<std::vector<unsigned int>> columnBits;
|
||||
Optional<std::vector<unsigned int>> bankBits;
|
||||
Optional<std::vector<unsigned int>> bankGroupBits;
|
||||
std::vector<unsigned int> rowBits;
|
||||
Optional<std::vector<unsigned int>> rowBits;
|
||||
Optional<std::vector<unsigned int>> channelBits;
|
||||
Optional<std::vector<unsigned int>> rankBits;
|
||||
Optional<std::vector<XorPair>> xorBits;
|
||||
|
||||
@@ -70,7 +70,7 @@ void from_json(const json &j, McConfig &c)
|
||||
if (j_mcconfig.contains("PagePolicy"))
|
||||
j_mcconfig.at("PagePolicy").get_to(c.pagePolicy);
|
||||
|
||||
if (j_mcconfig.contains("PagePolicy"))
|
||||
if (j_mcconfig.contains("Scheduler"))
|
||||
j_mcconfig.at("Scheduler").get_to(c.scheduler);
|
||||
|
||||
if (j_mcconfig.contains("SchedulerBuffer"))
|
||||
@@ -135,6 +135,38 @@ void from_json(const json &j, McConfig &c)
|
||||
invalidateEnum(c.arbiter);
|
||||
}
|
||||
|
||||
void to_json(json &j, const RefreshPolicy &r)
|
||||
{
|
||||
if (r == RefreshPolicy::NoRefresh)
|
||||
j = "NoRefresh";
|
||||
else if (r == RefreshPolicy::AllBank)
|
||||
j = "AllBank";
|
||||
else if (r == RefreshPolicy::PerBank)
|
||||
j = "PerBank";
|
||||
else if (r == RefreshPolicy::Per2Bank)
|
||||
j = "Per2Bank";
|
||||
else if (r == RefreshPolicy::SameBank)
|
||||
j = "SameBank";
|
||||
else
|
||||
j = nullptr;
|
||||
}
|
||||
|
||||
void from_json(const json &j, RefreshPolicy &r)
|
||||
{
|
||||
if (j == "NoRefresh")
|
||||
r = RefreshPolicy::NoRefresh;
|
||||
else if (j == "AllBank" || j == "Rankwise")
|
||||
r = RefreshPolicy::AllBank;
|
||||
else if (j == "PerBank" || j == "Bankwise")
|
||||
r = RefreshPolicy::PerBank;
|
||||
else if (j == "SameBank" || j == "Groupwise")
|
||||
r = RefreshPolicy::SameBank;
|
||||
else if (j == "Per2Bank")
|
||||
r = RefreshPolicy::Per2Bank;
|
||||
else
|
||||
r = RefreshPolicy::Invalid;
|
||||
}
|
||||
|
||||
void from_dump(const std::string &dump, McConfig &c)
|
||||
{
|
||||
json json_mcconfig = json::parse(dump).at("mcconfig");
|
||||
|
||||
@@ -119,21 +119,9 @@ enum class RefreshPolicy
|
||||
PerBank,
|
||||
Per2Bank,
|
||||
SameBank,
|
||||
Rankwise,
|
||||
Bankwise,
|
||||
Groupwise,
|
||||
Invalid = -1
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(RefreshPolicy, {{RefreshPolicy::Invalid, nullptr},
|
||||
{RefreshPolicy::NoRefresh, "NoRefresh"},
|
||||
{RefreshPolicy::AllBank, "AllBank"},
|
||||
{RefreshPolicy::PerBank, "PerBank"},
|
||||
{RefreshPolicy::Per2Bank, "Per2Bank"},
|
||||
{RefreshPolicy::Rankwise, "Rankwise"},
|
||||
{RefreshPolicy::Bankwise, "Bankwise"},
|
||||
{RefreshPolicy::Groupwise, "Groupwise"}})
|
||||
|
||||
enum class PowerDownPolicy
|
||||
{
|
||||
NoPowerDown,
|
||||
@@ -184,6 +172,9 @@ struct McConfig
|
||||
void to_json(json &j, const McConfig &c);
|
||||
void from_json(const json &j, McConfig &c);
|
||||
|
||||
void to_json(json &j, const RefreshPolicy &r);
|
||||
void from_json(const json &j, RefreshPolicy &r);
|
||||
|
||||
void from_dump(const std::string &dump, McConfig &c);
|
||||
std::string dump(const McConfig &c, unsigned int indentation = -1);
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ NLOHMANN_JSON_SERIALIZE_ENUM(StoreMode, {{StoreMode::Invalid, nullptr},
|
||||
|
||||
struct SimConfig
|
||||
{
|
||||
Optional<unsigned int> addressOffset;
|
||||
Optional<uint64_t> addressOffset;
|
||||
Optional<bool> checkTLM2Protocol;
|
||||
Optional<bool> databaseRecording;
|
||||
Optional<bool> debug;
|
||||
|
||||
@@ -42,10 +42,10 @@ using json = nlohmann::json;
|
||||
DRAMSysConfiguration::AddressMapping getAddressMapping()
|
||||
{
|
||||
return DRAMSysConfiguration::AddressMapping{{{0, 1}},
|
||||
{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
|
||||
{16},
|
||||
{{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}},
|
||||
{{16}},
|
||||
{{13, 14, 15}},
|
||||
{17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32},
|
||||
{{17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}},
|
||||
{{33}},
|
||||
{{}},
|
||||
{{}}};
|
||||
@@ -71,7 +71,7 @@ DRAMSysConfiguration::McConfig getMcConfig()
|
||||
DRAMSysConfiguration::SimConfig getSimConfig()
|
||||
{
|
||||
return DRAMSysConfiguration::SimConfig{
|
||||
0, false, true, false, DRAMSysConfiguration::ECCControllerMode::Disabled, false, {"error.csv"},
|
||||
0, false, true, false, false, {"error.csv"},
|
||||
42, false, {"ddr5"}, true, DRAMSysConfiguration::StoreMode::NoStorage, false, false,
|
||||
1000};
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ void Configuration::loadSimConfig(Configuration &config, const DRAMSysConfigurat
|
||||
if (simConfig.addressOffset.isValid())
|
||||
config.addressOffset = simConfig.addressOffset.getValue();
|
||||
|
||||
if (simConfig.addressOffset.isValid())
|
||||
if (simConfig.checkTLM2Protocol.isValid())
|
||||
config.checkTLM2Protocol = simConfig.checkTLM2Protocol.getValue();
|
||||
|
||||
if (simConfig.databaseRecording.isValid())
|
||||
@@ -250,13 +250,13 @@ void Configuration::loadMCConfig(Configuration &config, const DRAMSysConfigurati
|
||||
|
||||
if (policy == DRAMSysConfiguration::RefreshPolicy::NoRefresh)
|
||||
return RefreshPolicy::NoRefresh;
|
||||
else if (policy == DRAMSysConfiguration::RefreshPolicy::AllBank || policy == DRAMSysConfiguration::RefreshPolicy::Rankwise)
|
||||
else if (policy == DRAMSysConfiguration::RefreshPolicy::AllBank)
|
||||
return RefreshPolicy::AllBank;
|
||||
else if (policy == DRAMSysConfiguration::RefreshPolicy::PerBank || policy == DRAMSysConfiguration::RefreshPolicy::Bankwise)
|
||||
else if (policy == DRAMSysConfiguration::RefreshPolicy::PerBank)
|
||||
return RefreshPolicy::PerBank;
|
||||
else if (policy == DRAMSysConfiguration::RefreshPolicy::Per2Bank)
|
||||
return RefreshPolicy::Per2Bank;
|
||||
else // if (policy == DRAMSysConfiguration::RefreshPolicy::SameBank || policy == DRAMSysConfiguration::RefreshPolicy::Groupwise)
|
||||
else // if (policy == DRAMSysConfiguration::RefreshPolicy::SameBank)
|
||||
return RefreshPolicy::SameBank;
|
||||
}();
|
||||
|
||||
|
||||
@@ -100,8 +100,8 @@ MemSpecDDR5::MemSpecDDR5(const DRAMSysConfiguration::MemSpec &memSpec)
|
||||
: tCK * memSpec.memTimingSpec.entries.at("RFC2_dlr")),
|
||||
tRFC_dpr ((refMode == 1) ? tCK * memSpec.memTimingSpec.entries.at("RFC1_dpr")
|
||||
: tCK * memSpec.memTimingSpec.entries.at("RFC2_dpr")),
|
||||
tRFCsb_slr (tCK * memSpec.memTimingSpec.entries.at("WTR_S")),
|
||||
tRFCsb_dlr (tCK * memSpec.memTimingSpec.entries.at("WTR_S")),
|
||||
tRFCsb_slr (tCK * memSpec.memTimingSpec.entries.at("RFCsb_slr")),
|
||||
tRFCsb_dlr (tCK * memSpec.memTimingSpec.entries.at("RFCsb_dlr ")),
|
||||
tREFI ((refMode == 1) ? tCK * memSpec.memTimingSpec.entries.at("REFI1")
|
||||
: tCK * memSpec.memTimingSpec.entries.at("REFI2")),
|
||||
tREFIsb (tCK * memSpec.memTimingSpec.entries.at("REFISB")),
|
||||
|
||||
@@ -79,9 +79,23 @@ AddressDecoder::AddressDecoder(const DRAMSysConfiguration::AddressMapping &addre
|
||||
}
|
||||
}
|
||||
|
||||
std::copy(addressMapping.bankBits.begin(), addressMapping.bankBits.end(), std::back_inserter(vBankBits));
|
||||
std::copy(addressMapping.rowBits.begin(), addressMapping.rowBits.end(), std::back_inserter(vRowBits));
|
||||
std::copy(addressMapping.coloumnBits.begin(), addressMapping.coloumnBits.end(), std::back_inserter(vColumnBits));
|
||||
if (addressMapping.bankBits.isValid())
|
||||
{
|
||||
auto bankBits = addressMapping.bankBits.getValue();
|
||||
std::copy(bankBits.begin(), bankBits.end(), std::back_inserter(vBankBits));
|
||||
}
|
||||
|
||||
if (addressMapping.rowBits.isValid())
|
||||
{
|
||||
auto rowBits = addressMapping.rowBits.getValue();
|
||||
std::copy(rowBits.begin(), rowBits.end(), std::back_inserter(vRowBits));
|
||||
}
|
||||
|
||||
if (addressMapping.columnBits.isValid())
|
||||
{
|
||||
auto columnBits = addressMapping.columnBits.getValue();
|
||||
std::copy(columnBits.begin(), columnBits.end(), std::back_inserter(vColumnBits));
|
||||
}
|
||||
|
||||
unsigned channels = std::lround(std::pow(2.0, vChannelBits.size()));
|
||||
unsigned ranks = std::lround(std::pow(2.0, vRankBits.size()));
|
||||
|
||||
Reference in New Issue
Block a user