Add EccModule to simulator

This commit is contained in:
2023-01-12 10:54:39 +01:00
parent 2d0445d5a7
commit c8e509a120
12 changed files with 374 additions and 52 deletions

View File

@@ -288,4 +288,18 @@ public:
static bool notifyChildTransCompletion(tlm::tlm_generic_payload& trans);
};
class EccExtension : public tlm::tlm_extension<EccExtension>
{
public:
tlm_extension_base* clone() const override
{
return new EccExtension;
}
void copy_from(tlm_extension_base const &ext) override
{
auto const &cpyFrom = static_cast<EccExtension const &>(ext);
}
};
#endif // DRAMEXTENSIONS_H

View File

@@ -515,7 +515,10 @@ void Controller::manageResponses()
tlm_generic_payload* nextTransInRespQueue = respQueue->nextPayload();
if (nextTransInRespQueue != nullptr)
{
// Ignore ECC requests
if (nextTransInRespQueue->get_extension<EccExtension>() == nullptr)
numberOfBeatsServed += ControllerExtension::getBurstLength(*nextTransInRespQueue);
if (ChildExtension::isChildTrans(*nextTransInRespQueue))
{
tlm_generic_payload& parentTrans = ChildExtension::getParentTrans(*nextTransInRespQueue);

View File

@@ -37,13 +37,14 @@
*/
#include "AddressDecoder.h"
#include "DRAMSys/configuration/Configuration.h"
#include <cmath>
#include <iostream>
#include <iomanip>
#include <bitset>
AddressDecoder::AddressDecoder(const Configuration& config, const DRAMSys::Config::AddressMapping& addressMapping)
AddressDecoder::AddressDecoder(const DRAMSys::Config::AddressMapping &addressMapping, const MemSpec &memSpec)
{
if (const auto &channelBits = addressMapping.CONGEN.CHANNEL_BIT)
{
@@ -113,8 +114,6 @@ AddressDecoder::AddressDecoder(const Configuration& config, const DRAMSys::Confi
SC_REPORT_FATAL("AddressDecoder", "Not all address bits occur exactly once");
}
const MemSpec& memSpec = *config.memSpec;
unsigned highestByteBit = *std::max_element(vByteBits.begin(), vByteBits.end());
for (unsigned bitPosition = 0; bitPosition <= highestByteBit; bitPosition++)
@@ -213,6 +212,41 @@ unsigned AddressDecoder::decodeChannel(uint64_t encAddr) const
return channel;
}
uint64_t AddressDecoder::encodeAddress(DecodedAddress decodedAddress) const
{
// Convert absoulte addressing for bank, bankgroup to relative
decodedAddress.bankgroup = decodedAddress.bankgroup % bankgroupsPerRank;
decodedAddress.bank = decodedAddress.bank % banksPerGroup;
uint64_t address = 0;
for (unsigned i = 0; i < vChannelBits.size(); i++)
address |= ((decodedAddress.channel >> i) & 0x1) << vChannelBits[i];
for (unsigned i = 0; i < vRankBits.size(); i++)
address |= ((decodedAddress.rank >> i) & 0x1) << vRankBits[i];
for (unsigned i = 0; i < vBankGroupBits.size(); i++)
address |= ((decodedAddress.bankgroup >> i) & 0x1) << vBankGroupBits[i];
for (unsigned i = 0; i < vBankBits.size(); i++)
address |= ((decodedAddress.bank >> i) & 0x1) << vBankBits[i];
for (unsigned i = 0; i < vRowBits.size(); i++)
address |= ((decodedAddress.row >> i) & 0x1) << vRowBits[i];
for (unsigned i = 0; i < vColumnBits.size(); i++)
address |= ((decodedAddress.column >> i) & 0x1) << vColumnBits[i];
for (unsigned i = 0; i < vByteBits.size(); i++)
address |= ((decodedAddress.byte >> i) & 0x1) << vByteBits[i];
// TODO: XOR encoding
return address;
}
void AddressDecoder::print() const
{
std::cout << headline << std::endl;

View File

@@ -39,9 +39,8 @@
#ifndef ADDRESSDECODER_H
#define ADDRESSDECODER_H
#include "DRAMSys/configuration/Configuration.h"
#include "DRAMSys/config/DRAMSysConfiguration.h"
#include "DRAMSys/configuration/Configuration.h"
#include <vector>
#include <utility>
@@ -69,9 +68,10 @@ struct DecodedAddress
class AddressDecoder
{
public:
AddressDecoder(const Configuration& config, const DRAMSys::Config::AddressMapping& addressMapping);
AddressDecoder(const DRAMSys::Config::AddressMapping &addressMapping, const MemSpec &memSpec);
[[nodiscard]] DecodedAddress decodeAddress(uint64_t encAddr) const;
[[nodiscard]] unsigned decodeChannel(uint64_t encAddr) const;
[[nodiscard]] uint64_t encodeAddress(DecodedAddress decodedAddress) const;
void print() const;
private:

View File

@@ -157,7 +157,7 @@ void DRAMSys::setupDebugManager(NDEBUG_UNUSED(const std::string& traceName)) con
void DRAMSys::instantiateModules(const ::DRAMSys::Config::AddressMapping& addressMapping)
{
addressDecoder = std::make_unique<AddressDecoder>(config, addressMapping);
addressDecoder = std::make_unique<AddressDecoder>(addressMapping, *config.memSpec);
addressDecoder->print();
// Create arbiter

View File

@@ -70,6 +70,7 @@ public:
const ::DRAMSys::Config::Configuration& configLib);
const Configuration& getConfig() const;
const AddressDecoder &getAddressDecoder() const { return *addressDecoder; }
protected:
DRAMSys(const sc_core::sc_module_name& name,

View File

@@ -120,7 +120,7 @@ void DRAMSysRecordable::setupTlmRecorders(const std::string& traceName,
void DRAMSysRecordable::instantiateModules(const std::string& traceName,
const ::DRAMSys::Config::Configuration& configLib)
{
addressDecoder = std::make_unique<AddressDecoder>(config, configLib.addressmapping);
addressDecoder = std::make_unique<AddressDecoder>(configLib.addressmapping, *config.memSpec);
addressDecoder->print();
// Create and properly initialize TLM recorders.

View File

@@ -102,7 +102,7 @@ Request StlPlayer::nextRequest()
delay -= sc_core::sc_time_stamp();
}
Request request(std::move(*readoutIt));
Request request(*readoutIt);
request.delay = delay;
readoutIt++;

View File

@@ -0,0 +1,149 @@
/*
* Copyright (c) 2022, Technische Universität 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:
* Derek Christ
*/
#pragma once
#include <string>
inline constexpr std::string_view memSpecJsonString = R"(
{
"memspec": {
"memarchitecturespec": {
"burstLength": 16,
"dataRate": 8,
"nbrOfBankGroups": 4,
"nbrOfBanks": 16,
"nbrOfColumns": 1024,
"nbrOfRows": 65536,
"nbrOfRanks": 1,
"nbrOfDevices": 1,
"nbrOfChannels": 1,
"width": 16,
"per2BankOffset": 8
},
"memoryId": "JEDEC_1Gbx16_BG_LPDDR5-6400",
"memoryType": "LPDDR5",
"memtimingspec": {
"RCD": 15,
"PPD": 2,
"RPab": 17,
"RPpb": 15,
"RAS": 34,
"RCab": 51,
"RCpb": 48,
"FAW": 16,
"RRD": 4,
"RL": 17,
"WCK2CK": 0,
"WCK2DQO": 1,
"RBTP": 4,
"RPRE": 0,
"RPST": 0,
"WL": 9,
"WCK2DQI": 0,
"WPRE": 0,
"WPST": 0,
"WR": 28,
"WTR_L": 10,
"WTR_S": 5,
"CCDMW": 16,
"REFI": 3124,
"REFIpb": 390,
"RFCab": 224,
"RFCpb": 112,
"RTRS": 1,
"BL_n_min_16": 2,
"BL_n_max_16": 4,
"BL_n_L_16": 4,
"BL_n_S_16": 2,
"BL_n_min_32": 6,
"BL_n_max_32": 8,
"BL_n_L_32": 8,
"BL_n_S_32": 2,
"pbR2act": 6,
"pbR2pbR": 72,
"clkMhz": 800
}
}
}
)";
inline constexpr std::string_view addressMappingJsonString = R"(
{
"CONGEN": {
"BYTE_BIT": [
0
],
"COLUMN_BIT": [
1,
2,
3,
4,
9,
10,
11,
12,
13,
14
],
"BANKGROUP_BIT": [
5,
6
],
"BANK_BIT": [
7,
8
],
"ROW_BIT": [
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30
]
}
}
)";

View File

@@ -0,0 +1,119 @@
/*
* Copyright (c) 2022, Technische Universität 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:
* Derek Christ
*/
#include "AddressDecoderConfigs.h"
#include <gtest/gtest.h>
#include <DRAMSys/configuration/memspec/MemSpecLPDDR5.h>
#include <DRAMSys/simulation/AddressDecoder.h>
class AddressDecoderFixture : public ::testing::Test
{
protected:
AddressDecoderFixture() :
addressMappingJson(nlohmann::json::parse(addressMappingJsonString)),
memSpecJson(nlohmann::json::parse(memSpecJsonString).at("memspec")),
addressMappingConfig(addressMappingJson.get<DRAMSys::Config::AddressMapping>()),
memSpec(memSpecConfig),
memSpecConfig(memSpecJson.get<DRAMSys::Config::MemSpec>()),
addressDecoder(addressMappingConfig, memSpec)
{
}
nlohmann::json addressMappingJson;
nlohmann::json memSpecJson;
// Configs
DRAMSys::Config::AddressMapping addressMappingConfig;
DRAMSys::Config::MemSpec memSpecConfig;
MemSpecLPDDR5 memSpec;
AddressDecoder addressDecoder;
};
TEST_F(AddressDecoderFixture, Decoding)
{
uint64_t address = 0x3A59'1474;
auto decodedAddress = addressDecoder.decodeAddress(address);
unsigned int channel = decodedAddress.channel;
unsigned int rank = decodedAddress.rank;
unsigned int bankgroup = decodedAddress.bankgroup;
unsigned int bank = decodedAddress.bank;
unsigned int row = decodedAddress.row;
unsigned int column = decodedAddress.column;
unsigned int byte = decodedAddress.byte;
EXPECT_EQ(channel, 0);
EXPECT_EQ(rank, 0);
EXPECT_EQ(bankgroup, 3);
EXPECT_EQ(bank, 12);
EXPECT_EQ(row, 29874);
EXPECT_EQ(column, 170);
EXPECT_EQ(byte, 0);
}
TEST_F(AddressDecoderFixture, Encoding)
{
unsigned int channel = 0;
unsigned int rank = 0;
unsigned int bankgroup = 3;
unsigned int bank = 12;
unsigned int row = 29874;
unsigned int column = 170;
unsigned int byte = 0;
DecodedAddress decodedAddress(channel, rank, bankgroup, bank, row, column, byte);
uint64_t address = addressDecoder.encodeAddress(decodedAddress);
EXPECT_EQ(address, 0x3A59'1474);
}
TEST_F(AddressDecoderFixture, DeEncoding)
{
std::array testAddresses{std::uint64_t(0x3A59'1474),
std::uint64_t(0x0000'0000),
std::uint64_t(0x2FFA'1231),
std::uint64_t(0x0001'FFFF)};
for (auto address: testAddresses)
{
DecodedAddress decodedAddress = addressDecoder.decodeAddress(address);
uint64_t encodedAddress = addressDecoder.encodeAddress(decodedAddress);
EXPECT_EQ(encodedAddress, address);
}
}

View File

@@ -1,42 +1,43 @@
///*
// * Copyright (c) 2019, Technische Universität 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:
// * Lukas Steiner
// */
//
//#include <gtest/gtest.h>
//#include "../library/src/controller/Command.h"
//
//TEST(testsuite, test)
//{
// EXPECT_EQ(commandToString(Command::ACT), "ACT");
//}
/*
* Copyright (c) 2019, Technische Universität 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:
* Lukas Steiner
*/
#include <DRAMSys/controller/Command.h>
#include <gtest/gtest.h>
TEST(testsuite, test)
{
EXPECT_EQ(Command(Command::Type::ACT).toString(), "ACT");
}

View File

@@ -35,6 +35,7 @@
#include <gtest/gtest.h>
#include <systemc>
#include "Testfile.h"
int sc_main(int argc, char **argv)
{