Changes suggest by review colleagues.
This commit is contained in:
@@ -1,16 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2018, University of Kaiserslautern
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
|
||||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors:
|
||||
* Johannes Feldmann
|
||||
*/
|
||||
|
||||
#include "AddressDecoder.h"
|
||||
#include "xmlAddressdecoder.h"
|
||||
#include "jsonAddressDecoder.h"
|
||||
|
||||
CAddressDecoder* CAddressDecoder::m_pInstance = nullptr;
|
||||
AddressDecoder* AddressDecoder::m_pInstance = nullptr;
|
||||
|
||||
CAddressDecoder& CAddressDecoder::getInstance()
|
||||
AddressDecoder& AddressDecoder::getInstance()
|
||||
{
|
||||
assert(m_pInstance != nullptr);
|
||||
return *m_pInstance;
|
||||
}
|
||||
|
||||
void CAddressDecoder::createInstance(Type t)
|
||||
void AddressDecoder::createInstance(Type t)
|
||||
{
|
||||
assert(m_pInstance == nullptr);
|
||||
switch(t)
|
||||
@@ -24,7 +59,7 @@ void CAddressDecoder::createInstance(Type t)
|
||||
}
|
||||
}
|
||||
|
||||
CAddressDecoder::CAddressDecoder()
|
||||
AddressDecoder::AddressDecoder()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ struct DecodedAddress
|
||||
unsigned int bytes;
|
||||
};
|
||||
|
||||
class CAddressDecoder
|
||||
class AddressDecoder
|
||||
{
|
||||
public:
|
||||
enum class Type
|
||||
@@ -73,11 +73,11 @@ public:
|
||||
};
|
||||
|
||||
protected:
|
||||
CAddressDecoder();
|
||||
AddressDecoder();
|
||||
|
||||
static CAddressDecoder* m_pInstance;
|
||||
static AddressDecoder* m_pInstance;
|
||||
public:
|
||||
static CAddressDecoder& getInstance();
|
||||
static AddressDecoder& getInstance();
|
||||
static void createInstance(Type t);
|
||||
|
||||
virtual void setConfiguration(std::string url) = 0;
|
||||
|
||||
@@ -1,3 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2018, University of Kaiserslautern
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
|
||||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors:
|
||||
* Johannes Feldmann
|
||||
*/
|
||||
|
||||
#include "jsonAddressDecoder.h"
|
||||
#include "Utils.h"
|
||||
|
||||
|
||||
@@ -46,9 +46,11 @@ using std::pair;
|
||||
using std::map;
|
||||
|
||||
class JSONAddressDecoder
|
||||
: public CAddressDecoder
|
||||
: public AddressDecoder
|
||||
{
|
||||
friend class CAddressDecoder;
|
||||
// Friendship needed so that the AddressDecoder can access the
|
||||
// constructor of this class to create the object in CreateInstance.
|
||||
friend class AddressDecoder;
|
||||
|
||||
private:
|
||||
JSONAddressDecoder();
|
||||
|
||||
@@ -45,9 +45,11 @@
|
||||
#include "AddressDecoder.h"
|
||||
|
||||
class xmlAddressDecoder
|
||||
: public CAddressDecoder
|
||||
: public AddressDecoder
|
||||
{
|
||||
friend class CAddressDecoder;
|
||||
// Friendship needed so that the AddressDecoder can access the
|
||||
// constructor of this class to create the object in CreateInstance.
|
||||
friend class AddressDecoder;
|
||||
|
||||
private:
|
||||
xmlAddressDecoder();
|
||||
|
||||
@@ -191,7 +191,7 @@ void Configuration::setParameter(std::string name, std::string value)
|
||||
Debug = string2bool(value);
|
||||
else if (name == "NumberOfMemChannels") {
|
||||
NumberOfMemChannels = string2int(value);
|
||||
unsigned int maxNumberofMemChannels = CAddressDecoder::getInstance().amount["channel"];
|
||||
unsigned int maxNumberofMemChannels = AddressDecoder::getInstance().amount["channel"];
|
||||
if (NumberOfMemChannels > maxNumberofMemChannels) {
|
||||
SC_REPORT_FATAL("Configuration", ("Invalid value for parameter "
|
||||
+ name
|
||||
@@ -349,7 +349,7 @@ unsigned int Configuration::getBytesPerBurst()
|
||||
// The least significant bits of the physical address are the byte
|
||||
// offset of the N-byte-wide memory module (DIMM) (a single data word
|
||||
// or burst element has N bytes. N = 2^(# bits for byte offset)).
|
||||
unsigned int burstElementSizeInBytes = CAddressDecoder::getInstance().amount["bytes"];
|
||||
unsigned int burstElementSizeInBytes = AddressDecoder::getInstance().amount["bytes"];
|
||||
assert(bytesPerBurst == (burstElementSizeInBytes * memSpec.BurstLength));
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ void errorModel::init()
|
||||
// Get Configuration parameters:
|
||||
burstLenght = Configuration::getInstance().memSpec.BurstLength;
|
||||
numberOfColumns = Configuration::getInstance().memSpec.NumberOfColumns;
|
||||
bytesPerColumn = CAddressDecoder::getInstance().amount["bytes"];
|
||||
bytesPerColumn = AddressDecoder::getInstance().amount["bytes"];
|
||||
|
||||
// Adjust number of bytes per column dynamically to the selected ecc controller
|
||||
bytesPerColumn = Configuration::getInstance().adjustNumBytesAfterECC(bytesPerColumn);
|
||||
@@ -157,7 +157,7 @@ void errorModel::store(tlm::tlm_generic_payload &trans)
|
||||
markBitFlips();
|
||||
|
||||
// Get the key for the dataMap from the transaction's address:
|
||||
DecodedAddress key = CAddressDecoder::getInstance().decodeAddress(trans.get_address());
|
||||
DecodedAddress key = AddressDecoder::getInstance().decodeAddress(trans.get_address());
|
||||
// Set context:
|
||||
setContext(key);
|
||||
|
||||
@@ -225,7 +225,7 @@ void errorModel::load(tlm::tlm_generic_payload &trans)
|
||||
markBitFlips();
|
||||
|
||||
// Get the key for the dataMap from the transaction's address:
|
||||
DecodedAddress key = CAddressDecoder::getInstance().decodeAddress(trans.get_address());
|
||||
DecodedAddress key = AddressDecoder::getInstance().decodeAddress(trans.get_address());
|
||||
|
||||
// Set context:
|
||||
setContext(key);
|
||||
|
||||
@@ -120,8 +120,8 @@ class errorModel : public sc_module
|
||||
{
|
||||
bool operator()( const DecodedAddress& first , const DecodedAddress& second) const
|
||||
{
|
||||
sc_dt::uint64 addrFirst = CAddressDecoder::getInstance().encodeAddress(first);
|
||||
sc_dt::uint64 addrSecond = CAddressDecoder::getInstance().encodeAddress(second);
|
||||
sc_dt::uint64 addrFirst = AddressDecoder::getInstance().encodeAddress(first);
|
||||
sc_dt::uint64 addrSecond = AddressDecoder::getInstance().encodeAddress(second);
|
||||
return addrFirst < addrSecond;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -151,7 +151,7 @@ private:
|
||||
// adjust address offset:
|
||||
trans.set_address(trans.get_address() - Configuration::getInstance().AddressOffset);
|
||||
|
||||
DecodedAddress decodedAddress = CAddressDecoder::getInstance().decodeAddress(trans.get_address());
|
||||
DecodedAddress decodedAddress = AddressDecoder::getInstance().decodeAddress(trans.get_address());
|
||||
return iSocket[decodedAddress.channel]->transport_dbg(trans);
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ private:
|
||||
payload.set_auto_extension(genExtension);
|
||||
|
||||
unsigned int burstlength = payload.get_streaming_width();
|
||||
DecodedAddress decodedAddress = CAddressDecoder::getInstance().decodeAddress(payload.get_address());
|
||||
DecodedAddress decodedAddress = AddressDecoder::getInstance().decodeAddress(payload.get_address());
|
||||
// Check the valid range of decodedAddress
|
||||
if (addressIsValid(decodedAddress)) {
|
||||
DramExtension* extension = new DramExtension(Thread(socketId+1), Channel(decodedAddress.channel), Bank(decodedAddress.bank), BankGroup(decodedAddress.bankgroup), Row(decodedAddress.row), Column(decodedAddress.column),burstlength);
|
||||
@@ -260,19 +260,19 @@ private:
|
||||
|
||||
bool addressIsValid(DecodedAddress& decodedAddress)
|
||||
{
|
||||
if (decodedAddress.channel >= CAddressDecoder::getInstance().amount["channel"]) {
|
||||
if (decodedAddress.channel >= AddressDecoder::getInstance().amount["channel"]) {
|
||||
return false;
|
||||
}
|
||||
if (decodedAddress.bank >= CAddressDecoder::getInstance().amount["bank"]) {
|
||||
if (decodedAddress.bank >= AddressDecoder::getInstance().amount["bank"]) {
|
||||
return false;
|
||||
}
|
||||
if (decodedAddress.bankgroup > CAddressDecoder::getInstance().amount["bankgroup"]) {
|
||||
if (decodedAddress.bankgroup > AddressDecoder::getInstance().amount["bankgroup"]) {
|
||||
return false;
|
||||
}
|
||||
if (decodedAddress.column >= CAddressDecoder::getInstance().amount["column"]) {
|
||||
if (decodedAddress.column >= AddressDecoder::getInstance().amount["column"]) {
|
||||
return false;
|
||||
}
|
||||
if (decodedAddress.row >= CAddressDecoder::getInstance().amount["row"]) {
|
||||
if (decodedAddress.row >= AddressDecoder::getInstance().amount["row"]) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -86,15 +86,15 @@ DRAMSys::DRAMSys(sc_module_name __attribute__((unused)) name,
|
||||
|
||||
if(amconfig.find(".xml") != string::npos)
|
||||
{
|
||||
CAddressDecoder::createInstance(CAddressDecoder::Type::XML);
|
||||
CAddressDecoder::getInstance().setConfiguration(pathToResources
|
||||
AddressDecoder::createInstance(AddressDecoder::Type::XML);
|
||||
AddressDecoder::getInstance().setConfiguration(pathToResources
|
||||
+ "configs/amconfigs/"
|
||||
+ amconfig);
|
||||
}
|
||||
else if(amconfig.find(".json") != string::npos)
|
||||
{
|
||||
CAddressDecoder::createInstance(CAddressDecoder::Type::JSON);
|
||||
CAddressDecoder::getInstance().setConfiguration(pathToResources
|
||||
AddressDecoder::createInstance(AddressDecoder::Type::JSON);
|
||||
AddressDecoder::getInstance().setConfiguration(pathToResources
|
||||
+ "configs/amconfigs/"
|
||||
+ amconfig);
|
||||
}
|
||||
@@ -103,7 +103,7 @@ DRAMSys::DRAMSys(sc_module_name __attribute__((unused)) name,
|
||||
cout << "No address mapping loaded. Unknown file extension" << endl;
|
||||
}
|
||||
|
||||
CAddressDecoder::getInstance().print();
|
||||
AddressDecoder::getInstance().print();
|
||||
|
||||
ConfigurationLoader::loadMemSpec(Configuration::getInstance(),
|
||||
pathToResources
|
||||
|
||||
Reference in New Issue
Block a user