Functionality for JSONAddressDecoder added. Fixed several smaller bugs.
This commit is contained in:
@@ -51,6 +51,7 @@ INCLUDEPATH += $${systemc_home}/include
|
||||
|
||||
INCLUDEPATH += src/common/third_party/DRAMPower/src
|
||||
INCLUDEPATH += src/common/third_party/DRAMPower/src/libdrampower
|
||||
INCLUDEPATH += src/common/third_party/json/include
|
||||
|
||||
DEFINES += TIXML_USE_STL
|
||||
DEFINES += SC_INCLUDE_DYNAMIC_PROCESSES
|
||||
@@ -194,7 +195,8 @@ HEADERS += \
|
||||
src/controller/scheduler/Fr_Fcfs_read_priority.h \
|
||||
src/controller/scheduler/Fr_Fcfs_grouper.h \
|
||||
src/common/AddressDecoder.h \
|
||||
src/common/jsonAddressDecoder.h
|
||||
src/common/jsonAddressDecoder.h \
|
||||
src/common/third_party/json/include/nlohmann/json.hpp
|
||||
|
||||
thermalsim = $$(THERMALSIM)
|
||||
isEmpty(thermalsim) {
|
||||
|
||||
@@ -9,30 +9,31 @@
|
||||
"Name": "merged_sorted",
|
||||
"Solutions": [
|
||||
{
|
||||
"XOR": [],
|
||||
"XOR": [
|
||||
],
|
||||
"Banks Rows": [
|
||||
{
|
||||
"bank_bits": [
|
||||
18,
|
||||
12,
|
||||
11
|
||||
27,
|
||||
28,
|
||||
29
|
||||
],
|
||||
"rows": {
|
||||
"row_bits": [
|
||||
24,
|
||||
13,
|
||||
17,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
25,
|
||||
17,
|
||||
18,
|
||||
19,
|
||||
21,
|
||||
20,
|
||||
26,
|
||||
21,
|
||||
22,
|
||||
23,
|
||||
29,
|
||||
28
|
||||
24,
|
||||
25,
|
||||
26
|
||||
],
|
||||
"costs": 477468
|
||||
},
|
||||
@@ -41,4 +42,4 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,4 +172,5 @@ DISTFILES += \
|
||||
$$PWD/configs/simulator/lpddr4.xml \
|
||||
$$PWD/simulations/lpddr4-single-device.xml \
|
||||
$$PWD/configs/amconfigs/am_lpddr4.xml \
|
||||
$$PWD/configs/memspecs/MICRON_6Gb_LPDDR4-3200_NDA_NDA_NDA.xml
|
||||
$$PWD/configs/memspecs/MICRON_6Gb_LPDDR4-3200_NDA_NDA_NDA.xml \
|
||||
$$PWD/configs/amconfigs/am_test_congen_output.json
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "jsonAddressDecoder.h"
|
||||
#include "Utils.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
@@ -6,6 +7,14 @@ using std::ifstream;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
#include <set>
|
||||
|
||||
using std::set;
|
||||
|
||||
JSONAddressDecoder::JSONAddressDecoder()
|
||||
{
|
||||
|
||||
@@ -23,22 +32,173 @@ void JSONAddressDecoder::setConfiguration(std::string url)
|
||||
return;
|
||||
}
|
||||
|
||||
// parse json file
|
||||
json data;
|
||||
file >> data;
|
||||
|
||||
file.close();
|
||||
|
||||
// extract data
|
||||
// For simplicity takethe first solution of one or more available ones.
|
||||
auto sol = data["Solutions"].begin();
|
||||
assert(sol != data["Solutions"].end());
|
||||
|
||||
// Set for connected bits
|
||||
set<unsigned> sUsed;
|
||||
|
||||
// get XOR connections
|
||||
unsigned num = (*sol)["XOR"].size()>>1;
|
||||
|
||||
for(unsigned i = 0; i < num; i++)
|
||||
{
|
||||
m_vXor.push_back(pair<unsigned, unsigned> ((*sol)["XOR"].at(i), (*sol)["XOR"].at(i+num)));
|
||||
}
|
||||
|
||||
// get all bank bits
|
||||
unsigned counter = 0;
|
||||
for(auto it = (*sol)["Banks Rows"][0]["bank_bits"].begin(); it != (*sol)["Banks Rows"][0]["bank_bits"].end(); it++)
|
||||
{
|
||||
m_vBankBits.push_back(pair<unsigned,unsigned>(counter++, (*it)));
|
||||
sUsed.insert((unsigned)(*it));
|
||||
}
|
||||
|
||||
// get all row bits bits
|
||||
counter = 0;
|
||||
for(auto it = (*sol)["Banks Rows"][0]["rows"]["row_bits"].begin(); it != (*sol)["Banks Rows"][0]["rows"]["row_bits"].end(); it++)
|
||||
{
|
||||
m_vRowBits.push_back(pair<unsigned,unsigned>(counter++, (*it)));
|
||||
sUsed.insert((unsigned)(*it));
|
||||
}
|
||||
|
||||
// Add byte bits (fixed)
|
||||
sUsed.insert(0);
|
||||
sUsed.insert(1);
|
||||
sUsed.insert(2);
|
||||
|
||||
// Theset bits are ignored
|
||||
sUsed.insert(30);
|
||||
sUsed.insert(31);
|
||||
|
||||
// Create Column mapping
|
||||
counter = 0;
|
||||
for(unsigned i = 0; i < 32; i++)
|
||||
{
|
||||
if(sUsed.find(i) != sUsed.end())
|
||||
continue; // Already mapped
|
||||
|
||||
m_vColumnBits.push_back(pair<unsigned, unsigned>(counter++, i));
|
||||
}
|
||||
|
||||
amount["channel"] = 1;
|
||||
amount["bank"] = pow(2.0, m_vBankBits.size());
|
||||
amount["row"] = pow(2.0, m_vRowBits.size());
|
||||
amount["column"] = pow(2.0, m_vColumnBits.size());
|
||||
amount["bytes"] = pow(2.0, 3);
|
||||
}
|
||||
|
||||
DecodedAddress JSONAddressDecoder::decodeAddress(sc_dt::uint64 addr)
|
||||
{
|
||||
DecodedAddress result;
|
||||
|
||||
// Apply XOR
|
||||
for(auto it = m_vXor.begin(); it != m_vXor.end(); it++)
|
||||
{
|
||||
addr &= ~(1 << it->first);
|
||||
addr |= (((addr >> it->first) & 1) ^ ((addr >> it->second) & 1)) << it->first;
|
||||
}
|
||||
|
||||
// Unsed
|
||||
result.bankgroup = 0;
|
||||
result.channel = 0;
|
||||
result.rank = 0;
|
||||
|
||||
// Pass through of the three byte bits
|
||||
result.bytes = addr & 0x7;
|
||||
|
||||
// Bank
|
||||
result.bank = 0;
|
||||
for(auto it = m_vBankBits.begin(); it != m_vBankBits.end(); it++)
|
||||
{
|
||||
result.bank |= ((addr >> it->second) & 1) << it->first;
|
||||
}
|
||||
|
||||
// Row
|
||||
result.row = 0;
|
||||
for(auto it = m_vRowBits.begin(); it != m_vRowBits.end(); it++)
|
||||
{
|
||||
result.row |= ((addr >> it->second) & 1) << it->first;
|
||||
}
|
||||
|
||||
// Column
|
||||
result.column = 0;
|
||||
for(auto it = m_vColumnBits.begin(); it != m_vColumnBits.end(); it++)
|
||||
{
|
||||
result.column |= ((addr >> it->second) & 1) << it->first;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
sc_dt::uint64 JSONAddressDecoder::encodeAddress(DecodedAddress n)
|
||||
{
|
||||
return 0;
|
||||
sc_dt::uint64 address = 0;
|
||||
for(auto it = m_vBankBits.begin(); it != m_vBankBits.end(); it++)
|
||||
{
|
||||
address |= ((n.bank >> it->first) & 1) << it->second;
|
||||
}
|
||||
for(auto it = m_vRowBits.begin(); it != m_vRowBits.end(); it++)
|
||||
{
|
||||
address |= ((n.row >> it->first) & 1) << it->second;
|
||||
}
|
||||
for(auto it = m_vColumnBits.begin(); it != m_vColumnBits.end(); it++)
|
||||
{
|
||||
address |= ((n.column >> it->first) & 1) << it->second;
|
||||
}
|
||||
|
||||
address |= n.bytes;
|
||||
|
||||
// Apply XOR
|
||||
for(auto it = m_vXor.begin(); it != m_vXor.end(); it++)
|
||||
{
|
||||
address &= ~(1 << it->first);
|
||||
address |= (((address >> it->first) & 1) ^ ((address >> it->second) & 1)) << it->first;
|
||||
}
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
void JSONAddressDecoder::print()
|
||||
{
|
||||
map<unsigned, pair<unsigned, char>> output;
|
||||
|
||||
for(auto it = m_vBankBits.begin(); it != m_vBankBits.end(); it++)
|
||||
{
|
||||
output[it->second] = pair<unsigned, char>(it->first , 'B');
|
||||
}
|
||||
for(auto it = m_vRowBits.begin(); it != m_vRowBits.end(); it++)
|
||||
{
|
||||
output[it->second] = pair<unsigned, char>(it->first , 'R');
|
||||
}
|
||||
for(auto it = m_vColumnBits.begin(); it != m_vColumnBits.end(); it++)
|
||||
{
|
||||
output[it->second] = pair<unsigned, char>(it->first , 'C');
|
||||
}
|
||||
|
||||
// add byte bits
|
||||
output[0] = pair<unsigned, char>(0 , 'b');
|
||||
output[1] = pair<unsigned, char>(1 , 'b');
|
||||
output[2] = pair<unsigned, char>(2 , 'b');
|
||||
|
||||
cout << "Used addressmapping:" << endl;
|
||||
cout << headline << endl;
|
||||
for(unsigned i = 0; i < 32; i++)
|
||||
{
|
||||
cout << " " << i << " ";
|
||||
}
|
||||
cout << endl;
|
||||
for(unsigned i = 0; i < 32; i++)
|
||||
{
|
||||
cout << " " << output[i].second << "(" << output[i].first << ") ";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,13 @@
|
||||
|
||||
#include "AddressDecoder.h"
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
using std::vector;
|
||||
using std::pair;
|
||||
using std::map;
|
||||
|
||||
class JSONAddressDecoder
|
||||
: public CAddressDecoder
|
||||
{
|
||||
@@ -46,6 +53,11 @@ class JSONAddressDecoder
|
||||
private:
|
||||
JSONAddressDecoder();
|
||||
|
||||
vector<pair<unsigned,unsigned>> m_vXor;
|
||||
vector<pair<unsigned,unsigned>> m_vBankBits;
|
||||
vector<pair<unsigned,unsigned>> m_vRowBits;
|
||||
vector<pair<unsigned,unsigned>> m_vColumnBits;
|
||||
|
||||
public:
|
||||
virtual void setConfiguration(std::string url);
|
||||
|
||||
|
||||
@@ -50,7 +50,6 @@ class xmlAddressDecoder
|
||||
friend class CAddressDecoder;
|
||||
|
||||
private:
|
||||
|
||||
xmlAddressDecoder();
|
||||
|
||||
std::map<std::string, sc_dt::uint64> masks;
|
||||
@@ -59,16 +58,13 @@ private:
|
||||
tinyxml2::XMLElement* addressmapping;
|
||||
|
||||
public:
|
||||
DecodedAddress decodeAddress(sc_dt::uint64 addr);
|
||||
sc_dt::uint64 encodeAddress(DecodedAddress n);
|
||||
virtual DecodedAddress decodeAddress(sc_dt::uint64 addr);
|
||||
virtual sc_dt::uint64 encodeAddress(DecodedAddress n);
|
||||
|
||||
void setConfiguration(std::string url);
|
||||
private:
|
||||
void setConfiguration(tinyxml2::XMLElement* addressMap);
|
||||
public:
|
||||
void print();
|
||||
|
||||
std::map<std::string, unsigned int> amount;
|
||||
public:
|
||||
virtual void print();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -94,7 +94,9 @@ DRAMSys::DRAMSys(sc_module_name __attribute__((unused)) name,
|
||||
else if(amconfig.find(".json") != string::npos)
|
||||
{
|
||||
CAddressDecoder::createInstance(CAddressDecoder::Type::JSON);
|
||||
CAddressDecoder::getInstance().setConfiguration(pathToResources + amconfig);
|
||||
CAddressDecoder::getInstance().setConfiguration(pathToResources
|
||||
+ "configs/amconfigs/"
|
||||
+ amconfig);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user