fetch.hh revision 9020
11689SN/A/* 28707Sandreas.hansson@arm.com * Copyright (c) 2010-2011 ARM Limited 37849SAli.Saidi@ARM.com * All rights reserved 47849SAli.Saidi@ARM.com * 57849SAli.Saidi@ARM.com * The license below extends only to copyright in the software and shall 67849SAli.Saidi@ARM.com * not be construed as granting a license to any other intellectual 77849SAli.Saidi@ARM.com * property including but not limited to intellectual property relating 87849SAli.Saidi@ARM.com * to a hardware implementation of the functionality of the software 97849SAli.Saidi@ARM.com * licensed hereunder. You may use the software subject to the license 107849SAli.Saidi@ARM.com * terms below provided that you ensure that this notice is replicated 117849SAli.Saidi@ARM.com * unmodified and in its entirety in all distributions of the software, 127849SAli.Saidi@ARM.com * modified or unmodified, in source code or in binary form. 137849SAli.Saidi@ARM.com * 142329SN/A * Copyright (c) 2004-2006 The Regents of The University of Michigan 151689SN/A * All rights reserved. 161689SN/A * 171689SN/A * Redistribution and use in source and binary forms, with or without 181689SN/A * modification, are permitted provided that the following conditions are 191689SN/A * met: redistributions of source code must retain the above copyright 201689SN/A * notice, this list of conditions and the following disclaimer; 211689SN/A * redistributions in binary form must reproduce the above copyright 221689SN/A * notice, this list of conditions and the following disclaimer in the 231689SN/A * documentation and/or other materials provided with the distribution; 241689SN/A * neither the name of the copyright holders nor the names of its 251689SN/A * contributors may be used to endorse or promote products derived from 261689SN/A * this software without specific prior written permission. 271689SN/A * 281689SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 291689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 301689SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 311689SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 321689SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 331689SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 341689SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 351689SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 361689SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 371689SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 381689SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 392665Ssaidi@eecs.umich.edu * 402665Ssaidi@eecs.umich.edu * Authors: Kevin Lim 412756Sksewell@umich.edu * Korey Sewell 421689SN/A */ 431689SN/A 442292SN/A#ifndef __CPU_O3_FETCH_HH__ 452292SN/A#define __CPU_O3_FETCH_HH__ 461060SN/A 479020Sgblack@eecs.umich.edu#include "arch/decoder.hh" 488229Snate@binkert.org#include "arch/predecoder.hh" 492669Sktlim@umich.edu#include "arch/utility.hh" 501461SN/A#include "base/statistics.hh" 516658Snate@binkert.org#include "config/the_isa.hh" 521060SN/A#include "cpu/pc_event.hh" 538229Snate@binkert.org#include "cpu/timebuf.hh" 547849SAli.Saidi@ARM.com#include "cpu/translation.hh" 553348Sbinkertn@umich.edu#include "mem/packet.hh" 562669Sktlim@umich.edu#include "mem/port.hh" 571461SN/A#include "sim/eventq.hh" 581060SN/A 598737Skoansin.tan@gmail.comstruct DerivO3CPUParams; 605529Snate@binkert.org 611060SN/A/** 622329SN/A * DefaultFetch class handles both single threaded and SMT fetch. Its 632329SN/A * width is specified by the parameters; each cycle it tries to fetch 642329SN/A * that many instructions. It supports using a branch predictor to 652329SN/A * predict direction and targets. 662348SN/A * It supports the idling functionality of the CPU by indicating to 672329SN/A * the CPU when it is active and inactive. 681060SN/A */ 691060SN/Atemplate <class Impl> 702292SN/Aclass DefaultFetch 711060SN/A{ 721060SN/A public: 731060SN/A /** Typedefs from Impl. */ 741061SN/A typedef typename Impl::CPUPol CPUPol; 751060SN/A typedef typename Impl::DynInst DynInst; 761061SN/A typedef typename Impl::DynInstPtr DynInstPtr; 772733Sktlim@umich.edu typedef typename Impl::O3CPU O3CPU; 781060SN/A 792292SN/A /** Typedefs from the CPU policy. */ 801061SN/A typedef typename CPUPol::BPredUnit BPredUnit; 811061SN/A typedef typename CPUPol::FetchStruct FetchStruct; 821061SN/A typedef typename CPUPol::TimeStruct TimeStruct; 831060SN/A 841060SN/A /** Typedefs from ISA. */ 852107SN/A typedef TheISA::MachInst MachInst; 862292SN/A typedef TheISA::ExtMachInst ExtMachInst; 872632Sstever@eecs.umich.edu 887849SAli.Saidi@ARM.com class FetchTranslation : public BaseTLB::Translation 897849SAli.Saidi@ARM.com { 907849SAli.Saidi@ARM.com protected: 917849SAli.Saidi@ARM.com DefaultFetch<Impl> *fetch; 927849SAli.Saidi@ARM.com 937849SAli.Saidi@ARM.com public: 947849SAli.Saidi@ARM.com FetchTranslation(DefaultFetch<Impl> *_fetch) 957849SAli.Saidi@ARM.com : fetch(_fetch) 967849SAli.Saidi@ARM.com {} 977849SAli.Saidi@ARM.com 987849SAli.Saidi@ARM.com void 997944SGiacomo.Gabrielli@arm.com markDelayed() 1007944SGiacomo.Gabrielli@arm.com {} 1017944SGiacomo.Gabrielli@arm.com 1027944SGiacomo.Gabrielli@arm.com void 1037849SAli.Saidi@ARM.com finish(Fault fault, RequestPtr req, ThreadContext *tc, 1047849SAli.Saidi@ARM.com BaseTLB::Mode mode) 1057849SAli.Saidi@ARM.com { 1067849SAli.Saidi@ARM.com assert(mode == BaseTLB::Execute); 1077849SAli.Saidi@ARM.com fetch->finishTranslation(fault, req); 1087849SAli.Saidi@ARM.com delete this; 1097849SAli.Saidi@ARM.com } 1107849SAli.Saidi@ARM.com }; 1112935Sksewell@umich.edu 1128462Sgeoffrey.blake@arm.com private: 1138462Sgeoffrey.blake@arm.com /* Event to delay delivery of a fetch translation result in case of 1148462Sgeoffrey.blake@arm.com * a fault and the nop to carry the fault cannot be generated 1158462Sgeoffrey.blake@arm.com * immediately */ 1168462Sgeoffrey.blake@arm.com class FinishTranslationEvent : public Event 1178462Sgeoffrey.blake@arm.com { 1188462Sgeoffrey.blake@arm.com private: 1198462Sgeoffrey.blake@arm.com DefaultFetch<Impl> *fetch; 1208462Sgeoffrey.blake@arm.com Fault fault; 1218462Sgeoffrey.blake@arm.com RequestPtr req; 1228462Sgeoffrey.blake@arm.com 1238462Sgeoffrey.blake@arm.com public: 1248462Sgeoffrey.blake@arm.com FinishTranslationEvent(DefaultFetch<Impl> *_fetch) 1258462Sgeoffrey.blake@arm.com : fetch(_fetch) 1268462Sgeoffrey.blake@arm.com {} 1278462Sgeoffrey.blake@arm.com 1288462Sgeoffrey.blake@arm.com void setFault(Fault _fault) 1298462Sgeoffrey.blake@arm.com { 1308462Sgeoffrey.blake@arm.com fault = _fault; 1318462Sgeoffrey.blake@arm.com } 1328462Sgeoffrey.blake@arm.com 1338462Sgeoffrey.blake@arm.com void setReq(RequestPtr _req) 1348462Sgeoffrey.blake@arm.com { 1358462Sgeoffrey.blake@arm.com req = _req; 1368462Sgeoffrey.blake@arm.com } 1378462Sgeoffrey.blake@arm.com 1388462Sgeoffrey.blake@arm.com /** Process the delayed finish translation */ 1398462Sgeoffrey.blake@arm.com void process() 1408462Sgeoffrey.blake@arm.com { 1418462Sgeoffrey.blake@arm.com assert(fetch->numInst < fetch->fetchWidth); 1428462Sgeoffrey.blake@arm.com fetch->finishTranslation(fault, req); 1438462Sgeoffrey.blake@arm.com } 1448462Sgeoffrey.blake@arm.com 1458462Sgeoffrey.blake@arm.com const char *description() const 1468462Sgeoffrey.blake@arm.com { 1478462Sgeoffrey.blake@arm.com return "FullO3CPU FetchFinishTranslation"; 1488462Sgeoffrey.blake@arm.com } 1498462Sgeoffrey.blake@arm.com }; 1508462Sgeoffrey.blake@arm.com 1511060SN/A public: 1522329SN/A /** Overall fetch status. Used to determine if the CPU can 1532329SN/A * deschedule itsef due to a lack of activity. 1542292SN/A */ 1552292SN/A enum FetchStatus { 1562292SN/A Active, 1572292SN/A Inactive 1582292SN/A }; 1592292SN/A 1602292SN/A /** Individual thread status. */ 1612292SN/A enum ThreadStatus { 1621060SN/A Running, 1631060SN/A Idle, 1641060SN/A Squashing, 1651060SN/A Blocked, 1662292SN/A Fetching, 1672292SN/A TrapPending, 1682292SN/A QuiescePending, 1692307SN/A SwitchOut, 1707849SAli.Saidi@ARM.com ItlbWait, 1712669Sktlim@umich.edu IcacheWaitResponse, 1722696Sktlim@umich.edu IcacheWaitRetry, 1738460SAli.Saidi@ARM.com IcacheAccessComplete, 1748460SAli.Saidi@ARM.com NoGoodAddr 1751060SN/A }; 1761060SN/A 1772292SN/A /** Fetching Policy, Add new policies here.*/ 1782292SN/A enum FetchPriority { 1792292SN/A SingleThread, 1802292SN/A RoundRobin, 1812292SN/A Branch, 1822292SN/A IQ, 1832292SN/A LSQ 1842292SN/A }; 1851060SN/A 1862292SN/A private: 1872292SN/A /** Fetch status. */ 1882292SN/A FetchStatus _status; 1892292SN/A 1902292SN/A /** Per-thread status. */ 1912292SN/A ThreadStatus fetchStatus[Impl::MaxThreads]; 1922292SN/A 1932292SN/A /** Fetch policy. */ 1942292SN/A FetchPriority fetchPolicy; 1952292SN/A 1962292SN/A /** List that has the threads organized by priority. */ 1976221Snate@binkert.org std::list<ThreadID> priorityList; 1981060SN/A 1991060SN/A public: 2002292SN/A /** DefaultFetch constructor. */ 2015529Snate@binkert.org DefaultFetch(O3CPU *_cpu, DerivO3CPUParams *params); 2021684SN/A 2032292SN/A /** Returns the name of fetch. */ 2042292SN/A std::string name() const; 2051684SN/A 2062292SN/A /** Registers statistics. */ 2071062SN/A void regStats(); 2081062SN/A 2092292SN/A /** Sets the main backwards communication time buffer pointer. */ 2101060SN/A void setTimeBuffer(TimeBuffer<TimeStruct> *time_buffer); 2111060SN/A 2122292SN/A /** Sets pointer to list of active threads. */ 2136221Snate@binkert.org void setActiveThreads(std::list<ThreadID> *at_ptr); 2142292SN/A 2152292SN/A /** Sets pointer to time buffer used to communicate to the next stage. */ 2161060SN/A void setFetchQueue(TimeBuffer<FetchStruct> *fq_ptr); 2171060SN/A 2182292SN/A /** Initialize stage. */ 2192292SN/A void initStage(); 2202292SN/A 2214302Sktlim@umich.edu /** Tells the fetch stage that the Icache is set. */ 2224302Sktlim@umich.edu void setIcache(); 2234302Sktlim@umich.edu 2248707Sandreas.hansson@arm.com /** Handles retrying the fetch access. */ 2258707Sandreas.hansson@arm.com void recvRetry(); 2268707Sandreas.hansson@arm.com 2272292SN/A /** Processes cache completion event. */ 2282669Sktlim@umich.edu void processCacheCompletion(PacketPtr pkt); 2292292SN/A 2302843Sktlim@umich.edu /** Begins the drain of the fetch stage. */ 2312863Sktlim@umich.edu bool drain(); 2322843Sktlim@umich.edu 2332843Sktlim@umich.edu /** Resumes execution after a drain. */ 2342843Sktlim@umich.edu void resume(); 2352843Sktlim@umich.edu 2362843Sktlim@umich.edu /** Tells fetch stage to prepare to be switched out. */ 2372307SN/A void switchOut(); 2382307SN/A 2392348SN/A /** Takes over from another CPU's thread. */ 2402307SN/A void takeOverFrom(); 2412307SN/A 2422348SN/A /** Checks if the fetch stage is switched out. */ 2432307SN/A bool isSwitchedOut() { return switchedOut; } 2442307SN/A 2452348SN/A /** Tells fetch to wake up from a quiesce instruction. */ 2462292SN/A void wakeFromQuiesce(); 2471060SN/A 2481061SN/A private: 2492329SN/A /** Changes the status of this stage to active, and indicates this 2502329SN/A * to the CPU. 2512292SN/A */ 2522292SN/A inline void switchToActive(); 2532292SN/A 2542329SN/A /** Changes the status of this stage to inactive, and indicates 2552329SN/A * this to the CPU. 2562292SN/A */ 2572292SN/A inline void switchToInactive(); 2582292SN/A 2591061SN/A /** 2601061SN/A * Looks up in the branch predictor to see if the next PC should be 2611061SN/A * either next PC+=MachInst or a branch target. 2621763SN/A * @param next_PC Next PC variable passed in by reference. It is 2631061SN/A * expected to be set to the current PC; it will be updated with what 2641061SN/A * the next PC will be. 2652935Sksewell@umich.edu * @param next_NPC Used for ISAs which use delay slots. 2661061SN/A * @return Whether or not a branch was predicted as taken. 2671061SN/A */ 2687720Sgblack@eecs.umich.edu bool lookupAndUpdateNextPC(DynInstPtr &inst, TheISA::PCState &pc); 2691062SN/A 2701062SN/A /** 2711062SN/A * Fetches the cache line that contains fetch_PC. Returns any 2721062SN/A * fault that happened. Puts the data into the class variable 2731062SN/A * cacheData. 2747764Sgblack@eecs.umich.edu * @param vaddr The memory address that is being fetched from. 2752292SN/A * @param ret_fault The fault reference that will be set to the result of 2762292SN/A * the icache access. 2772292SN/A * @param tid Thread id. 2787764Sgblack@eecs.umich.edu * @param pc The actual PC of the current instruction. 2791062SN/A * @return Any fault that occured. 2801062SN/A */ 2817849SAli.Saidi@ARM.com bool fetchCacheLine(Addr vaddr, ThreadID tid, Addr pc); 2827849SAli.Saidi@ARM.com void finishTranslation(Fault fault, RequestPtr mem_req); 2831062SN/A 2847847Sminkyu.jeong@arm.com 2857847Sminkyu.jeong@arm.com /** Check if an interrupt is pending and that we need to handle 2867847Sminkyu.jeong@arm.com */ 2877847Sminkyu.jeong@arm.com bool 2887847Sminkyu.jeong@arm.com checkInterrupt(Addr pc) 2897847Sminkyu.jeong@arm.com { 2907847Sminkyu.jeong@arm.com return (interruptPending && (THE_ISA != ALPHA_ISA || !(pc & 0x3))); 2917847Sminkyu.jeong@arm.com } 2927847Sminkyu.jeong@arm.com 2932292SN/A /** Squashes a specific thread and resets the PC. */ 2948503Sgblack@eecs.umich.edu inline void doSquash(const TheISA::PCState &newPC, 2958503Sgblack@eecs.umich.edu const DynInstPtr squashInst, ThreadID tid); 2961684SN/A 2972292SN/A /** Squashes a specific thread and resets the PC. Also tells the CPU to 2982292SN/A * remove any instructions between fetch and decode that should be sqaushed. 2992292SN/A */ 3007720Sgblack@eecs.umich.edu void squashFromDecode(const TheISA::PCState &newPC, 3018503Sgblack@eecs.umich.edu const DynInstPtr squashInst, 3028503Sgblack@eecs.umich.edu const InstSeqNum seq_num, ThreadID tid); 3032292SN/A 3042292SN/A /** Checks if a thread is stalled. */ 3056221Snate@binkert.org bool checkStall(ThreadID tid) const; 3062292SN/A 3072292SN/A /** Updates overall fetch stage status; to be called at the end of each 3082292SN/A * cycle. */ 3092292SN/A FetchStatus updateFetchStatus(); 3101684SN/A 3111684SN/A public: 3122292SN/A /** Squashes a specific thread and resets the PC. Also tells the CPU to 3132292SN/A * remove any instructions that are not in the ROB. The source of this 3142292SN/A * squash should be the commit stage. 3152292SN/A */ 3168503Sgblack@eecs.umich.edu void squash(const TheISA::PCState &newPC, const InstSeqNum seq_num, 3178503Sgblack@eecs.umich.edu DynInstPtr squashInst, ThreadID tid); 3181684SN/A 3192292SN/A /** Ticks the fetch stage, processing all inputs signals and fetching 3202292SN/A * as many instructions as possible. 3212292SN/A */ 3221684SN/A void tick(); 3231684SN/A 3242292SN/A /** Checks all input signals and updates the status as necessary. 3252292SN/A * @return: Returns if the status has changed due to input signals. 3262292SN/A */ 3276221Snate@binkert.org bool checkSignalsAndUpdate(ThreadID tid); 3281684SN/A 3292292SN/A /** Does the actual fetching of instructions and passing them on to the 3302292SN/A * next stage. 3312292SN/A * @param status_change fetch() sets this variable if there was a status 3322292SN/A * change (ie switching to IcacheMissStall). 3332292SN/A */ 3342292SN/A void fetch(bool &status_change); 3352292SN/A 3362292SN/A /** Align a PC to the start of an I-cache block. */ 3371062SN/A Addr icacheBlockAlignPC(Addr addr) 3381062SN/A { 3391062SN/A return (addr & ~(cacheBlkMask)); 3401062SN/A } 3411061SN/A 3428541Sgblack@eecs.umich.edu /** The decoder. */ 3439020Sgblack@eecs.umich.edu TheISA::Decoder decoder; 3448541Sgblack@eecs.umich.edu 3451060SN/A private: 3467764Sgblack@eecs.umich.edu DynInstPtr buildInst(ThreadID tid, StaticInstPtr staticInst, 3477764Sgblack@eecs.umich.edu StaticInstPtr curMacroop, TheISA::PCState thisPC, 3487764Sgblack@eecs.umich.edu TheISA::PCState nextPC, bool trace); 3497764Sgblack@eecs.umich.edu 3502292SN/A /** Returns the appropriate thread to fetch, given the fetch policy. */ 3516221Snate@binkert.org ThreadID getFetchingThread(FetchPriority &fetch_priority); 3522292SN/A 3532292SN/A /** Returns the appropriate thread to fetch using a round robin policy. */ 3546221Snate@binkert.org ThreadID roundRobin(); 3552292SN/A 3562292SN/A /** Returns the appropriate thread to fetch using the IQ count policy. */ 3576221Snate@binkert.org ThreadID iqCount(); 3582292SN/A 3592292SN/A /** Returns the appropriate thread to fetch using the LSQ count policy. */ 3606221Snate@binkert.org ThreadID lsqCount(); 3612292SN/A 3626221Snate@binkert.org /** Returns the appropriate thread to fetch using the branch count 3636221Snate@binkert.org * policy. */ 3646221Snate@binkert.org ThreadID branchCount(); 3652292SN/A 3668462Sgeoffrey.blake@arm.com /** Pipeline the next I-cache access to the current one. */ 3678462Sgeoffrey.blake@arm.com void pipelineIcacheAccesses(ThreadID tid); 3688462Sgeoffrey.blake@arm.com 3698462Sgeoffrey.blake@arm.com /** Profile the reasons of fetch stall. */ 3708462Sgeoffrey.blake@arm.com void profileStall(ThreadID tid); 3718462Sgeoffrey.blake@arm.com 3722292SN/A private: 3732733Sktlim@umich.edu /** Pointer to the O3CPU. */ 3742733Sktlim@umich.edu O3CPU *cpu; 3751060SN/A 3761060SN/A /** Time buffer interface. */ 3771060SN/A TimeBuffer<TimeStruct> *timeBuffer; 3781060SN/A 3791060SN/A /** Wire to get decode's information from backwards time buffer. */ 3801060SN/A typename TimeBuffer<TimeStruct>::wire fromDecode; 3811060SN/A 3821060SN/A /** Wire to get rename's information from backwards time buffer. */ 3831060SN/A typename TimeBuffer<TimeStruct>::wire fromRename; 3841060SN/A 3851060SN/A /** Wire to get iew's information from backwards time buffer. */ 3861060SN/A typename TimeBuffer<TimeStruct>::wire fromIEW; 3871060SN/A 3881060SN/A /** Wire to get commit's information from backwards time buffer. */ 3891060SN/A typename TimeBuffer<TimeStruct>::wire fromCommit; 3901060SN/A 3911060SN/A /** Internal fetch instruction queue. */ 3921060SN/A TimeBuffer<FetchStruct> *fetchQueue; 3931060SN/A 3941060SN/A //Might be annoying how this name is different than the queue. 3951060SN/A /** Wire used to write any information heading to decode. */ 3961060SN/A typename TimeBuffer<FetchStruct>::wire toDecode; 3971060SN/A 3981061SN/A /** BPredUnit. */ 3991061SN/A BPredUnit branchPred; 4001061SN/A 4014182Sgblack@eecs.umich.edu /** Predecoder. */ 4024182Sgblack@eecs.umich.edu TheISA::Predecoder predecoder; 4034182Sgblack@eecs.umich.edu 4047720Sgblack@eecs.umich.edu TheISA::PCState pc[Impl::MaxThreads]; 4052292SN/A 4067764Sgblack@eecs.umich.edu Addr fetchOffset[Impl::MaxThreads]; 4077764Sgblack@eecs.umich.edu 4087764Sgblack@eecs.umich.edu StaticInstPtr macroop[Impl::MaxThreads]; 4097764Sgblack@eecs.umich.edu 4108314Sgeoffrey.blake@arm.com /** Can the fetch stage redirect from an interrupt on this instruction? */ 4118314Sgeoffrey.blake@arm.com bool delayedCommit[Impl::MaxThreads]; 4128314Sgeoffrey.blake@arm.com 4132678Sktlim@umich.edu /** Memory request used to access cache. */ 4142678Sktlim@umich.edu RequestPtr memReq[Impl::MaxThreads]; 4152292SN/A 4162292SN/A /** Variable that tracks if fetch has written to the time buffer this 4172292SN/A * cycle. Used to tell CPU if there is activity this cycle. 4182292SN/A */ 4192292SN/A bool wroteToTimeBuffer; 4202292SN/A 4212292SN/A /** Tracks how many instructions has been fetched this cycle. */ 4222292SN/A int numInst; 4232292SN/A 4242292SN/A /** Source of possible stalls. */ 4252292SN/A struct Stalls { 4262292SN/A bool decode; 4272292SN/A bool rename; 4282292SN/A bool iew; 4292292SN/A bool commit; 4302292SN/A }; 4312292SN/A 4322292SN/A /** Tracks which stages are telling fetch to stall. */ 4332292SN/A Stalls stalls[Impl::MaxThreads]; 4341060SN/A 4351060SN/A /** Decode to fetch delay, in ticks. */ 4361060SN/A unsigned decodeToFetchDelay; 4371060SN/A 4381060SN/A /** Rename to fetch delay, in ticks. */ 4391060SN/A unsigned renameToFetchDelay; 4401060SN/A 4411060SN/A /** IEW to fetch delay, in ticks. */ 4421060SN/A unsigned iewToFetchDelay; 4431060SN/A 4441060SN/A /** Commit to fetch delay, in ticks. */ 4451060SN/A unsigned commitToFetchDelay; 4461060SN/A 4471060SN/A /** The width of fetch in instructions. */ 4481060SN/A unsigned fetchWidth; 4491060SN/A 4502696Sktlim@umich.edu /** Is the cache blocked? If so no threads can access it. */ 4512696Sktlim@umich.edu bool cacheBlocked; 4522696Sktlim@umich.edu 4532696Sktlim@umich.edu /** The packet that is waiting to be retried. */ 4542696Sktlim@umich.edu PacketPtr retryPkt; 4552696Sktlim@umich.edu 4562696Sktlim@umich.edu /** The thread that is waiting on the cache to tell fetch to retry. */ 4576221Snate@binkert.org ThreadID retryTid; 4582696Sktlim@umich.edu 4591060SN/A /** Cache block size. */ 4601062SN/A int cacheBlkSize; 4611060SN/A 4621060SN/A /** Mask to get a cache block's address. */ 4631062SN/A Addr cacheBlkMask; 4641060SN/A 4651062SN/A /** The cache line being fetched. */ 4662292SN/A uint8_t *cacheData[Impl::MaxThreads]; 4671060SN/A 4682893Sktlim@umich.edu /** The PC of the cacheline that has been loaded. */ 4692893Sktlim@umich.edu Addr cacheDataPC[Impl::MaxThreads]; 4702893Sktlim@umich.edu 4712906Sktlim@umich.edu /** Whether or not the cache data is valid. */ 4722906Sktlim@umich.edu bool cacheDataValid[Impl::MaxThreads]; 4732906Sktlim@umich.edu 4741060SN/A /** Size of instructions. */ 4751060SN/A int instSize; 4761060SN/A 4771060SN/A /** Icache stall statistics. */ 4782292SN/A Counter lastIcacheStall[Impl::MaxThreads]; 4791062SN/A 4802292SN/A /** List of Active Threads */ 4816221Snate@binkert.org std::list<ThreadID> *activeThreads; 4822292SN/A 4832292SN/A /** Number of threads. */ 4846221Snate@binkert.org ThreadID numThreads; 4852292SN/A 4862292SN/A /** Number of threads that are actively fetching. */ 4876221Snate@binkert.org ThreadID numFetchingThreads; 4882292SN/A 4892292SN/A /** Thread ID being fetched. */ 4906221Snate@binkert.org ThreadID threadFetched; 4912292SN/A 4922348SN/A /** Checks if there is an interrupt pending. If there is, fetch 4932348SN/A * must stop once it is not fetching PAL instructions. 4942348SN/A */ 4952292SN/A bool interruptPending; 4962292SN/A 4972843Sktlim@umich.edu /** Is there a drain pending. */ 4982843Sktlim@umich.edu bool drainPending; 4992843Sktlim@umich.edu 5002348SN/A /** Records if fetch is switched out. */ 5012307SN/A bool switchedOut; 5022307SN/A 5038462Sgeoffrey.blake@arm.com /** Set to true if a pipelined I-cache request should be issued. */ 5048462Sgeoffrey.blake@arm.com bool issuePipelinedIfetch[Impl::MaxThreads]; 5058462Sgeoffrey.blake@arm.com 5068462Sgeoffrey.blake@arm.com /** Event used to delay fault generation of translation faults */ 5078462Sgeoffrey.blake@arm.com FinishTranslationEvent finishTranslationEvent; 5088462Sgeoffrey.blake@arm.com 5092292SN/A // @todo: Consider making these vectors and tracking on a per thread basis. 5102292SN/A /** Stat for total number of cycles stalled due to an icache miss. */ 5115999Snate@binkert.org Stats::Scalar icacheStallCycles; 5122292SN/A /** Stat for total number of fetched instructions. */ 5135999Snate@binkert.org Stats::Scalar fetchedInsts; 5142727Sktlim@umich.edu /** Total number of fetched branches. */ 5155999Snate@binkert.org Stats::Scalar fetchedBranches; 5162292SN/A /** Stat for total number of predicted branches. */ 5175999Snate@binkert.org Stats::Scalar predictedBranches; 5182292SN/A /** Stat for total number of cycles spent fetching. */ 5195999Snate@binkert.org Stats::Scalar fetchCycles; 5202292SN/A /** Stat for total number of cycles spent squashing. */ 5215999Snate@binkert.org Stats::Scalar fetchSquashCycles; 5227849SAli.Saidi@ARM.com /** Stat for total number of cycles spent waiting for translation */ 5237849SAli.Saidi@ARM.com Stats::Scalar fetchTlbCycles; 5242292SN/A /** Stat for total number of cycles spent blocked due to other stages in 5252292SN/A * the pipeline. 5262292SN/A */ 5275999Snate@binkert.org Stats::Scalar fetchIdleCycles; 5282348SN/A /** Total number of cycles spent blocked. */ 5295999Snate@binkert.org Stats::Scalar fetchBlockedCycles; 5302348SN/A /** Total number of cycles spent in any other state. */ 5315999Snate@binkert.org Stats::Scalar fetchMiscStallCycles; 5328462Sgeoffrey.blake@arm.com /** Total number of cycles spent in waiting for drains. */ 5338462Sgeoffrey.blake@arm.com Stats::Scalar fetchPendingDrainCycles; 5348462Sgeoffrey.blake@arm.com /** Total number of stall cycles caused by no active threads to run. */ 5358462Sgeoffrey.blake@arm.com Stats::Scalar fetchNoActiveThreadStallCycles; 5368462Sgeoffrey.blake@arm.com /** Total number of stall cycles caused by pending traps. */ 5378462Sgeoffrey.blake@arm.com Stats::Scalar fetchPendingTrapStallCycles; 5388462Sgeoffrey.blake@arm.com /** Total number of stall cycles caused by pending quiesce instructions. */ 5398462Sgeoffrey.blake@arm.com Stats::Scalar fetchPendingQuiesceStallCycles; 5408462Sgeoffrey.blake@arm.com /** Total number of stall cycles caused by I-cache wait retrys. */ 5418462Sgeoffrey.blake@arm.com Stats::Scalar fetchIcacheWaitRetryStallCycles; 5422292SN/A /** Stat for total number of fetched cache lines. */ 5435999Snate@binkert.org Stats::Scalar fetchedCacheLines; 5442348SN/A /** Total number of outstanding icache accesses that were dropped 5452348SN/A * due to a squash. 5462348SN/A */ 5475999Snate@binkert.org Stats::Scalar fetchIcacheSquashes; 5488064SAli.Saidi@ARM.com /** Total number of outstanding tlb accesses that were dropped 5498064SAli.Saidi@ARM.com * due to a squash. 5508064SAli.Saidi@ARM.com */ 5518064SAli.Saidi@ARM.com Stats::Scalar fetchTlbSquashes; 5522292SN/A /** Distribution of number of instructions fetched each cycle. */ 5535999Snate@binkert.org Stats::Distribution fetchNisnDist; 5542348SN/A /** Rate of how often fetch was idle. */ 5552292SN/A Stats::Formula idleRate; 5562348SN/A /** Number of branch fetches per cycle. */ 5572292SN/A Stats::Formula branchRate; 5582348SN/A /** Number of instruction fetched per cycle. */ 5592292SN/A Stats::Formula fetchRate; 5601060SN/A}; 5611060SN/A 5622292SN/A#endif //__CPU_O3_FETCH_HH__ 563