cpu.hh revision 14085
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;
791060SN/Aclass Process;
801060SN/A
818737Skoansin.tan@gmail.comstruct BaseCPUParams;
825529Snate@binkert.org
832733Sktlim@umich.educlass BaseO3CPU : public BaseCPU
841060SN/A{
851060SN/A    //Stuff that's pretty ISA independent will go here.
861060SN/A  public:
875529Snate@binkert.org    BaseO3CPU(BaseCPUParams *params);
882292SN/A
892292SN/A    void regStats();
901060SN/A};
911060SN/A
922348SN/A/**
932348SN/A * FullO3CPU class, has each of the stages (fetch through commit)
942348SN/A * within it, as well as all of the time buffers between stages.  The
952348SN/A * tick() function for the CPU is defined here.
962348SN/A */
971060SN/Atemplate <class Impl>
982733Sktlim@umich.educlass FullO3CPU : public BaseO3CPU
991060SN/A{
1001060SN/A  public:
1012325SN/A    // Typedefs from the Impl here.
1021060SN/A    typedef typename Impl::CPUPol CPUPolicy;
1031061SN/A    typedef typename Impl::DynInstPtr DynInstPtr;
1044329Sktlim@umich.edu    typedef typename Impl::O3CPU O3CPU;
1051060SN/A
10612109SRekai.GonzalezAlberquilla@arm.com    using VecElem =  TheISA::VecElem;
10712109SRekai.GonzalezAlberquilla@arm.com    using VecRegContainer =  TheISA::VecRegContainer;
10812109SRekai.GonzalezAlberquilla@arm.com
10913610Sgiacomo.gabrielli@arm.com    using VecPredRegContainer = TheISA::VecPredRegContainer;
11013610Sgiacomo.gabrielli@arm.com
1115595Sgblack@eecs.umich.edu    typedef O3ThreadState<Impl> ImplState;
1122292SN/A    typedef O3ThreadState<Impl> Thread;
1132292SN/A
1142292SN/A    typedef typename std::list<DynInstPtr>::iterator ListIt;
1152292SN/A
1162817Sksewell@umich.edu    friend class O3ThreadContext<Impl>;
1172829Sksewell@umich.edu
1181060SN/A  public:
1191060SN/A    enum Status {
1201060SN/A        Running,
1211060SN/A        Idle,
1221060SN/A        Halted,
1232307SN/A        Blocked,
1242307SN/A        SwitchedOut
1251060SN/A    };
1261060SN/A
12712406Sgabeblack@google.com    BaseTLB *itb;
12812406Sgabeblack@google.com    BaseTLB *dtb;
12913590Srekai.gonzalezalberquilla@arm.com    using LSQRequest = typename LSQ<Impl>::LSQRequest;
1303781Sgblack@eecs.umich.edu
1312292SN/A    /** Overall CPU status. */
1321060SN/A    Status _status;
1331060SN/A
1341060SN/A  private:
1358707Sandreas.hansson@arm.com
1368707Sandreas.hansson@arm.com    /**
1378707Sandreas.hansson@arm.com     * IcachePort class for instruction fetch.
1388707Sandreas.hansson@arm.com     */
1399608Sandreas.hansson@arm.com    class IcachePort : public MasterPort
1408707Sandreas.hansson@arm.com    {
1418707Sandreas.hansson@arm.com      protected:
1428707Sandreas.hansson@arm.com        /** Pointer to fetch. */
1438707Sandreas.hansson@arm.com        DefaultFetch<Impl> *fetch;
1448707Sandreas.hansson@arm.com
1458707Sandreas.hansson@arm.com      public:
1468707Sandreas.hansson@arm.com        /** Default constructor. */
1478707Sandreas.hansson@arm.com        IcachePort(DefaultFetch<Impl> *_fetch, FullO3CPU<Impl>* _cpu)
1489608Sandreas.hansson@arm.com            : MasterPort(_cpu->name() + ".icache_port", _cpu), fetch(_fetch)
1498707Sandreas.hansson@arm.com        { }
1508707Sandreas.hansson@arm.com
1518707Sandreas.hansson@arm.com      protected:
1528707Sandreas.hansson@arm.com
1538707Sandreas.hansson@arm.com        /** Timing version of receive.  Handles setting fetch to the
1548707Sandreas.hansson@arm.com         * proper status to start fetching. */
1558975Sandreas.hansson@arm.com        virtual bool recvTimingResp(PacketPtr pkt);
1568707Sandreas.hansson@arm.com
1578707Sandreas.hansson@arm.com        /** Handles doing a retry of a failed fetch. */
15810713Sandreas.hansson@arm.com        virtual void recvReqRetry();
1598707Sandreas.hansson@arm.com    };
1608707Sandreas.hansson@arm.com
1618707Sandreas.hansson@arm.com    /**
1628707Sandreas.hansson@arm.com     * DcachePort class for the load/store queue.
1638707Sandreas.hansson@arm.com     */
1649608Sandreas.hansson@arm.com    class DcachePort : public MasterPort
1658707Sandreas.hansson@arm.com    {
1668707Sandreas.hansson@arm.com      protected:
1678707Sandreas.hansson@arm.com
1688707Sandreas.hansson@arm.com        /** Pointer to LSQ. */
1698707Sandreas.hansson@arm.com        LSQ<Impl> *lsq;
17010529Smorr@cs.wisc.edu        FullO3CPU<Impl> *cpu;
1718707Sandreas.hansson@arm.com
1728707Sandreas.hansson@arm.com      public:
1738707Sandreas.hansson@arm.com        /** Default constructor. */
1748707Sandreas.hansson@arm.com        DcachePort(LSQ<Impl> *_lsq, FullO3CPU<Impl>* _cpu)
17510529Smorr@cs.wisc.edu            : MasterPort(_cpu->name() + ".dcache_port", _cpu), lsq(_lsq),
17610529Smorr@cs.wisc.edu              cpu(_cpu)
1778707Sandreas.hansson@arm.com        { }
1788707Sandreas.hansson@arm.com
1798707Sandreas.hansson@arm.com      protected:
1808707Sandreas.hansson@arm.com
1818707Sandreas.hansson@arm.com        /** Timing version of receive.  Handles writing back and
1828707Sandreas.hansson@arm.com         * completing the load or store that has returned from
1838707Sandreas.hansson@arm.com         * memory. */
1848975Sandreas.hansson@arm.com        virtual bool recvTimingResp(PacketPtr pkt);
1858975Sandreas.hansson@arm.com        virtual void recvTimingSnoopReq(PacketPtr pkt);
1868707Sandreas.hansson@arm.com
1879608Sandreas.hansson@arm.com        virtual void recvFunctionalSnoop(PacketPtr pkt)
1889608Sandreas.hansson@arm.com        {
1899608Sandreas.hansson@arm.com            // @todo: Is there a need for potential invalidation here?
1909608Sandreas.hansson@arm.com        }
1919608Sandreas.hansson@arm.com
1928707Sandreas.hansson@arm.com        /** Handles doing a retry of the previous send. */
19310713Sandreas.hansson@arm.com        virtual void recvReqRetry();
1948707Sandreas.hansson@arm.com
1958707Sandreas.hansson@arm.com        /**
1968707Sandreas.hansson@arm.com         * As this CPU requires snooping to maintain the load store queue
1978707Sandreas.hansson@arm.com         * change the behaviour from the base CPU port.
1988707Sandreas.hansson@arm.com         *
1998711Sandreas.hansson@arm.com         * @return true since we have to snoop
2008707Sandreas.hansson@arm.com         */
2018922Swilliam.wang@arm.com        virtual bool isSnooping() const { return true; }
2028707Sandreas.hansson@arm.com    };
2038707Sandreas.hansson@arm.com
2042292SN/A    /** The tick event used for scheduling CPU ticks. */
20512127Sspwilson2@wisc.edu    EventFunctionWrapper tickEvent;
2061060SN/A
20713641Sqtt2@cornell.edu    /** The exit event used for terminating all ready-to-exit threads */
20813641Sqtt2@cornell.edu    EventFunctionWrapper threadExitEvent;
20913641Sqtt2@cornell.edu
2102292SN/A    /** Schedule tick event, regardless of its current state. */
2119180Sandreas.hansson@arm.com    void scheduleTickEvent(Cycles delay)
2121060SN/A    {
2131060SN/A        if (tickEvent.squashed())
2149179Sandreas.hansson@arm.com            reschedule(tickEvent, clockEdge(delay));
2151060SN/A        else if (!tickEvent.scheduled())
2169179Sandreas.hansson@arm.com            schedule(tickEvent, clockEdge(delay));
2171060SN/A    }
2181060SN/A
2192292SN/A    /** Unschedule tick event, regardless of its current state. */
2201060SN/A    void unscheduleTickEvent()
2211060SN/A    {
2221060SN/A        if (tickEvent.scheduled())
2231060SN/A            tickEvent.squash();
2241060SN/A    }
2251060SN/A
2269444SAndreas.Sandberg@ARM.com    /**
22710913Sandreas.sandberg@arm.com     * Check if the pipeline has drained and signal drain done.
2289444SAndreas.Sandberg@ARM.com     *
2299444SAndreas.Sandberg@ARM.com     * This method checks if a drain has been requested and if the CPU
2309444SAndreas.Sandberg@ARM.com     * has drained successfully (i.e., there are no instructions in
2319444SAndreas.Sandberg@ARM.com     * the pipeline). If the CPU has drained, it deschedules the tick
2329444SAndreas.Sandberg@ARM.com     * event and signals the drain manager.
2339444SAndreas.Sandberg@ARM.com     *
2349444SAndreas.Sandberg@ARM.com     * @return False if a drain hasn't been requested or the CPU
2359444SAndreas.Sandberg@ARM.com     * hasn't drained, true otherwise.
2369444SAndreas.Sandberg@ARM.com     */
2379444SAndreas.Sandberg@ARM.com    bool tryDrain();
2389444SAndreas.Sandberg@ARM.com
2399444SAndreas.Sandberg@ARM.com    /**
2409444SAndreas.Sandberg@ARM.com     * Perform sanity checks after a drain.
2419444SAndreas.Sandberg@ARM.com     *
2429444SAndreas.Sandberg@ARM.com     * This method is called from drain() when it has determined that
2439444SAndreas.Sandberg@ARM.com     * the CPU is fully drained when gem5 is compiled with the NDEBUG
2449444SAndreas.Sandberg@ARM.com     * macro undefined. The intention of this method is to do more
2459444SAndreas.Sandberg@ARM.com     * extensive tests than the isDrained() method to weed out any
2469444SAndreas.Sandberg@ARM.com     * draining bugs.
2479444SAndreas.Sandberg@ARM.com     */
2489444SAndreas.Sandberg@ARM.com    void drainSanityCheck() const;
2499444SAndreas.Sandberg@ARM.com
2509444SAndreas.Sandberg@ARM.com    /** Check if a system is in a drained state. */
25114085Sgiacomo.travaglini@arm.com    bool isCpuDrained() const;
2529444SAndreas.Sandberg@ARM.com
2531060SN/A  public:
2542292SN/A    /** Constructs a CPU with the given parameters. */
2555595Sgblack@eecs.umich.edu    FullO3CPU(DerivO3CPUParams *params);
2562292SN/A    /** Destructor. */
2571755SN/A    ~FullO3CPU();
2581060SN/A
2592292SN/A    /** Registers statistics. */
26011169Sandreas.hansson@arm.com    void regStats() override;
2611684SN/A
26210023Smatt.horsnell@ARM.com    ProbePointArg<PacketPtr> *ppInstAccessComplete;
26310023Smatt.horsnell@ARM.com    ProbePointArg<std::pair<DynInstPtr, PacketPtr> > *ppDataAccessComplete;
26410023Smatt.horsnell@ARM.com
26510023Smatt.horsnell@ARM.com    /** Register probe points. */
26611169Sandreas.hansson@arm.com    void regProbePoints() override;
26710023Smatt.horsnell@ARM.com
2685358Sgblack@eecs.umich.edu    void demapPage(Addr vaddr, uint64_t asn)
2695358Sgblack@eecs.umich.edu    {
2705358Sgblack@eecs.umich.edu        this->itb->demapPage(vaddr, asn);
2715358Sgblack@eecs.umich.edu        this->dtb->demapPage(vaddr, asn);
2725358Sgblack@eecs.umich.edu    }
2735358Sgblack@eecs.umich.edu
2745358Sgblack@eecs.umich.edu    void demapInstPage(Addr vaddr, uint64_t asn)
2755358Sgblack@eecs.umich.edu    {
2765358Sgblack@eecs.umich.edu        this->itb->demapPage(vaddr, asn);
2775358Sgblack@eecs.umich.edu    }
2785358Sgblack@eecs.umich.edu
2795358Sgblack@eecs.umich.edu    void demapDataPage(Addr vaddr, uint64_t asn)
2805358Sgblack@eecs.umich.edu    {
2815358Sgblack@eecs.umich.edu        this->dtb->demapPage(vaddr, asn);
2825358Sgblack@eecs.umich.edu    }
2835358Sgblack@eecs.umich.edu
2842292SN/A    /** Ticks CPU, calling tick() on each stage, and checking the overall
2852292SN/A     *  activity to see if the CPU should deschedule itself.
2862292SN/A     */
2871684SN/A    void tick();
2881684SN/A
2892292SN/A    /** Initialize the CPU */
29011169Sandreas.hansson@arm.com    void init() override;
2911060SN/A
29211169Sandreas.hansson@arm.com    void startup() override;
2939427SAndreas.Sandberg@ARM.com
2942834Sksewell@umich.edu    /** Returns the Number of Active Threads in the CPU */
2952834Sksewell@umich.edu    int numActiveThreads()
2962834Sksewell@umich.edu    { return activeThreads.size(); }
2972834Sksewell@umich.edu
2982829Sksewell@umich.edu    /** Add Thread to Active Threads List */
2996221Snate@binkert.org    void activateThread(ThreadID tid);
3002875Sksewell@umich.edu
3012875Sksewell@umich.edu    /** Remove Thread from Active Threads List */
3026221Snate@binkert.org    void deactivateThread(ThreadID tid);
3032829Sksewell@umich.edu
3042292SN/A    /** Setup CPU to insert a thread's context */
3056221Snate@binkert.org    void insertThread(ThreadID tid);
3061060SN/A
3072292SN/A    /** Remove all of a thread's context from CPU */
3086221Snate@binkert.org    void removeThread(ThreadID tid);
3092292SN/A
3102292SN/A    /** Count the Total Instructions Committed in the CPU. */
31111169Sandreas.hansson@arm.com    Counter totalInsts() const override;
3128834Satgutier@umich.edu
3138834Satgutier@umich.edu    /** Count the Total Ops (including micro ops) committed in the CPU. */
31411169Sandreas.hansson@arm.com    Counter totalOps() const override;
3152292SN/A
3162292SN/A    /** Add Thread to Active Threads List. */
31711169Sandreas.hansson@arm.com    void activateContext(ThreadID tid) override;
3182292SN/A
3192292SN/A    /** Remove Thread from Active Threads List */
32011169Sandreas.hansson@arm.com    void suspendContext(ThreadID tid) override;
3212292SN/A
3222292SN/A    /** Remove Thread from Active Threads List &&
3232292SN/A     *  Remove Thread Context from CPU.
3242292SN/A     */
32511169Sandreas.hansson@arm.com    void haltContext(ThreadID tid) override;
3262292SN/A
3272292SN/A    /** Update The Order In Which We Process Threads. */
3282292SN/A    void updateThreadPriority();
3292292SN/A
3309444SAndreas.Sandberg@ARM.com    /** Is the CPU draining? */
33110913Sandreas.sandberg@arm.com    bool isDraining() const { return drainState() == DrainState::Draining; }
3329444SAndreas.Sandberg@ARM.com
33311168Sandreas.hansson@arm.com    void serializeThread(CheckpointOut &cp, ThreadID tid) const override;
33411168Sandreas.hansson@arm.com    void unserializeThread(CheckpointIn &cp, ThreadID tid) override;
3352864Sktlim@umich.edu
33613641Sqtt2@cornell.edu    /** Insert tid to the list of threads trying to exit */
33713641Sqtt2@cornell.edu    void addThreadToExitingList(ThreadID tid);
33813641Sqtt2@cornell.edu
33913641Sqtt2@cornell.edu    /** Is the thread trying to exit? */
34013641Sqtt2@cornell.edu    bool isThreadExiting(ThreadID tid) const;
34113641Sqtt2@cornell.edu
34213641Sqtt2@cornell.edu    /**
34313641Sqtt2@cornell.edu     *  If a thread is trying to exit and its corresponding trap event
34413641Sqtt2@cornell.edu     *  has been completed, schedule an event to terminate the thread.
34513641Sqtt2@cornell.edu     */
34613641Sqtt2@cornell.edu    void scheduleThreadExitEvent(ThreadID tid);
34713641Sqtt2@cornell.edu
34813641Sqtt2@cornell.edu    /** Terminate all threads that are ready to exit */
34913641Sqtt2@cornell.edu    void exitThreads();
35013641Sqtt2@cornell.edu
3512864Sktlim@umich.edu  public:
3525595Sgblack@eecs.umich.edu    /** Executes a syscall.
3535595Sgblack@eecs.umich.edu     * @todo: Determine if this needs to be virtual.
3542292SN/A     */
35511877Sbrandon.potter@amd.com    void syscall(int64_t callnum, ThreadID tid, Fault *fault);
3562292SN/A
3572843Sktlim@umich.edu    /** Starts draining the CPU's pipeline of all instructions in
3582843Sktlim@umich.edu     * order to stop all memory accesses. */
35911168Sandreas.hansson@arm.com    DrainState drain() override;
3602843Sktlim@umich.edu
3612843Sktlim@umich.edu    /** Resumes execution after a drain. */
36211168Sandreas.hansson@arm.com    void drainResume() override;
3632292SN/A
3649444SAndreas.Sandberg@ARM.com    /**
3659444SAndreas.Sandberg@ARM.com     * Commit has reached a safe point to drain a thread.
3669444SAndreas.Sandberg@ARM.com     *
3679444SAndreas.Sandberg@ARM.com     * Commit calls this method to inform the pipeline that it has
3689444SAndreas.Sandberg@ARM.com     * reached a point where it is not executed microcode and is about
3699444SAndreas.Sandberg@ARM.com     * to squash uncommitted instructions to fully drain the pipeline.
3709444SAndreas.Sandberg@ARM.com     */
3719444SAndreas.Sandberg@ARM.com    void commitDrained(ThreadID tid);
3722843Sktlim@umich.edu
3732843Sktlim@umich.edu    /** Switches out this CPU. */
37411169Sandreas.hansson@arm.com    void switchOut() override;
3752316SN/A
3762348SN/A    /** Takes over from another CPU. */
37711169Sandreas.hansson@arm.com    void takeOverFrom(BaseCPU *oldCPU) override;
3781060SN/A
37911169Sandreas.hansson@arm.com    void verifyMemoryMode() const override;
3809523SAndreas.Sandberg@ARM.com
3811060SN/A    /** Get the current instruction sequence number, and increment it. */
3822316SN/A    InstSeqNum getAndIncrementInstSeq()
3832316SN/A    { return globalSeqNum++; }
3841060SN/A
3855595Sgblack@eecs.umich.edu    /** Traps to handle given fault. */
38610417Sandreas.hansson@arm.com    void trap(const Fault &fault, ThreadID tid, const StaticInstPtr &inst);
3875595Sgblack@eecs.umich.edu
38813601Sgiacomo.travaglini@arm.com    /** Check if a change in renaming is needed for vector registers.
38913601Sgiacomo.travaglini@arm.com     * The vecMode variable is updated and propagated to rename maps.
39013601Sgiacomo.travaglini@arm.com     *
39113601Sgiacomo.travaglini@arm.com     * @param tid ThreadID
39213601Sgiacomo.travaglini@arm.com     * @param freelist list of free registers
39313601Sgiacomo.travaglini@arm.com     */
39413601Sgiacomo.travaglini@arm.com    void switchRenameMode(ThreadID tid, UnifiedFreeList* freelist);
39513601Sgiacomo.travaglini@arm.com
3965595Sgblack@eecs.umich.edu    /** Returns the Fault for any valid interrupt. */
3975595Sgblack@eecs.umich.edu    Fault getInterrupts();
3985595Sgblack@eecs.umich.edu
3995595Sgblack@eecs.umich.edu    /** Processes any an interrupt fault. */
40010379Sandreas.hansson@arm.com    void processInterrupts(const Fault &interrupt);
4015595Sgblack@eecs.umich.edu
4025595Sgblack@eecs.umich.edu    /** Halts the CPU. */
4035595Sgblack@eecs.umich.edu    void halt() { panic("Halt not implemented!\n"); }
4045595Sgblack@eecs.umich.edu
4052348SN/A    /** Register accessors.  Index refers to the physical register index. */
4065595Sgblack@eecs.umich.edu
4075595Sgblack@eecs.umich.edu    /** Reads a miscellaneous register. */
40813557Sgabeblack@google.com    RegVal readMiscRegNoEffect(int misc_reg, ThreadID tid) const;
4095595Sgblack@eecs.umich.edu
4105595Sgblack@eecs.umich.edu    /** Reads a misc. register, including any side effects the read
4115595Sgblack@eecs.umich.edu     * might have as defined by the architecture.
4125595Sgblack@eecs.umich.edu     */
41313557Sgabeblack@google.com    RegVal readMiscReg(int misc_reg, ThreadID tid);
4145595Sgblack@eecs.umich.edu
4155595Sgblack@eecs.umich.edu    /** Sets a miscellaneous register. */
41613582Sgabeblack@google.com    void setMiscRegNoEffect(int misc_reg, RegVal val, ThreadID tid);
4175595Sgblack@eecs.umich.edu
4185595Sgblack@eecs.umich.edu    /** Sets a misc. register, including any side effects the write
4195595Sgblack@eecs.umich.edu     * might have as defined by the architecture.
4205595Sgblack@eecs.umich.edu     */
42113582Sgabeblack@google.com    void setMiscReg(int misc_reg, RegVal val, ThreadID tid);
4225595Sgblack@eecs.umich.edu
42313557Sgabeblack@google.com    RegVal readIntReg(PhysRegIdPtr phys_reg);
4241060SN/A
42513611Sgabeblack@google.com    RegVal readFloatReg(PhysRegIdPtr phys_reg);
4262455SN/A
42712109SRekai.GonzalezAlberquilla@arm.com    const VecRegContainer& readVecReg(PhysRegIdPtr reg_idx) const;
42812109SRekai.GonzalezAlberquilla@arm.com
42912109SRekai.GonzalezAlberquilla@arm.com    /**
43012109SRekai.GonzalezAlberquilla@arm.com     * Read physical vector register for modification.
43112109SRekai.GonzalezAlberquilla@arm.com     */
43212109SRekai.GonzalezAlberquilla@arm.com    VecRegContainer& getWritableVecReg(PhysRegIdPtr reg_idx);
43312109SRekai.GonzalezAlberquilla@arm.com
43413601Sgiacomo.travaglini@arm.com    /** Returns current vector renaming mode */
43513601Sgiacomo.travaglini@arm.com    Enums::VecRegRenameMode vecRenameMode() const { return vecMode; }
43613601Sgiacomo.travaglini@arm.com
43713601Sgiacomo.travaglini@arm.com    /** Sets the current vector renaming mode */
43813601Sgiacomo.travaglini@arm.com    void vecRenameMode(Enums::VecRegRenameMode vec_mode)
43913601Sgiacomo.travaglini@arm.com    { vecMode = vec_mode; }
44013601Sgiacomo.travaglini@arm.com
44112109SRekai.GonzalezAlberquilla@arm.com    /**
44212109SRekai.GonzalezAlberquilla@arm.com     * Read physical vector register lane
44312109SRekai.GonzalezAlberquilla@arm.com     */
44412109SRekai.GonzalezAlberquilla@arm.com    template<typename VecElem, int LaneIdx>
44512109SRekai.GonzalezAlberquilla@arm.com    VecLaneT<VecElem, true>
44612109SRekai.GonzalezAlberquilla@arm.com    readVecLane(PhysRegIdPtr phys_reg) const
44712109SRekai.GonzalezAlberquilla@arm.com    {
44812109SRekai.GonzalezAlberquilla@arm.com        vecRegfileReads++;
44912109SRekai.GonzalezAlberquilla@arm.com        return regFile.readVecLane<VecElem, LaneIdx>(phys_reg);
45012109SRekai.GonzalezAlberquilla@arm.com    }
45112109SRekai.GonzalezAlberquilla@arm.com
45212109SRekai.GonzalezAlberquilla@arm.com    /**
45312109SRekai.GonzalezAlberquilla@arm.com     * Read physical vector register lane
45412109SRekai.GonzalezAlberquilla@arm.com     */
45512109SRekai.GonzalezAlberquilla@arm.com    template<typename VecElem>
45612109SRekai.GonzalezAlberquilla@arm.com    VecLaneT<VecElem, true>
45712109SRekai.GonzalezAlberquilla@arm.com    readVecLane(PhysRegIdPtr phys_reg) const
45812109SRekai.GonzalezAlberquilla@arm.com    {
45912109SRekai.GonzalezAlberquilla@arm.com        vecRegfileReads++;
46012109SRekai.GonzalezAlberquilla@arm.com        return regFile.readVecLane<VecElem>(phys_reg);
46112109SRekai.GonzalezAlberquilla@arm.com    }
46212109SRekai.GonzalezAlberquilla@arm.com
46312109SRekai.GonzalezAlberquilla@arm.com    /** Write a lane of the destination vector register. */
46412109SRekai.GonzalezAlberquilla@arm.com    template<typename LD>
46512109SRekai.GonzalezAlberquilla@arm.com    void
46612109SRekai.GonzalezAlberquilla@arm.com    setVecLane(PhysRegIdPtr phys_reg, const LD& val)
46712109SRekai.GonzalezAlberquilla@arm.com    {
46812109SRekai.GonzalezAlberquilla@arm.com        vecRegfileWrites++;
46912109SRekai.GonzalezAlberquilla@arm.com        return regFile.setVecLane(phys_reg, val);
47012109SRekai.GonzalezAlberquilla@arm.com    }
47112109SRekai.GonzalezAlberquilla@arm.com
47212109SRekai.GonzalezAlberquilla@arm.com    const VecElem& readVecElem(PhysRegIdPtr reg_idx) const;
47312109SRekai.GonzalezAlberquilla@arm.com
47413610Sgiacomo.gabrielli@arm.com    const VecPredRegContainer& readVecPredReg(PhysRegIdPtr reg_idx) const;
47513610Sgiacomo.gabrielli@arm.com
47613610Sgiacomo.gabrielli@arm.com    VecPredRegContainer& getWritableVecPredReg(PhysRegIdPtr reg_idx);
47713610Sgiacomo.gabrielli@arm.com
47813622Sgabeblack@google.com    RegVal readCCReg(PhysRegIdPtr phys_reg);
4799920Syasuko.eckert@amd.com
48013557Sgabeblack@google.com    void setIntReg(PhysRegIdPtr phys_reg, RegVal val);
4811060SN/A
48213611Sgabeblack@google.com    void setFloatReg(PhysRegIdPtr phys_reg, RegVal val);
4832455SN/A
48412109SRekai.GonzalezAlberquilla@arm.com    void setVecReg(PhysRegIdPtr reg_idx, const VecRegContainer& val);
48512109SRekai.GonzalezAlberquilla@arm.com
48612109SRekai.GonzalezAlberquilla@arm.com    void setVecElem(PhysRegIdPtr reg_idx, const VecElem& val);
48712109SRekai.GonzalezAlberquilla@arm.com
48813610Sgiacomo.gabrielli@arm.com    void setVecPredReg(PhysRegIdPtr reg_idx, const VecPredRegContainer& val);
48913610Sgiacomo.gabrielli@arm.com
49013622Sgabeblack@google.com    void setCCReg(PhysRegIdPtr phys_reg, RegVal val);
4919920Syasuko.eckert@amd.com
49213557Sgabeblack@google.com    RegVal readArchIntReg(int reg_idx, ThreadID tid);
4931060SN/A
49413611Sgabeblack@google.com    RegVal readArchFloatReg(int reg_idx, ThreadID tid);
4952292SN/A
49612109SRekai.GonzalezAlberquilla@arm.com    const VecRegContainer& readArchVecReg(int reg_idx, ThreadID tid) const;
49712109SRekai.GonzalezAlberquilla@arm.com    /** Read architectural vector register for modification. */
49812109SRekai.GonzalezAlberquilla@arm.com    VecRegContainer& getWritableArchVecReg(int reg_idx, ThreadID tid);
49912109SRekai.GonzalezAlberquilla@arm.com
50012109SRekai.GonzalezAlberquilla@arm.com    /** Read architectural vector register lane. */
50112109SRekai.GonzalezAlberquilla@arm.com    template<typename VecElem>
50212109SRekai.GonzalezAlberquilla@arm.com    VecLaneT<VecElem, true>
50312109SRekai.GonzalezAlberquilla@arm.com    readArchVecLane(int reg_idx, int lId, ThreadID tid) const
50412109SRekai.GonzalezAlberquilla@arm.com    {
50512109SRekai.GonzalezAlberquilla@arm.com        PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup(
50612109SRekai.GonzalezAlberquilla@arm.com                    RegId(VecRegClass, reg_idx));
50712109SRekai.GonzalezAlberquilla@arm.com        return readVecLane<VecElem>(phys_reg);
50812109SRekai.GonzalezAlberquilla@arm.com    }
50912109SRekai.GonzalezAlberquilla@arm.com
51012109SRekai.GonzalezAlberquilla@arm.com
51112109SRekai.GonzalezAlberquilla@arm.com    /** Write a lane of the destination vector register. */
51212109SRekai.GonzalezAlberquilla@arm.com    template<typename LD>
51312109SRekai.GonzalezAlberquilla@arm.com    void
51412109SRekai.GonzalezAlberquilla@arm.com    setArchVecLane(int reg_idx, int lId, ThreadID tid, const LD& val)
51512109SRekai.GonzalezAlberquilla@arm.com    {
51612109SRekai.GonzalezAlberquilla@arm.com        PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup(
51712109SRekai.GonzalezAlberquilla@arm.com                    RegId(VecRegClass, reg_idx));
51812109SRekai.GonzalezAlberquilla@arm.com        setVecLane(phys_reg, val);
51912109SRekai.GonzalezAlberquilla@arm.com    }
52012109SRekai.GonzalezAlberquilla@arm.com
52112109SRekai.GonzalezAlberquilla@arm.com    const VecElem& readArchVecElem(const RegIndex& reg_idx,
52212109SRekai.GonzalezAlberquilla@arm.com                                   const ElemIndex& ldx, ThreadID tid) const;
52312109SRekai.GonzalezAlberquilla@arm.com
52413610Sgiacomo.gabrielli@arm.com    const VecPredRegContainer& readArchVecPredReg(int reg_idx,
52513610Sgiacomo.gabrielli@arm.com                                                  ThreadID tid) const;
52613610Sgiacomo.gabrielli@arm.com
52713610Sgiacomo.gabrielli@arm.com    VecPredRegContainer& getWritableArchVecPredReg(int reg_idx, ThreadID tid);
52813610Sgiacomo.gabrielli@arm.com
52913622Sgabeblack@google.com    RegVal readArchCCReg(int reg_idx, ThreadID tid);
5309920Syasuko.eckert@amd.com
5312348SN/A    /** Architectural register accessors.  Looks up in the commit
5322348SN/A     * rename table to obtain the true physical index of the
5332348SN/A     * architected register first, then accesses that physical
5342348SN/A     * register.
5352348SN/A     */
53613557Sgabeblack@google.com    void setArchIntReg(int reg_idx, RegVal val, ThreadID tid);
5372292SN/A
53813611Sgabeblack@google.com    void setArchFloatReg(int reg_idx, RegVal val, ThreadID tid);
5392292SN/A
54013610Sgiacomo.gabrielli@arm.com    void setArchVecPredReg(int reg_idx, const VecPredRegContainer& val,
54113610Sgiacomo.gabrielli@arm.com                           ThreadID tid);
54213610Sgiacomo.gabrielli@arm.com
54312109SRekai.GonzalezAlberquilla@arm.com    void setArchVecReg(int reg_idx, const VecRegContainer& val, ThreadID tid);
54412109SRekai.GonzalezAlberquilla@arm.com
54512109SRekai.GonzalezAlberquilla@arm.com    void setArchVecElem(const RegIndex& reg_idx, const ElemIndex& ldx,
54612109SRekai.GonzalezAlberquilla@arm.com                        const VecElem& val, ThreadID tid);
54712109SRekai.GonzalezAlberquilla@arm.com
54813622Sgabeblack@google.com    void setArchCCReg(int reg_idx, RegVal val, ThreadID tid);
5499920Syasuko.eckert@amd.com
5507720Sgblack@eecs.umich.edu    /** Sets the commit PC state of a specific thread. */
5517720Sgblack@eecs.umich.edu    void pcState(const TheISA::PCState &newPCState, ThreadID tid);
5527720Sgblack@eecs.umich.edu
5537720Sgblack@eecs.umich.edu    /** Reads the commit PC state of a specific thread. */
5547720Sgblack@eecs.umich.edu    TheISA::PCState pcState(ThreadID tid);
5557720Sgblack@eecs.umich.edu
5562348SN/A    /** Reads the commit PC of a specific thread. */
5577720Sgblack@eecs.umich.edu    Addr instAddr(ThreadID tid);
5582292SN/A
5594636Sgblack@eecs.umich.edu    /** Reads the commit micro PC of a specific thread. */
5607720Sgblack@eecs.umich.edu    MicroPC microPC(ThreadID tid);
5614636Sgblack@eecs.umich.edu
5622348SN/A    /** Reads the next PC of a specific thread. */
5637720Sgblack@eecs.umich.edu    Addr nextInstAddr(ThreadID tid);
5642756Sksewell@umich.edu
5655595Sgblack@eecs.umich.edu    /** Initiates a squash of all in-flight instructions for a given
5665595Sgblack@eecs.umich.edu     * thread.  The source of the squash is an external update of
5675595Sgblack@eecs.umich.edu     * state through the TC.
5685595Sgblack@eecs.umich.edu     */
5696221Snate@binkert.org    void squashFromTC(ThreadID tid);
5705595Sgblack@eecs.umich.edu
5711060SN/A    /** Function to add instruction onto the head of the list of the
5721060SN/A     *  instructions.  Used when new instructions are fetched.
5731060SN/A     */
57413429Srekai.gonzalezalberquilla@arm.com    ListIt addInst(const DynInstPtr &inst);
5751060SN/A
5761060SN/A    /** Function to tell the CPU that an instruction has completed. */
57713429Srekai.gonzalezalberquilla@arm.com    void instDone(ThreadID tid, const DynInstPtr &inst);
5781060SN/A
5792325SN/A    /** Remove an instruction from the front end of the list.  There's
5802325SN/A     *  no restriction on location of the instruction.
5811060SN/A     */
58213429Srekai.gonzalezalberquilla@arm.com    void removeFrontInst(const DynInstPtr &inst);
5831060SN/A
5842935Sksewell@umich.edu    /** Remove all instructions that are not currently in the ROB.
5852935Sksewell@umich.edu     *  There's also an option to not squash delay slot instructions.*/
5866221Snate@binkert.org    void removeInstsNotInROB(ThreadID tid);
5871060SN/A
5881062SN/A    /** Remove all instructions younger than the given sequence number. */
5896221Snate@binkert.org    void removeInstsUntil(const InstSeqNum &seq_num, ThreadID tid);
5902292SN/A
5912348SN/A    /** Removes the instruction pointed to by the iterator. */
5926221Snate@binkert.org    inline void squashInstIt(const ListIt &instIt, ThreadID tid);
5932292SN/A
5942348SN/A    /** Cleans up all instructions on the remove list. */
5952292SN/A    void cleanUpRemovedInsts();
5961062SN/A
5972348SN/A    /** Debug function to print all instructions on the list. */
5981060SN/A    void dumpInsts();
5991060SN/A
6001060SN/A  public:
6015737Scws3k@cs.virginia.edu#ifndef NDEBUG
6025737Scws3k@cs.virginia.edu    /** Count of total number of dynamic instructions in flight. */
6035737Scws3k@cs.virginia.edu    int instcount;
6045737Scws3k@cs.virginia.edu#endif
6055737Scws3k@cs.virginia.edu
6061060SN/A    /** List of all the instructions in flight. */
6072292SN/A    std::list<DynInstPtr> instList;
6081060SN/A
6092292SN/A    /** List of all the instructions that will be removed at the end of this
6102292SN/A     *  cycle.
6112292SN/A     */
6122292SN/A    std::queue<ListIt> removeList;
6132292SN/A
6142325SN/A#ifdef DEBUG
6152348SN/A    /** Debug structure to keep track of the sequence numbers still in
6162348SN/A     * flight.
6172348SN/A     */
6182292SN/A    std::set<InstSeqNum> snList;
6192325SN/A#endif
6202292SN/A
6212325SN/A    /** Records if instructions need to be removed this cycle due to
6222325SN/A     *  being retired or squashed.
6232292SN/A     */
6242292SN/A    bool removeInstsThisCycle;
6252292SN/A
6261060SN/A  protected:
6271060SN/A    /** The fetch stage. */
6281060SN/A    typename CPUPolicy::Fetch fetch;
6291060SN/A
6301060SN/A    /** The decode stage. */
6311060SN/A    typename CPUPolicy::Decode decode;
6321060SN/A
6331060SN/A    /** The dispatch stage. */
6341060SN/A    typename CPUPolicy::Rename rename;
6351060SN/A
6361060SN/A    /** The issue/execute/writeback stages. */
6371060SN/A    typename CPUPolicy::IEW iew;
6381060SN/A
6391060SN/A    /** The commit stage. */
6401060SN/A    typename CPUPolicy::Commit commit;
6411060SN/A
64212109SRekai.GonzalezAlberquilla@arm.com    /** The rename mode of the vector registers */
64312109SRekai.GonzalezAlberquilla@arm.com    Enums::VecRegRenameMode vecMode;
64412109SRekai.GonzalezAlberquilla@arm.com
6451060SN/A    /** The register file. */
6469919Ssteve.reinhardt@amd.com    PhysRegFile regFile;
6471060SN/A
6481060SN/A    /** The free list. */
6491060SN/A    typename CPUPolicy::FreeList freeList;
6501060SN/A
6511060SN/A    /** The rename map. */
6522292SN/A    typename CPUPolicy::RenameMap renameMap[Impl::MaxThreads];
6532292SN/A
6542292SN/A    /** The commit rename map. */
6552292SN/A    typename CPUPolicy::RenameMap commitRenameMap[Impl::MaxThreads];
6561060SN/A
6571060SN/A    /** The re-order buffer. */
6581060SN/A    typename CPUPolicy::ROB rob;
6591060SN/A
6602292SN/A    /** Active Threads List */
6616221Snate@binkert.org    std::list<ThreadID> activeThreads;
6622292SN/A
66313641Sqtt2@cornell.edu    /**
66413641Sqtt2@cornell.edu     *  This is a list of threads that are trying to exit. Each thread id
66513641Sqtt2@cornell.edu     *  is mapped to a boolean value denoting whether the thread is ready
66613641Sqtt2@cornell.edu     *  to exit.
66713641Sqtt2@cornell.edu     */
66813641Sqtt2@cornell.edu    std::unordered_map<ThreadID, bool> exitingThreads;
66913641Sqtt2@cornell.edu
6702292SN/A    /** Integer Register Scoreboard */
6712292SN/A    Scoreboard scoreboard;
6722292SN/A
6739384SAndreas.Sandberg@arm.com    std::vector<TheISA::ISA *> isa;
6746313Sgblack@eecs.umich.edu
6758707Sandreas.hansson@arm.com    /** Instruction port. Note that it has to appear after the fetch stage. */
6768707Sandreas.hansson@arm.com    IcachePort icachePort;
6778707Sandreas.hansson@arm.com
6788707Sandreas.hansson@arm.com    /** Data port. Note that it has to appear after the iew stages */
6798707Sandreas.hansson@arm.com    DcachePort dcachePort;
6808707Sandreas.hansson@arm.com
6811060SN/A  public:
6822292SN/A    /** Enum to give each stage a specific index, so when calling
6832292SN/A     *  activateStage() or deactivateStage(), they can specify which stage
6842292SN/A     *  is being activated/deactivated.
6852292SN/A     */
6862292SN/A    enum StageIdx {
6872292SN/A        FetchIdx,
6882292SN/A        DecodeIdx,
6892292SN/A        RenameIdx,
6902292SN/A        IEWIdx,
6912292SN/A        CommitIdx,
6922292SN/A        NumStages };
6932292SN/A
6941060SN/A    /** Typedefs from the Impl to get the structs that each of the
6951060SN/A     *  time buffers should use.
6961060SN/A     */
6971061SN/A    typedef typename CPUPolicy::TimeStruct TimeStruct;
6981060SN/A
6991061SN/A    typedef typename CPUPolicy::FetchStruct FetchStruct;
7001060SN/A
7011061SN/A    typedef typename CPUPolicy::DecodeStruct DecodeStruct;
7021060SN/A
7031061SN/A    typedef typename CPUPolicy::RenameStruct RenameStruct;
7041060SN/A
7051061SN/A    typedef typename CPUPolicy::IEWStruct IEWStruct;
7061060SN/A
7071060SN/A    /** The main time buffer to do backwards communication. */
7081060SN/A    TimeBuffer<TimeStruct> timeBuffer;
7091060SN/A
7101060SN/A    /** The fetch stage's instruction queue. */
7111060SN/A    TimeBuffer<FetchStruct> fetchQueue;
7121060SN/A
7131060SN/A    /** The decode stage's instruction queue. */
7141060SN/A    TimeBuffer<DecodeStruct> decodeQueue;
7151060SN/A
7161060SN/A    /** The rename stage's instruction queue. */
7171060SN/A    TimeBuffer<RenameStruct> renameQueue;
7181060SN/A
7191060SN/A    /** The IEW stage's instruction queue. */
7201060SN/A    TimeBuffer<IEWStruct> iewQueue;
7211060SN/A
7222348SN/A  private:
7232348SN/A    /** The activity recorder; used to tell if the CPU has any
7242348SN/A     * activity remaining or if it can go to idle and deschedule
7252348SN/A     * itself.
7262348SN/A     */
7272325SN/A    ActivityRecorder activityRec;
7281060SN/A
7292348SN/A  public:
7302348SN/A    /** Records that there was time buffer activity this cycle. */
7312325SN/A    void activityThisCycle() { activityRec.activity(); }
7322292SN/A
7332348SN/A    /** Changes a stage's status to active within the activity recorder. */
7342325SN/A    void activateStage(const StageIdx idx)
7352325SN/A    { activityRec.activateStage(idx); }
7362292SN/A
7372348SN/A    /** Changes a stage's status to inactive within the activity recorder. */
7382325SN/A    void deactivateStage(const StageIdx idx)
7392325SN/A    { activityRec.deactivateStage(idx); }
7402292SN/A
7412292SN/A    /** Wakes the CPU, rescheduling the CPU if it's not already active. */
7422292SN/A    void wakeCPU();
7432260SN/A
74411168Sandreas.hansson@arm.com    virtual void wakeup(ThreadID tid) override;
7455807Snate@binkert.org
7462292SN/A    /** Gets a free thread id. Use if thread ids change across system. */
7476221Snate@binkert.org    ThreadID getFreeTid();
7482292SN/A
7492292SN/A  public:
7502680Sktlim@umich.edu    /** Returns a pointer to a thread context. */
7516221Snate@binkert.org    ThreadContext *
7526221Snate@binkert.org    tcBase(ThreadID tid)
7531681SN/A    {
7542680Sktlim@umich.edu        return thread[tid]->getTC();
7552190SN/A    }
7562190SN/A
7572292SN/A    /** The global sequence number counter. */
7583093Sksewell@umich.edu    InstSeqNum globalSeqNum;//[Impl::MaxThreads];
7591060SN/A
7602348SN/A    /** Pointer to the checker, which can dynamically verify
7612348SN/A     * instruction results at run time.  This can be set to NULL if it
7622348SN/A     * is not being used.
7632348SN/A     */
7648733Sgeoffrey.blake@arm.com    Checker<Impl> *checker;
7652316SN/A
7662292SN/A    /** Pointer to the system. */
7671060SN/A    System *system;
7681060SN/A
7692348SN/A    /** Pointers to all of the threads in the CPU. */
7702292SN/A    std::vector<Thread *> thread;
7712260SN/A
7722292SN/A    /** Threads Scheduled to Enter CPU */
7732292SN/A    std::list<int> cpuWaitList;
7742292SN/A
7752292SN/A    /** The cycle that the CPU was last running, used for statistics. */
7769180Sandreas.hansson@arm.com    Cycles lastRunningCycle;
7772292SN/A
7782829Sksewell@umich.edu    /** The cycle that the CPU was last activated by a new thread*/
7792829Sksewell@umich.edu    Tick lastActivatedCycle;
7802829Sksewell@umich.edu
7812292SN/A    /** Mapping for system thread id to cpu id */
7826221Snate@binkert.org    std::map<ThreadID, unsigned> threadMap;
7832292SN/A
7842292SN/A    /** Available thread ids in the cpu*/
7856221Snate@binkert.org    std::vector<ThreadID> tids;
7862292SN/A
78713590Srekai.gonzalezalberquilla@arm.com    /** CPU pushRequest function, forwards request to LSQ. */
78813590Srekai.gonzalezalberquilla@arm.com    Fault pushRequest(const DynInstPtr& inst, bool isLoad, uint8_t *data,
78913590Srekai.gonzalezalberquilla@arm.com                      unsigned int size, Addr addr, Request::Flags flags,
79013954Sgiacomo.gabrielli@arm.com                      uint64_t *res, AtomicOpFunctor *amo_op = nullptr,
79113954Sgiacomo.gabrielli@arm.com                      const std::vector<bool>& byteEnable =
79213954Sgiacomo.gabrielli@arm.com                          std::vector<bool>())
79313954Sgiacomo.gabrielli@arm.com
79413590Srekai.gonzalezalberquilla@arm.com    {
79513590Srekai.gonzalezalberquilla@arm.com        return iew.ldstQueue.pushRequest(inst, isLoad, data, size, addr,
79613954Sgiacomo.gabrielli@arm.com                flags, res, amo_op, byteEnable);
79713590Srekai.gonzalezalberquilla@arm.com    }
79813590Srekai.gonzalezalberquilla@arm.com
7995595Sgblack@eecs.umich.edu    /** CPU read function, forwards read to LSQ. */
80013590Srekai.gonzalezalberquilla@arm.com    Fault read(LSQRequest* req, int load_idx)
8015595Sgblack@eecs.umich.edu    {
80213590Srekai.gonzalezalberquilla@arm.com        return this->iew.ldstQueue.read(req, load_idx);
8035595Sgblack@eecs.umich.edu    }
8045595Sgblack@eecs.umich.edu
8055595Sgblack@eecs.umich.edu    /** CPU write function, forwards write to LSQ. */
80613590Srekai.gonzalezalberquilla@arm.com    Fault write(LSQRequest* req, uint8_t *data, int store_idx)
8075595Sgblack@eecs.umich.edu    {
80813590Srekai.gonzalezalberquilla@arm.com        return this->iew.ldstQueue.write(req, data, store_idx);
8095595Sgblack@eecs.umich.edu    }
8105595Sgblack@eecs.umich.edu
8118707Sandreas.hansson@arm.com    /** Used by the fetch unit to get a hold of the instruction port. */
81211169Sandreas.hansson@arm.com    MasterPort &getInstPort() override { return icachePort; }
8138707Sandreas.hansson@arm.com
8146974Stjones1@inf.ed.ac.uk    /** Get the dcache port (used to find block size for translations). */
81511169Sandreas.hansson@arm.com    MasterPort &getDataPort() override { return dcachePort; }
8166974Stjones1@inf.ed.ac.uk
8172292SN/A    /** Stat for total number of times the CPU is descheduled. */
8185999Snate@binkert.org    Stats::Scalar timesIdled;
8192292SN/A    /** Stat for total number of cycles the CPU spends descheduled. */
8205999Snate@binkert.org    Stats::Scalar idleCycles;
8218627SAli.Saidi@ARM.com    /** Stat for total number of cycles the CPU spends descheduled due to a
8228627SAli.Saidi@ARM.com     * quiesce operation or waiting for an interrupt. */
8238627SAli.Saidi@ARM.com    Stats::Scalar quiesceCycles;
8242292SN/A    /** Stat for the number of committed instructions per thread. */
8255999Snate@binkert.org    Stats::Vector committedInsts;
8268834Satgutier@umich.edu    /** Stat for the number of committed ops (including micro ops) per thread. */
8278834Satgutier@umich.edu    Stats::Vector committedOps;
8282292SN/A    /** Stat for the CPI per thread. */
8292292SN/A    Stats::Formula cpi;
8302292SN/A    /** Stat for the total CPI. */
8312292SN/A    Stats::Formula totalCpi;
8322292SN/A    /** Stat for the IPC per thread. */
8332292SN/A    Stats::Formula ipc;
8342292SN/A    /** Stat for the total IPC. */
8352292SN/A    Stats::Formula totalIpc;
8367897Shestness@cs.utexas.edu
8377897Shestness@cs.utexas.edu    //number of integer register file accesses
8387897Shestness@cs.utexas.edu    Stats::Scalar intRegfileReads;
8397897Shestness@cs.utexas.edu    Stats::Scalar intRegfileWrites;
8407897Shestness@cs.utexas.edu    //number of float register file accesses
8417897Shestness@cs.utexas.edu    Stats::Scalar fpRegfileReads;
8427897Shestness@cs.utexas.edu    Stats::Scalar fpRegfileWrites;
84312109SRekai.GonzalezAlberquilla@arm.com    //number of vector register file accesses
84412109SRekai.GonzalezAlberquilla@arm.com    mutable Stats::Scalar vecRegfileReads;
84512109SRekai.GonzalezAlberquilla@arm.com    Stats::Scalar vecRegfileWrites;
84613610Sgiacomo.gabrielli@arm.com    //number of predicate register file accesses
84713610Sgiacomo.gabrielli@arm.com    mutable Stats::Scalar vecPredRegfileReads;
84813610Sgiacomo.gabrielli@arm.com    Stats::Scalar vecPredRegfileWrites;
8499920Syasuko.eckert@amd.com    //number of CC register file accesses
8509920Syasuko.eckert@amd.com    Stats::Scalar ccRegfileReads;
8519920Syasuko.eckert@amd.com    Stats::Scalar ccRegfileWrites;
8527897Shestness@cs.utexas.edu    //number of misc
8537897Shestness@cs.utexas.edu    Stats::Scalar miscRegfileReads;
8547897Shestness@cs.utexas.edu    Stats::Scalar miscRegfileWrites;
8551060SN/A};
8561060SN/A
8572325SN/A#endif // __CPU_O3_CPU_HH__
858