cpu.hh revision 13610
11689SN/A/*
213601Sgiacomo.travaglini@arm.com * Copyright (c) 2011-2013, 2016-2019 ARM Limited
39919Ssteve.reinhardt@amd.com * Copyright (c) 2013 Advanced Micro Devices, Inc.
48707Sandreas.hansson@arm.com * All rights reserved
58707Sandreas.hansson@arm.com *
68707Sandreas.hansson@arm.com * The license below extends only to copyright in the software and shall
78707Sandreas.hansson@arm.com * not be construed as granting a license to any other intellectual
88707Sandreas.hansson@arm.com * property including but not limited to intellectual property relating
98707Sandreas.hansson@arm.com * to a hardware implementation of the functionality of the software
108707Sandreas.hansson@arm.com * licensed hereunder.  You may use the software subject to the license
118707Sandreas.hansson@arm.com * terms below provided that you ensure that this notice is replicated
128707Sandreas.hansson@arm.com * unmodified and in its entirety in all distributions of the software,
138707Sandreas.hansson@arm.com * modified or unmodified, in source code or in binary form.
148707Sandreas.hansson@arm.com *
151689SN/A * Copyright (c) 2004-2005 The Regents of The University of Michigan
167897Shestness@cs.utexas.edu * Copyright (c) 2011 Regents of the University of California
171689SN/A * All rights reserved.
181689SN/A *
191689SN/A * Redistribution and use in source and binary forms, with or without
201689SN/A * modification, are permitted provided that the following conditions are
211689SN/A * met: redistributions of source code must retain the above copyright
221689SN/A * notice, this list of conditions and the following disclaimer;
231689SN/A * redistributions in binary form must reproduce the above copyright
241689SN/A * notice, this list of conditions and the following disclaimer in the
251689SN/A * documentation and/or other materials provided with the distribution;
261689SN/A * neither the name of the copyright holders nor the names of its
271689SN/A * contributors may be used to endorse or promote products derived from
281689SN/A * this software without specific prior written permission.
291689SN/A *
301689SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
311689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
321689SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
331689SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
341689SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
351689SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
361689SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
371689SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
381689SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
391689SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
401689SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
412665Ssaidi@eecs.umich.edu *
422665Ssaidi@eecs.umich.edu * Authors: Kevin Lim
432756Sksewell@umich.edu *          Korey Sewell
447897Shestness@cs.utexas.edu *          Rick Strong
451689SN/A */
461689SN/A
472325SN/A#ifndef __CPU_O3_CPU_HH__
482325SN/A#define __CPU_O3_CPU_HH__
491060SN/A
501060SN/A#include <iostream>
511060SN/A#include <list>
522292SN/A#include <queue>
532292SN/A#include <set>
541681SN/A#include <vector>
551060SN/A
5612109SRekai.GonzalezAlberquilla@arm.com#include "arch/generic/types.hh"
572980Sgblack@eecs.umich.edu#include "arch/types.hh"
581060SN/A#include "base/statistics.hh"
596658Snate@binkert.org#include "config/the_isa.hh"
601717SN/A#include "cpu/o3/comm.hh"
611717SN/A#include "cpu/o3/cpu_policy.hh"
622292SN/A#include "cpu/o3/scoreboard.hh"
632292SN/A#include "cpu/o3/thread_state.hh"
648229Snate@binkert.org#include "cpu/activity.hh"
658229Snate@binkert.org#include "cpu/base.hh"
668229Snate@binkert.org#include "cpu/simple_thread.hh"
678229Snate@binkert.org#include "cpu/timebuf.hh"
682817Sksewell@umich.edu//#include "cpu/o3/thread_context.hh"
698229Snate@binkert.org#include "params/DerivO3CPU.hh"
701060SN/A#include "sim/process.hh"
711060SN/A
722316SN/Atemplate <class>
732316SN/Aclass Checker;
742680Sktlim@umich.educlass ThreadContext;
752817Sksewell@umich.edutemplate <class>
762817Sksewell@umich.educlass O3ThreadContext;
772843Sktlim@umich.edu
782843Sktlim@umich.educlass Checkpoint;
792669Sktlim@umich.educlass MemObject;
801060SN/Aclass Process;
811060SN/A
828737Skoansin.tan@gmail.comstruct BaseCPUParams;
835529Snate@binkert.org
842733Sktlim@umich.educlass BaseO3CPU : public BaseCPU
851060SN/A{
861060SN/A    //Stuff that's pretty ISA independent will go here.
871060SN/A  public:
885529Snate@binkert.org    BaseO3CPU(BaseCPUParams *params);
892292SN/A
902292SN/A    void regStats();
911060SN/A};
921060SN/A
932348SN/A/**
942348SN/A * FullO3CPU class, has each of the stages (fetch through commit)
952348SN/A * within it, as well as all of the time buffers between stages.  The
962348SN/A * tick() function for the CPU is defined here.
972348SN/A */
981060SN/Atemplate <class Impl>
992733Sktlim@umich.educlass FullO3CPU : public BaseO3CPU
1001060SN/A{
1011060SN/A  public:
1022325SN/A    // Typedefs from the Impl here.
1031060SN/A    typedef typename Impl::CPUPol CPUPolicy;
1041061SN/A    typedef typename Impl::DynInstPtr DynInstPtr;
1054329Sktlim@umich.edu    typedef typename Impl::O3CPU O3CPU;
1061060SN/A
10712109SRekai.GonzalezAlberquilla@arm.com    using VecElem =  TheISA::VecElem;
10812109SRekai.GonzalezAlberquilla@arm.com    using VecRegContainer =  TheISA::VecRegContainer;
10912109SRekai.GonzalezAlberquilla@arm.com
11013610Sgiacomo.gabrielli@arm.com    using VecPredRegContainer = TheISA::VecPredRegContainer;
11113610Sgiacomo.gabrielli@arm.com
1125595Sgblack@eecs.umich.edu    typedef O3ThreadState<Impl> ImplState;
1132292SN/A    typedef O3ThreadState<Impl> Thread;
1142292SN/A
1152292SN/A    typedef typename std::list<DynInstPtr>::iterator ListIt;
1162292SN/A
1172817Sksewell@umich.edu    friend class O3ThreadContext<Impl>;
1182829Sksewell@umich.edu
1191060SN/A  public:
1201060SN/A    enum Status {
1211060SN/A        Running,
1221060SN/A        Idle,
1231060SN/A        Halted,
1242307SN/A        Blocked,
1252307SN/A        SwitchedOut
1261060SN/A    };
1271060SN/A
12812406Sgabeblack@google.com    BaseTLB *itb;
12912406Sgabeblack@google.com    BaseTLB *dtb;
13013590Srekai.gonzalezalberquilla@arm.com    using LSQRequest = typename LSQ<Impl>::LSQRequest;
1313781Sgblack@eecs.umich.edu
1322292SN/A    /** Overall CPU status. */
1331060SN/A    Status _status;
1341060SN/A
1351060SN/A  private:
1368707Sandreas.hansson@arm.com
1378707Sandreas.hansson@arm.com    /**
1388707Sandreas.hansson@arm.com     * IcachePort class for instruction fetch.
1398707Sandreas.hansson@arm.com     */
1409608Sandreas.hansson@arm.com    class IcachePort : public MasterPort
1418707Sandreas.hansson@arm.com    {
1428707Sandreas.hansson@arm.com      protected:
1438707Sandreas.hansson@arm.com        /** Pointer to fetch. */
1448707Sandreas.hansson@arm.com        DefaultFetch<Impl> *fetch;
1458707Sandreas.hansson@arm.com
1468707Sandreas.hansson@arm.com      public:
1478707Sandreas.hansson@arm.com        /** Default constructor. */
1488707Sandreas.hansson@arm.com        IcachePort(DefaultFetch<Impl> *_fetch, FullO3CPU<Impl>* _cpu)
1499608Sandreas.hansson@arm.com            : MasterPort(_cpu->name() + ".icache_port", _cpu), fetch(_fetch)
1508707Sandreas.hansson@arm.com        { }
1518707Sandreas.hansson@arm.com
1528707Sandreas.hansson@arm.com      protected:
1538707Sandreas.hansson@arm.com
1548707Sandreas.hansson@arm.com        /** Timing version of receive.  Handles setting fetch to the
1558707Sandreas.hansson@arm.com         * proper status to start fetching. */
1568975Sandreas.hansson@arm.com        virtual bool recvTimingResp(PacketPtr pkt);
1578707Sandreas.hansson@arm.com
1588707Sandreas.hansson@arm.com        /** Handles doing a retry of a failed fetch. */
15910713Sandreas.hansson@arm.com        virtual void recvReqRetry();
1608707Sandreas.hansson@arm.com    };
1618707Sandreas.hansson@arm.com
1628707Sandreas.hansson@arm.com    /**
1638707Sandreas.hansson@arm.com     * DcachePort class for the load/store queue.
1648707Sandreas.hansson@arm.com     */
1659608Sandreas.hansson@arm.com    class DcachePort : public MasterPort
1668707Sandreas.hansson@arm.com    {
1678707Sandreas.hansson@arm.com      protected:
1688707Sandreas.hansson@arm.com
1698707Sandreas.hansson@arm.com        /** Pointer to LSQ. */
1708707Sandreas.hansson@arm.com        LSQ<Impl> *lsq;
17110529Smorr@cs.wisc.edu        FullO3CPU<Impl> *cpu;
1728707Sandreas.hansson@arm.com
1738707Sandreas.hansson@arm.com      public:
1748707Sandreas.hansson@arm.com        /** Default constructor. */
1758707Sandreas.hansson@arm.com        DcachePort(LSQ<Impl> *_lsq, FullO3CPU<Impl>* _cpu)
17610529Smorr@cs.wisc.edu            : MasterPort(_cpu->name() + ".dcache_port", _cpu), lsq(_lsq),
17710529Smorr@cs.wisc.edu              cpu(_cpu)
1788707Sandreas.hansson@arm.com        { }
1798707Sandreas.hansson@arm.com
1808707Sandreas.hansson@arm.com      protected:
1818707Sandreas.hansson@arm.com
1828707Sandreas.hansson@arm.com        /** Timing version of receive.  Handles writing back and
1838707Sandreas.hansson@arm.com         * completing the load or store that has returned from
1848707Sandreas.hansson@arm.com         * memory. */
1858975Sandreas.hansson@arm.com        virtual bool recvTimingResp(PacketPtr pkt);
1868975Sandreas.hansson@arm.com        virtual void recvTimingSnoopReq(PacketPtr pkt);
1878707Sandreas.hansson@arm.com
1889608Sandreas.hansson@arm.com        virtual void recvFunctionalSnoop(PacketPtr pkt)
1899608Sandreas.hansson@arm.com        {
1909608Sandreas.hansson@arm.com            // @todo: Is there a need for potential invalidation here?
1919608Sandreas.hansson@arm.com        }
1929608Sandreas.hansson@arm.com
1938707Sandreas.hansson@arm.com        /** Handles doing a retry of the previous send. */
19410713Sandreas.hansson@arm.com        virtual void recvReqRetry();
1958707Sandreas.hansson@arm.com
1968707Sandreas.hansson@arm.com        /**
1978707Sandreas.hansson@arm.com         * As this CPU requires snooping to maintain the load store queue
1988707Sandreas.hansson@arm.com         * change the behaviour from the base CPU port.
1998707Sandreas.hansson@arm.com         *
2008711Sandreas.hansson@arm.com         * @return true since we have to snoop
2018707Sandreas.hansson@arm.com         */
2028922Swilliam.wang@arm.com        virtual bool isSnooping() const { return true; }
2038707Sandreas.hansson@arm.com    };
2048707Sandreas.hansson@arm.com
2052292SN/A    /** The tick event used for scheduling CPU ticks. */
20612127Sspwilson2@wisc.edu    EventFunctionWrapper tickEvent;
2071060SN/A
2082292SN/A    /** Schedule tick event, regardless of its current state. */
2099180Sandreas.hansson@arm.com    void scheduleTickEvent(Cycles delay)
2101060SN/A    {
2111060SN/A        if (tickEvent.squashed())
2129179Sandreas.hansson@arm.com            reschedule(tickEvent, clockEdge(delay));
2131060SN/A        else if (!tickEvent.scheduled())
2149179Sandreas.hansson@arm.com            schedule(tickEvent, clockEdge(delay));
2151060SN/A    }
2161060SN/A
2172292SN/A    /** Unschedule tick event, regardless of its current state. */
2181060SN/A    void unscheduleTickEvent()
2191060SN/A    {
2201060SN/A        if (tickEvent.scheduled())
2211060SN/A            tickEvent.squash();
2221060SN/A    }
2231060SN/A
2249444SAndreas.Sandberg@ARM.com    /**
22510913Sandreas.sandberg@arm.com     * Check if the pipeline has drained and signal drain done.
2269444SAndreas.Sandberg@ARM.com     *
2279444SAndreas.Sandberg@ARM.com     * This method checks if a drain has been requested and if the CPU
2289444SAndreas.Sandberg@ARM.com     * has drained successfully (i.e., there are no instructions in
2299444SAndreas.Sandberg@ARM.com     * the pipeline). If the CPU has drained, it deschedules the tick
2309444SAndreas.Sandberg@ARM.com     * event and signals the drain manager.
2319444SAndreas.Sandberg@ARM.com     *
2329444SAndreas.Sandberg@ARM.com     * @return False if a drain hasn't been requested or the CPU
2339444SAndreas.Sandberg@ARM.com     * hasn't drained, true otherwise.
2349444SAndreas.Sandberg@ARM.com     */
2359444SAndreas.Sandberg@ARM.com    bool tryDrain();
2369444SAndreas.Sandberg@ARM.com
2379444SAndreas.Sandberg@ARM.com    /**
2389444SAndreas.Sandberg@ARM.com     * Perform sanity checks after a drain.
2399444SAndreas.Sandberg@ARM.com     *
2409444SAndreas.Sandberg@ARM.com     * This method is called from drain() when it has determined that
2419444SAndreas.Sandberg@ARM.com     * the CPU is fully drained when gem5 is compiled with the NDEBUG
2429444SAndreas.Sandberg@ARM.com     * macro undefined. The intention of this method is to do more
2439444SAndreas.Sandberg@ARM.com     * extensive tests than the isDrained() method to weed out any
2449444SAndreas.Sandberg@ARM.com     * draining bugs.
2459444SAndreas.Sandberg@ARM.com     */
2469444SAndreas.Sandberg@ARM.com    void drainSanityCheck() const;
2479444SAndreas.Sandberg@ARM.com
2489444SAndreas.Sandberg@ARM.com    /** Check if a system is in a drained state. */
2499444SAndreas.Sandberg@ARM.com    bool isDrained() const;
2509444SAndreas.Sandberg@ARM.com
2511060SN/A  public:
2522292SN/A    /** Constructs a CPU with the given parameters. */
2535595Sgblack@eecs.umich.edu    FullO3CPU(DerivO3CPUParams *params);
2542292SN/A    /** Destructor. */
2551755SN/A    ~FullO3CPU();
2561060SN/A
2572292SN/A    /** Registers statistics. */
25811169Sandreas.hansson@arm.com    void regStats() override;
2591684SN/A
26010023Smatt.horsnell@ARM.com    ProbePointArg<PacketPtr> *ppInstAccessComplete;
26110023Smatt.horsnell@ARM.com    ProbePointArg<std::pair<DynInstPtr, PacketPtr> > *ppDataAccessComplete;
26210023Smatt.horsnell@ARM.com
26310023Smatt.horsnell@ARM.com    /** Register probe points. */
26411169Sandreas.hansson@arm.com    void regProbePoints() override;
26510023Smatt.horsnell@ARM.com
2665358Sgblack@eecs.umich.edu    void demapPage(Addr vaddr, uint64_t asn)
2675358Sgblack@eecs.umich.edu    {
2685358Sgblack@eecs.umich.edu        this->itb->demapPage(vaddr, asn);
2695358Sgblack@eecs.umich.edu        this->dtb->demapPage(vaddr, asn);
2705358Sgblack@eecs.umich.edu    }
2715358Sgblack@eecs.umich.edu
2725358Sgblack@eecs.umich.edu    void demapInstPage(Addr vaddr, uint64_t asn)
2735358Sgblack@eecs.umich.edu    {
2745358Sgblack@eecs.umich.edu        this->itb->demapPage(vaddr, asn);
2755358Sgblack@eecs.umich.edu    }
2765358Sgblack@eecs.umich.edu
2775358Sgblack@eecs.umich.edu    void demapDataPage(Addr vaddr, uint64_t asn)
2785358Sgblack@eecs.umich.edu    {
2795358Sgblack@eecs.umich.edu        this->dtb->demapPage(vaddr, asn);
2805358Sgblack@eecs.umich.edu    }
2815358Sgblack@eecs.umich.edu
2822292SN/A    /** Ticks CPU, calling tick() on each stage, and checking the overall
2832292SN/A     *  activity to see if the CPU should deschedule itself.
2842292SN/A     */
2851684SN/A    void tick();
2861684SN/A
2872292SN/A    /** Initialize the CPU */
28811169Sandreas.hansson@arm.com    void init() override;
2891060SN/A
29011169Sandreas.hansson@arm.com    void startup() override;
2919427SAndreas.Sandberg@ARM.com
2922834Sksewell@umich.edu    /** Returns the Number of Active Threads in the CPU */
2932834Sksewell@umich.edu    int numActiveThreads()
2942834Sksewell@umich.edu    { return activeThreads.size(); }
2952834Sksewell@umich.edu
2962829Sksewell@umich.edu    /** Add Thread to Active Threads List */
2976221Snate@binkert.org    void activateThread(ThreadID tid);
2982875Sksewell@umich.edu
2992875Sksewell@umich.edu    /** Remove Thread from Active Threads List */
3006221Snate@binkert.org    void deactivateThread(ThreadID tid);
3012829Sksewell@umich.edu
3022292SN/A    /** Setup CPU to insert a thread's context */
3036221Snate@binkert.org    void insertThread(ThreadID tid);
3041060SN/A
3052292SN/A    /** Remove all of a thread's context from CPU */
3066221Snate@binkert.org    void removeThread(ThreadID tid);
3072292SN/A
3082292SN/A    /** Count the Total Instructions Committed in the CPU. */
30911169Sandreas.hansson@arm.com    Counter totalInsts() const override;
3108834Satgutier@umich.edu
3118834Satgutier@umich.edu    /** Count the Total Ops (including micro ops) committed in the CPU. */
31211169Sandreas.hansson@arm.com    Counter totalOps() const override;
3132292SN/A
3142292SN/A    /** Add Thread to Active Threads List. */
31511169Sandreas.hansson@arm.com    void activateContext(ThreadID tid) override;
3162292SN/A
3172292SN/A    /** Remove Thread from Active Threads List */
31811169Sandreas.hansson@arm.com    void suspendContext(ThreadID tid) override;
3192292SN/A
3202292SN/A    /** Remove Thread from Active Threads List &&
3212292SN/A     *  Remove Thread Context from CPU.
3222292SN/A     */
32311169Sandreas.hansson@arm.com    void haltContext(ThreadID tid) override;
3242292SN/A
3252292SN/A    /** Update The Order In Which We Process Threads. */
3262292SN/A    void updateThreadPriority();
3272292SN/A
3289444SAndreas.Sandberg@ARM.com    /** Is the CPU draining? */
32910913Sandreas.sandberg@arm.com    bool isDraining() const { return drainState() == DrainState::Draining; }
3309444SAndreas.Sandberg@ARM.com
33111168Sandreas.hansson@arm.com    void serializeThread(CheckpointOut &cp, ThreadID tid) const override;
33211168Sandreas.hansson@arm.com    void unserializeThread(CheckpointIn &cp, ThreadID tid) override;
3332864Sktlim@umich.edu
3342864Sktlim@umich.edu  public:
3355595Sgblack@eecs.umich.edu    /** Executes a syscall.
3365595Sgblack@eecs.umich.edu     * @todo: Determine if this needs to be virtual.
3372292SN/A     */
33811877Sbrandon.potter@amd.com    void syscall(int64_t callnum, ThreadID tid, Fault *fault);
3392292SN/A
3402843Sktlim@umich.edu    /** Starts draining the CPU's pipeline of all instructions in
3412843Sktlim@umich.edu     * order to stop all memory accesses. */
34211168Sandreas.hansson@arm.com    DrainState drain() override;
3432843Sktlim@umich.edu
3442843Sktlim@umich.edu    /** Resumes execution after a drain. */
34511168Sandreas.hansson@arm.com    void drainResume() override;
3462292SN/A
3479444SAndreas.Sandberg@ARM.com    /**
3489444SAndreas.Sandberg@ARM.com     * Commit has reached a safe point to drain a thread.
3499444SAndreas.Sandberg@ARM.com     *
3509444SAndreas.Sandberg@ARM.com     * Commit calls this method to inform the pipeline that it has
3519444SAndreas.Sandberg@ARM.com     * reached a point where it is not executed microcode and is about
3529444SAndreas.Sandberg@ARM.com     * to squash uncommitted instructions to fully drain the pipeline.
3539444SAndreas.Sandberg@ARM.com     */
3549444SAndreas.Sandberg@ARM.com    void commitDrained(ThreadID tid);
3552843Sktlim@umich.edu
3562843Sktlim@umich.edu    /** Switches out this CPU. */
35711169Sandreas.hansson@arm.com    void switchOut() override;
3582316SN/A
3592348SN/A    /** Takes over from another CPU. */
36011169Sandreas.hansson@arm.com    void takeOverFrom(BaseCPU *oldCPU) override;
3611060SN/A
36211169Sandreas.hansson@arm.com    void verifyMemoryMode() const override;
3639523SAndreas.Sandberg@ARM.com
3641060SN/A    /** Get the current instruction sequence number, and increment it. */
3652316SN/A    InstSeqNum getAndIncrementInstSeq()
3662316SN/A    { return globalSeqNum++; }
3671060SN/A
3685595Sgblack@eecs.umich.edu    /** Traps to handle given fault. */
36910417Sandreas.hansson@arm.com    void trap(const Fault &fault, ThreadID tid, const StaticInstPtr &inst);
3705595Sgblack@eecs.umich.edu
3715702Ssaidi@eecs.umich.edu    /** HW return from error interrupt. */
3726221Snate@binkert.org    Fault hwrei(ThreadID tid);
3735702Ssaidi@eecs.umich.edu
3746221Snate@binkert.org    bool simPalCheck(int palFunc, ThreadID tid);
3755702Ssaidi@eecs.umich.edu
37613601Sgiacomo.travaglini@arm.com    /** Check if a change in renaming is needed for vector registers.
37713601Sgiacomo.travaglini@arm.com     * The vecMode variable is updated and propagated to rename maps.
37813601Sgiacomo.travaglini@arm.com     *
37913601Sgiacomo.travaglini@arm.com     * @param tid ThreadID
38013601Sgiacomo.travaglini@arm.com     * @param freelist list of free registers
38113601Sgiacomo.travaglini@arm.com     */
38213601Sgiacomo.travaglini@arm.com    void switchRenameMode(ThreadID tid, UnifiedFreeList* freelist);
38313601Sgiacomo.travaglini@arm.com
3845595Sgblack@eecs.umich.edu    /** Returns the Fault for any valid interrupt. */
3855595Sgblack@eecs.umich.edu    Fault getInterrupts();
3865595Sgblack@eecs.umich.edu
3875595Sgblack@eecs.umich.edu    /** Processes any an interrupt fault. */
38810379Sandreas.hansson@arm.com    void processInterrupts(const Fault &interrupt);
3895595Sgblack@eecs.umich.edu
3905595Sgblack@eecs.umich.edu    /** Halts the CPU. */
3915595Sgblack@eecs.umich.edu    void halt() { panic("Halt not implemented!\n"); }
3925595Sgblack@eecs.umich.edu
3932348SN/A    /** Register accessors.  Index refers to the physical register index. */
3945595Sgblack@eecs.umich.edu
3955595Sgblack@eecs.umich.edu    /** Reads a miscellaneous register. */
39613557Sgabeblack@google.com    RegVal readMiscRegNoEffect(int misc_reg, ThreadID tid) const;
3975595Sgblack@eecs.umich.edu
3985595Sgblack@eecs.umich.edu    /** Reads a misc. register, including any side effects the read
3995595Sgblack@eecs.umich.edu     * might have as defined by the architecture.
4005595Sgblack@eecs.umich.edu     */
40113557Sgabeblack@google.com    RegVal readMiscReg(int misc_reg, ThreadID tid);
4025595Sgblack@eecs.umich.edu
4035595Sgblack@eecs.umich.edu    /** Sets a miscellaneous register. */
40413582Sgabeblack@google.com    void setMiscRegNoEffect(int misc_reg, RegVal val, ThreadID tid);
4055595Sgblack@eecs.umich.edu
4065595Sgblack@eecs.umich.edu    /** Sets a misc. register, including any side effects the write
4075595Sgblack@eecs.umich.edu     * might have as defined by the architecture.
4085595Sgblack@eecs.umich.edu     */
40913582Sgabeblack@google.com    void setMiscReg(int misc_reg, RegVal val, ThreadID tid);
4105595Sgblack@eecs.umich.edu
41113557Sgabeblack@google.com    RegVal readIntReg(PhysRegIdPtr phys_reg);
4121060SN/A
41313557Sgabeblack@google.com    RegVal readFloatRegBits(PhysRegIdPtr phys_reg);
4142455SN/A
41512109SRekai.GonzalezAlberquilla@arm.com    const VecRegContainer& readVecReg(PhysRegIdPtr reg_idx) const;
41612109SRekai.GonzalezAlberquilla@arm.com
41712109SRekai.GonzalezAlberquilla@arm.com    /**
41812109SRekai.GonzalezAlberquilla@arm.com     * Read physical vector register for modification.
41912109SRekai.GonzalezAlberquilla@arm.com     */
42012109SRekai.GonzalezAlberquilla@arm.com    VecRegContainer& getWritableVecReg(PhysRegIdPtr reg_idx);
42112109SRekai.GonzalezAlberquilla@arm.com
42213601Sgiacomo.travaglini@arm.com    /** Returns current vector renaming mode */
42313601Sgiacomo.travaglini@arm.com    Enums::VecRegRenameMode vecRenameMode() const { return vecMode; }
42413601Sgiacomo.travaglini@arm.com
42513601Sgiacomo.travaglini@arm.com    /** Sets the current vector renaming mode */
42613601Sgiacomo.travaglini@arm.com    void vecRenameMode(Enums::VecRegRenameMode vec_mode)
42713601Sgiacomo.travaglini@arm.com    { vecMode = vec_mode; }
42813601Sgiacomo.travaglini@arm.com
42912109SRekai.GonzalezAlberquilla@arm.com    /**
43012109SRekai.GonzalezAlberquilla@arm.com     * Read physical vector register lane
43112109SRekai.GonzalezAlberquilla@arm.com     */
43212109SRekai.GonzalezAlberquilla@arm.com    template<typename VecElem, int LaneIdx>
43312109SRekai.GonzalezAlberquilla@arm.com    VecLaneT<VecElem, true>
43412109SRekai.GonzalezAlberquilla@arm.com    readVecLane(PhysRegIdPtr phys_reg) const
43512109SRekai.GonzalezAlberquilla@arm.com    {
43612109SRekai.GonzalezAlberquilla@arm.com        vecRegfileReads++;
43712109SRekai.GonzalezAlberquilla@arm.com        return regFile.readVecLane<VecElem, LaneIdx>(phys_reg);
43812109SRekai.GonzalezAlberquilla@arm.com    }
43912109SRekai.GonzalezAlberquilla@arm.com
44012109SRekai.GonzalezAlberquilla@arm.com    /**
44112109SRekai.GonzalezAlberquilla@arm.com     * Read physical vector register lane
44212109SRekai.GonzalezAlberquilla@arm.com     */
44312109SRekai.GonzalezAlberquilla@arm.com    template<typename VecElem>
44412109SRekai.GonzalezAlberquilla@arm.com    VecLaneT<VecElem, true>
44512109SRekai.GonzalezAlberquilla@arm.com    readVecLane(PhysRegIdPtr phys_reg) const
44612109SRekai.GonzalezAlberquilla@arm.com    {
44712109SRekai.GonzalezAlberquilla@arm.com        vecRegfileReads++;
44812109SRekai.GonzalezAlberquilla@arm.com        return regFile.readVecLane<VecElem>(phys_reg);
44912109SRekai.GonzalezAlberquilla@arm.com    }
45012109SRekai.GonzalezAlberquilla@arm.com
45112109SRekai.GonzalezAlberquilla@arm.com    /** Write a lane of the destination vector register. */
45212109SRekai.GonzalezAlberquilla@arm.com    template<typename LD>
45312109SRekai.GonzalezAlberquilla@arm.com    void
45412109SRekai.GonzalezAlberquilla@arm.com    setVecLane(PhysRegIdPtr phys_reg, const LD& val)
45512109SRekai.GonzalezAlberquilla@arm.com    {
45612109SRekai.GonzalezAlberquilla@arm.com        vecRegfileWrites++;
45712109SRekai.GonzalezAlberquilla@arm.com        return regFile.setVecLane(phys_reg, val);
45812109SRekai.GonzalezAlberquilla@arm.com    }
45912109SRekai.GonzalezAlberquilla@arm.com
46012109SRekai.GonzalezAlberquilla@arm.com    const VecElem& readVecElem(PhysRegIdPtr reg_idx) const;
46112109SRekai.GonzalezAlberquilla@arm.com
46213610Sgiacomo.gabrielli@arm.com    const VecPredRegContainer& readVecPredReg(PhysRegIdPtr reg_idx) const;
46313610Sgiacomo.gabrielli@arm.com
46413610Sgiacomo.gabrielli@arm.com    VecPredRegContainer& getWritableVecPredReg(PhysRegIdPtr reg_idx);
46513610Sgiacomo.gabrielli@arm.com
46612105Snathanael.premillieu@arm.com    TheISA::CCReg readCCReg(PhysRegIdPtr phys_reg);
4679920Syasuko.eckert@amd.com
46813557Sgabeblack@google.com    void setIntReg(PhysRegIdPtr phys_reg, RegVal val);
4691060SN/A
47013557Sgabeblack@google.com    void setFloatRegBits(PhysRegIdPtr phys_reg, RegVal val);
4712455SN/A
47212109SRekai.GonzalezAlberquilla@arm.com    void setVecReg(PhysRegIdPtr reg_idx, const VecRegContainer& val);
47312109SRekai.GonzalezAlberquilla@arm.com
47412109SRekai.GonzalezAlberquilla@arm.com    void setVecElem(PhysRegIdPtr reg_idx, const VecElem& val);
47512109SRekai.GonzalezAlberquilla@arm.com
47613610Sgiacomo.gabrielli@arm.com    void setVecPredReg(PhysRegIdPtr reg_idx, const VecPredRegContainer& val);
47713610Sgiacomo.gabrielli@arm.com
47812105Snathanael.premillieu@arm.com    void setCCReg(PhysRegIdPtr phys_reg, TheISA::CCReg val);
4799920Syasuko.eckert@amd.com
48013557Sgabeblack@google.com    RegVal readArchIntReg(int reg_idx, ThreadID tid);
4811060SN/A
48213557Sgabeblack@google.com    RegVal readArchFloatRegBits(int reg_idx, ThreadID tid);
4832292SN/A
48412109SRekai.GonzalezAlberquilla@arm.com    const VecRegContainer& readArchVecReg(int reg_idx, ThreadID tid) const;
48512109SRekai.GonzalezAlberquilla@arm.com    /** Read architectural vector register for modification. */
48612109SRekai.GonzalezAlberquilla@arm.com    VecRegContainer& getWritableArchVecReg(int reg_idx, ThreadID tid);
48712109SRekai.GonzalezAlberquilla@arm.com
48812109SRekai.GonzalezAlberquilla@arm.com    /** Read architectural vector register lane. */
48912109SRekai.GonzalezAlberquilla@arm.com    template<typename VecElem>
49012109SRekai.GonzalezAlberquilla@arm.com    VecLaneT<VecElem, true>
49112109SRekai.GonzalezAlberquilla@arm.com    readArchVecLane(int reg_idx, int lId, ThreadID tid) const
49212109SRekai.GonzalezAlberquilla@arm.com    {
49312109SRekai.GonzalezAlberquilla@arm.com        PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup(
49412109SRekai.GonzalezAlberquilla@arm.com                    RegId(VecRegClass, reg_idx));
49512109SRekai.GonzalezAlberquilla@arm.com        return readVecLane<VecElem>(phys_reg);
49612109SRekai.GonzalezAlberquilla@arm.com    }
49712109SRekai.GonzalezAlberquilla@arm.com
49812109SRekai.GonzalezAlberquilla@arm.com
49912109SRekai.GonzalezAlberquilla@arm.com    /** Write a lane of the destination vector register. */
50012109SRekai.GonzalezAlberquilla@arm.com    template<typename LD>
50112109SRekai.GonzalezAlberquilla@arm.com    void
50212109SRekai.GonzalezAlberquilla@arm.com    setArchVecLane(int reg_idx, int lId, ThreadID tid, const LD& val)
50312109SRekai.GonzalezAlberquilla@arm.com    {
50412109SRekai.GonzalezAlberquilla@arm.com        PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup(
50512109SRekai.GonzalezAlberquilla@arm.com                    RegId(VecRegClass, reg_idx));
50612109SRekai.GonzalezAlberquilla@arm.com        setVecLane(phys_reg, val);
50712109SRekai.GonzalezAlberquilla@arm.com    }
50812109SRekai.GonzalezAlberquilla@arm.com
50912109SRekai.GonzalezAlberquilla@arm.com    const VecElem& readArchVecElem(const RegIndex& reg_idx,
51012109SRekai.GonzalezAlberquilla@arm.com                                   const ElemIndex& ldx, ThreadID tid) const;
51112109SRekai.GonzalezAlberquilla@arm.com
51213610Sgiacomo.gabrielli@arm.com    const VecPredRegContainer& readArchVecPredReg(int reg_idx,
51313610Sgiacomo.gabrielli@arm.com                                                  ThreadID tid) const;
51413610Sgiacomo.gabrielli@arm.com
51513610Sgiacomo.gabrielli@arm.com    VecPredRegContainer& getWritableArchVecPredReg(int reg_idx, ThreadID tid);
51613610Sgiacomo.gabrielli@arm.com
5179920Syasuko.eckert@amd.com    TheISA::CCReg readArchCCReg(int reg_idx, ThreadID tid);
5189920Syasuko.eckert@amd.com
5192348SN/A    /** Architectural register accessors.  Looks up in the commit
5202348SN/A     * rename table to obtain the true physical index of the
5212348SN/A     * architected register first, then accesses that physical
5222348SN/A     * register.
5232348SN/A     */
52413557Sgabeblack@google.com    void setArchIntReg(int reg_idx, RegVal val, ThreadID tid);
5252292SN/A
52613557Sgabeblack@google.com    void setArchFloatRegBits(int reg_idx, RegVal val, ThreadID tid);
5272292SN/A
52813610Sgiacomo.gabrielli@arm.com    void setArchVecPredReg(int reg_idx, const VecPredRegContainer& val,
52913610Sgiacomo.gabrielli@arm.com                           ThreadID tid);
53013610Sgiacomo.gabrielli@arm.com
53112109SRekai.GonzalezAlberquilla@arm.com    void setArchVecReg(int reg_idx, const VecRegContainer& val, ThreadID tid);
53212109SRekai.GonzalezAlberquilla@arm.com
53312109SRekai.GonzalezAlberquilla@arm.com    void setArchVecElem(const RegIndex& reg_idx, const ElemIndex& ldx,
53412109SRekai.GonzalezAlberquilla@arm.com                        const VecElem& val, ThreadID tid);
53512109SRekai.GonzalezAlberquilla@arm.com
5369920Syasuko.eckert@amd.com    void setArchCCReg(int reg_idx, TheISA::CCReg val, ThreadID tid);
5379920Syasuko.eckert@amd.com
5387720Sgblack@eecs.umich.edu    /** Sets the commit PC state of a specific thread. */
5397720Sgblack@eecs.umich.edu    void pcState(const TheISA::PCState &newPCState, ThreadID tid);
5407720Sgblack@eecs.umich.edu
5417720Sgblack@eecs.umich.edu    /** Reads the commit PC state of a specific thread. */
5427720Sgblack@eecs.umich.edu    TheISA::PCState pcState(ThreadID tid);
5437720Sgblack@eecs.umich.edu
5442348SN/A    /** Reads the commit PC of a specific thread. */
5457720Sgblack@eecs.umich.edu    Addr instAddr(ThreadID tid);
5462292SN/A
5474636Sgblack@eecs.umich.edu    /** Reads the commit micro PC of a specific thread. */
5487720Sgblack@eecs.umich.edu    MicroPC microPC(ThreadID tid);
5494636Sgblack@eecs.umich.edu
5502348SN/A    /** Reads the next PC of a specific thread. */
5517720Sgblack@eecs.umich.edu    Addr nextInstAddr(ThreadID tid);
5522756Sksewell@umich.edu
5535595Sgblack@eecs.umich.edu    /** Initiates a squash of all in-flight instructions for a given
5545595Sgblack@eecs.umich.edu     * thread.  The source of the squash is an external update of
5555595Sgblack@eecs.umich.edu     * state through the TC.
5565595Sgblack@eecs.umich.edu     */
5576221Snate@binkert.org    void squashFromTC(ThreadID tid);
5585595Sgblack@eecs.umich.edu
5591060SN/A    /** Function to add instruction onto the head of the list of the
5601060SN/A     *  instructions.  Used when new instructions are fetched.
5611060SN/A     */
56213429Srekai.gonzalezalberquilla@arm.com    ListIt addInst(const DynInstPtr &inst);
5631060SN/A
5641060SN/A    /** Function to tell the CPU that an instruction has completed. */
56513429Srekai.gonzalezalberquilla@arm.com    void instDone(ThreadID tid, const DynInstPtr &inst);
5661060SN/A
5672325SN/A    /** Remove an instruction from the front end of the list.  There's
5682325SN/A     *  no restriction on location of the instruction.
5691060SN/A     */
57013429Srekai.gonzalezalberquilla@arm.com    void removeFrontInst(const DynInstPtr &inst);
5711060SN/A
5722935Sksewell@umich.edu    /** Remove all instructions that are not currently in the ROB.
5732935Sksewell@umich.edu     *  There's also an option to not squash delay slot instructions.*/
5746221Snate@binkert.org    void removeInstsNotInROB(ThreadID tid);
5751060SN/A
5761062SN/A    /** Remove all instructions younger than the given sequence number. */
5776221Snate@binkert.org    void removeInstsUntil(const InstSeqNum &seq_num, ThreadID tid);
5782292SN/A
5792348SN/A    /** Removes the instruction pointed to by the iterator. */
5806221Snate@binkert.org    inline void squashInstIt(const ListIt &instIt, ThreadID tid);
5812292SN/A
5822348SN/A    /** Cleans up all instructions on the remove list. */
5832292SN/A    void cleanUpRemovedInsts();
5841062SN/A
5852348SN/A    /** Debug function to print all instructions on the list. */
5861060SN/A    void dumpInsts();
5871060SN/A
5881060SN/A  public:
5895737Scws3k@cs.virginia.edu#ifndef NDEBUG
5905737Scws3k@cs.virginia.edu    /** Count of total number of dynamic instructions in flight. */
5915737Scws3k@cs.virginia.edu    int instcount;
5925737Scws3k@cs.virginia.edu#endif
5935737Scws3k@cs.virginia.edu
5941060SN/A    /** List of all the instructions in flight. */
5952292SN/A    std::list<DynInstPtr> instList;
5961060SN/A
5972292SN/A    /** List of all the instructions that will be removed at the end of this
5982292SN/A     *  cycle.
5992292SN/A     */
6002292SN/A    std::queue<ListIt> removeList;
6012292SN/A
6022325SN/A#ifdef DEBUG
6032348SN/A    /** Debug structure to keep track of the sequence numbers still in
6042348SN/A     * flight.
6052348SN/A     */
6062292SN/A    std::set<InstSeqNum> snList;
6072325SN/A#endif
6082292SN/A
6092325SN/A    /** Records if instructions need to be removed this cycle due to
6102325SN/A     *  being retired or squashed.
6112292SN/A     */
6122292SN/A    bool removeInstsThisCycle;
6132292SN/A
6141060SN/A  protected:
6151060SN/A    /** The fetch stage. */
6161060SN/A    typename CPUPolicy::Fetch fetch;
6171060SN/A
6181060SN/A    /** The decode stage. */
6191060SN/A    typename CPUPolicy::Decode decode;
6201060SN/A
6211060SN/A    /** The dispatch stage. */
6221060SN/A    typename CPUPolicy::Rename rename;
6231060SN/A
6241060SN/A    /** The issue/execute/writeback stages. */
6251060SN/A    typename CPUPolicy::IEW iew;
6261060SN/A
6271060SN/A    /** The commit stage. */
6281060SN/A    typename CPUPolicy::Commit commit;
6291060SN/A
63012109SRekai.GonzalezAlberquilla@arm.com    /** The rename mode of the vector registers */
63112109SRekai.GonzalezAlberquilla@arm.com    Enums::VecRegRenameMode vecMode;
63212109SRekai.GonzalezAlberquilla@arm.com
6331060SN/A    /** The register file. */
6349919Ssteve.reinhardt@amd.com    PhysRegFile regFile;
6351060SN/A
6361060SN/A    /** The free list. */
6371060SN/A    typename CPUPolicy::FreeList freeList;
6381060SN/A
6391060SN/A    /** The rename map. */
6402292SN/A    typename CPUPolicy::RenameMap renameMap[Impl::MaxThreads];
6412292SN/A
6422292SN/A    /** The commit rename map. */
6432292SN/A    typename CPUPolicy::RenameMap commitRenameMap[Impl::MaxThreads];
6441060SN/A
6451060SN/A    /** The re-order buffer. */
6461060SN/A    typename CPUPolicy::ROB rob;
6471060SN/A
6482292SN/A    /** Active Threads List */
6496221Snate@binkert.org    std::list<ThreadID> activeThreads;
6502292SN/A
6512292SN/A    /** Integer Register Scoreboard */
6522292SN/A    Scoreboard scoreboard;
6532292SN/A
6549384SAndreas.Sandberg@arm.com    std::vector<TheISA::ISA *> isa;
6556313Sgblack@eecs.umich.edu
6568707Sandreas.hansson@arm.com    /** Instruction port. Note that it has to appear after the fetch stage. */
6578707Sandreas.hansson@arm.com    IcachePort icachePort;
6588707Sandreas.hansson@arm.com
6598707Sandreas.hansson@arm.com    /** Data port. Note that it has to appear after the iew stages */
6608707Sandreas.hansson@arm.com    DcachePort dcachePort;
6618707Sandreas.hansson@arm.com
6621060SN/A  public:
6632292SN/A    /** Enum to give each stage a specific index, so when calling
6642292SN/A     *  activateStage() or deactivateStage(), they can specify which stage
6652292SN/A     *  is being activated/deactivated.
6662292SN/A     */
6672292SN/A    enum StageIdx {
6682292SN/A        FetchIdx,
6692292SN/A        DecodeIdx,
6702292SN/A        RenameIdx,
6712292SN/A        IEWIdx,
6722292SN/A        CommitIdx,
6732292SN/A        NumStages };
6742292SN/A
6751060SN/A    /** Typedefs from the Impl to get the structs that each of the
6761060SN/A     *  time buffers should use.
6771060SN/A     */
6781061SN/A    typedef typename CPUPolicy::TimeStruct TimeStruct;
6791060SN/A
6801061SN/A    typedef typename CPUPolicy::FetchStruct FetchStruct;
6811060SN/A
6821061SN/A    typedef typename CPUPolicy::DecodeStruct DecodeStruct;
6831060SN/A
6841061SN/A    typedef typename CPUPolicy::RenameStruct RenameStruct;
6851060SN/A
6861061SN/A    typedef typename CPUPolicy::IEWStruct IEWStruct;
6871060SN/A
6881060SN/A    /** The main time buffer to do backwards communication. */
6891060SN/A    TimeBuffer<TimeStruct> timeBuffer;
6901060SN/A
6911060SN/A    /** The fetch stage's instruction queue. */
6921060SN/A    TimeBuffer<FetchStruct> fetchQueue;
6931060SN/A
6941060SN/A    /** The decode stage's instruction queue. */
6951060SN/A    TimeBuffer<DecodeStruct> decodeQueue;
6961060SN/A
6971060SN/A    /** The rename stage's instruction queue. */
6981060SN/A    TimeBuffer<RenameStruct> renameQueue;
6991060SN/A
7001060SN/A    /** The IEW stage's instruction queue. */
7011060SN/A    TimeBuffer<IEWStruct> iewQueue;
7021060SN/A
7032348SN/A  private:
7042348SN/A    /** The activity recorder; used to tell if the CPU has any
7052348SN/A     * activity remaining or if it can go to idle and deschedule
7062348SN/A     * itself.
7072348SN/A     */
7082325SN/A    ActivityRecorder activityRec;
7091060SN/A
7102348SN/A  public:
7112348SN/A    /** Records that there was time buffer activity this cycle. */
7122325SN/A    void activityThisCycle() { activityRec.activity(); }
7132292SN/A
7142348SN/A    /** Changes a stage's status to active within the activity recorder. */
7152325SN/A    void activateStage(const StageIdx idx)
7162325SN/A    { activityRec.activateStage(idx); }
7172292SN/A
7182348SN/A    /** Changes a stage's status to inactive within the activity recorder. */
7192325SN/A    void deactivateStage(const StageIdx idx)
7202325SN/A    { activityRec.deactivateStage(idx); }
7212292SN/A
7222292SN/A    /** Wakes the CPU, rescheduling the CPU if it's not already active. */
7232292SN/A    void wakeCPU();
7242260SN/A
72511168Sandreas.hansson@arm.com    virtual void wakeup(ThreadID tid) override;
7265807Snate@binkert.org
7272292SN/A    /** Gets a free thread id. Use if thread ids change across system. */
7286221Snate@binkert.org    ThreadID getFreeTid();
7292292SN/A
7302292SN/A  public:
7312680Sktlim@umich.edu    /** Returns a pointer to a thread context. */
7326221Snate@binkert.org    ThreadContext *
7336221Snate@binkert.org    tcBase(ThreadID tid)
7341681SN/A    {
7352680Sktlim@umich.edu        return thread[tid]->getTC();
7362190SN/A    }
7372190SN/A
7382292SN/A    /** The global sequence number counter. */
7393093Sksewell@umich.edu    InstSeqNum globalSeqNum;//[Impl::MaxThreads];
7401060SN/A
7412348SN/A    /** Pointer to the checker, which can dynamically verify
7422348SN/A     * instruction results at run time.  This can be set to NULL if it
7432348SN/A     * is not being used.
7442348SN/A     */
7458733Sgeoffrey.blake@arm.com    Checker<Impl> *checker;
7462316SN/A
7472292SN/A    /** Pointer to the system. */
7481060SN/A    System *system;
7491060SN/A
7502348SN/A    /** Pointers to all of the threads in the CPU. */
7512292SN/A    std::vector<Thread *> thread;
7522260SN/A
7532292SN/A    /** Threads Scheduled to Enter CPU */
7542292SN/A    std::list<int> cpuWaitList;
7552292SN/A
7562292SN/A    /** The cycle that the CPU was last running, used for statistics. */
7579180Sandreas.hansson@arm.com    Cycles lastRunningCycle;
7582292SN/A
7592829Sksewell@umich.edu    /** The cycle that the CPU was last activated by a new thread*/
7602829Sksewell@umich.edu    Tick lastActivatedCycle;
7612829Sksewell@umich.edu
7622292SN/A    /** Mapping for system thread id to cpu id */
7636221Snate@binkert.org    std::map<ThreadID, unsigned> threadMap;
7642292SN/A
7652292SN/A    /** Available thread ids in the cpu*/
7666221Snate@binkert.org    std::vector<ThreadID> tids;
7672292SN/A
76813590Srekai.gonzalezalberquilla@arm.com    /** CPU pushRequest function, forwards request to LSQ. */
76913590Srekai.gonzalezalberquilla@arm.com    Fault pushRequest(const DynInstPtr& inst, bool isLoad, uint8_t *data,
77013590Srekai.gonzalezalberquilla@arm.com                      unsigned int size, Addr addr, Request::Flags flags,
77113590Srekai.gonzalezalberquilla@arm.com                      uint64_t *res)
77213590Srekai.gonzalezalberquilla@arm.com    {
77313590Srekai.gonzalezalberquilla@arm.com        return iew.ldstQueue.pushRequest(inst, isLoad, data, size, addr,
77413590Srekai.gonzalezalberquilla@arm.com                flags, res);
77513590Srekai.gonzalezalberquilla@arm.com    }
77613590Srekai.gonzalezalberquilla@arm.com
7775595Sgblack@eecs.umich.edu    /** CPU read function, forwards read to LSQ. */
77813590Srekai.gonzalezalberquilla@arm.com    Fault read(LSQRequest* req, int load_idx)
7795595Sgblack@eecs.umich.edu    {
78013590Srekai.gonzalezalberquilla@arm.com        return this->iew.ldstQueue.read(req, load_idx);
7815595Sgblack@eecs.umich.edu    }
7825595Sgblack@eecs.umich.edu
7835595Sgblack@eecs.umich.edu    /** CPU write function, forwards write to LSQ. */
78413590Srekai.gonzalezalberquilla@arm.com    Fault write(LSQRequest* req, uint8_t *data, int store_idx)
7855595Sgblack@eecs.umich.edu    {
78613590Srekai.gonzalezalberquilla@arm.com        return this->iew.ldstQueue.write(req, data, store_idx);
7875595Sgblack@eecs.umich.edu    }
7885595Sgblack@eecs.umich.edu
7898707Sandreas.hansson@arm.com    /** Used by the fetch unit to get a hold of the instruction port. */
79011169Sandreas.hansson@arm.com    MasterPort &getInstPort() override { return icachePort; }
7918707Sandreas.hansson@arm.com
7926974Stjones1@inf.ed.ac.uk    /** Get the dcache port (used to find block size for translations). */
79311169Sandreas.hansson@arm.com    MasterPort &getDataPort() override { return dcachePort; }
7946974Stjones1@inf.ed.ac.uk
7952292SN/A    /** Stat for total number of times the CPU is descheduled. */
7965999Snate@binkert.org    Stats::Scalar timesIdled;
7972292SN/A    /** Stat for total number of cycles the CPU spends descheduled. */
7985999Snate@binkert.org    Stats::Scalar idleCycles;
7998627SAli.Saidi@ARM.com    /** Stat for total number of cycles the CPU spends descheduled due to a
8008627SAli.Saidi@ARM.com     * quiesce operation or waiting for an interrupt. */
8018627SAli.Saidi@ARM.com    Stats::Scalar quiesceCycles;
8022292SN/A    /** Stat for the number of committed instructions per thread. */
8035999Snate@binkert.org    Stats::Vector committedInsts;
8048834Satgutier@umich.edu    /** Stat for the number of committed ops (including micro ops) per thread. */
8058834Satgutier@umich.edu    Stats::Vector committedOps;
8062292SN/A    /** Stat for the CPI per thread. */
8072292SN/A    Stats::Formula cpi;
8082292SN/A    /** Stat for the total CPI. */
8092292SN/A    Stats::Formula totalCpi;
8102292SN/A    /** Stat for the IPC per thread. */
8112292SN/A    Stats::Formula ipc;
8122292SN/A    /** Stat for the total IPC. */
8132292SN/A    Stats::Formula totalIpc;
8147897Shestness@cs.utexas.edu
8157897Shestness@cs.utexas.edu    //number of integer register file accesses
8167897Shestness@cs.utexas.edu    Stats::Scalar intRegfileReads;
8177897Shestness@cs.utexas.edu    Stats::Scalar intRegfileWrites;
8187897Shestness@cs.utexas.edu    //number of float register file accesses
8197897Shestness@cs.utexas.edu    Stats::Scalar fpRegfileReads;
8207897Shestness@cs.utexas.edu    Stats::Scalar fpRegfileWrites;
82112109SRekai.GonzalezAlberquilla@arm.com    //number of vector register file accesses
82212109SRekai.GonzalezAlberquilla@arm.com    mutable Stats::Scalar vecRegfileReads;
82312109SRekai.GonzalezAlberquilla@arm.com    Stats::Scalar vecRegfileWrites;
82413610Sgiacomo.gabrielli@arm.com    //number of predicate register file accesses
82513610Sgiacomo.gabrielli@arm.com    mutable Stats::Scalar vecPredRegfileReads;
82613610Sgiacomo.gabrielli@arm.com    Stats::Scalar vecPredRegfileWrites;
8279920Syasuko.eckert@amd.com    //number of CC register file accesses
8289920Syasuko.eckert@amd.com    Stats::Scalar ccRegfileReads;
8299920Syasuko.eckert@amd.com    Stats::Scalar ccRegfileWrites;
8307897Shestness@cs.utexas.edu    //number of misc
8317897Shestness@cs.utexas.edu    Stats::Scalar miscRegfileReads;
8327897Shestness@cs.utexas.edu    Stats::Scalar miscRegfileWrites;
8331060SN/A};
8341060SN/A
8352325SN/A#endif // __CPU_O3_CPU_HH__
836