Go to the documentation of this file.
44 #include "arch/locked_mem.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"
102 DPRINTF(Drain,
"No need to drain.\n");
106 DPRINTF(Drain,
"Requesting drain.\n");
125 DPRINTF(SimpleCPU,
"Resume\n");
134 threadInfo[tid]->execContextStats.notIdleFraction = 1;
145 threadInfo[tid]->execContextStats.notIdleFraction = 0;
159 DPRINTF(Drain,
"tryCompleteDrain.\n");
163 DPRINTF(Drain,
"CPU done draining, processing drain event\n");
184 assert(thread->microPC() == 0);
203 fatal(
"The timing CPU requires the memory system to be in "
211 DPRINTF(SimpleCPU,
"ActivateContext %d\n", thread_num);
215 threadInfo[thread_num]->execContextStats.notIdleFraction = 1;
235 DPRINTF(SimpleCPU,
"SuspendContext %d\n", thread_num);
249 threadInfo[thread_num]->execContextStats.notIdleFraction = 0;
272 if (req->isHTMCmd()) {
273 assert(!req->isLocalAccess());
278 if (pkt->
isRead() && pkt->
req->isLLSC()) {
281 if (req->isLocalAccess()) {
282 Cycles delay = req->localAccessor(thread->
getTC(), pkt);
312 if (is_htm_speculative || req->isHTMAbort()) {
315 if (req->isHTMAbort())
325 bool do_access =
true;
329 }
else if (req->isCondSwap()) {
331 req->setExtraData(*res);
355 assert(!req1->isHTMCmd() && !req2->isHTMCmd());
421 uint8_t *
data,
bool read)
425 assert(!req1->isLocalAccess() && !req2->isLocalAccess());
443 main_send_state->fragments[0] = pkt1;
444 main_send_state->fragments[1] = pkt2;
445 main_send_state->outstanding = 2;
468 req->setByteEnable(byte_enable);
473 assert(split_addr <=
addr || split_addr -
addr < block_size);
476 if (split_addr >
addr) {
478 assert(!req->isLLSC() && !req->isSwap());
479 req->splitOnVaddr(split_addr, req1, req2);
509 if (req->isLocalAccess()) {
532 uint8_t *newData =
new uint8_t[size];
540 memset(newData, 0, size);
542 memcpy(newData,
data, size);
550 req->setByteEnable(byte_enable);
555 assert(split_addr <=
addr || split_addr -
addr < block_size);
562 if (split_addr >
addr) {
564 assert(!req->isLLSC() && !req->isSwap());
565 req->splitOnVaddr(split_addr, req1, req2);
608 assert(req->hasAtomicOpFunctor());
621 if (split_addr >
addr) {
622 panic(
"AMO requests should not access across a cache line boundary\n");
659 delete [] state->
data;
702 RequestPtr ifetch_req = std::make_shared<Request>();
703 ifetch_req->taskId(
taskId());
704 ifetch_req->setContext(thread->
contextId());
706 DPRINTF(SimpleCPU,
"Translating address %#x\n", ifetch_req->getVaddr());
726 DPRINTF(SimpleCPU,
"Sending fetch for addr %#x(pa: %#x)\n",
727 req->getVaddr(), req->getPaddr());
742 DPRINTF(SimpleCPU,
"Translation of addr %#x faulted\n", req->getVaddr());
766 !std::dynamic_pointer_cast<GenericHtmFailureFault>(fault)) {
767 DPRINTF(HtmCpu,
"fault (%s) occurred - "
768 "replacing with HTM abort fault htmUid=%u\n",
771 Fault tmfault = std::make_shared<GenericHtmFailureFault>(
781 DPRINTF(SimpleCPU,
"Fault occured. Handling the fault\n");
791 DPRINTF(SimpleCPU,
"Scheduling fetch event after the Fault\n");
793 Tick stall = std::dynamic_pointer_cast<SyscallRetryFault>(fault) ?
824 DPRINTF(SimpleCPU,
"Complete ICache Fetch for addr %#x\n", pkt ?
829 assert(!pkt || !pkt->
isError());
838 pkt->
req->setAccessLatency();
851 DPRINTF(HtmCpu,
"htmTransactionStarts++=%u\n",
909 DPRINTF(SimpleCPU,
"Received fetch response %#x\n", pkt->
getAddr());
915 panic(
"HTM transactional support for"
916 " instruction stream not yet supported\n");
948 GEM5_VAR_USED
const bool is_htm_speculative =
957 pkt->
req->setAccessLatency();
965 if (pkt->
req->isHTMCmd()) {
966 panic(
"unexpected HTM case");
976 assert(is_htm_speculative);
984 assert(is_htm_speculative);
994 assert(main_send_state);
1002 delete main_send_state;
1021 assert(is_htm_speculative);
1028 DPRINTF(HtmCpu,
"HTM abortion in cache (rc=%s) detected htmUid=%u\n",
1040 fault = std::make_shared<GenericHtmFailureFault>(
1044 fault = std::make_shared<GenericHtmFailureFault>(
1060 DPRINTF(HtmCpu,
"htmTransactionStops++=%u\n",
1121 DPRINTF(SimpleCPU,
"Received load/store response %#x\n", pkt->
getAddr());
1162 assert(main_send_state);
1169 if (other_index > 0) {
1170 tmp = main_send_state->
fragments[other_index];
1174 main_send_state->
fragments[other_index] = NULL;
1191 : pkt(_pkt),
cpu(_cpu)
1199 cpu->completeDataAccess(pkt);
1205 return "Timing Simple CPU Delay IPR event";
1234 req->setInstCount(t_info.
numInst);
1236 assert(req->isHTMCmd());
1240 uint8_t *
data =
new uint8_t[size];
1242 uint64_t
rc = 0xdeadbeeflu;
1243 memcpy (
data, &
rc, size);
1246 if (req->isHTMStart())
1248 else if (req->isHTMCommit())
1250 else if (req->isHTMCancel())
1253 panic(
"initiateHtmCmd: unknown CMD");
1283 req->setInstCount(t_info.
numInst);
1284 req->setHtmAbortCause(cause);
1286 assert(req->isHTMAbort());
1288 uint8_t *
data =
new uint8_t[size];
1291 memcpy (
data, &
rc, size);
#define fatal(...)
This implements a cprintf based fatal() function.
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
constexpr decltype(nullptr) NoFault
bool switchedOut() const
Determine if the CPU is switched out.
bool sendTimingReq(PacketPtr pkt)
Attempt to send a timing request to the responder port by calling its corresponding receive function.
Fault initiateHtmCmd(Request::Flags flags) override
hardware transactional memory
void sendData(const RequestPtr &req, uint8_t *data, uint64_t *res, bool read)
int64_t htmTransactionStops
std::vector< SimpleExecContext * > threadInfo
bool isPrefetch() const
Check if this request is a prefetch.
@ STRICT_ORDER
The request is required to be strictly ordered by CPU models and is non-speculative.
void setMem(Addr a, Addr s, unsigned f)
Cycles curCycle() const
Determine the current cycle, corresponding to a tick aligned to a clock edge.
Trace::InstRecord * traceData
void setNoFault()
Remove all faults from the translation.
DrainState drainState() const
Return the current drain state of an object.
EventFunctionWrapper retryRespEvent
static bool isRomMicroPC(MicroPC upc)
@ HTM_ABORT
The request aborts a HTM transaction.
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
RequestPtr req
A pointer to the original request.
Command responseCommand() const
void buildSplitPacket(PacketPtr &pkt1, PacketPtr &pkt2, const RequestPtr &req1, const RequestPtr &req2, const RequestPtr &req, uint8_t *data, bool read)
unsigned int cacheLineSize() const
Get the cache line size of the system.
bool doMonitor(PacketPtr pkt)
Addr instAddr() const override
void updateCycleCounters(CPUState state)
base method keeping track of cycle progression
void setHtmTransactional(uint64_t val)
Stipulates that this packet/request originates in the CPU executing in transactional mode,...
StaticInstPtr curStaticInst
Current instruction.
PacketPtr buildPacket(const RequestPtr &req, bool read)
uint64_t newHtmTransactionUid() const override
void verifyMemoryMode() const override
Verify that the system is in a memory mode supported by the CPU.
@ PHYSICAL
The virtual address is also the physical address.
static PacketPtr createWrite(const RequestPtr &req)
void schedule(Event &event, Tick when)
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...
bool isDelayedCommit() const
void sendFetch(const Fault &fault, const RequestPtr &req, ThreadContext *tc)
virtual void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
bool isFirstMicroop() const
void deleteReqs()
Delete all requests that make up this translation.
void schedulePowerGatingEvent()
int64_t htmTransactionStarts
The SimpleThread object provides a combination of the ThreadState object and the ThreadContext interf...
void completeDataAccess(PacketPtr pkt)
void checkForInterrupts()
virtual Fault execute(ExecContext *xc, Trace::InstRecord *traceData) const =0
virtual bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Cycles is a wrapper class for representing cycle counts, i.e.
bool handleLockedWrite(XC *xc, const RequestPtr &req, Addr cacheBlockMask)
ThreadID numThreads
Number of threads we're actually simulating (<= SMT_MAX_THREADS).
void dataStatic(T *p)
Set the data pointer to the following value that should not be freed.
void deschedulePowerGatingEvent()
DrainState
Object drain/handover states.
virtual void suspendContext(ThreadID thread_num)
Notify the CPU that the indicated context is now suspended.
gem5::BaseCPU::BaseCPUStats baseStats
uint32_t taskId() const
Get cpu task id.
void switchOut() override
Prepare for another CPU to take over execution.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
std::shared_ptr< FaultBase > Fault
This class represents part of a data address translation.
bool inHtmTransactionalState() const override
Fault initiateMemAMO(Addr addr, unsigned size, Request::Flags flags, AtomicOpFunctorPtr amo_op) override
EventFunctionWrapper fetchEvent
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
void printAddr(Addr a)
Print state of address in memory system via PrintReq (for debugging).
statistics::Scalar numCycles
bool htmTransactionFailedInCache() const
Returns whether or not this packet/request has returned from the cache hierarchy in a failed transact...
virtual ~TimingSimpleCPU()
GenericISA::DelaySlotPCState< 4 > PCState
ProbePointArg< PacketInfo > Packet
Packet probe point.
uint64_t Tick
Tick count type.
void setupFetchRequest(const RequestPtr &req)
std::shared_ptr< Request > RequestPtr
uint64_t getHtmTransactionUid() const
If a packet/request originates in a CPU executing in transactional mode, i.e.
void activateContext(ThreadID thread_num) override
Notify the CPU that the indicated context is now active.
IprEvent(Packet *_pkt, TimingSimpleCPU *_cpu, Tick t)
void completeIfetch(PacketPtr)
std::list< ThreadID > activeThreads
Fault initiateMemRead(Addr addr, unsigned size, Request::Flags flags, const std::vector< bool > &byte_enable=std::vector< bool >()) override
void reschedule(Event &event, Tick when, bool always=false)
void advanceInst(const Fault &fault)
HtmCacheFailure getHtmTransactionFailedInCacheRC() const
If a packet/request has returned from the cache hierarchy in a failed transaction,...
static constexpr T roundDown(const T &val, const U &align)
This function is used to align addresses in memory.
void traceFault()
Handler used when encountering a fault; its purpose is to tear down the InstRecord.
Counter numInst
PER-THREAD STATS.
TheISA::PCState pcState() const override
@ Drained
Buffers drained, ready for serialization/handover.
bool isTimingMode() const
Is the system in timing mode?
MemCmd cmd
The command field of the packet.
virtual void recvFunctionalSnoop(PacketPtr pkt)
Receive a functional snoop request packet from the peer.
AddressMonitor * getCpuAddrMonitor(ThreadID tid)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
virtual bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
void threadSnoop(PacketPtr pkt, ThreadID sender)
SenderState * senderState
This packet's sender state.
const std::string & name()
void translateTiming(const RequestPtr &req, ThreadContext *tc, Translation *translation, Mode mode)
Tick instCnt
Instruction count used for SPARC misc register.
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 deschedule(Event &event)
virtual void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
ContextID contextId() const override
void signalDrainDone() const
Signal that an object is drained.
void htmSendAbortSignal(HtmFailureFaultCause) override
This function is used to instruct the memory subsystem that a transaction should be aborted and the s...
Tick nextCycle() const
Based on the clock of the object, determine the start tick of the first cycle that is at least one cy...
ThreadContext * getTC()
Returns the pointer to this SimpleThread's ThreadContext.
static const FlagsType STORE_NO_DATA
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...
void finishTranslation(WholeTranslationState *state)
Finish a DTB translation.
bool tryCompleteDrain()
Try to complete a drain request.
void drainResume() override
Resume execution after a successful drain.
std::vector< ThreadContext * > threadContexts
virtual Fault completeAcc(Packet *pkt, ExecContext *xc, Trace::InstRecord *trace_data) const
void translationFault(const Fault &fault)
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...
std::string htmFailureToStr(HtmFailureFaultCause cause)
Convert enum into string to be used for debug purposes.
virtual void activateContext(ThreadID thread_num)
Notify the CPU that the indicated context is now active.
This class captures the state of an address translation.
virtual Fault initiateAcc(ExecContext *xc, Trace::InstRecord *traceData) const
bool handleReadPacket(PacketPtr pkt)
void suspendContext(ThreadID thread_num) override
Notify the CPU that the indicated context is now suspended.
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
void dataDynamic(T *p)
Set the data pointer to a value that should have delete [] called on it.
virtual const char * description() const
Return a C string describing the event.
void serviceInstCountEvents()
virtual void switchOut()
Prepare for another CPU to take over execution.
void handleLockedRead(XC *xc, const RequestPtr &req)
Cycles syscallRetryLatency
void wakeup(ThreadID tid) override
@ NO_ACCESS
The request should not cause a memory access.
void advancePC(const Fault &fault)
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
void schedule(PacketPtr _pkt, Tick t)
RequestorID dataRequestorId() const
Reads this CPU's unique data requestor ID.
Fault getFault() const
Determine whether this translation produced a fault.
void setHtmTransactionFailedInCache(const HtmCacheFailure ret_code)
Stipulates that this packet/request has returned from the cache hierarchy in a failed transaction.
void handleLockedSnoop(XC *xc, PacketPtr pkt, Addr cacheBlockMask)
bool isHtmTransactional() const
Returns whether or not this packet/request originates in the CPU executing in transactional mode,...
void sendSplitData(const RequestPtr &req1, const RequestPtr &req2, const RequestPtr &req, uint8_t *data, bool read)
std::unique_ptr< AtomicOpFunctor > AtomicOpFunctorPtr
FetchTranslation fetchTranslation
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
static PacketPtr createRead(const RequestPtr &req)
Constructor-like methods that return Packets based on Request objects.
uint64_t getHtmTransactionUid() const override
void printAddr(Addr a)
Inject a PrintReq for the given address to print the state of that address throughout the memory syst...
StaticInstPtr curMacroStaticInst
bool isCpuDrained() const
Check if a system is in a drained state.
@ Draining
Draining buffers pending serialization/handover.
bool scheduled() const
Determine if the current event is scheduled.
int16_t ThreadID
Thread index/ID type.
bool isInvalidate() const
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
#define panic(...)
This implements a cprintf based panic() function.
TimingSimpleCPU(const TimingSimpleCPUParams ¶ms)
Generated on Tue Sep 7 2021 14:53:45 for gem5 by doxygen 1.8.17