40#include "DRAMSim2/Callback.h"
43#include "debug/DRAMSim2.hh"
44#include "debug/Drain.hh"
55 port(
name() +
".port", *this),
56 wrapper(
p.deviceConfigFile,
p.systemConfigFile,
p.filePath,
57 p.traceFile,
p.range.size() / 1024 / 1024,
p.enableDebug),
58 retryReq(false), retryResp(false), startTick(0),
59 nbrOutstandingReads(0), nbrOutstandingWrites(0),
61 tickEvent([
this]{ tick(); },
name())
64 "Instantiated DRAMSim2 with clock %d ns and queue size %d\n",
65 wrapper.clockPeriod(), wrapper.queueSize());
67 DRAMSim::TransactionCompleteCB* read_cb =
68 new DRAMSim::Callback<DRAMSim2, void, unsigned, uint64_t, uint64_t>(
70 DRAMSim::TransactionCompleteCB* write_cb =
71 new DRAMSim::Callback<DRAMSim2, void, unsigned, uint64_t, uint64_t>(
73 wrapper.setCallbacks(read_cb, write_cb);
86 fatal(
"DRAMSim2 %s is unconnected!\n",
name());
92 fatal(
"DRAMSim2 burst size %d does not match cache line size %d\n",
117 DPRINTF(
DRAMSim2,
"Have %d read, %d write, %d responses outstanding\n",
306 if (
p->second.empty())
332 if (
p->second.empty())
345 if (if_name !=
"port") {
369 ranges.push_back(
mem.getAddrRange());
376 return mem.recvAtomic(pkt);
382 mem.recvFunctional(pkt);
389 return mem.recvTimingReq(pkt);
Tick clockEdge(Cycles cycles=Cycles(0)) const
Determine the tick when a cycle begins, by default the current one, but the argument also enables the...
virtual std::string name() const
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
void pushLabel(const std::string &lbl)
Push label for PrintReq (safe to call unconditionally).
bool needsResponse() const
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
uint32_t headerDelay
The extra delay from seeing the packet until the header is transmitted.
bool trySatisfyFunctional(PacketPtr other)
Check a functional request against a memory value stored in another packet (i.e.
void popLabel()
Pop label for PrintReq (safe to call unconditionally).
bool cacheResponding() const
Ports are used to interface objects to each other.
bool isConnected() const
Is this port currently connected to a peer?
A ResponsePort is a specialization of a port.
bool sendTimingResp(PacketPtr pkt)
Attempt to send a timing response to the request port by calling its corresponding receive function.
void sendRangeChange() const
Called by the owner to send a range change.
void sendRetryReq()
Send a retry to the request port that previously attempted a sendTimingReq to this response port and ...
An abstract memory represents a contiguous block of physical memory, with an associated address range...
void access(PacketPtr pkt)
Perform an untimed memory access and update all the state (e.g.
uint64_t size() const
Get the memory size.
void functionalAccess(PacketPtr pkt)
Perform an untimed memory read or write without changing anything but the memory itself.
System * system() const
read the system pointer Implemented for completeness with the setter
void enqueue(bool is_write, uint64_t addr)
Enqueue a packet.
double clockPeriod() const
Get the internal clock period used by DRAMSim2, specified in ns.
unsigned int queueSize() const
Get the transaction queue size used by DRAMSim2.
unsigned int burstSize() const
Get the burst size in bytes used by DRAMSim2.
bool canAccept() const
Determine if the controller can accept a new packet or not.
void tick()
Progress the memory controller one cycle.
Tick recvAtomic(PacketPtr pkt)
Receive an atomic request packet from the peer.
MemoryPort(const std::string &_name, DRAMSim2 &_memory)
void recvFunctional(PacketPtr pkt)
Receive a functional request packet from the peer.
void recvRespRetry()
Called by the peer if sendTimingResp was called on this protocol (causing recvTimingResp to be called...
bool recvTimingReq(PacketPtr pkt)
Receive a timing request from the peer.
AddrRangeList getAddrRanges() const
Get a list of the non-overlapping address ranges the owner is responsible for.
DRAMSim2Wrapper wrapper
The actual DRAMSim2 wrapper.
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
bool retryResp
Are we waiting for a retry for sending a response.
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
void accessAndRespond(PacketPtr pkt)
When a packet is ready, use the "access()" method in AbstractMemory to actually create the response p...
EventFunctionWrapper tickEvent
Event to schedule clock ticks.
unsigned int nbrOutstanding() const
std::unique_ptr< Packet > pendingDelete
Upstream caches need this packet until true is returned, so hold it for deletion until a subsequent c...
void writeComplete(unsigned id, uint64_t addr, uint64_t cycle)
Write completion callback.
bool retryReq
Is the connected port waiting for a retry from us.
std::unordered_map< Addr, std::queue< PacketPtr > > outstandingWrites
bool recvTimingReq(PacketPtr pkt)
Tick startTick
Keep track of when the wrapper is started.
unsigned int nbrOutstandingReads
Count the number of outstanding transactions so that we can block any further requests until there is...
Tick recvAtomic(PacketPtr pkt)
std::unordered_map< Addr, std::queue< PacketPtr > > outstandingReads
Keep track of what packets are outstanding per address, and do so separately for reads and writes.
void startup() override
startup() is the final initialization call before simulation.
void recvFunctional(PacketPtr pkt)
DRAMSim2(const Params &p)
EventFunctionWrapper sendResponseEvent
Event to schedule sending of responses.
void readComplete(unsigned id, uint64_t addr, uint64_t cycle)
Read completion callback.
unsigned int nbrOutstandingWrites
std::deque< PacketPtr > responseQueue
Queue to hold response packets until we can send them back.
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
void tick()
Progress the controller one clock cycle.
static constexpr T divCeil(const T &a, const U &b)
void signalDrainDone() const
Signal that an object is drained.
DrainState
Object drain/handover states.
@ Draining
Draining buffers pending serialization/handover.
@ Drained
Buffers drained, ready for serialization/handover.
bool scheduled() const
Determine if the current event is scheduled.
void schedule(Event &event, Tick when)
#define fatal(...)
This implements a cprintf based fatal() function.
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
virtual void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Tick curTick()
The universal simulation clock.
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
uint64_t Tick
Tick count type.
void registerExitCallback(const std::function< void()> &callback)
Register an exit callback.
const std::string & name()