cpu.hh revision 9176
12315SN/A/*
28733Sgeoffrey.blake@arm.com * Copyright (c) 2011 ARM Limited
38733Sgeoffrey.blake@arm.com * All rights reserved
48733Sgeoffrey.blake@arm.com *
58733Sgeoffrey.blake@arm.com * The license below extends only to copyright in the software and shall
68733Sgeoffrey.blake@arm.com * not be construed as granting a license to any other intellectual
78733Sgeoffrey.blake@arm.com * property including but not limited to intellectual property relating
88733Sgeoffrey.blake@arm.com * to a hardware implementation of the functionality of the software
98733Sgeoffrey.blake@arm.com * licensed hereunder.  You may use the software subject to the license
108733Sgeoffrey.blake@arm.com * terms below provided that you ensure that this notice is replicated
118733Sgeoffrey.blake@arm.com * unmodified and in its entirety in all distributions of the software,
128733Sgeoffrey.blake@arm.com * modified or unmodified, in source code or in binary form.
138733Sgeoffrey.blake@arm.com *
142332SN/A * Copyright (c) 2006 The Regents of The University of Michigan
152315SN/A * All rights reserved.
162315SN/A *
172315SN/A * Redistribution and use in source and binary forms, with or without
182315SN/A * modification, are permitted provided that the following conditions are
192315SN/A * met: redistributions of source code must retain the above copyright
202315SN/A * notice, this list of conditions and the following disclaimer;
212315SN/A * redistributions in binary form must reproduce the above copyright
222315SN/A * notice, this list of conditions and the following disclaimer in the
232315SN/A * documentation and/or other materials provided with the distribution;
242315SN/A * neither the name of the copyright holders nor the names of its
252315SN/A * contributors may be used to endorse or promote products derived from
262315SN/A * this software without specific prior written permission.
272315SN/A *
282315SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
292315SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
302315SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
312315SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
322315SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
332315SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
342315SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
352315SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
362315SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
372315SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
382315SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
392689Sktlim@umich.edu *
402689Sktlim@umich.edu * Authors: Kevin Lim
412315SN/A */
422315SN/A
432315SN/A#ifndef __CPU_CHECKER_CPU_HH__
442315SN/A#define __CPU_CHECKER_CPU_HH__
452315SN/A
462315SN/A#include <list>
478229Snate@binkert.org#include <map>
482315SN/A#include <queue>
492315SN/A
502669Sktlim@umich.edu#include "arch/types.hh"
512315SN/A#include "base/statistics.hh"
522315SN/A#include "cpu/base.hh"
532315SN/A#include "cpu/base_dyn_inst.hh"
548229Snate@binkert.org#include "cpu/pc_event.hh"
552683Sktlim@umich.edu#include "cpu/simple_thread.hh"
562315SN/A#include "cpu/static_inst.hh"
578733Sgeoffrey.blake@arm.com#include "debug/Checker.hh"
588733Sgeoffrey.blake@arm.com#include "params/CheckerCPU.hh"
592315SN/A#include "sim/eventq.hh"
602315SN/A
612315SN/A// forward declarations
623468Sgblack@eecs.umich.edunamespace TheISA
633468Sgblack@eecs.umich.edu{
646022Sgblack@eecs.umich.edu    class TLB;
653468Sgblack@eecs.umich.edu}
662315SN/A
672315SN/Atemplate <class>
682315SN/Aclass BaseDynInst;
692680Sktlim@umich.educlass ThreadContext;
702669Sktlim@umich.educlass Request;
712315SN/A
722350SN/A/**
732350SN/A * CheckerCPU class.  Dynamically verifies instructions as they are
742350SN/A * completed by making sure that the instruction and its results match
752350SN/A * the independent execution of the benchmark inside the checker.  The
762350SN/A * checker verifies instructions in order, regardless of the order in
772350SN/A * which instructions complete.  There are certain results that can
782350SN/A * not be verified, specifically the result of a store conditional or
792350SN/A * the values of uncached accesses.  In these cases, and with
802350SN/A * instructions marked as "IsUnverifiable", the checker assumes that
812350SN/A * the value from the main CPU's execution is correct and simply
822680Sktlim@umich.edu * copies that value.  It provides a CheckerThreadContext (see
832683Sktlim@umich.edu * checker/thread_context.hh) that provides hooks for updating the
842680Sktlim@umich.edu * Checker's state through any ThreadContext accesses.  This allows the
852350SN/A * checker to be able to correctly verify instructions, even with
862680Sktlim@umich.edu * external accesses to the ThreadContext that change state.
872350SN/A */
882315SN/Aclass CheckerCPU : public BaseCPU
892315SN/A{
902315SN/A  protected:
912315SN/A    typedef TheISA::MachInst MachInst;
922669Sktlim@umich.edu    typedef TheISA::FloatReg FloatReg;
932669Sktlim@umich.edu    typedef TheISA::FloatRegBits FloatRegBits;
942315SN/A    typedef TheISA::MiscReg MiscReg;
958832SAli.Saidi@ARM.com
968832SAli.Saidi@ARM.com    /** id attached to all issued requests */
978832SAli.Saidi@ARM.com    MasterID masterId;
982315SN/A  public:
992315SN/A    virtual void init();
1002315SN/A
1015529Snate@binkert.org    typedef CheckerCPUParams Params;
1022315SN/A    CheckerCPU(Params *p);
1032315SN/A    virtual ~CheckerCPU();
1042315SN/A
1052315SN/A    void setSystem(System *system);
1062315SN/A
1078887Sgeoffrey.blake@arm.com    void setIcachePort(CpuPort *icache_port);
1082679Sktlim@umich.edu
1098887Sgeoffrey.blake@arm.com    void setDcachePort(CpuPort *dcache_port);
1102679Sktlim@umich.edu
1118887Sgeoffrey.blake@arm.com    CpuPort &getDataPort()
1128887Sgeoffrey.blake@arm.com    {
1139176Sandreas.hansson@arm.com        // the checker does not have ports on its own so return the
1149176Sandreas.hansson@arm.com        // data port of the actual CPU core
1159176Sandreas.hansson@arm.com        assert(dcachePort);
1168887Sgeoffrey.blake@arm.com        return *dcachePort;
1178887Sgeoffrey.blake@arm.com    }
1188887Sgeoffrey.blake@arm.com
1198887Sgeoffrey.blake@arm.com    CpuPort &getInstPort()
1208887Sgeoffrey.blake@arm.com    {
1219176Sandreas.hansson@arm.com        // the checker does not have ports on its own so return the
1229176Sandreas.hansson@arm.com        // data port of the actual CPU core
1239176Sandreas.hansson@arm.com        assert(icachePort);
1248887Sgeoffrey.blake@arm.com        return *icachePort;
1258887Sgeoffrey.blake@arm.com    }
1262679Sktlim@umich.edu
1279176Sandreas.hansson@arm.com  protected:
1289176Sandreas.hansson@arm.com
1299176Sandreas.hansson@arm.com    std::vector<Process*> workload;
1309176Sandreas.hansson@arm.com
1319176Sandreas.hansson@arm.com    System *systemPtr;
1329176Sandreas.hansson@arm.com
1339176Sandreas.hansson@arm.com    CpuPort *icachePort;
1349176Sandreas.hansson@arm.com    CpuPort *dcachePort;
1352315SN/A
1362680Sktlim@umich.edu    ThreadContext *tc;
1372315SN/A
1386022Sgblack@eecs.umich.edu    TheISA::TLB *itb;
1396022Sgblack@eecs.umich.edu    TheISA::TLB *dtb;
1402315SN/A
1412315SN/A    Addr dbg_vtophys(Addr addr);
1422315SN/A
1432315SN/A    union Result {
1442315SN/A        uint64_t integer;
1452315SN/A        double dbl;
1468733Sgeoffrey.blake@arm.com        void set(uint64_t i) { integer = i; }
1478733Sgeoffrey.blake@arm.com        void set(double d) { dbl = d; }
1488733Sgeoffrey.blake@arm.com        void get(uint64_t& i) { i = integer; }
1498733Sgeoffrey.blake@arm.com        void get(double& d) { d = dbl; }
1502315SN/A    };
1512315SN/A
1528733Sgeoffrey.blake@arm.com    // ISAs like ARM can have multiple destination registers to check,
1538733Sgeoffrey.blake@arm.com    // keep them all in a std::queue
1548733Sgeoffrey.blake@arm.com    std::queue<Result> result;
1552315SN/A
1562679Sktlim@umich.edu    // Pointer to the one memory request.
1572679Sktlim@umich.edu    RequestPtr memReq;
1582315SN/A
1592315SN/A    StaticInstPtr curStaticInst;
1608733Sgeoffrey.blake@arm.com    StaticInstPtr curMacroStaticInst;
1612315SN/A
1622315SN/A    // number of simulated instructions
1632315SN/A    Counter numInst;
1642315SN/A    Counter startNumInst;
1652315SN/A
1662315SN/A    std::queue<int> miscRegIdxs;
1672315SN/A
1689176Sandreas.hansson@arm.com  public:
1699176Sandreas.hansson@arm.com
1709176Sandreas.hansson@arm.com    // Primary thread being run.
1719176Sandreas.hansson@arm.com    SimpleThread *thread;
1729176Sandreas.hansson@arm.com
1738733Sgeoffrey.blake@arm.com    TheISA::TLB* getITBPtr() { return itb; }
1748733Sgeoffrey.blake@arm.com    TheISA::TLB* getDTBPtr() { return dtb; }
1758733Sgeoffrey.blake@arm.com
1768887Sgeoffrey.blake@arm.com    virtual Counter totalInsts() const
1778887Sgeoffrey.blake@arm.com    {
1788887Sgeoffrey.blake@arm.com        return 0;
1798887Sgeoffrey.blake@arm.com    }
1808887Sgeoffrey.blake@arm.com
1818887Sgeoffrey.blake@arm.com    virtual Counter totalOps() const
1822315SN/A    {
1832930Sktlim@umich.edu        return 0;
1842315SN/A    }
1852315SN/A
1862315SN/A    // number of simulated loads
1872315SN/A    Counter numLoad;
1882315SN/A    Counter startNumLoad;
1892315SN/A
1902315SN/A    virtual void serialize(std::ostream &os);
1912315SN/A    virtual void unserialize(Checkpoint *cp, const std::string &section);
1922315SN/A
1932315SN/A    // These functions are only used in CPU models that split
1942315SN/A    // effective address computation from the actual memory access.
1952315SN/A    void setEA(Addr EA) { panic("SimpleCPU::setEA() not implemented\n"); }
1965543Ssaidi@eecs.umich.edu    Addr getEA()        { panic("SimpleCPU::getEA() not implemented\n"); }
1972315SN/A
1982315SN/A    // The register accessor methods provide the index of the
1992315SN/A    // instruction's operand (e.g., 0 or 1), not the architectural
2002315SN/A    // register index, to simplify the implementation of register
2012315SN/A    // renaming.  We find the architectural register index by indexing
2022315SN/A    // into the instruction's own operand index table.  Note that a
2032315SN/A    // raw pointer to the StaticInst is provided instead of a
2042315SN/A    // ref-counted StaticInstPtr to redice overhead.  This is fine as
2052315SN/A    // long as these methods don't copy the pointer into any long-term
2062315SN/A    // storage (which is pretty hard to imagine they would have reason
2072315SN/A    // to do).
2082315SN/A
2093735Sstever@eecs.umich.edu    uint64_t readIntRegOperand(const StaticInst *si, int idx)
2102315SN/A    {
2112683Sktlim@umich.edu        return thread->readIntReg(si->srcRegIdx(idx));
2122315SN/A    }
2132315SN/A
2143735Sstever@eecs.umich.edu    FloatReg readFloatRegOperand(const StaticInst *si, int idx)
2152315SN/A    {
2162315SN/A        int reg_idx = si->srcRegIdx(idx) - TheISA::FP_Base_DepTag;
2172683Sktlim@umich.edu        return thread->readFloatReg(reg_idx);
2182315SN/A    }
2192315SN/A
2203735Sstever@eecs.umich.edu    FloatRegBits readFloatRegOperandBits(const StaticInst *si, int idx)
2212669Sktlim@umich.edu    {
2222669Sktlim@umich.edu        int reg_idx = si->srcRegIdx(idx) - TheISA::FP_Base_DepTag;
2232683Sktlim@umich.edu        return thread->readFloatRegBits(reg_idx);
2242315SN/A    }
2252315SN/A
2268733Sgeoffrey.blake@arm.com    template <class T>
2278733Sgeoffrey.blake@arm.com    void setResult(T t)
2288733Sgeoffrey.blake@arm.com    {
2298733Sgeoffrey.blake@arm.com        Result instRes;
2308733Sgeoffrey.blake@arm.com        instRes.set(t);
2318733Sgeoffrey.blake@arm.com        result.push(instRes);
2328733Sgeoffrey.blake@arm.com    }
2338733Sgeoffrey.blake@arm.com
2343735Sstever@eecs.umich.edu    void setIntRegOperand(const StaticInst *si, int idx, uint64_t val)
2352315SN/A    {
2362683Sktlim@umich.edu        thread->setIntReg(si->destRegIdx(idx), val);
2378733Sgeoffrey.blake@arm.com        setResult<uint64_t>(val);
2382315SN/A    }
2392315SN/A
2403735Sstever@eecs.umich.edu    void setFloatRegOperand(const StaticInst *si, int idx, FloatReg val)
2412669Sktlim@umich.edu    {
2422669Sktlim@umich.edu        int reg_idx = si->destRegIdx(idx) - TheISA::FP_Base_DepTag;
2432683Sktlim@umich.edu        thread->setFloatReg(reg_idx, val);
2448733Sgeoffrey.blake@arm.com        setResult<double>(val);
2452315SN/A    }
2462315SN/A
2473735Sstever@eecs.umich.edu    void setFloatRegOperandBits(const StaticInst *si, int idx,
2483735Sstever@eecs.umich.edu                                FloatRegBits val)
2492315SN/A    {
2502315SN/A        int reg_idx = si->destRegIdx(idx) - TheISA::FP_Base_DepTag;
2512683Sktlim@umich.edu        thread->setFloatRegBits(reg_idx, val);
2528733Sgeoffrey.blake@arm.com        setResult<uint64_t>(val);
2532315SN/A    }
2542315SN/A
2558733Sgeoffrey.blake@arm.com    bool readPredicate() { return thread->readPredicate(); }
2568733Sgeoffrey.blake@arm.com    void setPredicate(bool val)
2578733Sgeoffrey.blake@arm.com    {
2588733Sgeoffrey.blake@arm.com        thread->setPredicate(val);
2598733Sgeoffrey.blake@arm.com    }
2602669Sktlim@umich.edu
2618733Sgeoffrey.blake@arm.com    TheISA::PCState pcState() { return thread->pcState(); }
2628733Sgeoffrey.blake@arm.com    void pcState(const TheISA::PCState &val)
2638733Sgeoffrey.blake@arm.com    {
2648733Sgeoffrey.blake@arm.com        DPRINTF(Checker, "Changing PC to %s, old PC %s.\n",
2658733Sgeoffrey.blake@arm.com                         val, thread->pcState());
2668733Sgeoffrey.blake@arm.com        thread->pcState(val);
2678733Sgeoffrey.blake@arm.com    }
2688733Sgeoffrey.blake@arm.com    Addr instAddr() { return thread->instAddr(); }
2698733Sgeoffrey.blake@arm.com    Addr nextInstAddr() { return thread->nextInstAddr(); }
2708733Sgeoffrey.blake@arm.com    MicroPC microPC() { return thread->microPC(); }
2718733Sgeoffrey.blake@arm.com    //////////////////////////////////////////
2722315SN/A
2734172Ssaidi@eecs.umich.edu    MiscReg readMiscRegNoEffect(int misc_reg)
2744172Ssaidi@eecs.umich.edu    {
2754172Ssaidi@eecs.umich.edu        return thread->readMiscRegNoEffect(misc_reg);
2764172Ssaidi@eecs.umich.edu    }
2774172Ssaidi@eecs.umich.edu
2782315SN/A    MiscReg readMiscReg(int misc_reg)
2792315SN/A    {
2802683Sktlim@umich.edu        return thread->readMiscReg(misc_reg);
2812315SN/A    }
2822315SN/A
2834172Ssaidi@eecs.umich.edu    void setMiscRegNoEffect(int misc_reg, const MiscReg &val)
2842315SN/A    {
2854172Ssaidi@eecs.umich.edu        miscRegIdxs.push(misc_reg);
2864172Ssaidi@eecs.umich.edu        return thread->setMiscRegNoEffect(misc_reg, val);
2872315SN/A    }
2882315SN/A
2893468Sgblack@eecs.umich.edu    void setMiscReg(int misc_reg, const MiscReg &val)
2902315SN/A    {
2912315SN/A        miscRegIdxs.push(misc_reg);
2922683Sktlim@umich.edu        return thread->setMiscReg(misc_reg, val);
2932315SN/A    }
2942315SN/A
2958733Sgeoffrey.blake@arm.com    MiscReg readMiscRegOperand(const StaticInst *si, int idx)
2968733Sgeoffrey.blake@arm.com    {
2978733Sgeoffrey.blake@arm.com        int reg_idx = si->srcRegIdx(idx) - TheISA::Ctrl_Base_DepTag;
2988733Sgeoffrey.blake@arm.com        return thread->readMiscReg(reg_idx);
2998733Sgeoffrey.blake@arm.com    }
3008733Sgeoffrey.blake@arm.com
3018733Sgeoffrey.blake@arm.com    void setMiscRegOperand(
3028733Sgeoffrey.blake@arm.com            const StaticInst *si, int idx, const MiscReg &val)
3038733Sgeoffrey.blake@arm.com    {
3048733Sgeoffrey.blake@arm.com        int reg_idx = si->destRegIdx(idx) - TheISA::Ctrl_Base_DepTag;
3058733Sgeoffrey.blake@arm.com        return thread->setMiscReg(reg_idx, val);
3068733Sgeoffrey.blake@arm.com    }
3078888Sgeoffrey.blake@arm.com
3088888Sgeoffrey.blake@arm.com#if THE_ISA == MIPS_ISA
3098888Sgeoffrey.blake@arm.com    uint64_t readRegOtherThread(int misc_reg)
3108888Sgeoffrey.blake@arm.com    {
3118888Sgeoffrey.blake@arm.com        panic("MIPS MT not defined for CheckerCPU.\n");
3128888Sgeoffrey.blake@arm.com        return 0;
3138888Sgeoffrey.blake@arm.com    }
3148888Sgeoffrey.blake@arm.com
3158888Sgeoffrey.blake@arm.com    void setRegOtherThread(int misc_reg, const TheISA::MiscReg &val)
3168888Sgeoffrey.blake@arm.com    {
3178888Sgeoffrey.blake@arm.com        panic("MIPS MT not defined for CheckerCPU.\n");
3188888Sgeoffrey.blake@arm.com    }
3198888Sgeoffrey.blake@arm.com#endif
3208888Sgeoffrey.blake@arm.com
3218733Sgeoffrey.blake@arm.com    /////////////////////////////////////////
3228733Sgeoffrey.blake@arm.com
3238733Sgeoffrey.blake@arm.com    void recordPCChange(const TheISA::PCState &val)
3248733Sgeoffrey.blake@arm.com    {
3258733Sgeoffrey.blake@arm.com       changedPC = true;
3268733Sgeoffrey.blake@arm.com       newPCState = val;
3278733Sgeoffrey.blake@arm.com    }
3282315SN/A
3295358Sgblack@eecs.umich.edu    void demapPage(Addr vaddr, uint64_t asn)
3305358Sgblack@eecs.umich.edu    {
3315358Sgblack@eecs.umich.edu        this->itb->demapPage(vaddr, asn);
3325358Sgblack@eecs.umich.edu        this->dtb->demapPage(vaddr, asn);
3335358Sgblack@eecs.umich.edu    }
3345358Sgblack@eecs.umich.edu
3355358Sgblack@eecs.umich.edu    void demapInstPage(Addr vaddr, uint64_t asn)
3365358Sgblack@eecs.umich.edu    {
3375358Sgblack@eecs.umich.edu        this->itb->demapPage(vaddr, asn);
3385358Sgblack@eecs.umich.edu    }
3395358Sgblack@eecs.umich.edu
3405358Sgblack@eecs.umich.edu    void demapDataPage(Addr vaddr, uint64_t asn)
3415358Sgblack@eecs.umich.edu    {
3425358Sgblack@eecs.umich.edu        this->dtb->demapPage(vaddr, asn);
3435358Sgblack@eecs.umich.edu    }
3445358Sgblack@eecs.umich.edu
3458733Sgeoffrey.blake@arm.com    Fault readMem(Addr addr, uint8_t *data, unsigned size, unsigned flags);
3468733Sgeoffrey.blake@arm.com    Fault writeMem(uint8_t *data, unsigned size,
3478733Sgeoffrey.blake@arm.com                   Addr addr, unsigned flags, uint64_t *res);
3488733Sgeoffrey.blake@arm.com
3498733Sgeoffrey.blake@arm.com    void setStCondFailures(unsigned sc_failures)
3508733Sgeoffrey.blake@arm.com    {}
3518733Sgeoffrey.blake@arm.com    /////////////////////////////////////////////////////
3528733Sgeoffrey.blake@arm.com
3535702Ssaidi@eecs.umich.edu    Fault hwrei() { return thread->hwrei(); }
3545702Ssaidi@eecs.umich.edu    bool simPalCheck(int palFunc) { return thread->simPalCheck(palFunc); }
3558733Sgeoffrey.blake@arm.com    void wakeup() { }
3562315SN/A    // Assume that the normal CPU's call to syscall was successful.
3572332SN/A    // The checker's state would have already been updated by the syscall.
3582669Sktlim@umich.edu    void syscall(uint64_t callnum) { }
3592315SN/A
3602315SN/A    void handleError()
3612315SN/A    {
3622315SN/A        if (exitOnError)
3632732Sktlim@umich.edu            dumpAndExit();
3642315SN/A    }
3652732Sktlim@umich.edu
3668733Sgeoffrey.blake@arm.com    bool checkFlags(Request *unverified_req, Addr vAddr,
3678733Sgeoffrey.blake@arm.com                    Addr pAddr, int flags);
3682315SN/A
3692732Sktlim@umich.edu    void dumpAndExit();
3702732Sktlim@umich.edu
3712680Sktlim@umich.edu    ThreadContext *tcBase() { return tc; }
3722683Sktlim@umich.edu    SimpleThread *threadBase() { return thread; }
3732315SN/A
3742315SN/A    Result unverifiedResult;
3752669Sktlim@umich.edu    Request *unverifiedReq;
3762679Sktlim@umich.edu    uint8_t *unverifiedMemData;
3772315SN/A
3782315SN/A    bool changedPC;
3792315SN/A    bool willChangePC;
3808733Sgeoffrey.blake@arm.com    TheISA::PCState newPCState;
3812315SN/A    bool changedNextPC;
3822315SN/A    bool exitOnError;
3832354SN/A    bool updateOnError;
3842732Sktlim@umich.edu    bool warnOnlyOnLoadError;
3852315SN/A
3862315SN/A    InstSeqNum youngestSN;
3872315SN/A};
3882315SN/A
3892350SN/A/**
3902350SN/A * Templated Checker class.  This Checker class is templated on the
3912350SN/A * DynInstPtr of the instruction type that will be verified.  Proper
3922350SN/A * template instantiations of the Checker must be placed at the bottom
3932350SN/A * of checker/cpu.cc.
3942350SN/A */
3958733Sgeoffrey.blake@arm.comtemplate <class Impl>
3962315SN/Aclass Checker : public CheckerCPU
3972315SN/A{
3988733Sgeoffrey.blake@arm.com  private:
3998733Sgeoffrey.blake@arm.com    typedef typename Impl::DynInstPtr DynInstPtr;
4008733Sgeoffrey.blake@arm.com
4012315SN/A  public:
4022315SN/A    Checker(Params *p)
4039023Sgblack@eecs.umich.edu        : CheckerCPU(p), updateThisCycle(false), unverifiedInst(NULL)
4042315SN/A    { }
4052315SN/A
4062840Sktlim@umich.edu    void switchOut();
4072315SN/A    void takeOverFrom(BaseCPU *oldCPU);
4082315SN/A
4098733Sgeoffrey.blake@arm.com    void advancePC(Fault fault);
4108733Sgeoffrey.blake@arm.com
4112732Sktlim@umich.edu    void verify(DynInstPtr &inst);
4122315SN/A
4132315SN/A    void validateInst(DynInstPtr &inst);
4142315SN/A    void validateExecution(DynInstPtr &inst);
4152315SN/A    void validateState();
4162315SN/A
4178733Sgeoffrey.blake@arm.com    void copyResult(DynInstPtr &inst, uint64_t mismatch_val, int start_idx);
4188733Sgeoffrey.blake@arm.com    void handlePendingInt();
4192732Sktlim@umich.edu
4202732Sktlim@umich.edu  private:
4212732Sktlim@umich.edu    void handleError(DynInstPtr &inst)
4222732Sktlim@umich.edu    {
4232360SN/A        if (exitOnError) {
4242732Sktlim@umich.edu            dumpAndExit(inst);
4252360SN/A        } else if (updateOnError) {
4262354SN/A            updateThisCycle = true;
4272360SN/A        }
4282732Sktlim@umich.edu    }
4292732Sktlim@umich.edu
4302732Sktlim@umich.edu    void dumpAndExit(DynInstPtr &inst);
4312732Sktlim@umich.edu
4322354SN/A    bool updateThisCycle;
4332354SN/A
4342354SN/A    DynInstPtr unverifiedInst;
4352354SN/A
4362315SN/A    std::list<DynInstPtr> instList;
4372315SN/A    typedef typename std::list<DynInstPtr>::iterator InstListIt;
4382315SN/A    void dumpInsts();
4392315SN/A};
4402315SN/A
4412315SN/A#endif // __CPU_CHECKER_CPU_HH__
442