Skip to content

Commit

Permalink
Updated LPDDR5 unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IESE-T3 committed Jul 19, 2024
1 parent d304bb3 commit 8bb3e2e
Show file tree
Hide file tree
Showing 101 changed files with 161 additions and 306 deletions.
8 changes: 4 additions & 4 deletions src/DRAMPower/DRAMPower/data/energy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ double energy_info_t::total() const
return total;
};

void energy_info_t::to_json(nlohmann::json &j) const
void energy_info_t::to_json(json_t &j) const
{
j = nlohmann::json{
{"ACT", E_act},
Expand Down Expand Up @@ -80,7 +80,7 @@ double DRAMPower::energy_t::total() const
return total;
}

void DRAMPower::interface_energy_info_t::to_json(nlohmann::json &j) const
void DRAMPower::interface_energy_info_t::to_json(json_t &j) const
{
j = nlohmann::json{};
j["controller"]["dynamicEnergy"] = controller.dynamicEnergy;
Expand All @@ -89,7 +89,7 @@ void DRAMPower::interface_energy_info_t::to_json(nlohmann::json &j) const
j["dram"]["staticEnergy"] = dram.staticEnergy;
}

void DRAMPower::energy_t::to_json(nlohmann::json &j) const
void DRAMPower::energy_t::to_json(json_t &j) const
{
j = nlohmann::json{
{"E_bg_act_shared", E_bg_act_shared},
Expand All @@ -103,7 +103,7 @@ void DRAMPower::energy_t::to_json(nlohmann::json &j) const
auto energy_arr = nlohmann::json::array();
for (const energy_info_t& energy : bank_energy)
{
nlohmann::json bank_energy_json;
json_t bank_energy_json;
energy.to_json(bank_energy_json);
energy_arr.push_back(bank_energy_json);
}
Expand Down
9 changes: 5 additions & 4 deletions src/DRAMPower/DRAMPower/data/energy.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

#include <vector>
#include <iostream>
#include <nlohmann/json.hpp>

#include <DRAMUtils/util/json.h>

namespace DRAMPower {

Expand All @@ -29,7 +30,7 @@ struct energy_info_t
double E_ref_2B = 0.0;

double total() const;
void to_json(nlohmann::json &j) const;
void to_json(json_t &j) const;
energy_info_t& operator+=(const energy_info_t & other);
// Operator << for std::cout
friend std::ostream & operator<<(std::ostream & os, const energy_info_t & ei)
Expand Down Expand Up @@ -57,7 +58,7 @@ struct energy_t
{
std::vector<energy_info_t> bank_energy;
energy_info_t total_energy(); // TODO rename
void to_json(nlohmann::json &j) const;
void to_json(json_t &j) const;
constexpr inline const char * const get_Bank_energy_keyword() const
{
return "BankEnergy";
Expand Down Expand Up @@ -137,7 +138,7 @@ struct interface_energy_info_t
os << "Total: " << e.total() << std::endl;
return os;
}
void to_json(nlohmann::json &j) const;
void to_json(json_t &j) const;
};

};
Expand Down
2 changes: 1 addition & 1 deletion src/DRAMPower/DRAMPower/memspec/MemSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@


using namespace DRAMPower;
using json = nlohmann::json;
using json_t = nlohmann::json;


3 changes: 1 addition & 2 deletions src/DRAMPower/DRAMPower/memspec/MemSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@

#include <DRAMPower/command/CmdType.h>

#include <nlohmann/json.hpp>
#include <DRAMUtils/util/json.h>
#include <DRAMUtils/memspec/MemSpec.h>

#include <vector>
#include <algorithm>


using json = nlohmann::json;
namespace DRAMPower {

struct MemSpecContainer
Expand Down
2 changes: 1 addition & 1 deletion src/DRAMPower/DRAMPower/memspec/MemSpecDDR4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

#include "MemSpecDDR4.h"
using namespace DRAMPower;
using json = nlohmann::json;
using json_t = nlohmann::json;


MemSpecDDR4::MemSpecDDR4(const DRAMUtils::MemSpec::MemSpecDDR4 &memspec)
Expand Down
10 changes: 6 additions & 4 deletions src/DRAMPower/DRAMPower/memspec/MemSpecDDR4.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@
#define DRAMPOWER_MEMSPEC_MEMSPECDDR4_H

#include "MemSpec.h"

#include <DRAMUtils/memspec/standards/MemSpecDDR4.h>
#include <nlohmann/json.hpp>

using json = nlohmann::json;
#include <DRAMUtils/util/json.h>


namespace DRAMPower {

class MemSpecDDR4 final : public MemSpec<DRAMUtils::MemSpec::MemSpecDDR4>
Expand All @@ -59,8 +61,8 @@ class MemSpecDDR4 final : public MemSpec<DRAMUtils::MemSpec::MemSpecDDR4>

MemSpecDDR4(const DRAMUtils::MemSpec::MemSpecDDR4 &memspec);

MemSpecDDR4(json &data) = delete;
MemSpecDDR4(const json &data) = delete;
MemSpecDDR4(json_t &data) = delete;
MemSpecDDR4(const json_t &data) = delete;

~MemSpecDDR4() = default;

Expand Down
2 changes: 1 addition & 1 deletion src/DRAMPower/DRAMPower/memspec/MemSpecDDR5.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "MemSpecDDR5.h"
using namespace DRAMPower;
using json = nlohmann::json;
using json_t = nlohmann::json;


MemSpecDDR5::MemSpecDDR5(const DRAMUtils::MemSpec::MemSpecDDR5 &memspec)
Expand Down
5 changes: 3 additions & 2 deletions src/DRAMPower/DRAMPower/memspec/MemSpecDDR5.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define DRAMPOWER_MEMSPEC_MEMSPECDDR5_H

#include "MemSpec.h"

#include <DRAMUtils/memspec/standards/MemSpecDDR5.h>


Expand All @@ -20,8 +21,8 @@ namespace DRAMPower {

MemSpecDDR5(const DRAMUtils::MemSpec::MemSpecDDR5 &memspec);

MemSpecDDR5(json &data) = delete;
MemSpecDDR5(const json &data) = delete;
MemSpecDDR5(json_t &data) = delete;
MemSpecDDR5(const json_t &data) = delete;

~MemSpecDDR5() = default;

Expand Down
2 changes: 1 addition & 1 deletion src/DRAMPower/DRAMPower/memspec/MemSpecLPDDR4.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "MemSpecLPDDR4.h"
using namespace DRAMPower;
using json = nlohmann::json;
using json_t = nlohmann::json;


MemSpecLPDDR4::MemSpecLPDDR4(const DRAMUtils::MemSpec::MemSpecLPDDR4 &memspec)
Expand Down
5 changes: 3 additions & 2 deletions src/DRAMPower/DRAMPower/memspec/MemSpecLPDDR4.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define DRAMPOWER_MEMSPEC_MEMSPECLPDDR4_H

#include "MemSpec.h"

#include <DRAMUtils/memspec/standards/MemSpecLPDDR4.h>


Expand All @@ -21,8 +22,8 @@ class MemSpecLPDDR4 final : public MemSpec<DRAMUtils::MemSpec::MemSpecLPDDR4>

MemSpecLPDDR4(const DRAMUtils::MemSpec::MemSpecLPDDR4 &memspec);

MemSpecLPDDR4(json &data) = delete;
MemSpecLPDDR4(const json &data) = delete;
MemSpecLPDDR4(json_t &data) = delete;
MemSpecLPDDR4(const json_t &data) = delete;

~MemSpecLPDDR4() = default;
uint64_t timeToCompletion(CmdType type) override;
Expand Down
7 changes: 6 additions & 1 deletion src/DRAMPower/DRAMPower/memspec/MemSpecLPDDR5.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "DRAMPower/memspec/MemSpecLPDDR5.h"

using namespace DRAMPower;
using json = nlohmann::json;
using json_t = nlohmann::json;

MemSpecLPDDR5::MemSpecLPDDR5(const DRAMUtils::MemSpec::MemSpecLPDDR5 &memspec)
: MemSpec(memspec)
Expand Down Expand Up @@ -163,3 +163,8 @@ void MemSpecLPDDR5::parseImpedanceSpec(const DRAMUtils::MemSpec::MemSpecLPDDR5 &
memImpedanceSpec.R_eq_rb = memspec.memimpedancespec.R_eq_rb;
memImpedanceSpec.R_eq_wb = memspec.memimpedancespec.R_eq_wb;
}

MemSpecLPDDR5 MemSpecLPDDR5::from_memspec(const DRAMUtils::MemSpec::MemSpecVariant& memSpec)
{
return std::get<DRAMUtils::MemSpec::MemSpecLPDDR5>(memSpec.getVariant());
}
7 changes: 5 additions & 2 deletions src/DRAMPower/DRAMPower/memspec/MemSpecLPDDR5.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ namespace DRAMPower {

MemSpecLPDDR5(const DRAMUtils::MemSpec::MemSpecLPDDR5 &memspec);

MemSpecLPDDR5(json &data) = delete;
MemSpecLPDDR5(const json &data) = delete;
MemSpecLPDDR5(json_t &data) = delete;
MemSpecLPDDR5(const json_t &data) = delete;

~MemSpecLPDDR5() = default;

Expand Down Expand Up @@ -108,6 +108,9 @@ namespace DRAMPower {

private:
void parseImpedanceSpec(const DRAMUtils::MemSpec::MemSpecLPDDR5 &memspec);

public:
static MemSpecLPDDR5 from_memspec(const DRAMUtils::MemSpec::MemSpecVariant&);
};

} // namespace DRAMPower
Expand Down
2 changes: 1 addition & 1 deletion tests/tests_drampower/base/test_pattern_pre_cycles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DramPowerTest_Pre_Cycles : public ::testing::Test {
std::cout << "Error: Could not open memory specification" << std::endl;
exit(1);
}
json data = json::parse(f);
json_t data = json_t::parse(f);
MemSpecContainer memspeccontainer = data;
MemSpecDDR4 memSpec(std::get<DRAMUtils::MemSpec::MemSpecDDR4>(memspeccontainer.memspec.getVariant()));
memSpec.numberOfRanks = 1;
Expand Down
2 changes: 1 addition & 1 deletion tests/tests_drampower/core/DDR4/ddr4_multidevice_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class DramPowerTest_DDR4_MultiDevice : public ::testing::Test {
std::cout << "Error: Could not open memory specification" << std::endl;
exit(1);
}
json data = json::parse(f);
json_t data = json_t::parse(f);
MemSpecContainer memspeccontainer = data;
MemSpecDDR4 memSpec(std::get<DRAMUtils::MemSpec::MemSpecDDR4>(memspeccontainer.memspec.getVariant()));
memSpec.numberOfDevices = 5;
Expand Down
2 changes: 1 addition & 1 deletion tests/tests_drampower/core/DDR4/ddr4_multirank_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DDR4_MultirankTests : public ::testing::Test {
std::cout << "Error: Could not open memory specification" << std::endl;
exit(1);
}
json data = json::parse(f);
json_t data = json_t::parse(f);
DRAMPower::MemSpecContainer memspeccontainer = data;
spec = std::make_unique<MemSpecDDR4>(std::get<DRAMUtils::MemSpec::MemSpecDDR4>(memspeccontainer.memspec.getVariant()));
spec->numberOfRanks = 2;
Expand Down
2 changes: 1 addition & 1 deletion tests/tests_drampower/core/DDR4/ddr4_test_pattern_0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DramPowerTest_DDR4_0 : public ::testing::Test {
std::cout << "Error: Could not open memory specification" << std::endl;
exit(1);
}
json data = json::parse(f);
json_t data = json_t::parse(f);
MemSpecContainer memspeccontainer = data;
MemSpecDDR4 memSpec(std::get<DRAMUtils::MemSpec::MemSpecDDR4>(memspeccontainer.memspec.getVariant()));

Expand Down
2 changes: 1 addition & 1 deletion tests/tests_drampower/core/DDR4/ddr4_test_pattern_1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DramPowerTest_DDR4_1 : public ::testing::Test {
std::cout << "Error: Could not open memory specification" << std::endl;
exit(1);
}
json data = json::parse(f);
json_t data = json_t::parse(f);
MemSpecContainer memspeccontainer = data;
MemSpecDDR4 memSpec(std::get<DRAMUtils::MemSpec::MemSpecDDR4>(memspeccontainer.memspec.getVariant()));

Expand Down
2 changes: 1 addition & 1 deletion tests/tests_drampower/core/DDR4/ddr4_test_pattern_10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class DramPowerTest_DDR4_10 : public ::testing::Test {
std::cout << "Error: Could not open memory specification" << std::endl;
exit(1);
}
json data = json::parse(f);
json_t data = json_t::parse(f);
MemSpecContainer memspeccontainer = data;
MemSpecDDR4 memSpec(std::get<DRAMUtils::MemSpec::MemSpecDDR4>(memspeccontainer.memspec.getVariant()));
memSpec.numberOfRanks = 1;
Expand Down
2 changes: 1 addition & 1 deletion tests/tests_drampower/core/DDR4/ddr4_test_pattern_11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DramPowerTest_DDR4_11 : public ::testing::Test {
std::cout << "Error: Could not open memory specification" << std::endl;
exit(1);
}
json data = json::parse(f);
json_t data = json_t::parse(f);
MemSpecContainer memspeccontainer = data;
MemSpecDDR4 memSpec(std::get<DRAMUtils::MemSpec::MemSpecDDR4>(memspeccontainer.memspec.getVariant()));
memSpec.numberOfRanks = 1;
Expand Down
2 changes: 1 addition & 1 deletion tests/tests_drampower/core/DDR4/ddr4_test_pattern_12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class DramPowerTest_DDR4_12 : public ::testing::Test {
std::cout << "Error: Could not open memory specification" << std::endl;
exit(1);
}
json data = json::parse(f);
json_t data = json_t::parse(f);
MemSpecContainer memspeccontainer = data;
MemSpecDDR4 memSpec(std::get<DRAMUtils::MemSpec::MemSpecDDR4>(memspeccontainer.memspec.getVariant()));

Expand Down
2 changes: 1 addition & 1 deletion tests/tests_drampower/core/DDR4/ddr4_test_pattern_13.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class DramPowerTest_DDR4_13 : public ::testing::Test {
std::cout << "Error: Could not open memory specification" << std::endl;
exit(1);
}
json data = json::parse(f);
json_t data = json_t::parse(f);
MemSpecContainer memspeccontainer = data;
MemSpecDDR4 memSpec(std::get<DRAMUtils::MemSpec::MemSpecDDR4>(memspeccontainer.memspec.getVariant()));
memSpec.numberOfRanks = 1;
Expand Down
2 changes: 1 addition & 1 deletion tests/tests_drampower/core/DDR4/ddr4_test_pattern_14.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DramPowerTest_DDR4_14 : public ::testing::Test {
std::cout << "Error: Could not open memory specification" << std::endl;
exit(1);
}
json data = json::parse(f);
json_t data = json_t::parse(f);
MemSpecContainer memspeccontainer = data;
MemSpecDDR4 memSpec(std::get<DRAMUtils::MemSpec::MemSpecDDR4>(memspeccontainer.memspec.getVariant()));
memSpec.numberOfRanks = 1;
Expand Down
2 changes: 1 addition & 1 deletion tests/tests_drampower/core/DDR4/ddr4_test_pattern_15.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class DramPowerTest_DDR4_15 : public ::testing::Test {
std::cout << "Error: Could not open memory specification" << std::endl;
exit(1);
}
json data = json::parse(f);
json_t data = json_t::parse(f);
MemSpecContainer memspeccontainer = data;
MemSpecDDR4 memSpec(std::get<DRAMUtils::MemSpec::MemSpecDDR4>(memspeccontainer.memspec.getVariant()));

Expand Down
2 changes: 1 addition & 1 deletion tests/tests_drampower/core/DDR4/ddr4_test_pattern_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class DramPowerTest_DDR4_2 : public ::testing::Test {
std::cout << "Error: Could not open memory specification" << std::endl;
exit(1);
}
json data = json::parse(f);
json_t data = json_t::parse(f);
MemSpecContainer memspeccontainer = data;
MemSpecDDR4 memSpec(std::get<DRAMUtils::MemSpec::MemSpecDDR4>(memspeccontainer.memspec.getVariant()));

Expand Down
2 changes: 1 addition & 1 deletion tests/tests_drampower/core/DDR4/ddr4_test_pattern_3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DramPowerTest_DDR4_3 : public ::testing::Test {
std::cout << "Error: Could not open memory specification" << std::endl;
exit(1);
}
json data = json::parse(f);
json_t data = json_t::parse(f);
MemSpecContainer memspeccontainer = data;
MemSpecDDR4 memSpec(std::get<DRAMUtils::MemSpec::MemSpecDDR4>(memspeccontainer.memspec.getVariant()));

Expand Down
2 changes: 1 addition & 1 deletion tests/tests_drampower/core/DDR4/ddr4_test_pattern_4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DramPowerTest_DDR4_4 : public ::testing::Test {
std::cout << "Error: Could not open memory specification" << std::endl;
exit(1);
}
json data = json::parse(f);
json_t data = json_t::parse(f);
MemSpecContainer memspeccontainer = data;
MemSpecDDR4 memSpec(std::get<DRAMUtils::MemSpec::MemSpecDDR4>(memspeccontainer.memspec.getVariant()));

Expand Down
2 changes: 1 addition & 1 deletion tests/tests_drampower/core/DDR4/ddr4_test_pattern_5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class DramPowerTest_DDR4_5 : public ::testing::Test {
std::cout << "Error: Could not open memory specification" << std::endl;
exit(1);
}
json data = json::parse(f);
json_t data = json_t::parse(f);
MemSpecContainer memspeccontainer = data;
MemSpecDDR4 memSpec(std::get<DRAMUtils::MemSpec::MemSpecDDR4>(memspeccontainer.memspec.getVariant()));

Expand Down
2 changes: 1 addition & 1 deletion tests/tests_drampower/core/DDR4/ddr4_test_pattern_6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DramPowerTest_DDR4_6 : public ::testing::Test {
std::cout << "Error: Could not open memory specification" << std::endl;
exit(1);
}
json data = json::parse(f);
json_t data = json_t::parse(f);
MemSpecContainer memspeccontainer = data;
MemSpecDDR4 memSpec(std::get<DRAMUtils::MemSpec::MemSpecDDR4>(memspeccontainer.memspec.getVariant()));

Expand Down
2 changes: 1 addition & 1 deletion tests/tests_drampower/core/DDR4/ddr4_test_pattern_7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DramPowerTest_DDR4_7 : public ::testing::Test {
std::cout << "Error: Could not open memory specification" << std::endl;
exit(1);
}
json data = json::parse(f);
json_t data = json_t::parse(f);
MemSpecContainer memspeccontainer = data;
MemSpecDDR4 memSpec(std::get<DRAMUtils::MemSpec::MemSpecDDR4>(memspeccontainer.memspec.getVariant()));

Expand Down
2 changes: 1 addition & 1 deletion tests/tests_drampower/core/DDR4/ddr4_test_pattern_8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class DramPowerTest_DDR4_8 : public ::testing::Test {
std::cout << "Error: Could not open memory specification" << std::endl;
exit(1);
}
json data = json::parse(f);
json_t data = json_t::parse(f);
MemSpecContainer memspeccontainer = data;
MemSpecDDR4 memSpec(std::get<DRAMUtils::MemSpec::MemSpecDDR4>(memspeccontainer.memspec.getVariant()));

Expand Down
2 changes: 1 addition & 1 deletion tests/tests_drampower/core/DDR4/ddr4_test_pattern_9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class DramPowerTest_DDR4_9 : public ::testing::Test {
std::cout << "Error: Could not open memory specification" << std::endl;
exit(1);
}
json data = json::parse(f);
json_t data = json_t::parse(f);
MemSpecContainer memspeccontainer = data;
MemSpecDDR4 memSpec(std::get<DRAMUtils::MemSpec::MemSpecDDR4>(memspeccontainer.memspec.getVariant()));

Expand Down
Loading

0 comments on commit 8bb3e2e

Please sign in to comment.