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