Go to the documentation of this file.
44 #include "arch/locked_mem.hh"
45 #include "arch/utility.hh"
46 #include "config/the_isa.hh"
48 #include "debug/Config.hh"
49 #include "debug/Drain.hh"
50 #include "debug/ExecFaulting.hh"
51 #include "debug/HtmCpu.hh"
52 #include "debug/Mwait.hh"
53 #include "debug/SimpleCPU.hh"
56 #include "params/TimingSimpleCPU.hh"
74 cpu->schedule(
this,
t);
79 dcachePort(this), ifetch_pkt(NULL), dcache_pkt(NULL), previousCycle(0),
102 DPRINTF(Drain,
"No need to drain.\n");
106 DPRINTF(Drain,
"Requesting drain.\n");
125 DPRINTF(SimpleCPU,
"Resume\n");
161 DPRINTF(Drain,
"tryCompleteDrain.\n");
165 DPRINTF(Drain,
"CPU done draining, processing drain event\n");
186 assert(thread->microPC() == 0);
205 fatal(
"The timing CPU requires the memory system to be in "
213 DPRINTF(SimpleCPU,
"ActivateContext %d\n", thread_num);
237 DPRINTF(SimpleCPU,
"SuspendContext %d\n", thread_num);
274 if (req->isHTMCmd()) {
275 assert(!req->isLocalAccess());
280 if (pkt->
isRead() && pkt->
req->isLLSC()) {
283 if (req->isLocalAccess()) {
284 Cycles delay = req->localAccessor(thread->
getTC(), pkt);
285 new IprEvent(pkt,
this, clockEdge(delay));
314 if (is_htm_speculative || req->isHTMAbort()) {
317 if (req->isHTMAbort())
327 bool do_access =
true;
331 }
else if (req->isCondSwap()) {
333 req->setExtraData(*res);
357 assert(!req1->isHTMCmd() && !req2->isHTMCmd());
423 uint8_t *
data,
bool read)
427 assert(!req1->isLocalAccess() && !req2->isLocalAccess());
445 main_send_state->fragments[0] = pkt1;
446 main_send_state->fragments[1] = pkt2;
447 main_send_state->outstanding = 2;
470 if (!byte_enable.empty()) {
471 req->setByteEnable(byte_enable);
477 assert(split_addr <=
addr || split_addr -
addr < block_size);
480 if (split_addr >
addr) {
482 assert(!req->isLLSC() && !req->isSwap());
483 req->splitOnVaddr(split_addr, req1, req2);
513 if (req->isLocalAccess()) {
536 uint8_t *newData =
new uint8_t[size];
544 memset(newData, 0, size);
546 memcpy(newData,
data, size);
554 if (!byte_enable.empty()) {
555 req->setByteEnable(byte_enable);
561 assert(split_addr <=
addr || split_addr -
addr < block_size);
568 if (split_addr >
addr) {
570 assert(!req->isLLSC() && !req->isSwap());
571 req->splitOnVaddr(split_addr, req1, req2);
614 assert(req->hasAtomicOpFunctor());
627 if (split_addr >
addr) {
628 panic(
"AMO requests should not access across a cache line boundary\n");
665 delete [] state->
data;
708 RequestPtr ifetch_req = std::make_shared<Request>();
709 ifetch_req->taskId(
taskId());
710 ifetch_req->setContext(thread->
contextId());
712 DPRINTF(SimpleCPU,
"Translating address %#x\n", ifetch_req->getVaddr());
730 DPRINTF(SimpleCPU,
"Sending fetch for addr %#x(pa: %#x)\n",
731 req->getVaddr(), req->getPaddr());
746 DPRINTF(SimpleCPU,
"Translation of addr %#x faulted\n", req->getVaddr());
770 !std::dynamic_pointer_cast<GenericHtmFailureFault>(fault)) {
771 DPRINTF(HtmCpu,
"fault (%s) occurred - "
772 "replacing with HTM abort fault htmUid=%u\n",
775 Fault tmfault = std::make_shared<GenericHtmFailureFault>(
785 DPRINTF(SimpleCPU,
"Fault occured. Handling the fault\n");
795 DPRINTF(SimpleCPU,
"Scheduling fetch event after the Fault\n");
797 Tick stall = dynamic_pointer_cast<SyscallRetryFault>(fault) ?
826 DPRINTF(SimpleCPU,
"Complete ICache Fetch for addr %#x\n", pkt ?
831 assert(!pkt || !pkt->
isError());
840 pkt->
req->setAccessLatency();
853 DPRINTF(HtmCpu,
"htmTransactionStarts++=%u\n",
911 DPRINTF(SimpleCPU,
"Received fetch response %#x\n", pkt->
getAddr());
917 panic(
"HTM transactional support for"
918 " instruction stream not yet supported\n");
950 const bool is_htm_speculative M5_VAR_USED =
959 pkt->
req->setAccessLatency();
967 if (pkt->
req->isHTMCmd()) {
968 panic(
"unexpected HTM case");
978 assert(is_htm_speculative);
986 assert(is_htm_speculative);
996 assert(main_send_state);
1004 delete main_send_state;
1023 assert(is_htm_speculative);
1030 DPRINTF(HtmCpu,
"HTM abortion in cache (rc=%s) detected htmUid=%u\n",
1042 fault = std::make_shared<GenericHtmFailureFault>(
1046 fault = std::make_shared<GenericHtmFailureFault>(
1062 DPRINTF(HtmCpu,
"htmTransactionStops++=%u\n",
1123 DPRINTF(SimpleCPU,
"Received load/store response %#x\n", pkt->
getAddr());
1164 assert(main_send_state);
1171 if (other_index > 0) {
1172 tmp = main_send_state->
fragments[other_index];
1176 main_send_state->
fragments[other_index] = NULL;
1193 : pkt(_pkt),
cpu(_cpu)
1195 cpu->schedule(
this,
t);
1201 cpu->completeDataAccess(pkt);
1207 return "Timing Simple CPU Delay IPR event";
1236 req->setInstCount(t_info.
numInst);
1238 assert(req->isHTMCmd());
1242 uint8_t *
data =
new uint8_t[size];
1244 uint64_t rc = 0xdeadbeeflu;
1245 memcpy (
data, &rc, size);
1248 if (req->isHTMStart())
1250 else if (req->isHTMCommit())
1252 else if (req->isHTMCancel())
1255 panic(
"initiateHtmCmd: unknown CMD");
1285 req->setInstCount(t_info.
numInst);
1286 req->setHtmAbortCause(cause);
1288 assert(req->isHTMAbort());
1290 uint8_t *
data =
new uint8_t[size];
1293 memcpy (
data, &rc, size);
1304 TimingSimpleCPUParams::create()
#define fatal(...)
This implements a cprintf based fatal() function.
std::unique_ptr< AtomicOpFunctor > AtomicOpFunctorPtr
bool scheduled() const
Determine if the current event is scheduled.
bool handleLockedWrite(XC *xc, const RequestPtr &req, Addr cacheBlockMask)
Fault initiateMemRead(Addr addr, unsigned size, Request::Flags flags, const std::vector< bool > &byte_enable=std::vector< bool >()) override
ContextID contextId() const override
void schedule(PacketPtr _pkt, Tick t)
T roundDown(const T &val, const U &align)
This function is used to align addresses in memory.
void completeIfetch(PacketPtr)
TheISA::PCState pcState() const override
Trace::InstRecord * traceData
virtual Fault initiateAcc(ExecContext *xc, Trace::InstRecord *traceData) const
StaticInstPtr curMacroStaticInst
void handleLockedSnoop(XC *xc, PacketPtr pkt, Addr cacheBlockMask)
bool isTimingMode() const
Is the system in timing mode?
bool isHtmTransactional() const
Returns whether or not this packet/request originates in the CPU executing in transactional mode,...
int16_t ThreadID
Thread index/ID type.
void setNoFault()
Remove all faults from the translation.
@ NO_ACCESS
The request should not cause a memory access.
bool doMonitor(PacketPtr pkt)
unsigned int cacheLineSize() const
Get the cache line size of the system.
virtual void translateTiming(const RequestPtr &req, ThreadContext *tc, Translation *translation, Mode mode)=0
IprEvent(Packet *_pkt, TimingSimpleCPU *_cpu, Tick t)
void translationFault(const Fault &fault)
uint64_t Tick
Tick count type.
bool isCpuDrained() const
Check if a system is in a drained state.
Cycles syscallRetryLatency
void setMem(Addr a, Addr s, unsigned f)
void setupFetchRequest(const RequestPtr &req)
bool isInvalidate() const
std::shared_ptr< Request > RequestPtr
RequestPtr req
A pointer to the original request.
void suspendContext(ThreadID thread_num) override
Notify the CPU that the indicated context is now suspended.
void drainResume() override
bool isPrefetch() const
Check if this request is a prefetch.
void dataDynamic(T *p)
Set the data pointer to a value that should have delete [] called on it.
void deschedulePowerGatingEvent()
std::vector< SimpleExecContext * > threadInfo
void traceFault()
Handler used when encountering a fault; its purpose is to tear down the InstRecord.
This class captures the state of an address translation.
EventFunctionWrapper fetchEvent
void buildSplitPacket(PacketPtr &pkt1, PacketPtr &pkt2, const RequestPtr &req1, const RequestPtr &req2, const RequestPtr &req, uint8_t *data, bool read)
PacketPtr buildPacket(const RequestPtr &req, bool read)
void updateCycleCounters(CPUState state)
base method keeping track of cycle progression
The SimpleThread object provides a combination of the ThreadState object and the ThreadContext interf...
@ Drained
Buffers drained, ready for serialization/handover.
void threadSnoop(PacketPtr pkt, ThreadID sender)
std::list< ThreadID > activeThreads
DrainState
Object drain/handover states.
@ STRICT_ORDER
The request is required to be strictly ordered by CPU models and is non-speculative.
virtual void recvFunctionalSnoop(PacketPtr pkt)
Receive a functional snoop request packet from the peer.
Fault initiateHtmCmd(Request::Flags flags) override
hardware transactional memory
bool isFirstMicroop() const
@ PHYSICAL
The virtual address is also the physical address.
FetchTranslation fetchTranslation
int64_t htmTransactionStops
EventFunctionWrapper retryRespEvent
Addr instAddr() const override
ThreadContext is the external interface to all thread state for anything outside of the CPU.
bool isDelayedCommit() const
ThreadContext * getTC()
Returns the pointer to this SimpleThread's ThreadContext.
bool sendTimingReq(PacketPtr pkt)
Attempt to send a timing request to the responder port by calling its corresponding receive function.
Tick instCnt
Instruction count used for SPARC misc register.
void advanceInst(const Fault &fault)
std::shared_ptr< FaultBase > Fault
virtual const char * description() const
Return a C string describing the event.
static PacketPtr createRead(const RequestPtr &req)
Constructor-like methods that return Packets based on Request objects.
TheISA::MachInst inst
Current instruction.
std::vector< ThreadContext * > threadContexts
void finishTranslation(WholeTranslationState *state)
Finish a DTB translation.
void completeDataAccess(PacketPtr pkt)
virtual void activateContext(ThreadID thread_num)
Notify the CPU that the indicated context is now active.
void setHtmTransactionFailedInCache(const HtmCacheFailure ret_code)
Stipulates that this packet/request has returned from the cache hierarchy in a failed transaction.
void setHtmTransactional(uint64_t val)
Stipulates that this packet/request originates in the CPU executing in transactional mode,...
DrainState drain() override
void checkForInterrupts()
virtual void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
AddressMonitor * getCpuAddrMonitor(ThreadID tid)
Fault writeMem(uint8_t *data, unsigned size, Addr addr, Request::Flags flags, uint64_t *res, const std::vector< bool > &byte_enable=std::vector< bool >()) override
constexpr decltype(nullptr) NoFault
ProbePointArg< PacketInfo > Packet
Packet probe point.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
const std::string & name()
static bool isRomMicroPC(MicroPC upc)
void sendData(const RequestPtr &req, uint8_t *data, uint64_t *res, bool read)
bool htmTransactionFailedInCache() const
Returns whether or not this packet/request has returned from the cache hierarchy in a failed transact...
uint64_t getHtmTransactionUid() const
If a packet/request originates in a CPU executing in transactional mode, i.e.
uint32_t taskId() const
Get cpu task id.
void wakeup(ThreadID tid) override
StaticInstPtr curStaticInst
MemCmd cmd
The command field of the packet.
void advancePC(const Fault &fault)
static PacketPtr createWrite(const RequestPtr &req)
void handleLockedRead(XC *xc, const RequestPtr &req)
Counter numInst
PER-THREAD STATS.
void deleteReqs()
Delete all requests that make up this translation.
Fault getFault() const
Determine whether this translation produced a fault.
bool handleReadPacket(PacketPtr pkt)
uint64_t newHtmTransactionUid() const override
int64_t htmTransactionStarts
@ HTM_ABORT
The request aborts a HTM transaction.
Overload hash function for BasicBlockRange type.
GenericISA::DelaySlotPCState< MachInst > PCState
void schedulePowerGatingEvent()
void dataStatic(T *p)
Set the data pointer to the following value that should not be freed.
virtual void takeOverFrom(BaseCPU *cpu)
Load the state of a CPU from the previous CPU object, invoked on all new CPUs that are about to be sw...
virtual void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
void takeOverFrom(BaseCPU *oldCPU) override
Load the state of a CPU from the previous CPU object, invoked on all new CPUs that are about to be sw...
virtual void switchOut()
Prepare for another CPU to take over execution.
virtual Fault completeAcc(Packet *pkt, ExecContext *xc, Trace::InstRecord *traceData) const
void printAddr(Addr a)
Inject a PrintReq for the given address to print the state of that address throughout the memory syst...
ThreadID numThreads
Number of threads we're actually simulating (<= SMT_MAX_THREADS).
TimingSimpleCPU(TimingSimpleCPUParams *params)
void switchOut() override
Prepare for another CPU to take over execution.
std::string htmFailureToStr(HtmFailureFaultCause cause)
Convert enum into string to be used for debug purposes.
RequestorID dataRequestorId() const
Reads this CPU's unique data requestor ID.
Cycles is a wrapper class for representing cycle counts, i.e.
virtual bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
void sendFetch(const Fault &fault, const RequestPtr &req, ThreadContext *tc)
virtual void suspendContext(ThreadID thread_num)
Notify the CPU that the indicated context is now suspended.
virtual void recvTimingSnoopReq(PacketPtr pkt)
Snoop a coherence request, we need to check if this causes a wakeup event on a cpu that is monitoring...
virtual Fault execute(ExecContext *xc, Trace::InstRecord *traceData) const =0
SenderState * senderState
This packet's sender state.
HtmCacheFailure getHtmTransactionFailedInCacheRC() const
If a packet/request has returned from the cache hierarchy in a failed transaction,...
This class represents part of a data address translation.
static const FlagsType STORE_NO_DATA
bool tryCompleteDrain()
Try to complete a drain request.
bool switchedOut() const
Determine if the CPU is switched out.
bool inHtmTransactionalState() const override
uint64_t getHtmTransactionUid() const override
virtual ~TimingSimpleCPU()
void sendSplitData(const RequestPtr &req1, const RequestPtr &req2, const RequestPtr &req, uint8_t *data, bool read)
void verifyMemoryMode() const override
Verify that the system is in a memory mode supported by the CPU.
Fault initiateMemAMO(Addr addr, unsigned size, Request::Flags flags, AtomicOpFunctorPtr amo_op) override
void activateContext(ThreadID thread_num) override
Notify the CPU that the indicated context is now active.
Command responseCommand() const
void htmSendAbortSignal(HtmFailureFaultCause) override
This function is used to instruct the memory subsystem that a transaction should be aborted and the s...
virtual bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
@ Draining
Draining buffers pending serialization/handover.
void printAddr(Addr a)
Print state of address in memory system via PrintReq (for debugging).
#define panic(...)
This implements a cprintf based panic() function.
Generated on Wed Sep 30 2020 14:02:09 for gem5 by doxygen 1.8.17