42 #ifndef __CPU_O3_FETCH_IMPL_HH__ 43 #define __CPU_O3_FETCH_IMPL_HH__ 52 #include "arch/isa_traits.hh" 53 #include "arch/utility.hh" 56 #include "config/the_isa.hh" 62 #include "debug/Activity.hh" 63 #include "debug/Drain.hh" 64 #include "debug/Fetch.hh" 65 #include "debug/O3CPU.hh" 66 #include "debug/O3PipeView.hh" 68 #include "params/DerivO3CPU.hh" 80 : fetchPolicy(params->smtFetchPolicy),
83 decodeToFetchDelay(params->decodeToFetchDelay),
84 renameToFetchDelay(params->renameToFetchDelay),
85 iewToFetchDelay(params->iewToFetchDelay),
86 commitToFetchDelay(params->commitToFetchDelay),
87 fetchWidth(params->fetchWidth),
88 decodeWidth(params->decodeWidth),
91 cacheBlkSize(cpu->cacheLineSize()),
92 fetchBufferSize(params->fetchBufferSize),
93 fetchBufferMask(fetchBufferSize - 1),
94 fetchQueueSize(params->fetchQueueSize),
95 numThreads(params->numThreads),
96 numFetchingThreads(params->smtNumFetchingThreads),
97 icachePort(this, _cpu),
98 finishTranslationEvent(this)
101 fatal(
"numThreads (%d) is larger than compiled limit (%d),\n" 102 "\tincrease MaxThreads in src/cpu/o3/impl.hh\n",
103 numThreads, static_cast<int>(Impl::MaxThreads));
105 fatal(
"fetchWidth (%d) is larger than compiled limit (%d),\n" 106 "\tincrease MaxWidth in src/cpu/o3/impl.hh\n",
107 fetchWidth, static_cast<int>(Impl::MaxWidth));
109 fatal(
"fetch buffer size (%u bytes) is greater than the cache " 112 fatal(
"cache block (%u bytes) is not a multiple of the " 113 "fetch buffer (%u bytes)\n",
cacheBlkSize, fetchBufferSize);
117 "Invalid Fetch Policy for a SMT workload.");
122 for (
int i = 0;
i < Impl::MaxThreads;
i++) {
141 decoder[tid] =
new TheISA::Decoder(
142 dynamic_cast<TheISA::ISA *>(params->isa[tid]));
149 template <
class Impl>
153 return cpu->name() +
".fetch";
156 template <
class Impl>
166 template <
class Impl>
171 .
name(
name() +
".icacheStallCycles")
172 .
desc(
"Number of cycles fetch is stalled on an Icache miss")
177 .
desc(
"Number of instructions fetch has processed")
182 .
desc(
"Number of branches that fetch encountered")
186 .
name(
name() +
".predictedBranches")
187 .
desc(
"Number of branches that fetch has predicted taken")
192 .
desc(
"Number of cycles fetch has run and was not squashing or" 198 .
desc(
"Number of cycles fetch has spent squashing")
203 .
desc(
"Number of cycles fetch has spent waiting for tlb")
208 .
desc(
"Number of cycles fetch was idle")
213 .
desc(
"Number of cycles fetch has spent blocked")
218 .
desc(
"Number of cache lines fetched")
223 .
desc(
"Number of cycles fetch has spent waiting on interrupts, or " 224 "bad addresses, or out of MSHRs")
228 .
name(
name() +
".PendingDrainCycles")
229 .
desc(
"Number of cycles fetch has spent waiting on pipes to drain")
233 .
name(
name() +
".NoActiveThreadStallCycles")
234 .
desc(
"Number of stall cycles due to no active thread to fetch from")
238 .
name(
name() +
".PendingTrapStallCycles")
239 .
desc(
"Number of stall cycles due to pending traps")
243 .
name(
name() +
".PendingQuiesceStallCycles")
244 .
desc(
"Number of stall cycles due to pending quiesce instructions")
248 .
name(
name() +
".IcacheWaitRetryStallCycles")
249 .
desc(
"Number of stall cycles due to full MSHR")
254 .
desc(
"Number of outstanding Icache misses that were squashed")
259 .
desc(
"Number of outstanding ITLB misses that were squashed")
267 .
desc(
"Number of instructions fetched each cycle (Total)")
272 .
desc(
"Percent of cycles fetch was idle")
278 .
desc(
"Number of branch fetches per cycle")
284 .
desc(
"Number of inst fetches per cycle")
334 pc[tid] =
cpu->pcState(tid);
362 pc[tid] =
cpu->pcState(tid);
390 DPRINTF(Fetch,
"[tid:%i] Waking up from cache miss.\n", tid);
391 assert(!
cpu->switchedOut());
409 DPRINTF(Activity,
"[tid:%i] Activating fetch due to cache completion\n",
421 pkt->
req->setAccessLatency();
422 cpu->ppInstAccessComplete->notify(pkt);
428 template <
class Impl>
438 template <
class Impl>
456 template <
class Impl>
487 template <
class Impl>
491 assert(
cpu->getInstPort().isConnected());
496 template <
class Impl>
500 assert(
cpu->isDraining());
501 assert(!
stalls[tid].drain);
502 DPRINTF(Drain,
"%i: Thread drained.\n", tid);
506 template <
class Impl>
510 DPRINTF(Fetch,
"Waking up from quiesce\n");
516 template <
class Impl>
521 DPRINTF(Activity,
"Activating stage.\n");
523 cpu->activateStage(O3CPU::FetchIdx);
529 template <
class Impl>
534 DPRINTF(Activity,
"Deactivating stage.\n");
536 cpu->deactivateStage(O3CPU::FetchIdx);
542 template <
class Impl>
553 template <
class Impl>
563 if (!inst->isControl()) {
565 inst->setPredTarg(nextPC);
566 inst->setPredTaken(
false);
575 DPRINTF(Fetch,
"[tid:%i] [sn:%llu] Branch at PC %#x " 576 "predicted to be taken to %s\n",
577 tid, inst->seqNum, inst->pcState().instAddr(), nextPC);
579 DPRINTF(Fetch,
"[tid:%i] [sn:%llu] Branch at PC %#x " 580 "predicted to be not taken\n",
581 tid, inst->seqNum, inst->pcState().instAddr());
584 DPRINTF(Fetch,
"[tid:%i] [sn:%llu] Branch at PC %#x " 585 "predicted to go to %s\n",
586 tid, inst->seqNum, inst->pcState().instAddr(), nextPC);
587 inst->setPredTarg(nextPC);
588 inst->setPredTaken(predict_taken);
596 return predict_taken;
599 template <
class Impl>
605 assert(!
cpu->switchedOut());
610 DPRINTF(Fetch,
"[tid:%i] Can't fetch cache line, cache blocked\n",
618 DPRINTF(Fetch,
"[tid:%i] Can't fetch cache line, interrupt pending\n",
626 DPRINTF(Fetch,
"[tid:%i] Fetching cache line %#x for addr %#x\n",
627 tid, fetchBufferBlockPC, vaddr);
632 RequestPtr mem_req = std::make_shared<Request>(
635 cpu->thread[tid]->contextId());
637 mem_req->taskId(
cpu->taskId());
644 cpu->itb->translateTiming(mem_req,
cpu->thread[tid]->getTC(),
649 template <
class Impl>
654 ThreadID tid =
cpu->contextToThread(mem_req->contextId());
655 Addr fetchBufferBlockPC = mem_req->getVaddr();
657 assert(!
cpu->switchedOut());
663 mem_req->getVaddr() !=
memReq[tid]->getVaddr()) {
664 DPRINTF(Fetch,
"[tid:%i] Ignoring itlb completed after squash\n",
676 if (!
cpu->system->isMemAddr(mem_req->getPaddr())) {
677 warn(
"Address %#x is outside of physical memory, stopping fetch\n",
678 mem_req->getPaddr());
690 DPRINTF(Fetch,
"Fetch: Doing instruction read.\n");
698 DPRINTF(Fetch,
"[tid:%i] Out of MSHRs!\n", tid);
705 DPRINTF(Fetch,
"[tid:%i] Doing Icache access.\n", tid);
706 DPRINTF(Activity,
"[tid:%i] Activity: Waiting on I-cache " 724 DPRINTF(Fetch,
"[tid:%i] Got back req with addr %#x but expected %#x\n",
725 tid, mem_req->getVaddr(),
memReq[tid]->getVaddr());
734 DPRINTF(Fetch,
"[tid:%i] Translation faulted, building noop.\n", tid);
737 NULL, fetchPC, fetchPC,
false);
738 instruction->setNotAnInst();
740 instruction->setPredTarg(fetchPC);
741 instruction->fault = fault;
744 DPRINTF(Activity,
"Activity this cycle.\n");
745 cpu->activityThisCycle();
749 DPRINTF(Fetch,
"[tid:%i] Blocked, need to handle the trap.\n", tid);
750 DPRINTF(Fetch,
"[tid:%i] fault (%s) detected @ PC %s.\n",
751 tid, fault->name(),
pc[tid]);
756 template <
class Impl>
761 DPRINTF(Fetch,
"[tid:%i] Squashing, setting PC to: %s.\n",
766 if (squashInst && squashInst->pcState().instAddr() == newPC.instAddr())
767 macroop[tid] = squashInst->macroop;
774 DPRINTF(Fetch,
"[tid:%i] Squashing outstanding Icache miss.\n",
778 DPRINTF(Fetch,
"[tid:%i] Squashing outstanding ITLB miss.\n",
814 DPRINTF(Fetch,
"[tid:%i] Squashing from decode.\n", tid);
820 cpu->removeInstsUntil(seq_num, tid);
827 bool ret_val =
false;
830 assert(
cpu->isDraining());
831 DPRINTF(Fetch,
"[tid:%i] Drain stall detected.\n",tid);
846 while (threads != end) {
854 DPRINTF(Activity,
"[tid:%i] Activating stage.\n",tid);
857 DPRINTF(Activity,
"[tid:%i] Activating fetch due to cache" 861 cpu->activateStage(O3CPU::FetchIdx);
870 DPRINTF(Activity,
"Deactivating stage.\n");
872 cpu->deactivateStage(O3CPU::FetchIdx);
878 template <
class Impl>
884 DPRINTF(Fetch,
"[tid:%i] Squash from commit.\n", tid);
889 cpu->removeInstsNotInROB(tid);
892 template <
class Impl>
898 bool status_change =
false;
906 while (threads != end) {
912 status_change = status_change || updated_status;
915 DPRINTF(Fetch,
"Running stage.\n");
918 if (
fromCommit->commitInfo[0].interruptPending) {
922 if (
fromCommit->commitInfo[0].clearInterrupt) {
930 fetch(status_change);
950 unsigned insts_to_decode = 0;
951 unsigned available_insts = 0;
954 if (!
stalls[tid].decode) {
960 auto tid_itr = activeThreads->begin();
961 std::advance(tid_itr,
random_mt.
random<uint8_t>(0, activeThreads->size() - 1));
963 while (available_insts != 0 && insts_to_decode <
decodeWidth) {
968 DPRINTF(Fetch,
"[tid:%i] [sn:%llu] Sending instruction to decode " 969 "from fetch queue. Fetch queue size: %i.\n",
980 if (tid_itr == activeThreads->end())
981 tid_itr = activeThreads->begin();
986 DPRINTF(Activity,
"Activity this cycle.\n");
987 cpu->activityThisCycle();
994 template <
class Impl>
1004 assert(
stalls[tid].decode);
1012 DPRINTF(Fetch,
"[tid:%i] Squashing instructions due to squash " 1013 "from commit.\n",tid);
1017 fromCommit->commitInfo[tid].squashInst, tid);
1022 if (
fromCommit->commitInfo[tid].mispredictInst &&
1023 fromCommit->commitInfo[tid].mispredictInst->isControl()) {
1034 }
else if (
fromCommit->commitInfo[tid].doneSeqNum) {
1042 DPRINTF(Fetch,
"[tid:%i] Squashing instructions due to squash " 1043 "from decode.\n",tid);
1046 if (
fromDecode->decodeInfo[tid].branchMispredict) {
1058 DPRINTF(Fetch,
"Squashing from decode with PC = %s\n",
1075 DPRINTF(Fetch,
"[tid:%i] Setting to blocked\n",tid);
1086 DPRINTF(Fetch,
"[tid:%i] Done squashing, switching to running.\n",
1099 template<
class Impl>
1100 typename Impl::DynInstPtr
1110 new DynInst(staticInst, curMacroop, thisPC, nextPC, seq,
cpu);
1111 instruction->setTid(tid);
1113 instruction->setThreadState(
cpu->thread[tid]);
1115 DPRINTF(Fetch,
"[tid:%i] Instruction PC %#x (%d) created " 1116 "[sn:%lli].\n", tid, thisPC.instAddr(),
1117 thisPC.microPC(), seq);
1119 DPRINTF(Fetch,
"[tid:%i] Instruction is: %s\n", tid,
1120 instruction->staticInst->
1121 disassemble(thisPC.instAddr()));
1125 instruction->traceData =
1126 cpu->getTracer()->getInstRecord(
curTick(),
cpu->tcBase(tid),
1127 instruction->staticInst, thisPC, curMacroop);
1130 instruction->traceData = NULL;
1134 instruction->setInstListIt(
cpu->addInst(instruction));
1141 DPRINTF(Fetch,
"[tid:%i] Fetch queue entry created (%i/%i).\n",
1151 template<
class Impl>
1160 assert(!
cpu->switchedOut());
1173 DPRINTF(Fetch,
"Attempting to fetch from [tid:%i]\n", tid);
1187 DPRINTF(Fetch,
"[tid:%i] Icache miss is complete.\n", tid);
1190 status_change =
true;
1200 DPRINTF(Fetch,
"[tid:%i] Attempting to translate and read " 1201 "instruction, starting at PC %s.\n", tid, thisPC);
1217 DPRINTF(Fetch,
"[tid:%i] Fetch is stalled!\n", tid);
1223 DPRINTF(Fetch,
"[tid:%i] Fetch is idle!\n", tid);
1241 DPRINTF(Fetch,
"[tid:%i] Adding instructions to queue to " 1246 bool predictedBranch =
false;
1261 && !predictedBranch && !
quiesce) {
1265 bool needMem = !inRom && !curMacroop &&
1277 if (blkOffset >= numInsts) {
1283 decoder[tid]->moreBytes(thisPC, fetchAddr, cacheInsts[blkOffset]);
1285 if (
decoder[tid]->needMoreBytes()) {
1295 if (!(curMacroop || inRom)) {
1296 if (
decoder[tid]->instReady()) {
1297 staticInst =
decoder[tid]->decode(thisPC);
1303 curMacroop = staticInst;
1316 bool newMacro =
false;
1317 if (curMacroop || inRom) {
1319 staticInst =
cpu->microcodeRom.fetchMicroop(
1320 thisPC.microPC(), curMacroop);
1322 staticInst = curMacroop->
fetchMicroop(thisPC.microPC());
1329 thisPC, nextPC,
true);
1335 if (
DTRACE(O3PipeView)) {
1336 instruction->fetchTick =
curTick();
1344 predictedBranch |= thisPC.branching();
1347 if (predictedBranch) {
1348 DPRINTF(Fetch,
"Branch detected with PC = %s\n", thisPC);
1351 newMacro |= thisPC.instAddr() != nextPC.instAddr();
1364 if (instruction->isQuiesce()) {
1366 "Quiesce instruction encountered, halting fetch!\n");
1368 status_change =
true;
1372 }
while ((curMacroop ||
decoder[tid]->instReady()) &&
1381 if (predictedBranch) {
1382 DPRINTF(Fetch,
"[tid:%i] Done fetching, predicted branch " 1383 "instruction encountered.\n", tid);
1385 DPRINTF(Fetch,
"[tid:%i] Done fetching, reached fetch bandwidth " 1386 "for this cycle.\n", tid);
1388 DPRINTF(Fetch,
"[tid:%i] Done fetching, reached the end of the" 1389 "fetch buffer.\n", tid);
1413 template<
class Impl>
1444 template<
class Impl>
1450 case FetchPolicy::RoundRobin:
1452 case FetchPolicy::IQCount:
1454 case FetchPolicy::LSQCount:
1456 case FetchPolicy::Branch:
1480 template<
class Impl>
1489 while (pri_iter != end) {
1490 high_pri = *pri_iter;
1510 template<
class Impl>
1515 std::priority_queue<unsigned,vector<unsigned>,
1516 std::greater<unsigned> > PQ;
1517 std::map<unsigned, ThreadID> threadMap;
1522 while (threads != end) {
1532 while (!PQ.empty()) {
1533 ThreadID high_pri = threadMap[PQ.top()];
1547 template<
class Impl>
1552 std::priority_queue<unsigned,vector<unsigned>,
1553 std::greater<unsigned> > PQ;
1554 std::map<unsigned, ThreadID> threadMap;
1559 while (threads != end) {
1561 unsigned ldstqCount =
fromIEW->iewInfo[tid].ldstqCount;
1565 PQ.push(ldstqCount);
1566 threadMap[ldstqCount] = tid;
1569 while (!PQ.empty()) {
1570 ThreadID high_pri = threadMap[PQ.top()];
1583 template<
class Impl>
1587 panic(
"Branch Count Fetch policy unimplemented\n");
1591 template<
class Impl>
1614 DPRINTF(Fetch,
"[tid:%i] Issuing a pipelined I-cache access, " 1615 "starting at PC %s.\n", tid, thisPC);
1621 template<
class Impl>
1624 DPRINTF(Fetch,
"There are no more threads available to fetch from.\n");
1630 DPRINTF(Fetch,
"Fetch is waiting for a drain!\n");
1633 DPRINTF(Fetch,
"Fetch has no active thread!\n");
1636 DPRINTF(Fetch,
"[tid:%i] Fetch is blocked!\n", tid);
1639 DPRINTF(Fetch,
"[tid:%i] Fetch is squashing!\n", tid);
1642 DPRINTF(Fetch,
"[tid:%i] Fetch is waiting cache response!\n",
1646 DPRINTF(Fetch,
"[tid:%i] Fetch is waiting ITLB walk to " 1650 DPRINTF(Fetch,
"[tid:%i] Fetch is waiting for a pending trap!\n",
1654 DPRINTF(Fetch,
"[tid:%i] Fetch is waiting for a pending quiesce " 1655 "instruction!\n", tid);
1658 DPRINTF(Fetch,
"[tid:%i] Fetch is waiting for an I-cache retry!\n",
1661 DPRINTF(Fetch,
"[tid:%i] Fetch predicted non-executable address\n",
1664 DPRINTF(Fetch,
"[tid:%i] Unexpected fetch stall reason " 1670 template<
class Impl>
1676 assert(pkt->
req->isUncacheable() ||
1678 fetch->processCacheCompletion(pkt);
1683 template<
class Impl>
1687 fetch->recvReqRetry();
1690 #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]
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.
The request was an instruction fetch.
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 advancePC(PCState &pc, const StaticInstPtr &inst)
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.
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.
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.
bool scheduled() const
Determine if the current event is scheduled.
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.
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.
GenericISA::DelaySlotPCState< MachInst > PCState
#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.