diff --git a/src/libdramsys/DRAMSys/controller/BankMachine.h b/src/libdramsys/DRAMSys/controller/BankMachine.h index b6591cb3..2b3fa701 100644 --- a/src/libdramsys/DRAMSys/controller/BankMachine.h +++ b/src/libdramsys/DRAMSys/controller/BankMachine.h @@ -35,6 +35,7 @@ #ifndef BANKMACHINE_H #define BANKMACHINE_H +#include "DRAMSys/controller/ManagerIF.h" #include "DRAMSys/controller/scheduler/SchedulerIF.h" #include "DRAMSys/controller/checker/CheckerIF.h" #include "DRAMSys/controller/Command.h" @@ -45,13 +46,11 @@ #include #include -class BankMachine +class BankMachine : public ManagerIF { public: - virtual ~BankMachine() = default; - virtual void evaluate() = 0; - CommandTuple::Type getNextCommand(); - void update(Command); + CommandTuple::Type getNextCommand() override; + void update(Command) override; void block(); [[nodiscard]] Rank getRank() const; diff --git a/src/libdramsys/DRAMSys/controller/ManagerIF.h b/src/libdramsys/DRAMSys/controller/ManagerIF.h new file mode 100644 index 00000000..3b26adb3 --- /dev/null +++ b/src/libdramsys/DRAMSys/controller/ManagerIF.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023, RPTU Kaiserslautern-Landau + * 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. + * + * Author: Lukas Steiner + */ + +#ifndef MANAGERIF_H +#define MANAGERIF_H + +#include "DRAMSys/controller/Command.h" + +class ManagerIF +{ +public: + virtual void evaluate() = 0; + virtual CommandTuple::Type getNextCommand() = 0; + virtual void update(Command) = 0; + virtual ~ManagerIF() = default; +}; + +#endif // MANAGERIF_H diff --git a/src/libdramsys/DRAMSys/controller/powerdown/PowerDownManagerIF.h b/src/libdramsys/DRAMSys/controller/powerdown/PowerDownManagerIF.h index f24d0f57..a88606c6 100644 --- a/src/libdramsys/DRAMSys/controller/powerdown/PowerDownManagerIF.h +++ b/src/libdramsys/DRAMSys/controller/powerdown/PowerDownManagerIF.h @@ -35,22 +35,17 @@ #ifndef POWERDOWNMANAGERIF_H #define POWERDOWNMANAGERIF_H +#include "DRAMSys/controller/ManagerIF.h" #include "DRAMSys/controller/Command.h" #include -class PowerDownManagerIF +class PowerDownManagerIF : public ManagerIF { public: - virtual ~PowerDownManagerIF() = default; - virtual void triggerEntry() = 0; virtual void triggerExit() = 0; virtual void triggerInterruption() = 0; - - virtual CommandTuple::Type getNextCommand() = 0; - virtual void update(Command) = 0; - virtual void evaluate() = 0; }; #endif // POWERDOWNMANAGERIF_H diff --git a/src/libdramsys/DRAMSys/controller/refresh/RefreshManagerIF.h b/src/libdramsys/DRAMSys/controller/refresh/RefreshManagerIF.h index 3e8966b3..0970f8da 100644 --- a/src/libdramsys/DRAMSys/controller/refresh/RefreshManagerIF.h +++ b/src/libdramsys/DRAMSys/controller/refresh/RefreshManagerIF.h @@ -35,21 +35,16 @@ #ifndef REFRESHMANAGERIF_H #define REFRESHMANAGERIF_H - +#include "DRAMSys/controller/ManagerIF.h" #include "DRAMSys/controller/Command.h" #include "DRAMSys/configuration/Configuration.h" #include #include -class RefreshManagerIF +class RefreshManagerIF : public ManagerIF { public: - virtual ~RefreshManagerIF() = default; - - virtual CommandTuple::Type getNextCommand() = 0; - virtual void evaluate() = 0; - virtual void update(Command) = 0; virtual sc_core::sc_time getTimeForNextTrigger() = 0; protected: diff --git a/src/simulator/simulator/TlmProfiler.h b/src/simulator/simulator/TlmProfiler.h deleted file mode 100644 index 02e2f753..00000000 --- a/src/simulator/simulator/TlmProfiler.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2020, 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 TLMPROFILER_H -#define TLMPROFILER_H - -#include -#include -#include -#include - - -template -class TlmProfiler : public sc_core::sc_module -{ -public: - tlm_utils::simple_target_socket tSocket; - tlm_utils::simple_initiator_socket iSocket; - - TlmProfiler(sc_core::sc_module_name name) : sc_core::sc_module(name) - { - tSocket.register_nb_transport_fw(this, &TlmProfiler::nb_transport_fw); - tSocket.register_transport_dbg(this, &TlmProfiler::transport_dbg); - iSocket.register_nb_transport_bw(this, &TlmProfiler::nb_transport_bw); - - std::cout << "Constructor called" << std::endl; - } - -private: - std::unordered_map transStart; - uint64_t totalTranses = 0; - uint64_t totalTranses2 = 0; - sc_core::sc_time totalLatency = sc_core::SC_ZERO_TIME; - - tlm::tlm_sync_enum nb_transport_fw(tlm::tlm_generic_payload& trans, - tlm::tlm_phase& phase, sc_core::sc_time& delay) - { - //std::cout << "nb_transport_fw: " << phase << " @ " << sc_core::sc_time_stamp() << ", command: " << trans.get_command() << std::endl; - tlm::tlm_sync_enum returnVal = iSocket->nb_transport_fw(trans, phase, delay); - //std::cout << "tlm_sync_enum: " << returnVal << ", phase: " << phase << ", delay: " << delay << std::endl; - return returnVal; - } - - unsigned transport_dbg(tlm::tlm_generic_payload& trans) - { - return iSocket->transport_dbg(trans); - } - - tlm::tlm_sync_enum nb_transport_bw(tlm::tlm_generic_payload& trans, - tlm::tlm_phase& phase, sc_core::sc_time& delay) - { - //std::cout << "nb_transport_bw: " << phase << " @ " << sc_core::sc_time_stamp() << ", command: " << trans.get_command() << std::endl; - if (phase == tlm::END_REQ) - { - totalTranses2++; - transStart[&trans] = sc_core::sc_time_stamp(); - } - else if (phase == tlm::BEGIN_RESP) - { - totalLatency += (sc_core::sc_time_stamp() - transStart.at(&trans)); - totalTranses++; - } - tlm::tlm_sync_enum returnVal = tSocket->nb_transport_bw(trans, phase, delay); - //std::cout << "tlm_sync_enum: " << returnVal << ", phase: " << phase << ", delay: " << delay << std::endl; - return returnVal; - } - - void end_of_simulation() override - { - std::cout << "Total transactions: " << totalTranses << ", " << totalTranses2 << std::endl; - std::cout << sc_core::sc_time_stamp().to_seconds() << std::endl; - std::cout << "AVG Bandwidth: " << 512ULL * totalTranses / sc_core::sc_time_stamp().to_seconds() / 1'000'000'000 << std::endl; - std::cout << "AVG Latency: " << totalLatency / totalTranses << std::endl; - } -}; - -#endif // TLMPROFILER_H