45 #ifndef __CPU_O3_FETCH_IMPL_HH__ 46 #define __CPU_O3_FETCH_IMPL_HH__ 55 #include "arch/isa_traits.hh" 56 #include "arch/utility.hh" 57 #include "arch/vtophys.hh" 60 #include "config/the_isa.hh" 66 #include "debug/Activity.hh" 67 #include "debug/Drain.hh" 68 #include "debug/Fetch.hh" 69 #include "debug/O3CPU.hh" 70 #include "debug/O3PipeView.hh" 72 #include "params/DerivO3CPU.hh" 84 : fetchPolicy(params->smtFetchPolicy),
87 decodeToFetchDelay(params->decodeToFetchDelay),
88 renameToFetchDelay(params->renameToFetchDelay),
89 iewToFetchDelay(params->iewToFetchDelay),
90 commitToFetchDelay(params->commitToFetchDelay),
91 fetchWidth(params->fetchWidth),
92 decodeWidth(params->decodeWidth),
95 cacheBlkSize(cpu->cacheLineSize()),
96 fetchBufferSize(params->fetchBufferSize),
97 fetchBufferMask(fetchBufferSize - 1),
98 fetchQueueSize(params->fetchQueueSize),
99 numThreads(params->numThreads),
100 numFetchingThreads(params->smtNumFetchingThreads),
101 icachePort(this, _cpu),
102 finishTranslationEvent(this)
105 fatal(
"numThreads (%d) is larger than compiled limit (%d),\n" 106 "\tincrease MaxThreads in src/cpu/o3/impl.hh\n",
107 numThreads, static_cast<int>(Impl::MaxThreads));
109 fatal(
"fetchWidth (%d) is larger than compiled limit (%d),\n" 110 "\tincrease MaxWidth in src/cpu/o3/impl.hh\n",
111 fetchWidth, static_cast<int>(Impl::MaxWidth));
113 fatal(
"fetch buffer size (%u bytes) is greater than the cache " 116 fatal(
"cache block (%u bytes) is not a multiple of the " 117 "fetch buffer (%u bytes)\n",
cacheBlkSize, fetchBufferSize);
121 "Invalid Fetch Policy for a SMT workload.");
126 for (
int i = 0;
i < Impl::MaxThreads;
i++) {
145 decoder[tid] =
new TheISA::Decoder(params->isa[tid]);
152 template <
class Impl>
156 return cpu->name() +
".fetch";
159 template <
class Impl>
169 template <
class Impl>
174 .
name(
name() +
".icacheStallCycles")
175 .
desc(
"Number of cycles fetch is stalled on an Icache miss")
180 .
desc(
"Number of instructions fetch has processed")
185 .
desc(
"Number of branches that fetch encountered")
189 .
name(
name() +
".predictedBranches")
190 .
desc(
"Number of branches that fetch has predicted taken")
195 .
desc(
"Number of cycles fetch has run and was not squashing or" 201 .
desc(
"Number of cycles fetch has spent squashing")
206 .
desc(
"Number of cycles fetch has spent waiting for tlb")
211 .
desc(
"Number of cycles fetch was idle")
216 .
desc(
"Number of cycles fetch has spent blocked")
221 .
desc(
"Number of cache lines fetched")
226 .
desc(
"Number of cycles fetch has spent waiting on interrupts, or " 227 "bad addresses, or out of MSHRs")
231 .
name(
name() +
".PendingDrainCycles")
232 .
desc(
"Number of cycles fetch has spent waiting on pipes to drain")
236 .
name(
name() +
".NoActiveThreadStallCycles")
237 .
desc(
"Number of stall cycles due to no active thread to fetch from")
241 .
name(
name() +
".PendingTrapStallCycles")
242 .
desc(
"Number of stall cycles due to pending traps")
246 .
name(
name() +
".PendingQuiesceStallCycles")
247 .
desc(
"Number of stall cycles due to pending quiesce instructions")
251 .
name(
name() +
".IcacheWaitRetryStallCycles")
252 .
desc(
"Number of stall cycles due to full MSHR")
257 .
desc(
"Number of outstanding Icache misses that were squashed")
262 .
desc(
"Number of outstanding ITLB misses that were squashed")
270 .
desc(
"Number of instructions fetched each cycle (Total)")
275 .
desc(
"Percent of cycles fetch was idle")
281 .
desc(
"Number of branch fetches per cycle")
287 .
desc(
"Number of inst fetches per cycle")
337 pc[tid] =
cpu->pcState(tid);
365 pc[tid] =
cpu->pcState(tid);
393 DPRINTF(Fetch,
"[tid:%i] Waking up from cache miss.\n", tid);
394 assert(!
cpu->switchedOut());
412 DPRINTF(Activity,
"[tid:%i] Activating fetch due to cache completion\n",
424 pkt->
req->setAccessLatency();
425 cpu->ppInstAccessComplete->notify(pkt);
431 template <
class Impl>
441 template <
class Impl>
459 template <
class Impl>
490 template <
class Impl>
494 assert(
cpu->getInstPort().isConnected());
499 template <
class Impl>
503 assert(
cpu->isDraining());
504 assert(!
stalls[tid].drain);
505 DPRINTF(Drain,
"%i: Thread drained.\n", tid);
509 template <
class Impl>
513 DPRINTF(Fetch,
"Waking up from quiesce\n");
519 template <
class Impl>
524 DPRINTF(Activity,
"Activating stage.\n");
526 cpu->activateStage(O3CPU::FetchIdx);
532 template <
class Impl>
537 DPRINTF(Activity,
"Deactivating stage.\n");
539 cpu->deactivateStage(O3CPU::FetchIdx);
545 template <
class Impl>
556 template <
class Impl>
566 if (!inst->isControl()) {
568 inst->setPredTarg(nextPC);
569 inst->setPredTaken(
false);
578 DPRINTF(Fetch,
"[tid:%i] [sn:%llu] Branch at PC %#x " 579 "predicted to be taken to %s\n",
580 tid, inst->seqNum, inst->pcState().instAddr(), nextPC);
582 DPRINTF(Fetch,
"[tid:%i] [sn:%llu] Branch at PC %#x " 583 "predicted to be not taken\n",
584 tid, inst->seqNum, inst->pcState().instAddr());
587 DPRINTF(Fetch,
"[tid:%i] [sn:%llu] Branch at PC %#x " 588 "predicted to go to %s\n",
589 tid, inst->seqNum, inst->pcState().instAddr(), nextPC);
590 inst->setPredTarg(nextPC);
591 inst->setPredTaken(predict_taken);
599 return predict_taken;
602 template <
class Impl>
608 assert(!
cpu->switchedOut());
613 DPRINTF(Fetch,
"[tid:%i] Can't fetch cache line, cache blocked\n",
621 DPRINTF(Fetch,
"[tid:%i] Can't fetch cache line, interrupt pending\n",
629 DPRINTF(Fetch,
"[tid:%i] Fetching cache line %#x for addr %#x\n",
630 tid, fetchBufferBlockPC, vaddr);
635 RequestPtr mem_req = std::make_shared<Request>(
638 cpu->thread[tid]->contextId());
640 mem_req->taskId(
cpu->taskId());
647 cpu->itb->translateTiming(mem_req,
cpu->thread[tid]->getTC(),
652 template <
class Impl>
657 ThreadID tid =
cpu->contextToThread(mem_req->contextId());
658 Addr fetchBufferBlockPC = mem_req->getVaddr();
660 assert(!
cpu->switchedOut());
666 mem_req->getVaddr() !=
memReq[tid]->getVaddr()) {
667 DPRINTF(Fetch,
"[tid:%i] Ignoring itlb completed after squash\n",
679 if (!
cpu->system->isMemAddr(mem_req->getPaddr())) {
680 warn(
"Address %#x is outside of physical memory, stopping fetch\n",
681 mem_req->getPaddr());
693 DPRINTF(Fetch,
"Fetch: Doing instruction read.\n");
701 DPRINTF(Fetch,
"[tid:%i] Out of MSHRs!\n", tid);
708 DPRINTF(Fetch,
"[tid:%i] Doing Icache access.\n", tid);
709 DPRINTF(Activity,
"[tid:%i] Activity: Waiting on I-cache " 727 DPRINTF(Fetch,
"[tid:%i] Got back req with addr %#x but expected %#x\n",
728 tid, mem_req->getVaddr(),
memReq[tid]->getVaddr());
737 DPRINTF(Fetch,
"[tid:%i] Translation faulted, building noop.\n", tid);
740 NULL, fetchPC, fetchPC,
false);
741 instruction->setNotAnInst();
743 instruction->setPredTarg(fetchPC);
744 instruction->fault = fault;
747 DPRINTF(Activity,
"Activity this cycle.\n");
748 cpu->activityThisCycle();
752 DPRINTF(Fetch,
"[tid:%i] Blocked, need to handle the trap.\n", tid);
753 DPRINTF(Fetch,
"[tid:%i] fault (%s) detected @ PC %s.\n",
754 tid, fault->name(),
pc[tid]);
759 template <
class Impl>
764 DPRINTF(Fetch,
"[tid:%i] Squashing, setting PC to: %s.\n",
769 if (squashInst && squashInst->pcState().instAddr() == newPC.instAddr())
770 macroop[tid] = squashInst->macroop;
777 DPRINTF(Fetch,
"[tid:%i] Squashing outstanding Icache miss.\n",
781 DPRINTF(Fetch,
"[tid:%i] Squashing outstanding ITLB miss.\n",
817 DPRINTF(Fetch,
"[tid:%i] Squashing from decode.\n", tid);
823 cpu->removeInstsUntil(seq_num, tid);
830 bool ret_val =
false;
833 assert(
cpu->isDraining());
834 DPRINTF(Fetch,
"[tid:%i] Drain stall detected.\n",tid);
849 while (threads != end) {
857 DPRINTF(Activity,
"[tid:%i] Activating stage.\n",tid);
860 DPRINTF(Activity,
"[tid:%i] Activating fetch due to cache" 864 cpu->activateStage(O3CPU::FetchIdx);
873 DPRINTF(Activity,
"Deactivating stage.\n");
875 cpu->deactivateStage(O3CPU::FetchIdx);
881 template <
class Impl>
887 DPRINTF(Fetch,
"[tid:%i] Squash from commit.\n", tid);
892 cpu->removeInstsNotInROB(tid);
895 template <
class Impl>
901 bool status_change =
false;
909 while (threads != end) {
915 status_change = status_change || updated_status;
918 DPRINTF(Fetch,
"Running stage.\n");
921 if (
fromCommit->commitInfo[0].interruptPending) {
925 if (
fromCommit->commitInfo[0].clearInterrupt) {
933 fetch(status_change);
953 unsigned insts_to_decode = 0;
954 unsigned available_insts = 0;
957 if (!
stalls[tid].decode) {
963 auto tid_itr = activeThreads->begin();
964 std::advance(tid_itr,
random_mt.
random<uint8_t>(0, activeThreads->size() - 1));
966 while (available_insts != 0 && insts_to_decode <
decodeWidth) {
971 DPRINTF(Fetch,
"[tid:%i] [sn:%llu] Sending instruction to decode " 972 "from fetch queue. Fetch queue size: %i.\n",
983 if (tid_itr == activeThreads->end())
984 tid_itr = activeThreads->begin();
989 DPRINTF(Activity,
"Activity this cycle.\n");
990 cpu->activityThisCycle();
997 template <
class Impl>
1007 assert(
stalls[tid].decode);
1015 DPRINTF(Fetch,
"[tid:%i] Squashing instructions due to squash " 1016 "from commit.\n",tid);
1020 fromCommit->commitInfo[tid].squashInst, tid);
1025 if (
fromCommit->commitInfo[tid].mispredictInst &&
1026 fromCommit->commitInfo[tid].mispredictInst->isControl()) {
1037 }
else if (
fromCommit->commitInfo[tid].doneSeqNum) {
1045 DPRINTF(Fetch,
"[tid:%i] Squashing instructions due to squash " 1046 "from decode.\n",tid);
1049 if (
fromDecode->decodeInfo[tid].branchMispredict) {
1061 DPRINTF(Fetch,
"Squashing from decode with PC = %s\n",
1078 DPRINTF(Fetch,
"[tid:%i] Setting to blocked\n",tid);
1089 DPRINTF(Fetch,
"[tid:%i] Done squashing, switching to running.\n",
1102 template<
class Impl>
1103 typename Impl::DynInstPtr
1113 new DynInst(staticInst, curMacroop, thisPC, nextPC, seq,
cpu);
1114 instruction->setTid(tid);
1116 instruction->setASID(tid);
1118 instruction->setThreadState(
cpu->thread[tid]);
1120 DPRINTF(Fetch,
"[tid:%i] Instruction PC %#x (%d) created " 1121 "[sn:%lli].\n", tid, thisPC.instAddr(),
1122 thisPC.microPC(), seq);
1124 DPRINTF(Fetch,
"[tid:%i] Instruction is: %s\n", tid,
1125 instruction->staticInst->
1126 disassemble(thisPC.instAddr()));
1130 instruction->traceData =
1131 cpu->getTracer()->getInstRecord(
curTick(),
cpu->tcBase(tid),
1132 instruction->staticInst, thisPC, curMacroop);
1135 instruction->traceData = NULL;
1139 instruction->setInstListIt(
cpu->addInst(instruction));
1146 DPRINTF(Fetch,
"[tid:%i] Fetch queue entry created (%i/%i).\n",
1156 template<
class Impl>
1165 assert(!
cpu->switchedOut());
1178 DPRINTF(Fetch,
"Attempting to fetch from [tid:%i]\n", tid);
1192 DPRINTF(Fetch,
"[tid:%i] Icache miss is complete.\n", tid);
1195 status_change =
true;
1205 DPRINTF(Fetch,
"[tid:%i] Attempting to translate and read " 1206 "instruction, starting at PC %s.\n", tid, thisPC);
1222 DPRINTF(Fetch,
"[tid:%i] Fetch is stalled!\n", tid);
1228 DPRINTF(Fetch,
"[tid:%i] Fetch is idle!\n", tid);
1246 DPRINTF(Fetch,
"[tid:%i] Adding instructions to queue to " 1251 bool predictedBranch =
false;
1266 && !predictedBranch && !
quiesce) {
1270 bool needMem = !inRom && !curMacroop &&
1282 if (blkOffset >= numInsts) {
1288 decoder[tid]->moreBytes(thisPC, fetchAddr, cacheInsts[blkOffset]);
1290 if (
decoder[tid]->needMoreBytes()) {
1300 if (!(curMacroop || inRom)) {
1301 if (
decoder[tid]->instReady()) {
1302 staticInst =
decoder[tid]->decode(thisPC);
1308 curMacroop = staticInst;
1321 bool newMacro =
false;
1322 if (curMacroop || inRom) {
1324 staticInst =
cpu->microcodeRom.fetchMicroop(
1325 thisPC.microPC(), curMacroop);
1327 staticInst = curMacroop->
fetchMicroop(thisPC.microPC());
1334 thisPC, nextPC,
true);
1340 if (
DTRACE(O3PipeView)) {
1341 instruction->fetchTick =
curTick();
1349 predictedBranch |= thisPC.branching();
1352 if (predictedBranch) {
1353 DPRINTF(Fetch,
"Branch detected with PC = %s\n", thisPC);
1356 newMacro |= thisPC.instAddr() != nextPC.instAddr();
1369 if (instruction->isQuiesce()) {
1371 "Quiesce instruction encountered, halting fetch!\n");
1373 status_change =
true;
1377 }
while ((curMacroop ||
decoder[tid]->instReady()) &&
1386 if (predictedBranch) {
1387 DPRINTF(Fetch,
"[tid:%i] Done fetching, predicted branch " 1388 "instruction encountered.\n", tid);
1390 DPRINTF(Fetch,
"[tid:%i] Done fetching, reached fetch bandwidth " 1391 "for this cycle.\n", tid);
1393 DPRINTF(Fetch,
"[tid:%i] Done fetching, reached the end of the" 1394 "fetch buffer.\n", tid);
1418 template<
class Impl>
1449 template<
class Impl>
1455 case FetchPolicy::RoundRobin:
1457 case FetchPolicy::IQCount:
1459 case FetchPolicy::LSQCount:
1461 case FetchPolicy::Branch:
1485 template<
class Impl>
1494 while (pri_iter != end) {
1495 high_pri = *pri_iter;
1515 template<
class Impl>
1520 std::priority_queue<unsigned,vector<unsigned>,
1521 std::greater<unsigned> > PQ;
1522 std::map<unsigned, ThreadID> threadMap;
1527 while (threads != end) {
1537 while (!PQ.empty()) {
1538 ThreadID high_pri = threadMap[PQ.top()];
1552 template<
class Impl>
1557 std::priority_queue<unsigned,vector<unsigned>,
1558 std::greater<unsigned> > PQ;
1559 std::map<unsigned, ThreadID> threadMap;
1564 while (threads != end) {
1566 unsigned ldstqCount =
fromIEW->iewInfo[tid].ldstqCount;
1570 PQ.push(ldstqCount);
1571 threadMap[ldstqCount] = tid;
1574 while (!PQ.empty()) {
1575 ThreadID high_pri = threadMap[PQ.top()];
1588 template<
class Impl>
1592 panic(
"Branch Count Fetch policy unimplemented\n");
1596 template<
class Impl>
1619 DPRINTF(Fetch,
"[tid:%i] Issuing a pipelined I-cache access, " 1620 "starting at PC %s.\n", tid, thisPC);
1626 template<
class Impl>
1629 DPRINTF(Fetch,
"There are no more threads available to fetch from.\n");
1635 DPRINTF(Fetch,
"Fetch is waiting for a drain!\n");
1638 DPRINTF(Fetch,
"Fetch has no active thread!\n");
1641 DPRINTF(Fetch,
"[tid:%i] Fetch is blocked!\n", tid);
1644 DPRINTF(Fetch,
"[tid:%i] Fetch is squashing!\n", tid);
1647 DPRINTF(Fetch,
"[tid:%i] Fetch is waiting cache response!\n",
1651 DPRINTF(Fetch,
"[tid:%i] Fetch is waiting ITLB walk to " 1655 DPRINTF(Fetch,
"[tid:%i] Fetch is waiting for a pending trap!\n",
1659 DPRINTF(Fetch,
"[tid:%i] Fetch is waiting for a pending quiesce " 1660 "instruction!\n", tid);
1663 DPRINTF(Fetch,
"[tid:%i] Fetch is waiting for an I-cache retry!\n",
1666 DPRINTF(Fetch,
"[tid:%i] Fetch predicted non-executable address\n",
1669 DPRINTF(Fetch,
"[tid:%i] Unexpected fetch stall reason " 1675 template<
class Impl>
1681 assert(pkt->
req->isUncacheable() ||
1683 fetch->processCacheCompletion(pkt);
1688 template<
class Impl>
1692 fetch->recvReqRetry();
1695 #endif//__CPU_O3_FETCH_IMPL_HH__ #define panic(...)
This implements a cprintf based panic() function.
Stats::Formula fetchRate
Number of instruction fetched per cycle.
const FlagsType pdf
Print the percent of the total that this entry represents.
unsigned fetchWidth
The width of fetch in instructions.
virtual void recvReqRetry()
Handles doing a retry of a failed fetch.
ThreadID iqCount()
Returns the appropriate thread to fetch using the IQ count policy.
void profileStall(ThreadID tid)
Profile the reasons of fetch stall.
TheISA::Decoder * decoder[Impl::MaxThreads]
The decoder.
decltype(nullptr) constexpr NoFault
Cycles is a wrapper class for representing cycle counts, i.e.
Stats::Formula idleRate
Rate of how often fetch was idle.
#define fatal(...)
This implements a cprintf based fatal() function.
void tick()
Ticks the fetch stage, processing all inputs signals and fetching as many instructions as possible...
void resetStage()
Reset this pipeline stage.
void squashFromDecode(const TheISA::PCState &newPC, const DynInstPtr squashInst, const InstSeqNum seq_num, ThreadID tid)
Squashes a specific thread and resets the PC.
TimeBuffer< TimeStruct >::wire fromRename
Wire to get rename's information from backwards time buffer.
void pipelineIcacheAccesses(ThreadID tid)
Pipeline the next I-cache access to the current one.
Addr fetchBufferPC[Impl::MaxThreads]
The PC of the first instruction loaded into the fetch buffer.
bool checkInterrupt(Addr pc)
Check if an interrupt is pending and that we need to handle.
std::shared_ptr< Request > RequestPtr
FetchStatus _status
Fetch status.
void notify(const Arg &arg)
called at the ProbePoint call site, passes arg to each listener.
Impl::DynInstPtr DynInstPtr
bool checkStall(ThreadID tid) const
Checks if a thread is stalled.
Stats::Scalar fetchPendingTrapStallCycles
Total number of stall cycles caused by pending traps.
TimeBuffer< FetchStruct >::wire toDecode
Wire used to write any information heading to decode.
int numInst
Tracks how many instructions has been fetched this cycle.
bool cacheResponding() const
std::string name() const
Returns the name of fetch.
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
void processCacheCompletion(PacketPtr pkt)
Processes cache completion event.
Stats::Scalar fetchMiscStallCycles
Total number of cycles spent in any other state.
Stats::Scalar fetchIdleCycles
Stat for total number of cycles spent blocked due to other stages in the pipeline.
Stats::Formula branchRate
Number of branch fetches per cycle.
unsigned fetchQueueSize
The size of the fetch queue in micro-ops.
void update(const InstSeqNum &done_sn, ThreadID tid)
Tells the branch predictor to commit any updates until the given sequence number. ...
Overload hash function for BasicBlockRange type.
bool sendTimingReq(PacketPtr pkt)
Attempt to send a timing request to the slave port by calling its corresponding receive function...
Stats::Scalar fetchTlbSquashes
Total number of outstanding tlb accesses that were dropped due to a squash.
TimeBuffer< TimeStruct >::wire fromDecode
Wire to get decode's information from backwards time buffer.
Stats::Scalar icacheStallCycles
Stat for total number of cycles stalled due to an icache miss.
ThreadID getFetchingThread()
Returns the appropriate thread to fetch, given the fetch policy.
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
bool issuePipelinedIfetch[Impl::MaxThreads]
Set to true if a pipelined I-cache request should be issued.
ThreadID numThreads
Number of threads.
std::enable_if< std::is_integral< T >::value, T >::type random()
Use the SFINAE idiom to choose an implementation based on whether the type is integral or floating po...
Stats::Scalar fetchedInsts
Stat for total number of fetched instructions.
Stats::Scalar fetchNoActiveThreadStallCycles
Total number of stall cycles caused by no active threads to run.
void drainSanityCheck() const
Perform sanity checks after a drain.
RequestPtr req
A pointer to the original request.
FetchStatus
Overall fetch status.
Stats::Distribution fetchNisnDist
Distribution of number of instructions fetched each cycle.
void deactivateThread(ThreadID tid)
For priority-based fetch policies, need to keep update priorityList.
Stats::Scalar fetchPendingDrainCycles
Total number of cycles spent in waiting for drains.
PacketPtr retryPkt
The packet that is waiting to be retried.
ThreadID numFetchingThreads
Number of threads that are actively fetching.
Cycles iewToFetchDelay
IEW to fetch delay.
void takeOverFrom()
Takes over from another CPU's thread.
void drainStall(ThreadID tid)
Stall the fetch stage after reaching a safe drain point.
Stats::Scalar fetchCycles
Stat for total number of cycles spent fetching.
ThreadID threadFetched
Thread ID being fetched.
Tick curTick()
The current simulated tick.
void quiesce(ThreadContext *tc)
void regStats()
Registers statistics.
void clearStates(ThreadID tid)
Clear all thread-specific states.
Addr fetchOffset[Impl::MaxThreads]
bool scheduled() const
Determine if the current event is scheduled.
ThreadID roundRobin()
Returns the appropriate thread to fetch using a round robin policy.
virtual StaticInstPtr fetchMicroop(MicroPC upc) const
Return the microop that goes with a particular micropc.
void switchToActive()
Changes the status of this stage to active, and indicates this to the CPU.
Derived & prereq(const Stat &prereq)
Set the prerequisite stat and marks this stat to print at the end of simulation.
int instSize
Size of instructions.
void finishTranslation(const Fault &fault, const RequestPtr &mem_req)
void fetch(bool &status_change)
Does the actual fetching of instructions and passing them on to the next stage.
Stats::Scalar fetchTlbCycles
Stat for total number of cycles spent waiting for translation.
RequestPtr memReq[Impl::MaxThreads]
Memory request used to access cache.
IcachePort icachePort
Instruction port.
bool fetchCacheLine(Addr vaddr, ThreadID tid, Addr pc)
Fetches the cache line that contains the fetch PC.
void recvReqRetry()
Handles retrying the fetch access.
bool predict(const StaticInstPtr &inst, const InstSeqNum &seqNum, TheISA::PCState &pc, ThreadID tid)
Predicts whether or not the instruction is a taken branch, and the target of the branch if it is take...
DefaultFetch(O3CPU *_cpu, DerivO3CPUParams *params)
DefaultFetch constructor.
void setReq(const RequestPtr &_req)
ThreadID retryTid
The thread that is waiting on the cache to tell fetch to retry.
Distribution & init(Counter min, Counter max, Counter bkt)
Set the parameters of this distribution.
Stats::Scalar predictedBranches
Stat for total number of predicted branches.
void setActiveThreads(std::list< ThreadID > *at_ptr)
Sets pointer to list of active threads.
std::list< ThreadID > * activeThreads
List of Active Threads.
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void regProbePoints()
Registers probes.
void advancePC(PCState &pc, const StaticInstPtr &inst)
TimeBuffer< TimeStruct >::wire fromCommit
Wire to get commit's information from backwards time buffer.
Stats::Scalar fetchIcacheWaitRetryStallCycles
Total number of stall cycles caused by I-cache wait retrys.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
uint8_t * fetchBuffer[Impl::MaxThreads]
The fetch data that is being fetched and buffered.
static bool isRomMicroPC(MicroPC upc)
std::deque< DynInstPtr > fetchQueue[Impl::MaxThreads]
Queue of fetched instructions.
Stats::Scalar fetchIcacheSquashes
Total number of outstanding icache accesses that were dropped due to a squash.
bool interruptPending
Checks if there is an interrupt pending.
static StaticInstPtr nopStaticInstPtr
Pointer to a statically allocated generic "nop" instruction object.
ThreadID branchCount()
Returns the appropriate thread to fetch using the branch count policy.
The request was an instruction fetch.
const FlagsType total
Print the total.
const ThreadID InvalidThreadID
unsigned decodeWidth
The width of decode in instructions.
TheISA::PCState pc[Impl::MaxThreads]
Counter lastIcacheStall[Impl::MaxThreads]
Icache stall statistics.
FinishTranslationEvent finishTranslationEvent
Event used to delay fault generation of translation faults.
Derived & name(const std::string &name)
Set the name and marks this stat to print at the end of simulation.
Stats::Scalar fetchPendingQuiesceStallCycles
Total number of stall cycles caused by pending quiesce instructions.
int16_t ThreadID
Thread index/ID type.
void setTimeBuffer(TimeBuffer< TimeStruct > *time_buffer)
Sets the main backwards communication time buffer pointer.
void setFetchQueue(TimeBuffer< FetchStruct > *fq_ptr)
Sets pointer to time buffer used to communicate to the next stage.
Addr fetchBufferAlignPC(Addr addr)
Align a PC to the start of a fetch buffer block.
ThreadStatus fetchStatus[Impl::MaxThreads]
Per-thread status.
Declaration of the Packet class.
Stalls stalls[Impl::MaxThreads]
Tracks which stages are telling fetch to stall.
O3CPU * cpu
Pointer to the O3CPU.
void drainSanityCheck() const
Perform sanity checks after a drain.
bool cacheBlocked
Is the cache blocked? If so no threads can access it.
GenericISA::SimplePCState< MachInst > PCState
FetchStatus updateFetchStatus()
Updates overall fetch stage status; to be called at the end of each cycle.
Cycles decodeToFetchDelay
Decode to fetch delay.
Cycles commitToFetchDelay
Commit to fetch delay.
void switchToInactive()
Changes the status of this stage to inactive, and indicates this to the CPU.
void startupStage()
Initialize stage.
bool lookupAndUpdateNextPC(const DynInstPtr &inst, TheISA::PCState &pc)
Looks up in the branch predictor to see if the next PC should be either next PC+=MachInst or a branch...
ProbePointArg< RequestPtr > * ppFetchRequestSent
To probe when a fetch request is successfully sent.
const T * getConstPtr() const
ProbePointArg< DynInstPtr > * ppFetch
Probe points.
void dataDynamic(T *p)
Set the data pointer to a value that should have delete [] called on it.
void squash(const InstSeqNum &squashed_sn, ThreadID tid)
Squashes all outstanding updates until a given sequence number.
void setFault(Fault _fault)
Stats::Scalar fetchSquashCycles
Stat for total number of cycles spent squashing.
void squash(const TheISA::PCState &newPC, const InstSeqNum seq_num, DynInstPtr squashInst, ThreadID tid)
Squashes a specific thread and resets the PC.
unsigned fetchBufferSize
The size of the fetch buffer in bytes.
ThreadID lsqCount()
Returns the appropriate thread to fetch using the LSQ count policy.
FetchPolicy fetchPolicy
Fetch policy.
Derived & desc(const std::string &_desc)
Set the description and marks this stat to print at the end of simulation.
Cycles renameToFetchDelay
Rename to fetch delay.
virtual bool recvTimingResp(PacketPtr pkt)
Timing version of receive.
bool isDrained() const
Has the stage drained?
void wakeFromQuiesce()
Tells fetch to wake up from a quiesce instruction.
Stats::Scalar fetchBlockedCycles
Total number of cycles spent blocked.
Stats::Scalar fetchedCacheLines
Stat for total number of fetched cache lines.
void drainResume()
Resume after a drain.
std::list< ThreadID > priorityList
List that has the threads organized by priority.
bool checkSignalsAndUpdate(ThreadID tid)
Checks all input signals and updates the status as necessary.
StaticInstPtr macroop[Impl::MaxThreads]
bool delayedCommit[Impl::MaxThreads]
Can the fetch stage redirect from an interrupt on this instruction?
Stats::Scalar fetchedBranches
Total number of fetched branches.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
DynInstPtr buildInst(ThreadID tid, StaticInstPtr staticInst, StaticInstPtr curMacroop, TheISA::PCState thisPC, TheISA::PCState nextPC, bool trace)
std::shared_ptr< FaultBase > Fault
BPredUnit * branchPred
BPredUnit.
TimeBuffer< TimeStruct > * timeBuffer
Time buffer interface.
void sample(const U &v, int n=1)
Add a value to the distribtion n times.
bool wroteToTimeBuffer
Variable that tracks if fetch has written to the time buffer this cycle.
void doSquash(const TheISA::PCState &newPC, const DynInstPtr squashInst, ThreadID tid)
Squashes a specific thread and resets the PC.
unsigned int cacheBlkSize
Cache block size.
bool fetchBufferValid[Impl::MaxThreads]
Whether or not the fetch buffer data is valid.
bool isLastMicroop() const
ProbePointArg< PacketInfo > Packet
Packet probe point.
TimeBuffer< TimeStruct >::wire fromIEW
Wire to get iew's information from backwards time buffer.