From f8baef57c6532a144373a36ed7e7dc77078b1a31 Mon Sep 17 00:00:00 2001 From: Lukas Steiner Date: Sun, 23 Jun 2019 20:53:08 +0200 Subject: [PATCH] Adapting current DRAM to new structure. --- DRAMSys/library/src/simulation/DRAMSys.cpp | 3 +- DRAMSys/library/src/simulation/DramDDR3.cpp | 2 + DRAMSys/library/src/simulation/DramDDR3.h | 4 +- DRAMSys/library/src/simulation/DramDDR4.cpp | 2 + DRAMSys/library/src/simulation/DramDDR4.h | 41 +++++++++++++++++-- .../library/src/simulation/DramRecordable.cpp | 26 +++++++----- 6 files changed, 63 insertions(+), 15 deletions(-) diff --git a/DRAMSys/library/src/simulation/DRAMSys.cpp b/DRAMSys/library/src/simulation/DRAMSys.cpp index 61fbfc63..d4e37757 100644 --- a/DRAMSys/library/src/simulation/DRAMSys.cpp +++ b/DRAMSys/library/src/simulation/DRAMSys.cpp @@ -56,6 +56,7 @@ #include "../error/ecchamming.h" #include "DramRecordable.h" #include "DramDDR3.h" +#include "DramDDR4.h" #include "RecordableDram.h" using namespace std; @@ -263,7 +264,7 @@ void DRAMSys::instantiateModules(const string &traceName, Dram *dram; if (recordingEnabled) //dram = new RecordableDram(str.c_str(), tlmRecorders[i]); - dram = new DramRecordable(str.c_str(), tlmRecorders[i]); + dram = new DramRecordable(str.c_str(), tlmRecorders[i]); else dram = new Dram(str.c_str()); drams.push_back(dram); diff --git a/DRAMSys/library/src/simulation/DramDDR3.cpp b/DRAMSys/library/src/simulation/DramDDR3.cpp index 416f7c63..91ba5736 100644 --- a/DRAMSys/library/src/simulation/DramDDR3.cpp +++ b/DRAMSys/library/src/simulation/DramDDR3.cpp @@ -40,3 +40,5 @@ DramDDR3::DramDDR3(sc_module_name name) : Dram(name) { } + +//DramDDR3::~DramDDR3() {} diff --git a/DRAMSys/library/src/simulation/DramDDR3.h b/DRAMSys/library/src/simulation/DramDDR3.h index 894809bb..0bf0a8a9 100644 --- a/DRAMSys/library/src/simulation/DramDDR3.h +++ b/DRAMSys/library/src/simulation/DramDDR3.h @@ -37,6 +37,8 @@ #define DRAMDDR3_H #include "Dram.h" +#include +#include class DramDDR3 : public Dram { @@ -44,7 +46,7 @@ public: DramDDR3(sc_module_name); SC_HAS_PROCESS(DramDDR3); - ~DramDDR3(); + //~DramDDR3(); }; #endif // DRAMDDR3_H diff --git a/DRAMSys/library/src/simulation/DramDDR4.cpp b/DRAMSys/library/src/simulation/DramDDR4.cpp index 4eb6bb39..b10cd313 100644 --- a/DRAMSys/library/src/simulation/DramDDR4.cpp +++ b/DRAMSys/library/src/simulation/DramDDR4.cpp @@ -40,3 +40,5 @@ DramDDR4::DramDDR4(sc_module_name name) : Dram(name) { } + +//DramDDR4::~DramDDR4() {} diff --git a/DRAMSys/library/src/simulation/DramDDR4.h b/DRAMSys/library/src/simulation/DramDDR4.h index ed884bc1..64bae19d 100644 --- a/DRAMSys/library/src/simulation/DramDDR4.h +++ b/DRAMSys/library/src/simulation/DramDDR4.h @@ -1,9 +1,44 @@ +/* + * Copyright (c) 2019, 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: + * Lukas Steiner + */ + #ifndef DRAMDDR4_H #define DRAMDDR4_H #include "Dram.h" -#include "systemc" -#include "tlm" +#include +#include using namespace tlm; @@ -13,7 +48,7 @@ public: DramDDR4(sc_module_name); SC_HAS_PROCESS(DramDDR4); - ~DramDDR4(); + //~DramDDR4(); }; #endif // DRAMDDR4_H diff --git a/DRAMSys/library/src/simulation/DramRecordable.cpp b/DRAMSys/library/src/simulation/DramRecordable.cpp index d7312d5c..e9adc271 100644 --- a/DRAMSys/library/src/simulation/DramRecordable.cpp +++ b/DRAMSys/library/src/simulation/DramRecordable.cpp @@ -34,7 +34,12 @@ */ #include "DramRecordable.h" -#include "Dram.h" +#include +#include +#include "../common/TlmRecorder.h" +#include "DramDDR3.h" +#include "DramDDR4.h" +#include "../common/utils.h" using namespace tlm; @@ -79,7 +84,7 @@ tlm_sync_enum DramRecordable::nb_transport_fw(tlm_generic_payload &pay unsigned int col = DramExtension::getExtension(payload).getColumn().ID(); // TODO: printDebugMessage not inherited - printDebugMessage("Recording " + phaseNameToString(phase) + " thread " + + BaseDram::printDebugMessage("Recording " + phaseNameToString(phase) + " thread " + to_string(thr) + " channel " + to_string(ch) + " bank group " + to_string( bg) + " bank " + to_string(bank) + " row " + to_string(row) + " column " + to_string(col) + " at " + recTime.to_string()); @@ -103,20 +108,20 @@ void DramRecordable::powerWindow() clkCycles = sc_time_stamp().value() / Configuration::getInstance().memSpec->clk.value(); - DRAMPower->calcWindowEnergy(clkCycles); + BaseDram::DRAMPower->calcWindowEnergy(clkCycles); // During operation the energy should never be zero since the device is always consuming - assert(!isEqual(DRAMPower->getEnergy().window_energy, 0.0)); + assert(!isEqual(BaseDram::DRAMPower->getEnergy().window_energy, 0.0)); // Store the time (in seconds) and the current average power (in mW) into the database recordPower(); // Here considering that DRAMPower provides the energy in pJ and the power in mW - printDebugMessage(string("\tWindow Energy: \t") + to_string( - DRAMPower->getEnergy().window_energy * + BaseDram::printDebugMessage(string("\tWindow Energy: \t") + to_string( + BaseDram::DRAMPower->getEnergy().window_energy * Configuration::getInstance().NumberOfDevicesOnDIMM) + string("\t[pJ]")); - printDebugMessage(string("\tWindow Average Power: \t") + to_string( - DRAMPower->getPower().window_average_power * + BaseDram::printDebugMessage(string("\tWindow Average Power: \t") + to_string( + BaseDram::DRAMPower->getPower().window_average_power * Configuration::getInstance().NumberOfDevicesOnDIMM) + string("\t[mW]")); } while (true); @@ -126,10 +131,11 @@ template void DramRecordable::recordPower() { tlmRecorder->recordPower(sc_time_stamp().to_seconds(), - DRAMPower->getPower().window_average_power + BaseDram::DRAMPower->getPower().window_average_power * Configuration::getInstance().NumberOfDevicesOnDIMM); } -template class DramRecordable; +template class DramRecordable; +template class DramRecordable;