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"
99 DPRINTF(Drain,
"No need to drain.\n");
103 DPRINTF(Drain,
"Requesting drain.\n");
122 DPRINTF(SimpleCPU,
"Resume\n");
131 threadInfo[tid]->execContextStats.notIdleFraction = 1;
142 threadInfo[tid]->execContextStats.notIdleFraction = 0;
156 DPRINTF(Drain,
"tryCompleteDrain.\n");
160 DPRINTF(Drain,
"CPU done draining, processing drain event\n");
181 assert(thread->microPC() == 0);
200 fatal(
"The timing CPU requires the memory system to be in "
208 DPRINTF(SimpleCPU,
"ActivateContext %d\n", thread_num);
212 threadInfo[thread_num]->execContextStats.notIdleFraction = 1;
232 DPRINTF(SimpleCPU,
"SuspendContext %d\n", thread_num);
246 threadInfo[thread_num]->execContextStats.notIdleFraction = 0;
269 if (req->isHTMCmd()) {
270 assert(!req->isLocalAccess());
275 if (pkt->
isRead() && pkt->
req->isLLSC()) {
278 if (req->isLocalAccess()) {
279 Cycles delay = req->localAccessor(thread->
getTC(), pkt);
309 if (is_htm_speculative || req->isHTMAbort()) {
312 if (req->isHTMAbort())
322 bool do_access =
true;
326 }
else if (req->isCondSwap()) {
328 req->setExtraData(*res);
352 assert(!req1->isHTMCmd() && !req2->isHTMCmd());
418 uint8_t *
data,
bool read)
422 assert(!req1->isLocalAccess() && !req2->isLocalAccess());
440 main_send_state->fragments[0] = pkt1;
441 main_send_state->fragments[1] = pkt2;
442 main_send_state->outstanding = 2;
465 req->setByteEnable(byte_enable);
470 assert(split_addr <=
addr || split_addr -
addr < block_size);
473 if (split_addr >
addr) {
475 assert(!req->isLLSC() && !req->isSwap());
476 req->splitOnVaddr(split_addr, req1, req2);
506 if (req->isLocalAccess()) {
529 uint8_t *newData =
new uint8_t[size];
537 memset(newData, 0, size);
539 memcpy(newData,
data, size);
547 req->setByteEnable(byte_enable);
552 assert(split_addr <=
addr || split_addr -
addr < block_size);
559 if (split_addr >
addr) {
561 assert(!req->isLLSC() && !req->isSwap());
562 req->splitOnVaddr(split_addr, req1, req2);
605 assert(req->hasAtomicOpFunctor());
618 if (split_addr >
addr) {
619 panic(
"AMO requests should not access across a cache line boundary\n");
656 delete [] state->
data;
699 RequestPtr ifetch_req = std::make_shared<Request>();
700 ifetch_req->taskId(
taskId());
701 ifetch_req->setContext(thread->
contextId());
703 DPRINTF(SimpleCPU,
"Translating address %#x\n", ifetch_req->getVaddr());
721 DPRINTF(SimpleCPU,
"Sending fetch for addr %#x(pa: %#x)\n",
722 req->getVaddr(), req->getPaddr());
737 DPRINTF(SimpleCPU,
"Translation of addr %#x faulted\n", req->getVaddr());
761 !std::dynamic_pointer_cast<GenericHtmFailureFault>(fault)) {
762 DPRINTF(HtmCpu,
"fault (%s) occurred - "
763 "replacing with HTM abort fault htmUid=%u\n",
766 Fault tmfault = std::make_shared<GenericHtmFailureFault>(
776 DPRINTF(SimpleCPU,
"Fault occured. Handling the fault\n");
786 DPRINTF(SimpleCPU,
"Scheduling fetch event after the Fault\n");
788 Tick stall = std::dynamic_pointer_cast<SyscallRetryFault>(fault) ?
817 DPRINTF(SimpleCPU,
"Complete ICache Fetch for addr %#x\n", pkt ?
822 assert(!pkt || !pkt->
isError());
831 pkt->
req->setAccessLatency();
844 DPRINTF(HtmCpu,
"htmTransactionStarts++=%u\n",
902 DPRINTF(SimpleCPU,
"Received fetch response %#x\n", pkt->
getAddr());
908 panic(
"HTM transactional support for"
909 " instruction stream not yet supported\n");
941 M5_VAR_USED
const bool is_htm_speculative =
950 pkt->
req->setAccessLatency();
958 if (pkt->
req->isHTMCmd()) {
959 panic(
"unexpected HTM case");
969 assert(is_htm_speculative);
977 assert(is_htm_speculative);
987 assert(main_send_state);
995 delete main_send_state;
1014 assert(is_htm_speculative);
1021 DPRINTF(HtmCpu,
"HTM abortion in cache (rc=%s) detected htmUid=%u\n",
1033 fault = std::make_shared<GenericHtmFailureFault>(
1037 fault = std::make_shared<GenericHtmFailureFault>(
1053 DPRINTF(HtmCpu,
"htmTransactionStops++=%u\n",
1114 DPRINTF(SimpleCPU,
"Received load/store response %#x\n", pkt->
getAddr());
1155 assert(main_send_state);
1162 if (other_index > 0) {
1163 tmp = main_send_state->
fragments[other_index];
1167 main_send_state->
fragments[other_index] = NULL;
1184 : pkt(_pkt),
cpu(_cpu)
1192 cpu->completeDataAccess(pkt);
1198 return "Timing Simple CPU Delay IPR event";
1227 req->setInstCount(t_info.
numInst);
1229 assert(req->isHTMCmd());
1233 uint8_t *
data =
new uint8_t[size];
1235 uint64_t rc = 0xdeadbeeflu;
1236 memcpy (
data, &rc, size);
1239 if (req->isHTMStart())
1241 else if (req->isHTMCommit())
1243 else if (req->isHTMCancel())
1246 panic(
"initiateHtmCmd: unknown CMD");
1276 req->setInstCount(t_info.
numInst);
1277 req->setHtmAbortCause(cause);
1279 assert(req->isHTMAbort());
1281 uint8_t *
data =
new uint8_t[size];
1284 memcpy (
data, &rc, size);
#define fatal(...)
This implements a cprintf based fatal() function.
std::unique_ptr< AtomicOpFunctor > AtomicOpFunctorPtr
bool scheduled() const
Determine if the current event is scheduled.
TimingSimpleCPU(const TimingSimpleCPUParams ¶ms)
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
@ HTM_ABORT
The request aborts a HTM transaction.
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,...
void reschedule(Event &event, Tick when, bool always=false)
int16_t ThreadID
Thread index/ID type.
void setNoFault()
Remove all faults from the translation.
bool doMonitor(PacketPtr pkt)
unsigned int cacheLineSize() const
Get the cache line size of the system.
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
Resume execution after a successful drain.
void deschedule(Event &event)
BaseCPU::BaseCPUStats baseStats
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)
void translateTiming(const RequestPtr &req, ThreadContext *tc, BaseTLB::Translation *translation, BaseTLB::Mode mode)
std::list< ThreadID > activeThreads
DrainState
Object drain/handover states.
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
FetchTranslation fetchTranslation
void schedule(Event &event, Tick when)
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.
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
std::vector< ThreadContext * > threadContexts
Cycles curCycle() const
Determine the current cycle, corresponding to a tick aligned to a clock edge.
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...
@ STRICT_ORDER
The request is required to be strictly ordered by CPU models and is non-speculative.
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
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
void signalDrainDone() const
Signal that an object is drained.
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
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...
DrainState drainState() const
Return the current drain state of an object.
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.
@ NO_ACCESS
The request should not cause a memory access.
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
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...
@ PHYSICAL
The virtual address is also the physical address.
ThreadID numThreads
Number of threads we're actually simulating (<= SMT_MAX_THREADS).
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.
Tick nextCycle() const
Based on the clock of the object, determine the start tick of the first cycle that is at least one cy...
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 Tue Mar 23 2021 19:41:25 for gem5 by doxygen 1.8.17