Add common interface for BM, RM and PDM (2).
This commit is contained in:
@@ -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 <systemc>
|
||||
#include <tlm>
|
||||
|
||||
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;
|
||||
|
||||
49
src/libdramsys/DRAMSys/controller/ManagerIF.h
Normal file
49
src/libdramsys/DRAMSys/controller/ManagerIF.h
Normal file
@@ -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
|
||||
@@ -35,22 +35,17 @@
|
||||
#ifndef POWERDOWNMANAGERIF_H
|
||||
#define POWERDOWNMANAGERIF_H
|
||||
|
||||
#include "DRAMSys/controller/ManagerIF.h"
|
||||
#include "DRAMSys/controller/Command.h"
|
||||
|
||||
#include <systemc>
|
||||
|
||||
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
|
||||
|
||||
@@ -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 <cmath>
|
||||
#include <systemc>
|
||||
|
||||
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:
|
||||
|
||||
@@ -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 <systemc>
|
||||
#include <tlm_utils/simple_target_socket.h>
|
||||
#include <tlm_utils/simple_initiator_socket.h>
|
||||
#include <unordered_map>
|
||||
|
||||
|
||||
template<unsigned int BUSWIDTH = 32>
|
||||
class TlmProfiler : public sc_core::sc_module
|
||||
{
|
||||
public:
|
||||
tlm_utils::simple_target_socket<TlmProfiler, BUSWIDTH> tSocket;
|
||||
tlm_utils::simple_initiator_socket<TlmProfiler, BUSWIDTH> 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<tlm::tlm_generic_payload*, sc_core::sc_time> 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
|
||||
Reference in New Issue
Block a user