Extract plausability check from AddressDecoder to separate function
This commit is contained in:
@@ -47,8 +47,7 @@
|
||||
namespace DRAMSys
|
||||
{
|
||||
|
||||
AddressDecoder::AddressDecoder(const DRAMSys::Config::AddressMapping& addressMapping,
|
||||
const MemSpec& memSpec)
|
||||
AddressDecoder::AddressDecoder(const DRAMSys::Config::AddressMapping& addressMapping)
|
||||
{
|
||||
if (const auto& channelBits = addressMapping.CHANNEL_BIT)
|
||||
{
|
||||
@@ -108,6 +107,23 @@ AddressDecoder::AddressDecoder(const DRAMSys::Config::AddressMapping& addressMap
|
||||
unsigned columns = std::lround(std::pow(2.0, vColumnBits.size()));
|
||||
unsigned bytes = std::lround(std::pow(2.0, vByteBits.size()));
|
||||
|
||||
maximumAddress =
|
||||
static_cast<uint64_t>(bytes) * columns * rows * banks * bankGroups * ranks * channels - 1;
|
||||
|
||||
bankgroupsPerRank = bankGroups;
|
||||
banksPerGroup = banks;
|
||||
}
|
||||
|
||||
void AddressDecoder::plausibilityCheck(const MemSpec& memSpec)
|
||||
{
|
||||
unsigned channels = std::lround(std::pow(2.0, vChannelBits.size()));
|
||||
unsigned ranks = std::lround(std::pow(2.0, vRankBits.size()));
|
||||
unsigned bankGroups = std::lround(std::pow(2.0, vBankGroupBits.size()));
|
||||
unsigned banks = std::lround(std::pow(2.0, vBankBits.size()));
|
||||
unsigned rows = std::lround(std::pow(2.0, vRowBits.size()));
|
||||
unsigned columns = std::lround(std::pow(2.0, vColumnBits.size()));
|
||||
unsigned bytes = std::lround(std::pow(2.0, vByteBits.size()));
|
||||
|
||||
maximumAddress =
|
||||
static_cast<uint64_t>(bytes) * columns * rows * banks * bankGroups * ranks * channels - 1;
|
||||
|
||||
@@ -131,7 +147,8 @@ AddressDecoder::AddressDecoder(const DRAMSys::Config::AddressMapping& addressMap
|
||||
{
|
||||
highestByteBit = static_cast<int>(*std::max_element(vByteBits.begin(), vByteBits.end()));
|
||||
|
||||
for (unsigned bitPosition = 0; bitPosition <= static_cast<unsigned>(highestByteBit); bitPosition++)
|
||||
for (unsigned bitPosition = 0; bitPosition <= static_cast<unsigned>(highestByteBit);
|
||||
bitPosition++)
|
||||
{
|
||||
if (std::find(vByteBits.begin(), vByteBits.end(), bitPosition) == vByteBits.end())
|
||||
SC_REPORT_FATAL("AddressDecoder", "Byte bits are not continuous starting from 0");
|
||||
@@ -148,16 +165,13 @@ AddressDecoder::AddressDecoder(const DRAMSys::Config::AddressMapping& addressMap
|
||||
SC_REPORT_FATAL("AddressDecoder", "No continuous column bits for maximum burst length");
|
||||
}
|
||||
|
||||
bankgroupsPerRank = bankGroups;
|
||||
bankGroups = bankgroupsPerRank * ranks;
|
||||
|
||||
banksPerGroup = banks;
|
||||
banks = banksPerGroup * bankGroups;
|
||||
unsigned absoluteBankGroups = bankgroupsPerRank * ranks;
|
||||
unsigned absoluteBanks = banksPerGroup * absoluteBankGroups;
|
||||
|
||||
if (memSpec.numberOfChannels != channels || memSpec.ranksPerChannel != ranks ||
|
||||
memSpec.bankGroupsPerChannel != bankGroups || memSpec.banksPerChannel != banks ||
|
||||
memSpec.rowsPerBank != rows || memSpec.columnsPerRow != columns ||
|
||||
memSpec.devicesPerRank * memSpec.bitWidth != bytes * 8)
|
||||
memSpec.bankGroupsPerChannel != absoluteBankGroups ||
|
||||
memSpec.banksPerChannel != absoluteBanks || memSpec.rowsPerBank != rows ||
|
||||
memSpec.columnsPerRow != columns || memSpec.devicesPerRank * memSpec.bitWidth != bytes * 8)
|
||||
SC_REPORT_FATAL("AddressDecoder", "Memspec and address mapping do not match");
|
||||
}
|
||||
|
||||
|
||||
@@ -81,11 +81,14 @@ struct DecodedAddress
|
||||
class AddressDecoder
|
||||
{
|
||||
public:
|
||||
AddressDecoder(const DRAMSys::Config::AddressMapping& addressMapping, const MemSpec& memSpec);
|
||||
AddressDecoder(const DRAMSys::Config::AddressMapping& addressMapping);
|
||||
|
||||
[[nodiscard]] DecodedAddress decodeAddress(uint64_t encAddr) const;
|
||||
[[nodiscard]] unsigned decodeChannel(uint64_t encAddr) const;
|
||||
[[nodiscard]] uint64_t encodeAddress(DecodedAddress decodedAddress) const;
|
||||
|
||||
void print() const;
|
||||
void plausibilityCheck(const MemSpec &memSpec);
|
||||
|
||||
private:
|
||||
unsigned banksPerGroup;
|
||||
|
||||
@@ -151,7 +151,8 @@ void DRAMSys::setupDebugManager([[maybe_unused]] const std::string& traceName) c
|
||||
|
||||
void DRAMSys::instantiateModules(const ::DRAMSys::Config::AddressMapping& addressMapping)
|
||||
{
|
||||
addressDecoder = std::make_unique<AddressDecoder>(addressMapping, *config.memSpec);
|
||||
addressDecoder = std::make_unique<AddressDecoder>(addressMapping);
|
||||
addressDecoder->plausibilityCheck(*config.memSpec);
|
||||
addressDecoder->print();
|
||||
|
||||
// Create arbiter
|
||||
|
||||
@@ -106,7 +106,8 @@ void DRAMSysRecordable::setupTlmRecorders(const std::string& traceName,
|
||||
void DRAMSysRecordable::instantiateModules(const std::string& traceName,
|
||||
const ::DRAMSys::Config::Configuration& configLib)
|
||||
{
|
||||
addressDecoder = std::make_unique<AddressDecoder>(configLib.addressmapping, *config.memSpec);
|
||||
addressDecoder = std::make_unique<AddressDecoder>(configLib.addressmapping);
|
||||
addressDecoder->plausibilityCheck(*config.memSpec);
|
||||
addressDecoder->print();
|
||||
|
||||
// Create and properly initialize TLM recorders.
|
||||
|
||||
Reference in New Issue
Block a user