42#include "debug/DRAMsim3.hh"
43#include "debug/Drain.hh"
54 port(
name() +
".port", *this),
56 this, 0,
std::placeholders::_1)),
58 this, 0,
std::placeholders::_1)),
59 wrapper(
p.configFile,
p.filePath, read_cb, write_cb),
60 retryReq(false), retryResp(false), startTick(0),
61 nbrOutstandingReads(0), nbrOutstandingWrites(0),
63 tickEvent([
this]{ tick(); },
name())
66 "Instantiated DRAMsim3 with clock %d ns and queue size %d\n",
67 wrapper.clockPeriod(), wrapper.queueSize());
80 fatal(
"DRAMsim3 %s is unconnected!\n",
name());
86 fatal(
"DRAMsim3 burst size %d does not match cache line size %d\n",
116 DPRINTF(
DRAMsim3,
"Have %d read, %d write, %d responses outstanding\n",
144 if (
system()->isTimingMode()) {
306 if (
p->second.empty())
330 if (
p->second.empty())
343 if (if_name !=
"port") {
367 ranges.push_back(
mem.getAddrRange());
374 return mem.recvAtomic(pkt);
380 mem.recvFunctional(pkt);
387 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
unsigned int burstSize() const
Get the burst size in bytes used by DRAMsim3.
void tick()
Progress the memory controller one cycle.
void enqueue(uint64_t addr, bool is_write)
Enqueue a packet.
unsigned int queueSize() const
Get the transaction queue size used by DRAMsim3.
void resetStats()
Reset stats (useful for fastforwarding switch)
double clockPeriod() const
Get the internal clock period used by DRAMsim3, specified in ns.
bool canAccept(uint64_t addr, bool is_write) const
Determine if the controller can accept a new packet or not.
void recvRespRetry()
Called by the peer if sendTimingResp was called on this protocol (causing recvTimingResp to be called...
MemoryPort(const std::string &_name, DRAMsim3 &_memory)
void recvFunctional(PacketPtr pkt)
Receive a functional request packet from the peer.
Tick recvAtomic(PacketPtr pkt)
Receive an atomic request packet from the peer.
AddrRangeList getAddrRanges() const
Get a list of the non-overlapping address ranges the owner is responsible for.
bool recvTimingReq(PacketPtr pkt)
Receive a timing request from the peer.
Tick startTick
Keep track of when the wrapper is started.
EventFunctionWrapper tickEvent
Event to schedule clock ticks.
bool recvTimingReq(PacketPtr pkt)
void recvFunctional(PacketPtr pkt)
void accessAndRespond(PacketPtr pkt)
When a packet is ready, use the "access()" method in AbstractMemory to actually create the response p...
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
void tick()
Progress the controller one clock cycle.
std::deque< PacketPtr > responseQueue
Queue to hold response packets until we can send them back.
void startup() override
startup() is the final initialization call before simulation.
void resetStats() override
Callback to reset stats.
Tick recvAtomic(PacketPtr pkt)
std::unordered_map< Addr, std::queue< PacketPtr > > outstandingWrites
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
bool retryReq
Is the connected port waiting for a retry from us.
DRAMsim3Wrapper wrapper
The actual DRAMsim3 wrapper.
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
void readComplete(unsigned id, uint64_t addr)
Read completion callback.
EventFunctionWrapper sendResponseEvent
Event to schedule sending of responses.
bool retryResp
Are we waiting for a retry for sending a response.
std::unique_ptr< Packet > pendingDelete
Upstream caches need this packet until true is returned, so hold it for deletion until a subsequent c...
unsigned int nbrOutstandingWrites
unsigned int nbrOutstanding() const
DRAMsim3(const Params &p)
unsigned int nbrOutstandingReads
Count the number of outstanding transactions so that we can block any further requests until there is...
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 writeComplete(unsigned id, uint64_t addr)
Write completion callback.
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.
Overload hash function for BasicBlockRange type.
const std::string & name()