42 #include "DRAMSim2/Callback.h"
45 #include "debug/DRAMSim2.hh"
46 #include "debug/Drain.hh"
51 port(
name() +
".port", *this),
52 wrapper(p->deviceConfigFile, p->systemConfigFile, p->filePath,
53 p->traceFile, p->range.
size() / 1024 / 1024, p->enableDebug),
54 retryReq(false), retryResp(false),
startTick(0),
55 nbrOutstandingReads(0), nbrOutstandingWrites(0),
56 sendResponseEvent(this), tickEvent(this)
59 "Instantiated DRAMSim2 with clock %d ns and queue size %d\n",
62 DRAMSim::TransactionCompleteCB* read_cb =
63 new DRAMSim::Callback<DRAMSim2, void, unsigned, uint64_t, uint64_t>(
65 DRAMSim::TransactionCompleteCB* write_cb =
66 new DRAMSim::Callback<DRAMSim2, void, unsigned, uint64_t, uint64_t>(
83 fatal(
"DRAMSim2 %s is unconnected!\n",
name());
89 fatal(
"DRAMSim2 burst size %d does not match cache line size %d\n",
114 DPRINTF(
DRAMSim2,
"Have %d read, %d write, %d responses outstanding\n",
302 if (
p->second.empty())
328 if (
p->second.empty())
341 if (if_name !=
"port") {
358 :
SlavePort(_name, &_memory), memory(_memory)
365 ranges.push_back(memory.getAddrRange());
372 return memory.recvAtomic(pkt);
378 memory.recvFunctional(pkt);
385 return memory.recvTimingReq(pkt);
391 memory.recvRespRetry();
395 DRAMSim2Params::create()
MemoryPort(const std::string &_name, DRAMSim2 &_memory)
void functionalAccess(PacketPtr pkt)
Perform an untimed memory read or write without changing anything but the memory itself.
Tick recvAtomic(PacketPtr pkt)
Wrapper class to avoid having DRAMSim2 names like ClockDomain etc clashing with the normal gem5 world...
void printStats()
Print the stats gathered in DRAMsim2.
void recvFunctional(PacketPtr pkt)
const std::string & name()
DrainState drain() override
Notify an object that it needs to drain its state.
DrainState
Object drain/handover states.
void enqueue(bool is_write, uint64_t addr)
Enqueue a packet.
void recvFunctional(PacketPtr pkt)
Receive a functional request packet from the master port.
bool retryResp
Are we waiting for a retry for sending a response.
bool scheduled() const
Determine if the current event is scheduled.
std::unique_ptr< Packet > pendingDelete
Upstream caches need this packet until true is returned, so hold it for deletion until a subsequent c...
A SlavePort is a specialisation of a port.
virtual BaseSlavePort & getSlavePort(const std::string &if_name, PortID idx=InvalidPortID)
Get a slave port with a given name and index.
unsigned int nbrOutstanding() const
void readComplete(unsigned id, uint64_t addr, uint64_t cycle)
Read completion callback.
void pushLabel(const std::string &lbl)
Push label for PrintReq (safe to call unconditionally).
A BaseSlavePort is a protocol-agnostic slave port, responsible only for the structural connection to ...
std::unordered_map< Addr, std::queue< PacketPtr > > outstandingWrites
unsigned int cacheLineSize() const
Get the cache line size of the system.
unsigned int nbrOutstandingWrites
void recvRespRetry()
Called by the master port if sendTimingResp was called on this slave port (causing recvTimingResp to ...
void tick()
Progress the controller one clock cycle.
double clockPeriod() const
Get the internal clock period used by DRAMSim2, specified in ns.
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...
void startup() override
startup() is the final initialization call before simulation.
bool sendTimingResp(PacketPtr pkt)
Attempt to send a timing response to the master port by calling its corresponding receive function...
Tick curTick()
The current simulated tick.
bool recvTimingReq(PacketPtr pkt)
std::deque< PacketPtr > responseQueue
Queue to hold response packets until we can send them back.
AbstractMemoryParams Params
uint32_t headerDelay
The extra delay from seeing the packet until the header is transmitted.
uint64_t Tick
Tick count type.
System * system() const
read the system pointer Implemented for completeness with the setter
void popLabel()
Pop label for PrintReq (safe to call unconditionally).
void writeComplete(unsigned id, uint64_t addr, uint64_t cycle)
Write completion callback.
void access(PacketPtr pkt)
Perform an untimed memory access and update all the state (e.g.
void registerExitCallback(Callback *callback)
Register an exit callback.
void accessAndRespond(PacketPtr pkt)
When a packet is ready, use the "access()" method in AbstractMemory to actually create the response p...
bool needsResponse() const
DRAMSim2Wrapper wrapper
The actual DRAMSim2 wrapper.
Tick startTick
Keep track of when the wrapper is started.
bool cacheResponding() const
Draining buffers pending serialization/handover.
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
EventWrapper< DRAMSim2,&DRAMSim2::sendResponse > sendResponseEvent
Event to schedule sending of responses.
virtual BaseSlavePort & getSlavePort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a slave port with a given name and index.
void sendRangeChange() const
Called by the owner to send a range change.
void setCallbacks(DRAMSim::TransactionCompleteCB *read_callback, DRAMSim::TransactionCompleteCB *write_callback)
Set the callbacks to use for read and write completion.
bool checkFunctional(PacketPtr other)
Check a functional request against a memory value stored in another packet (i.e.
EventWrapper< DRAMSim2,&DRAMSim2::tick > tickEvent
Event to schedule clock ticks.
unsigned int queueSize() const
Get the transaction queue size used by DRAMSim2.
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 init() override
Initialise this memory.
Tick recvAtomic(PacketPtr pkt)
Receive an atomic request packet from the master port.
virtual const std::string name() const
bool retryReq
Is the connected port waiting for a retry from us.
bool canAccept() const
Determine if the controller can accept a new packet or not.
DRAMSim2(const Params *p)
void sendRetryReq()
Send a retry to the master port that previously attempted a sendTimingReq to this slave port and fail...
void signalDrainDone() const
Signal that an object is drained.
T divCeil(const T &a, const U &b)
void schedule(Event &event, Tick when)
An abstract memory represents a contiguous block of physical memory, with an associated address range...
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
unsigned int burstSize() const
Get the burst size in bytes used by DRAMSim2.
Helper template class to turn a simple class member function into a callback.
void tick()
Progress the memory controller one cycle.
unsigned int nbrOutstandingReads
Count the number of outstanding transactions so that we can block any further requests until there is...
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 master port.
void init() override
Initialise this memory.