base.cc revision 8832
12SN/A/*
28733Sgeoffrey.blake@arm.com * Copyright (c) 2010-2011 ARM Limited
37338SAli.Saidi@ARM.com * All rights reserved
47338SAli.Saidi@ARM.com *
57338SAli.Saidi@ARM.com * The license below extends only to copyright in the software and shall
67338SAli.Saidi@ARM.com * not be construed as granting a license to any other intellectual
77338SAli.Saidi@ARM.com * property including but not limited to intellectual property relating
87338SAli.Saidi@ARM.com * to a hardware implementation of the functionality of the software
97338SAli.Saidi@ARM.com * licensed hereunder.  You may use the software subject to the license
107338SAli.Saidi@ARM.com * terms below provided that you ensure that this notice is replicated
117338SAli.Saidi@ARM.com * unmodified and in its entirety in all distributions of the software,
127338SAli.Saidi@ARM.com * modified or unmodified, in source code or in binary form.
137338SAli.Saidi@ARM.com *
141762SN/A * Copyright (c) 2002-2005 The Regents of The University of Michigan
152SN/A * All rights reserved.
162SN/A *
172SN/A * Redistribution and use in source and binary forms, with or without
182SN/A * modification, are permitted provided that the following conditions are
192SN/A * met: redistributions of source code must retain the above copyright
202SN/A * notice, this list of conditions and the following disclaimer;
212SN/A * redistributions in binary form must reproduce the above copyright
222SN/A * notice, this list of conditions and the following disclaimer in the
232SN/A * documentation and/or other materials provided with the distribution;
242SN/A * neither the name of the copyright holders nor the names of its
252SN/A * contributors may be used to endorse or promote products derived from
262SN/A * this software without specific prior written permission.
272SN/A *
282SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
292SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
302SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
312SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
322SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
332SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
342SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
352SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
362SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
372SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
382SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
392665Ssaidi@eecs.umich.edu *
402665Ssaidi@eecs.umich.edu * Authors: Steve Reinhardt
412SN/A */
422SN/A
438779Sgblack@eecs.umich.edu#include "arch/kernel_stats.hh"
448779Sgblack@eecs.umich.edu#include "arch/stacktrace.hh"
458779Sgblack@eecs.umich.edu#include "arch/tlb.hh"
462439SN/A#include "arch/utility.hh"
478779Sgblack@eecs.umich.edu#include "arch/vtophys.hh"
488229Snate@binkert.org#include "base/loader/symtab.hh"
496216Snate@binkert.org#include "base/cp_annotate.hh"
50146SN/A#include "base/cprintf.hh"
51146SN/A#include "base/inifile.hh"
52146SN/A#include "base/misc.hh"
53146SN/A#include "base/pollevent.hh"
54146SN/A#include "base/range.hh"
55146SN/A#include "base/trace.hh"
566216Snate@binkert.org#include "base/types.hh"
576658Snate@binkert.org#include "config/the_isa.hh"
588733Sgeoffrey.blake@arm.com#include "config/use_checker.hh"
598229Snate@binkert.org#include "cpu/simple/base.hh"
601717SN/A#include "cpu/base.hh"
61146SN/A#include "cpu/exetrace.hh"
621977SN/A#include "cpu/profile.hh"
632683Sktlim@umich.edu#include "cpu/simple_thread.hh"
641717SN/A#include "cpu/smt.hh"
65146SN/A#include "cpu/static_inst.hh"
662683Sktlim@umich.edu#include "cpu/thread_context.hh"
678232Snate@binkert.org#include "debug/Decode.hh"
688232Snate@binkert.org#include "debug/Fetch.hh"
698232Snate@binkert.org#include "debug/Quiesce.hh"
708779Sgblack@eecs.umich.edu#include "mem/mem_object.hh"
713348Sbinkertn@umich.edu#include "mem/packet.hh"
726105Ssteve.reinhardt@amd.com#include "mem/request.hh"
736216Snate@binkert.org#include "params/BaseSimpleCPU.hh"
742036SN/A#include "sim/byteswap.hh"
75146SN/A#include "sim/debug.hh"
768817Sgblack@eecs.umich.edu#include "sim/faults.hh"
778793Sgblack@eecs.umich.edu#include "sim/full_system.hh"
7856SN/A#include "sim/sim_events.hh"
7956SN/A#include "sim/sim_object.hh"
80695SN/A#include "sim/stats.hh"
812901Ssaidi@eecs.umich.edu#include "sim/system.hh"
822SN/A
838733Sgeoffrey.blake@arm.com#if USE_CHECKER
848733Sgeoffrey.blake@arm.com#include "cpu/checker/cpu.hh"
858733Sgeoffrey.blake@arm.com#include "cpu/checker/thread_context.hh"
868733Sgeoffrey.blake@arm.com#endif
878733Sgeoffrey.blake@arm.com
882SN/Ausing namespace std;
892449SN/Ausing namespace TheISA;
901355SN/A
915529Snate@binkert.orgBaseSimpleCPU::BaseSimpleCPU(BaseSimpleCPUParams *p)
924495Sacolyte@umich.edu    : BaseCPU(p), traceData(NULL), thread(NULL), predecoder(NULL)
93224SN/A{
948793Sgblack@eecs.umich.edu    if (FullSystem)
958793Sgblack@eecs.umich.edu        thread = new SimpleThread(this, 0, p->system, p->itb, p->dtb);
968793Sgblack@eecs.umich.edu    else
978820Sgblack@eecs.umich.edu        thread = new SimpleThread(this, /* thread_num */ 0, p->system,
988820Sgblack@eecs.umich.edu                p->workload[0], p->itb, p->dtb);
992SN/A
1006029Ssteve.reinhardt@amd.com    thread->setStatus(ThreadContext::Halted);
1012672Sktlim@umich.edu
1022683Sktlim@umich.edu    tc = thread->getTC();
1032SN/A
1048733Sgeoffrey.blake@arm.com#if USE_CHECKER
1058733Sgeoffrey.blake@arm.com    if (p->checker) {
1068733Sgeoffrey.blake@arm.com        BaseCPU *temp_checker = p->checker;
1078733Sgeoffrey.blake@arm.com        checker = dynamic_cast<CheckerCPU *>(temp_checker);
1088733Sgeoffrey.blake@arm.com        checker->setSystem(p->system);
1098733Sgeoffrey.blake@arm.com        // Manipulate thread context
1108733Sgeoffrey.blake@arm.com        ThreadContext *cpu_tc = tc;
1118733Sgeoffrey.blake@arm.com        tc = new CheckerThreadContext<ThreadContext>(cpu_tc, this->checker);
1128733Sgeoffrey.blake@arm.com    } else {
1138733Sgeoffrey.blake@arm.com        checker = NULL;
1148733Sgeoffrey.blake@arm.com    }
1158733Sgeoffrey.blake@arm.com#endif
1168733Sgeoffrey.blake@arm.com
1172SN/A    numInst = 0;
118334SN/A    startNumInst = 0;
119140SN/A    numLoad = 0;
120334SN/A    startNumLoad = 0;
1212SN/A    lastIcacheStall = 0;
1222SN/A    lastDcacheStall = 0;
1232SN/A
1242680Sktlim@umich.edu    threadContexts.push_back(tc);
1254377Sgblack@eecs.umich.edu
1265169Ssaidi@eecs.umich.edu
1274377Sgblack@eecs.umich.edu    fetchOffset = 0;
1284377Sgblack@eecs.umich.edu    stayAtPC = false;
1292SN/A}
1302SN/A
1312623SN/ABaseSimpleCPU::~BaseSimpleCPU()
1322SN/A{
1332SN/A}
1342SN/A
135180SN/Avoid
1368737Skoansin.tan@gmail.comBaseSimpleCPU::deallocateContext(ThreadID thread_num)
137393SN/A{
138393SN/A    // for now, these are equivalent
139393SN/A    suspendContext(thread_num);
140393SN/A}
141384SN/A
142384SN/A
143393SN/Avoid
1448737Skoansin.tan@gmail.comBaseSimpleCPU::haltContext(ThreadID thread_num)
145393SN/A{
146393SN/A    // for now, these are equivalent
147393SN/A    suspendContext(thread_num);
148393SN/A}
149384SN/A
150189SN/A
151189SN/Avoid
1522623SN/ABaseSimpleCPU::regStats()
1532SN/A{
154729SN/A    using namespace Stats;
155334SN/A
1562SN/A    BaseCPU::regStats();
1572SN/A
1582SN/A    numInsts
1592SN/A        .name(name() + ".num_insts")
1602SN/A        .desc("Number of instructions executed")
1612SN/A        ;
1622SN/A
1637897Shestness@cs.utexas.edu    numIntAluAccesses
1647897Shestness@cs.utexas.edu        .name(name() + ".num_int_alu_accesses")
1657897Shestness@cs.utexas.edu        .desc("Number of integer alu accesses")
1667897Shestness@cs.utexas.edu        ;
1677897Shestness@cs.utexas.edu
1687897Shestness@cs.utexas.edu    numFpAluAccesses
1697897Shestness@cs.utexas.edu        .name(name() + ".num_fp_alu_accesses")
1707897Shestness@cs.utexas.edu        .desc("Number of float alu accesses")
1717897Shestness@cs.utexas.edu        ;
1727897Shestness@cs.utexas.edu
1737897Shestness@cs.utexas.edu    numCallsReturns
1747897Shestness@cs.utexas.edu        .name(name() + ".num_func_calls")
1757897Shestness@cs.utexas.edu        .desc("number of times a function call or return occured")
1767897Shestness@cs.utexas.edu        ;
1777897Shestness@cs.utexas.edu
1787897Shestness@cs.utexas.edu    numCondCtrlInsts
1797897Shestness@cs.utexas.edu        .name(name() + ".num_conditional_control_insts")
1807897Shestness@cs.utexas.edu        .desc("number of instructions that are conditional controls")
1817897Shestness@cs.utexas.edu        ;
1827897Shestness@cs.utexas.edu
1837897Shestness@cs.utexas.edu    numIntInsts
1847897Shestness@cs.utexas.edu        .name(name() + ".num_int_insts")
1857897Shestness@cs.utexas.edu        .desc("number of integer instructions")
1867897Shestness@cs.utexas.edu        ;
1877897Shestness@cs.utexas.edu
1887897Shestness@cs.utexas.edu    numFpInsts
1897897Shestness@cs.utexas.edu        .name(name() + ".num_fp_insts")
1907897Shestness@cs.utexas.edu        .desc("number of float instructions")
1917897Shestness@cs.utexas.edu        ;
1927897Shestness@cs.utexas.edu
1937897Shestness@cs.utexas.edu    numIntRegReads
1947897Shestness@cs.utexas.edu        .name(name() + ".num_int_register_reads")
1957897Shestness@cs.utexas.edu        .desc("number of times the integer registers were read")
1967897Shestness@cs.utexas.edu        ;
1977897Shestness@cs.utexas.edu
1987897Shestness@cs.utexas.edu    numIntRegWrites
1997897Shestness@cs.utexas.edu        .name(name() + ".num_int_register_writes")
2007897Shestness@cs.utexas.edu        .desc("number of times the integer registers were written")
2017897Shestness@cs.utexas.edu        ;
2027897Shestness@cs.utexas.edu
2037897Shestness@cs.utexas.edu    numFpRegReads
2047897Shestness@cs.utexas.edu        .name(name() + ".num_fp_register_reads")
2057897Shestness@cs.utexas.edu        .desc("number of times the floating registers were read")
2067897Shestness@cs.utexas.edu        ;
2077897Shestness@cs.utexas.edu
2087897Shestness@cs.utexas.edu    numFpRegWrites
2097897Shestness@cs.utexas.edu        .name(name() + ".num_fp_register_writes")
2107897Shestness@cs.utexas.edu        .desc("number of times the floating registers were written")
2117897Shestness@cs.utexas.edu        ;
2127897Shestness@cs.utexas.edu
2132SN/A    numMemRefs
2147897Shestness@cs.utexas.edu        .name(name()+".num_mem_refs")
2157897Shestness@cs.utexas.edu        .desc("number of memory refs")
2167897Shestness@cs.utexas.edu        ;
2177897Shestness@cs.utexas.edu
2187897Shestness@cs.utexas.edu    numStoreInsts
2197897Shestness@cs.utexas.edu        .name(name() + ".num_store_insts")
2207897Shestness@cs.utexas.edu        .desc("Number of store instructions")
2217897Shestness@cs.utexas.edu        ;
2227897Shestness@cs.utexas.edu
2237897Shestness@cs.utexas.edu    numLoadInsts
2247897Shestness@cs.utexas.edu        .name(name() + ".num_load_insts")
2257897Shestness@cs.utexas.edu        .desc("Number of load instructions")
2262SN/A        ;
2272SN/A
2281001SN/A    notIdleFraction
2291001SN/A        .name(name() + ".not_idle_fraction")
2301001SN/A        .desc("Percentage of non-idle cycles")
2311001SN/A        ;
2321001SN/A
2332SN/A    idleFraction
2342SN/A        .name(name() + ".idle_fraction")
2352SN/A        .desc("Percentage of idle cycles")
2362SN/A        ;
2372SN/A
2387897Shestness@cs.utexas.edu    numBusyCycles
2397897Shestness@cs.utexas.edu        .name(name() + ".num_busy_cycles")
2407897Shestness@cs.utexas.edu        .desc("Number of busy cycles")
2417897Shestness@cs.utexas.edu        ;
2427897Shestness@cs.utexas.edu
2437897Shestness@cs.utexas.edu    numIdleCycles
2447897Shestness@cs.utexas.edu        .name(name()+".num_idle_cycles")
2457897Shestness@cs.utexas.edu        .desc("Number of idle cycles")
2467897Shestness@cs.utexas.edu        ;
2477897Shestness@cs.utexas.edu
2482SN/A    icacheStallCycles
2492SN/A        .name(name() + ".icache_stall_cycles")
2502SN/A        .desc("ICache total stall cycles")
2512SN/A        .prereq(icacheStallCycles)
2522SN/A        ;
2532SN/A
2542SN/A    dcacheStallCycles
2552SN/A        .name(name() + ".dcache_stall_cycles")
2562SN/A        .desc("DCache total stall cycles")
2572SN/A        .prereq(dcacheStallCycles)
2582SN/A        ;
2592SN/A
2602390SN/A    icacheRetryCycles
2612390SN/A        .name(name() + ".icache_retry_cycles")
2622390SN/A        .desc("ICache total retry cycles")
2632390SN/A        .prereq(icacheRetryCycles)
2642390SN/A        ;
2652390SN/A
2662390SN/A    dcacheRetryCycles
2672390SN/A        .name(name() + ".dcache_retry_cycles")
2682390SN/A        .desc("DCache total retry cycles")
2692390SN/A        .prereq(dcacheRetryCycles)
2702390SN/A        ;
2712390SN/A
272385SN/A    idleFraction = constant(1.0) - notIdleFraction;
2737897Shestness@cs.utexas.edu    numIdleCycles = idleFraction * numCycles;
2747897Shestness@cs.utexas.edu    numBusyCycles = (notIdleFraction)*numCycles;
2752SN/A}
2762SN/A
2772SN/Avoid
2782623SN/ABaseSimpleCPU::resetStats()
279334SN/A{
2802361SN/A//    startNumInst = numInst;
2815496Ssaidi@eecs.umich.edu     notIdleFraction = (_status != Idle);
282334SN/A}
283334SN/A
284334SN/Avoid
2852623SN/ABaseSimpleCPU::serialize(ostream &os)
2862SN/A{
2875496Ssaidi@eecs.umich.edu    SERIALIZE_ENUM(_status);
288921SN/A    BaseCPU::serialize(os);
2892915Sktlim@umich.edu//    SERIALIZE_SCALAR(inst);
2902915Sktlim@umich.edu    nameOut(os, csprintf("%s.xc.0", name()));
2912683Sktlim@umich.edu    thread->serialize(os);
2922SN/A}
2932SN/A
2942SN/Avoid
2952623SN/ABaseSimpleCPU::unserialize(Checkpoint *cp, const string &section)
2962SN/A{
2975496Ssaidi@eecs.umich.edu    UNSERIALIZE_ENUM(_status);
298921SN/A    BaseCPU::unserialize(cp, section);
2992915Sktlim@umich.edu//    UNSERIALIZE_SCALAR(inst);
3002915Sktlim@umich.edu    thread->unserialize(cp, csprintf("%s.xc.0", section));
3012SN/A}
3022SN/A
3032SN/Avoid
3046221Snate@binkert.orgchange_thread_state(ThreadID tid, int activate, int priority)
3052SN/A{
3062SN/A}
3072SN/A
3082SN/AAddr
3092623SN/ABaseSimpleCPU::dbg_vtophys(Addr addr)
3102SN/A{
3112680Sktlim@umich.edu    return vtophys(tc, addr);
3122SN/A}
3132SN/A
3142SN/Avoid
3155807Snate@binkert.orgBaseSimpleCPU::wakeup()
3162SN/A{
3175807Snate@binkert.org    if (thread->status() != ThreadContext::Suspended)
3185807Snate@binkert.org        return;
3192SN/A
3205807Snate@binkert.org    DPRINTF(Quiesce,"Suspended Processor awoke\n");
3215807Snate@binkert.org    thread->activate();
3222SN/A}
3232SN/A
3242SN/Avoid
3252623SN/ABaseSimpleCPU::checkForInterrupts()
3262SN/A{
3275704Snate@binkert.org    if (checkInterrupts(tc)) {
3285647Sgblack@eecs.umich.edu        Fault interrupt = interrupts->getInterrupt(tc);
3292SN/A
3303520Sgblack@eecs.umich.edu        if (interrupt != NoFault) {
3317338SAli.Saidi@ARM.com            fetchOffset = 0;
3325647Sgblack@eecs.umich.edu            interrupts->updateIntrInfo(tc);
3333520Sgblack@eecs.umich.edu            interrupt->invoke(tc);
3347408Sgblack@eecs.umich.edu            predecoder.reset();
3352SN/A        }
3362SN/A    }
3372623SN/A}
3382SN/A
3392623SN/A
3405894Sgblack@eecs.umich.eduvoid
3412662Sstever@eecs.umich.eduBaseSimpleCPU::setupFetchRequest(Request *req)
3422623SN/A{
3437720Sgblack@eecs.umich.edu    Addr instAddr = thread->instAddr();
3444495Sacolyte@umich.edu
3452623SN/A    // set up memory request for instruction fetch
3467720Sgblack@eecs.umich.edu    DPRINTF(Fetch, "Fetch: PC:%08p\n", instAddr);
3472623SN/A
3487720Sgblack@eecs.umich.edu    Addr fetchPC = (instAddr & PCMask) + fetchOffset;
3498832SAli.Saidi@ARM.com    req->setVirt(0, fetchPC, sizeof(MachInst), Request::INST_FETCH, instMasterId(),
3508832SAli.Saidi@ARM.com            instAddr);
3512623SN/A}
3522623SN/A
3532623SN/A
3542623SN/Avoid
3552623SN/ABaseSimpleCPU::preExecute()
3562623SN/A{
3572SN/A    // maintain $r0 semantics
3582683Sktlim@umich.edu    thread->setIntReg(ZeroReg, 0);
3592427SN/A#if THE_ISA == ALPHA_ISA
3602683Sktlim@umich.edu    thread->setFloatReg(ZeroReg, 0.0);
3612427SN/A#endif // ALPHA_ISA
3622SN/A
3632623SN/A    // check for instruction-count-based events
3642623SN/A    comInstEventQueue[0]->serviceEvents(numInst);
3657897Shestness@cs.utexas.edu    system->instEventQueue.serviceEvents(system->totalNumInsts);
3662SN/A
3672623SN/A    // decode the instruction
3682623SN/A    inst = gtoh(inst);
3694377Sgblack@eecs.umich.edu
3707720Sgblack@eecs.umich.edu    TheISA::PCState pcState = thread->pcState();
3714377Sgblack@eecs.umich.edu
3727720Sgblack@eecs.umich.edu    if (isRomMicroPC(pcState.microPC())) {
3735665Sgblack@eecs.umich.edu        stayAtPC = false;
3747720Sgblack@eecs.umich.edu        curStaticInst = microcodeRom.fetchMicroop(pcState.microPC(),
3757720Sgblack@eecs.umich.edu                                                  curMacroStaticInst);
3765665Sgblack@eecs.umich.edu    } else if (!curMacroStaticInst) {
3775665Sgblack@eecs.umich.edu        //We're not in the middle of a macro instruction
3784181Sgblack@eecs.umich.edu        StaticInstPtr instPtr = NULL;
3794181Sgblack@eecs.umich.edu
3804181Sgblack@eecs.umich.edu        //Predecode, ie bundle up an ExtMachInst
3814182Sgblack@eecs.umich.edu        //This should go away once the constructor can be set up properly
3824182Sgblack@eecs.umich.edu        predecoder.setTC(thread->getTC());
3834182Sgblack@eecs.umich.edu        //If more fetch data is needed, pass it in.
3847720Sgblack@eecs.umich.edu        Addr fetchPC = (pcState.instAddr() & PCMask) + fetchOffset;
3854593Sgblack@eecs.umich.edu        //if(predecoder.needMoreBytes())
3867720Sgblack@eecs.umich.edu            predecoder.moreBytes(pcState, fetchPC, inst);
3874593Sgblack@eecs.umich.edu        //else
3884593Sgblack@eecs.umich.edu        //    predecoder.process();
3894377Sgblack@eecs.umich.edu
3904377Sgblack@eecs.umich.edu        //If an instruction is ready, decode it. Otherwise, we'll have to
3914377Sgblack@eecs.umich.edu        //fetch beyond the MachInst at the current pc.
3924377Sgblack@eecs.umich.edu        if (predecoder.extMachInstReady()) {
3934377Sgblack@eecs.umich.edu            stayAtPC = false;
3947720Sgblack@eecs.umich.edu            ExtMachInst machInst = predecoder.getExtMachInst(pcState);
3957720Sgblack@eecs.umich.edu            thread->pcState(pcState);
3968541Sgblack@eecs.umich.edu            instPtr = thread->decoder.decode(machInst, pcState.instAddr());
3974377Sgblack@eecs.umich.edu        } else {
3984377Sgblack@eecs.umich.edu            stayAtPC = true;
3994377Sgblack@eecs.umich.edu            fetchOffset += sizeof(MachInst);
4004377Sgblack@eecs.umich.edu        }
4014181Sgblack@eecs.umich.edu
4024181Sgblack@eecs.umich.edu        //If we decoded an instruction and it's microcoded, start pulling
4034181Sgblack@eecs.umich.edu        //out micro ops
4044539Sgblack@eecs.umich.edu        if (instPtr && instPtr->isMacroop()) {
4053276Sgblack@eecs.umich.edu            curMacroStaticInst = instPtr;
4067720Sgblack@eecs.umich.edu            curStaticInst = curMacroStaticInst->fetchMicroop(pcState.microPC());
4073280Sgblack@eecs.umich.edu        } else {
4083280Sgblack@eecs.umich.edu            curStaticInst = instPtr;
4093276Sgblack@eecs.umich.edu        }
4103276Sgblack@eecs.umich.edu    } else {
4113276Sgblack@eecs.umich.edu        //Read the next micro op from the macro op
4127720Sgblack@eecs.umich.edu        curStaticInst = curMacroStaticInst->fetchMicroop(pcState.microPC());
4133276Sgblack@eecs.umich.edu    }
4143276Sgblack@eecs.umich.edu
4154181Sgblack@eecs.umich.edu    //If we decoded an instruction this "tick", record information about it.
4164181Sgblack@eecs.umich.edu    if(curStaticInst)
4174181Sgblack@eecs.umich.edu    {
4184522Ssaidi@eecs.umich.edu#if TRACING_ON
4197823Ssteve.reinhardt@amd.com        traceData = tracer->getInstRecord(curTick(), tc,
4207720Sgblack@eecs.umich.edu                curStaticInst, thread->pcState(), curMacroStaticInst);
4212470SN/A
4224181Sgblack@eecs.umich.edu        DPRINTF(Decode,"Decode: Decoded %s instruction: 0x%x\n",
4234181Sgblack@eecs.umich.edu                curStaticInst->getName(), curStaticInst->machInst);
4244522Ssaidi@eecs.umich.edu#endif // TRACING_ON
4254181Sgblack@eecs.umich.edu    }
4262623SN/A}
4272623SN/A
4282623SN/Avoid
4292623SN/ABaseSimpleCPU::postExecute()
4302623SN/A{
4317720Sgblack@eecs.umich.edu    assert(curStaticInst);
4327720Sgblack@eecs.umich.edu
4337720Sgblack@eecs.umich.edu    TheISA::PCState pc = tc->pcState();
4347720Sgblack@eecs.umich.edu    Addr instAddr = pc.instAddr();
4358780Sgblack@eecs.umich.edu    if (FullSystem && thread->profile) {
4363577Sgblack@eecs.umich.edu        bool usermode = TheISA::inUserMode(tc);
4377720Sgblack@eecs.umich.edu        thread->profilePC = usermode ? 1 : instAddr;
4385086Sgblack@eecs.umich.edu        ProfileNode *node = thread->profile->consume(tc, curStaticInst);
4392623SN/A        if (node)
4402683Sktlim@umich.edu            thread->profileNode = node;
4412623SN/A    }
4422SN/A
4432623SN/A    if (curStaticInst->isMemRef()) {
4442623SN/A        numMemRefs++;
4452SN/A    }
4462SN/A
4472623SN/A    if (curStaticInst->isLoad()) {
4482623SN/A        ++numLoad;
4492623SN/A        comLoadEventQueue[0]->serviceEvents(numLoad);
4502623SN/A    }
4512SN/A
4525953Ssaidi@eecs.umich.edu    if (CPA::available()) {
4537720Sgblack@eecs.umich.edu        CPA::cpa()->swAutoBegin(tc, pc.nextInstAddr());
4545953Ssaidi@eecs.umich.edu    }
4555953Ssaidi@eecs.umich.edu
4567897Shestness@cs.utexas.edu    /* Power model statistics */
4577897Shestness@cs.utexas.edu    //integer alu accesses
4587897Shestness@cs.utexas.edu    if (curStaticInst->isInteger()){
4597897Shestness@cs.utexas.edu        numIntAluAccesses++;
4607897Shestness@cs.utexas.edu        numIntInsts++;
4617897Shestness@cs.utexas.edu    }
4627897Shestness@cs.utexas.edu
4637897Shestness@cs.utexas.edu    //float alu accesses
4647897Shestness@cs.utexas.edu    if (curStaticInst->isFloating()){
4657897Shestness@cs.utexas.edu        numFpAluAccesses++;
4667897Shestness@cs.utexas.edu        numFpInsts++;
4677897Shestness@cs.utexas.edu    }
4687897Shestness@cs.utexas.edu
4697897Shestness@cs.utexas.edu    //number of function calls/returns to get window accesses
4707897Shestness@cs.utexas.edu    if (curStaticInst->isCall() || curStaticInst->isReturn()){
4717897Shestness@cs.utexas.edu        numCallsReturns++;
4727897Shestness@cs.utexas.edu    }
4737897Shestness@cs.utexas.edu
4747897Shestness@cs.utexas.edu    //the number of branch predictions that will be made
4757897Shestness@cs.utexas.edu    if (curStaticInst->isCondCtrl()){
4767897Shestness@cs.utexas.edu        numCondCtrlInsts++;
4777897Shestness@cs.utexas.edu    }
4787897Shestness@cs.utexas.edu
4797897Shestness@cs.utexas.edu    //result bus acceses
4807897Shestness@cs.utexas.edu    if (curStaticInst->isLoad()){
4817897Shestness@cs.utexas.edu        numLoadInsts++;
4827897Shestness@cs.utexas.edu    }
4837897Shestness@cs.utexas.edu
4847897Shestness@cs.utexas.edu    if (curStaticInst->isStore()){
4857897Shestness@cs.utexas.edu        numStoreInsts++;
4867897Shestness@cs.utexas.edu    }
4877897Shestness@cs.utexas.edu    /* End power model statistics */
4887897Shestness@cs.utexas.edu
4898780Sgblack@eecs.umich.edu    if (FullSystem)
4908780Sgblack@eecs.umich.edu        traceFunctions(instAddr);
4912644Sstever@eecs.umich.edu
4922644Sstever@eecs.umich.edu    if (traceData) {
4934046Sbinkertn@umich.edu        traceData->dump();
4944046Sbinkertn@umich.edu        delete traceData;
4954046Sbinkertn@umich.edu        traceData = NULL;
4962644Sstever@eecs.umich.edu    }
4972623SN/A}
4982SN/A
4992SN/A
5002623SN/Avoid
5012623SN/ABaseSimpleCPU::advancePC(Fault fault)
5022623SN/A{
5034377Sgblack@eecs.umich.edu    //Since we're moving to a new pc, zero out the offset
5044377Sgblack@eecs.umich.edu    fetchOffset = 0;
5052090SN/A    if (fault != NoFault) {
5063905Ssaidi@eecs.umich.edu        curMacroStaticInst = StaticInst::nullStaticInstPtr;
5077678Sgblack@eecs.umich.edu        fault->invoke(tc, curStaticInst);
5085120Sgblack@eecs.umich.edu        predecoder.reset();
5094377Sgblack@eecs.umich.edu    } else {
5107720Sgblack@eecs.umich.edu        if (curStaticInst) {
5117720Sgblack@eecs.umich.edu            if (curStaticInst->isLastMicroop())
5127720Sgblack@eecs.umich.edu                curMacroStaticInst = StaticInst::nullStaticInstPtr;
5137720Sgblack@eecs.umich.edu            TheISA::PCState pcState = thread->pcState();
5147720Sgblack@eecs.umich.edu            TheISA::advancePC(pcState, curStaticInst);
5157720Sgblack@eecs.umich.edu            thread->pcState(pcState);
5163276Sgblack@eecs.umich.edu        }
5172SN/A    }
5182SN/A}
5192SN/A
5205250Sksewell@umich.edu/*Fault
5215222Sksewell@umich.eduBaseSimpleCPU::CacheOp(uint8_t Op, Addr EffAddr)
5225222Sksewell@umich.edu{
5235222Sksewell@umich.edu    // translate to physical address
5245222Sksewell@umich.edu    Fault fault = NoFault;
5255222Sksewell@umich.edu    int CacheID = Op & 0x3; // Lower 3 bits identify Cache
5265222Sksewell@umich.edu    int CacheOP = Op >> 2; // Upper 3 bits identify Cache Operation
5275222Sksewell@umich.edu    if(CacheID > 1)
5285222Sksewell@umich.edu      {
5295222Sksewell@umich.edu        warn("CacheOps not implemented for secondary/tertiary caches\n");
5305222Sksewell@umich.edu      }
5315222Sksewell@umich.edu    else
5325222Sksewell@umich.edu      {
5335222Sksewell@umich.edu        switch(CacheOP)
5345222Sksewell@umich.edu          { // Fill Packet Type
5355222Sksewell@umich.edu          case 0: warn("Invalidate Cache Op\n");
5365222Sksewell@umich.edu            break;
5375222Sksewell@umich.edu          case 1: warn("Index Load Tag Cache Op\n");
5385222Sksewell@umich.edu            break;
5395222Sksewell@umich.edu          case 2: warn("Index Store Tag Cache Op\n");
5405222Sksewell@umich.edu            break;
5415222Sksewell@umich.edu          case 4: warn("Hit Invalidate Cache Op\n");
5425222Sksewell@umich.edu            break;
5435222Sksewell@umich.edu          case 5: warn("Fill/Hit Writeback Invalidate Cache Op\n");
5445222Sksewell@umich.edu            break;
5455222Sksewell@umich.edu          case 6: warn("Hit Writeback\n");
5465222Sksewell@umich.edu            break;
5475222Sksewell@umich.edu          case 7: warn("Fetch & Lock Cache Op\n");
5485222Sksewell@umich.edu            break;
5495222Sksewell@umich.edu          default: warn("Unimplemented Cache Op\n");
5505222Sksewell@umich.edu          }
5515222Sksewell@umich.edu      }
5525222Sksewell@umich.edu    return fault;
5535250Sksewell@umich.edu}*/
554