base.cc revision 6029
12SN/A/*
21762SN/A * Copyright (c) 2002-2005 The Regents of The University of Michigan
32SN/A * All rights reserved.
42SN/A *
52SN/A * Redistribution and use in source and binary forms, with or without
62SN/A * modification, are permitted provided that the following conditions are
72SN/A * met: redistributions of source code must retain the above copyright
82SN/A * notice, this list of conditions and the following disclaimer;
92SN/A * redistributions in binary form must reproduce the above copyright
102SN/A * notice, this list of conditions and the following disclaimer in the
112SN/A * documentation and/or other materials provided with the distribution;
122SN/A * neither the name of the copyright holders nor the names of its
132SN/A * contributors may be used to endorse or promote products derived from
142SN/A * this software without specific prior written permission.
152SN/A *
162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * Authors: Steve Reinhardt
292SN/A */
302SN/A
312439SN/A#include "arch/utility.hh"
322984Sgblack@eecs.umich.edu#include "arch/faults.hh"
33146SN/A#include "base/cprintf.hh"
345953Ssaidi@eecs.umich.edu#include "base/cp_annotate.hh"
35146SN/A#include "base/inifile.hh"
36146SN/A#include "base/loader/symtab.hh"
37146SN/A#include "base/misc.hh"
38146SN/A#include "base/pollevent.hh"
39146SN/A#include "base/range.hh"
401717SN/A#include "base/stats/events.hh"
41146SN/A#include "base/trace.hh"
421717SN/A#include "cpu/base.hh"
43146SN/A#include "cpu/exetrace.hh"
441977SN/A#include "cpu/profile.hh"
452623SN/A#include "cpu/simple/base.hh"
462683Sktlim@umich.edu#include "cpu/simple_thread.hh"
471717SN/A#include "cpu/smt.hh"
48146SN/A#include "cpu/static_inst.hh"
492683Sktlim@umich.edu#include "cpu/thread_context.hh"
503348Sbinkertn@umich.edu#include "mem/packet.hh"
512036SN/A#include "sim/byteswap.hh"
52146SN/A#include "sim/debug.hh"
5356SN/A#include "sim/host.hh"
5456SN/A#include "sim/sim_events.hh"
5556SN/A#include "sim/sim_object.hh"
56695SN/A#include "sim/stats.hh"
572901Ssaidi@eecs.umich.edu#include "sim/system.hh"
582SN/A
591858SN/A#if FULL_SYSTEM
603565Sgblack@eecs.umich.edu#include "arch/kernel_stats.hh"
613565Sgblack@eecs.umich.edu#include "arch/stacktrace.hh"
622171SN/A#include "arch/tlb.hh"
632170SN/A#include "arch/vtophys.hh"
643562Sgblack@eecs.umich.edu#include "base/remote_gdb.hh"
65146SN/A#else // !FULL_SYSTEM
662462SN/A#include "mem/mem_object.hh"
67146SN/A#endif // FULL_SYSTEM
682SN/A
695529Snate@binkert.org#include "params/BaseSimpleCPU.hh"
705529Snate@binkert.org
712SN/Ausing namespace std;
722449SN/Ausing namespace TheISA;
731355SN/A
745529Snate@binkert.orgBaseSimpleCPU::BaseSimpleCPU(BaseSimpleCPUParams *p)
754495Sacolyte@umich.edu    : BaseCPU(p), traceData(NULL), thread(NULL), predecoder(NULL)
76224SN/A{
771858SN/A#if FULL_SYSTEM
782683Sktlim@umich.edu    thread = new SimpleThread(this, 0, p->system, p->itb, p->dtb);
792420SN/A#else
805529Snate@binkert.org    thread = new SimpleThread(this, /* thread_num */ 0, p->workload[0],
814997Sgblack@eecs.umich.edu            p->itb, p->dtb, /* asid */ 0);
822420SN/A#endif // !FULL_SYSTEM
832SN/A
846029Ssteve.reinhardt@amd.com    thread->setStatus(ThreadContext::Halted);
852672Sktlim@umich.edu
862683Sktlim@umich.edu    tc = thread->getTC();
872SN/A
882SN/A    numInst = 0;
89334SN/A    startNumInst = 0;
90140SN/A    numLoad = 0;
91334SN/A    startNumLoad = 0;
922SN/A    lastIcacheStall = 0;
932SN/A    lastDcacheStall = 0;
942SN/A
952680Sktlim@umich.edu    threadContexts.push_back(tc);
964377Sgblack@eecs.umich.edu
975169Ssaidi@eecs.umich.edu
984377Sgblack@eecs.umich.edu    fetchOffset = 0;
994377Sgblack@eecs.umich.edu    stayAtPC = false;
1002SN/A}
1012SN/A
1022623SN/ABaseSimpleCPU::~BaseSimpleCPU()
1032SN/A{
1042SN/A}
1052SN/A
106180SN/Avoid
1072623SN/ABaseSimpleCPU::deallocateContext(int thread_num)
108393SN/A{
109393SN/A    // for now, these are equivalent
110393SN/A    suspendContext(thread_num);
111393SN/A}
112384SN/A
113384SN/A
114393SN/Avoid
1152623SN/ABaseSimpleCPU::haltContext(int thread_num)
116393SN/A{
117393SN/A    // for now, these are equivalent
118393SN/A    suspendContext(thread_num);
119393SN/A}
120384SN/A
121189SN/A
122189SN/Avoid
1232623SN/ABaseSimpleCPU::regStats()
1242SN/A{
125729SN/A    using namespace Stats;
126334SN/A
1272SN/A    BaseCPU::regStats();
1282SN/A
1292SN/A    numInsts
1302SN/A        .name(name() + ".num_insts")
1312SN/A        .desc("Number of instructions executed")
1322SN/A        ;
1332SN/A
1342SN/A    numMemRefs
1352SN/A        .name(name() + ".num_refs")
1362SN/A        .desc("Number of memory references")
1372SN/A        ;
1382SN/A
1391001SN/A    notIdleFraction
1401001SN/A        .name(name() + ".not_idle_fraction")
1411001SN/A        .desc("Percentage of non-idle cycles")
1421001SN/A        ;
1431001SN/A
1442SN/A    idleFraction
1452SN/A        .name(name() + ".idle_fraction")
1462SN/A        .desc("Percentage of idle cycles")
1472SN/A        ;
1482SN/A
1492SN/A    icacheStallCycles
1502SN/A        .name(name() + ".icache_stall_cycles")
1512SN/A        .desc("ICache total stall cycles")
1522SN/A        .prereq(icacheStallCycles)
1532SN/A        ;
1542SN/A
1552SN/A    dcacheStallCycles
1562SN/A        .name(name() + ".dcache_stall_cycles")
1572SN/A        .desc("DCache total stall cycles")
1582SN/A        .prereq(dcacheStallCycles)
1592SN/A        ;
1602SN/A
1612390SN/A    icacheRetryCycles
1622390SN/A        .name(name() + ".icache_retry_cycles")
1632390SN/A        .desc("ICache total retry cycles")
1642390SN/A        .prereq(icacheRetryCycles)
1652390SN/A        ;
1662390SN/A
1672390SN/A    dcacheRetryCycles
1682390SN/A        .name(name() + ".dcache_retry_cycles")
1692390SN/A        .desc("DCache total retry cycles")
1702390SN/A        .prereq(dcacheRetryCycles)
1712390SN/A        ;
1722390SN/A
173385SN/A    idleFraction = constant(1.0) - notIdleFraction;
1742SN/A}
1752SN/A
1762SN/Avoid
1772623SN/ABaseSimpleCPU::resetStats()
178334SN/A{
1792361SN/A//    startNumInst = numInst;
1805496Ssaidi@eecs.umich.edu     notIdleFraction = (_status != Idle);
181334SN/A}
182334SN/A
183334SN/Avoid
1842623SN/ABaseSimpleCPU::serialize(ostream &os)
1852SN/A{
1865496Ssaidi@eecs.umich.edu    SERIALIZE_ENUM(_status);
187921SN/A    BaseCPU::serialize(os);
1882915Sktlim@umich.edu//    SERIALIZE_SCALAR(inst);
1892915Sktlim@umich.edu    nameOut(os, csprintf("%s.xc.0", name()));
1902683Sktlim@umich.edu    thread->serialize(os);
1912SN/A}
1922SN/A
1932SN/Avoid
1942623SN/ABaseSimpleCPU::unserialize(Checkpoint *cp, const string &section)
1952SN/A{
1965496Ssaidi@eecs.umich.edu    UNSERIALIZE_ENUM(_status);
197921SN/A    BaseCPU::unserialize(cp, section);
1982915Sktlim@umich.edu//    UNSERIALIZE_SCALAR(inst);
1992915Sktlim@umich.edu    thread->unserialize(cp, csprintf("%s.xc.0", section));
2002SN/A}
2012SN/A
2022SN/Avoid
2032SN/Achange_thread_state(int thread_number, int activate, int priority)
2042SN/A{
2052SN/A}
2062SN/A
207595SN/AFault
2082623SN/ABaseSimpleCPU::copySrcTranslate(Addr src)
209595SN/A{
2102390SN/A#if 0
2111080SN/A    static bool no_warn = true;
2121080SN/A    int blk_size = (dcacheInterface) ? dcacheInterface->getBlockSize() : 64;
2131080SN/A    // Only support block sizes of 64 atm.
2141080SN/A    assert(blk_size == 64);
2151080SN/A    int offset = src & (blk_size - 1);
2161080SN/A
2171080SN/A    // Make sure block doesn't span page
2181121SN/A    if (no_warn &&
2192107SN/A        (src & PageMask) != ((src + blk_size) & PageMask) &&
2201089SN/A        (src >> 40) != 0xfffffc) {
2211089SN/A        warn("Copied block source spans pages %x.", src);
2221080SN/A        no_warn = false;
2231080SN/A    }
2241080SN/A
2251080SN/A    memReq->reset(src & ~(blk_size - 1), blk_size);
226595SN/A
2272623SN/A    // translate to physical address
2282683Sktlim@umich.edu    Fault fault = thread->translateDataReadReq(req);
229595SN/A
2302090SN/A    if (fault == NoFault) {
2312683Sktlim@umich.edu        thread->copySrcAddr = src;
2322683Sktlim@umich.edu        thread->copySrcPhysAddr = memReq->paddr + offset;
233595SN/A    } else {
2342205SN/A        assert(!fault->isAlignmentFault());
2352205SN/A
2362683Sktlim@umich.edu        thread->copySrcAddr = 0;
2372683Sktlim@umich.edu        thread->copySrcPhysAddr = 0;
238595SN/A    }
239595SN/A    return fault;
2402390SN/A#else
2412423SN/A    return NoFault;
2422390SN/A#endif
243595SN/A}
244595SN/A
245595SN/AFault
2462623SN/ABaseSimpleCPU::copy(Addr dest)
247595SN/A{
2482390SN/A#if 0
2491080SN/A    static bool no_warn = true;
250595SN/A    int blk_size = (dcacheInterface) ? dcacheInterface->getBlockSize() : 64;
2511080SN/A    // Only support block sizes of 64 atm.
2521080SN/A    assert(blk_size == 64);
253595SN/A    uint8_t data[blk_size];
2542683Sktlim@umich.edu    //assert(thread->copySrcAddr);
2551080SN/A    int offset = dest & (blk_size - 1);
2561080SN/A
2571080SN/A    // Make sure block doesn't span page
2581121SN/A    if (no_warn &&
2592107SN/A        (dest & PageMask) != ((dest + blk_size) & PageMask) &&
2601089SN/A        (dest >> 40) != 0xfffffc) {
2611080SN/A        no_warn = false;
2621089SN/A        warn("Copied block destination spans pages %x. ", dest);
2631080SN/A    }
2641080SN/A
2651080SN/A    memReq->reset(dest & ~(blk_size -1), blk_size);
266595SN/A    // translate to physical address
2672683Sktlim@umich.edu    Fault fault = thread->translateDataWriteReq(req);
2681080SN/A
2692090SN/A    if (fault == NoFault) {
2701080SN/A        Addr dest_addr = memReq->paddr + offset;
271595SN/A        // Need to read straight from memory since we have more than 8 bytes.
2722683Sktlim@umich.edu        memReq->paddr = thread->copySrcPhysAddr;
2732683Sktlim@umich.edu        thread->mem->read(memReq, data);
274595SN/A        memReq->paddr = dest_addr;
2752683Sktlim@umich.edu        thread->mem->write(memReq, data);
2761098SN/A        if (dcacheInterface) {
2771098SN/A            memReq->cmd = Copy;
2781098SN/A            memReq->completionEvent = NULL;
2792683Sktlim@umich.edu            memReq->paddr = thread->copySrcPhysAddr;
2801098SN/A            memReq->dest = dest_addr;
2811098SN/A            memReq->size = 64;
2821098SN/A            memReq->time = curTick;
2832012SN/A            memReq->flags &= ~INST_READ;
2841098SN/A            dcacheInterface->access(memReq);
2851098SN/A        }
286595SN/A    }
2872205SN/A    else
2882205SN/A        assert(!fault->isAlignmentFault());
2892205SN/A
290595SN/A    return fault;
2912390SN/A#else
2922420SN/A    panic("copy not implemented");
2932423SN/A    return NoFault;
2942390SN/A#endif
295595SN/A}
296595SN/A
2971858SN/A#if FULL_SYSTEM
2982SN/AAddr
2992623SN/ABaseSimpleCPU::dbg_vtophys(Addr addr)
3002SN/A{
3012680Sktlim@umich.edu    return vtophys(tc, addr);
3022SN/A}
3032SN/A#endif // FULL_SYSTEM
3042SN/A
3051858SN/A#if FULL_SYSTEM
3062SN/Avoid
3075807Snate@binkert.orgBaseSimpleCPU::wakeup()
3082SN/A{
3095807Snate@binkert.org    if (thread->status() != ThreadContext::Suspended)
3105807Snate@binkert.org        return;
3112SN/A
3125807Snate@binkert.org    DPRINTF(Quiesce,"Suspended Processor awoke\n");
3135807Snate@binkert.org    thread->activate();
3142SN/A}
3152SN/A#endif // FULL_SYSTEM
3162SN/A
3172SN/Avoid
3182623SN/ABaseSimpleCPU::checkForInterrupts()
3192SN/A{
3201858SN/A#if FULL_SYSTEM
3215704Snate@binkert.org    if (checkInterrupts(tc)) {
3225647Sgblack@eecs.umich.edu        Fault interrupt = interrupts->getInterrupt(tc);
3232SN/A
3243520Sgblack@eecs.umich.edu        if (interrupt != NoFault) {
3255835Sgblack@eecs.umich.edu            predecoder.reset();
3265647Sgblack@eecs.umich.edu            interrupts->updateIntrInfo(tc);
3273520Sgblack@eecs.umich.edu            interrupt->invoke(tc);
3282SN/A        }
3292SN/A    }
3302SN/A#endif
3312623SN/A}
3322SN/A
3332623SN/A
3345894Sgblack@eecs.umich.eduvoid
3352662Sstever@eecs.umich.eduBaseSimpleCPU::setupFetchRequest(Request *req)
3362623SN/A{
3374514Ssaidi@eecs.umich.edu    Addr threadPC = thread->readPC();
3384495Sacolyte@umich.edu
3392623SN/A    // set up memory request for instruction fetch
3403093Sksewell@umich.edu#if ISA_HAS_DELAY_SLOT
3414495Sacolyte@umich.edu    DPRINTF(Fetch,"Fetch: PC:%08p NPC:%08p NNPC:%08p\n",threadPC,
3423093Sksewell@umich.edu            thread->readNextPC(),thread->readNextNPC());
3433093Sksewell@umich.edu#else
3444564Sgblack@eecs.umich.edu    DPRINTF(Fetch,"Fetch: PC:%08p NPC:%08p\n",threadPC,
3452741Sksewell@umich.edu            thread->readNextPC());
3462741Sksewell@umich.edu#endif
3472623SN/A
3484564Sgblack@eecs.umich.edu    Addr fetchPC = (threadPC & PCMask) + fetchOffset;
3494564Sgblack@eecs.umich.edu    req->setVirt(0, fetchPC, sizeof(MachInst), 0, threadPC);
3502623SN/A}
3512623SN/A
3522623SN/A
3532623SN/Avoid
3542623SN/ABaseSimpleCPU::preExecute()
3552623SN/A{
3562SN/A    // maintain $r0 semantics
3572683Sktlim@umich.edu    thread->setIntReg(ZeroReg, 0);
3582427SN/A#if THE_ISA == ALPHA_ISA
3592683Sktlim@umich.edu    thread->setFloatReg(ZeroReg, 0.0);
3602427SN/A#endif // ALPHA_ISA
3612SN/A
3622623SN/A    // check for instruction-count-based events
3632623SN/A    comInstEventQueue[0]->serviceEvents(numInst);
3642SN/A
3652623SN/A    // decode the instruction
3662623SN/A    inst = gtoh(inst);
3674377Sgblack@eecs.umich.edu
3685665Sgblack@eecs.umich.edu    MicroPC upc = thread->readMicroPC();
3694377Sgblack@eecs.umich.edu
3705665Sgblack@eecs.umich.edu    if (isRomMicroPC(upc)) {
3715665Sgblack@eecs.umich.edu        stayAtPC = false;
3725665Sgblack@eecs.umich.edu        curStaticInst = microcodeRom.fetchMicroop(upc, curMacroStaticInst);
3735665Sgblack@eecs.umich.edu    } else if (!curMacroStaticInst) {
3745665Sgblack@eecs.umich.edu        //We're not in the middle of a macro instruction
3754181Sgblack@eecs.umich.edu        StaticInstPtr instPtr = NULL;
3764181Sgblack@eecs.umich.edu
3774181Sgblack@eecs.umich.edu        //Predecode, ie bundle up an ExtMachInst
3784182Sgblack@eecs.umich.edu        //This should go away once the constructor can be set up properly
3794182Sgblack@eecs.umich.edu        predecoder.setTC(thread->getTC());
3804182Sgblack@eecs.umich.edu        //If more fetch data is needed, pass it in.
3814593Sgblack@eecs.umich.edu        Addr fetchPC = (thread->readPC() & PCMask) + fetchOffset;
3824593Sgblack@eecs.umich.edu        //if(predecoder.needMoreBytes())
3834593Sgblack@eecs.umich.edu            predecoder.moreBytes(thread->readPC(), fetchPC, inst);
3844593Sgblack@eecs.umich.edu        //else
3854593Sgblack@eecs.umich.edu        //    predecoder.process();
3864377Sgblack@eecs.umich.edu
3874377Sgblack@eecs.umich.edu        //If an instruction is ready, decode it. Otherwise, we'll have to
3884377Sgblack@eecs.umich.edu        //fetch beyond the MachInst at the current pc.
3894377Sgblack@eecs.umich.edu        if (predecoder.extMachInstReady()) {
3904377Sgblack@eecs.umich.edu#if THE_ISA == X86_ISA
3914377Sgblack@eecs.umich.edu            thread->setNextPC(thread->readPC() + predecoder.getInstSize());
3924377Sgblack@eecs.umich.edu#endif // X86_ISA
3934377Sgblack@eecs.umich.edu            stayAtPC = false;
3944572Sacolyte@umich.edu            instPtr = StaticInst::decode(predecoder.getExtMachInst(),
3954572Sacolyte@umich.edu                                         thread->readPC());
3964377Sgblack@eecs.umich.edu        } else {
3974377Sgblack@eecs.umich.edu            stayAtPC = true;
3984377Sgblack@eecs.umich.edu            fetchOffset += sizeof(MachInst);
3994377Sgblack@eecs.umich.edu        }
4004181Sgblack@eecs.umich.edu
4014181Sgblack@eecs.umich.edu        //If we decoded an instruction and it's microcoded, start pulling
4024181Sgblack@eecs.umich.edu        //out micro ops
4034539Sgblack@eecs.umich.edu        if (instPtr && instPtr->isMacroop()) {
4043276Sgblack@eecs.umich.edu            curMacroStaticInst = instPtr;
4055665Sgblack@eecs.umich.edu            curStaticInst = curMacroStaticInst->fetchMicroop(upc);
4063280Sgblack@eecs.umich.edu        } else {
4073280Sgblack@eecs.umich.edu            curStaticInst = instPtr;
4083276Sgblack@eecs.umich.edu        }
4093276Sgblack@eecs.umich.edu    } else {
4103276Sgblack@eecs.umich.edu        //Read the next micro op from the macro op
4115665Sgblack@eecs.umich.edu        curStaticInst = curMacroStaticInst->fetchMicroop(upc);
4123276Sgblack@eecs.umich.edu    }
4133276Sgblack@eecs.umich.edu
4144181Sgblack@eecs.umich.edu    //If we decoded an instruction this "tick", record information about it.
4154181Sgblack@eecs.umich.edu    if(curStaticInst)
4164181Sgblack@eecs.umich.edu    {
4174522Ssaidi@eecs.umich.edu#if TRACING_ON
4185784Sgblack@eecs.umich.edu        traceData = tracer->getInstRecord(curTick, tc,
4195784Sgblack@eecs.umich.edu                curStaticInst, thread->readPC(),
4205784Sgblack@eecs.umich.edu                curMacroStaticInst, thread->readMicroPC());
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
4252623SN/A
4262623SN/A#if FULL_SYSTEM
4274181Sgblack@eecs.umich.edu        thread->setInst(inst);
4282623SN/A#endif // FULL_SYSTEM
4294181Sgblack@eecs.umich.edu    }
4302623SN/A}
4312623SN/A
4322623SN/Avoid
4332623SN/ABaseSimpleCPU::postExecute()
4342623SN/A{
4352623SN/A#if FULL_SYSTEM
4365086Sgblack@eecs.umich.edu    if (thread->profile && curStaticInst) {
4373577Sgblack@eecs.umich.edu        bool usermode = TheISA::inUserMode(tc);
4382683Sktlim@umich.edu        thread->profilePC = usermode ? 1 : thread->readPC();
4395086Sgblack@eecs.umich.edu        ProfileNode *node = thread->profile->consume(tc, curStaticInst);
4402623SN/A        if (node)
4412683Sktlim@umich.edu            thread->profileNode = node;
4422623SN/A    }
4432420SN/A#endif
4442SN/A
4452623SN/A    if (curStaticInst->isMemRef()) {
4462623SN/A        numMemRefs++;
4472SN/A    }
4482SN/A
4492623SN/A    if (curStaticInst->isLoad()) {
4502623SN/A        ++numLoad;
4512623SN/A        comLoadEventQueue[0]->serviceEvents(numLoad);
4522623SN/A    }
4532SN/A
4545953Ssaidi@eecs.umich.edu    if (CPA::available()) {
4555953Ssaidi@eecs.umich.edu        CPA::cpa()->swAutoBegin(tc, thread->readNextPC());
4565953Ssaidi@eecs.umich.edu    }
4575953Ssaidi@eecs.umich.edu
4582683Sktlim@umich.edu    traceFunctions(thread->readPC());
4592644Sstever@eecs.umich.edu
4602644Sstever@eecs.umich.edu    if (traceData) {
4614046Sbinkertn@umich.edu        traceData->dump();
4624046Sbinkertn@umich.edu        delete traceData;
4634046Sbinkertn@umich.edu        traceData = NULL;
4642644Sstever@eecs.umich.edu    }
4652623SN/A}
4662SN/A
4672SN/A
4682623SN/Avoid
4692623SN/ABaseSimpleCPU::advancePC(Fault fault)
4702623SN/A{
4714377Sgblack@eecs.umich.edu    //Since we're moving to a new pc, zero out the offset
4724377Sgblack@eecs.umich.edu    fetchOffset = 0;
4732090SN/A    if (fault != NoFault) {
4743905Ssaidi@eecs.umich.edu        curMacroStaticInst = StaticInst::nullStaticInstPtr;
4755120Sgblack@eecs.umich.edu        predecoder.reset();
4765281Sgblack@eecs.umich.edu        fault->invoke(tc);
4774377Sgblack@eecs.umich.edu    } else {
4783276Sgblack@eecs.umich.edu        //If we're at the last micro op for this instruction
4794539Sgblack@eecs.umich.edu        if (curStaticInst && curStaticInst->isLastMicroop()) {
4805665Sgblack@eecs.umich.edu            //We should be working with a macro op or be in the ROM
4815665Sgblack@eecs.umich.edu            assert(curMacroStaticInst ||
4825665Sgblack@eecs.umich.edu                    isRomMicroPC(thread->readMicroPC()));
4833276Sgblack@eecs.umich.edu            //Close out this macro op, and clean up the
4843276Sgblack@eecs.umich.edu            //microcode state
4853280Sgblack@eecs.umich.edu            curMacroStaticInst = StaticInst::nullStaticInstPtr;
4865665Sgblack@eecs.umich.edu            thread->setMicroPC(normalMicroPC(0));
4875665Sgblack@eecs.umich.edu            thread->setNextMicroPC(normalMicroPC(1));
4883276Sgblack@eecs.umich.edu        }
4893276Sgblack@eecs.umich.edu        //If we're still in a macro op
4905665Sgblack@eecs.umich.edu        if (curMacroStaticInst || isRomMicroPC(thread->readMicroPC())) {
4913276Sgblack@eecs.umich.edu            //Advance the micro pc
4923280Sgblack@eecs.umich.edu            thread->setMicroPC(thread->readNextMicroPC());
4933276Sgblack@eecs.umich.edu            //Advance the "next" micro pc. Note that there are no delay
4943276Sgblack@eecs.umich.edu            //slots, and micro ops are "word" addressed.
4953280Sgblack@eecs.umich.edu            thread->setNextMicroPC(thread->readNextMicroPC() + 1);
4963276Sgblack@eecs.umich.edu        } else {
4973276Sgblack@eecs.umich.edu            // go to the next instruction
4983276Sgblack@eecs.umich.edu            thread->setPC(thread->readNextPC());
4993276Sgblack@eecs.umich.edu            thread->setNextPC(thread->readNextNPC());
5003276Sgblack@eecs.umich.edu            thread->setNextNPC(thread->readNextNPC() + sizeof(MachInst));
5013276Sgblack@eecs.umich.edu            assert(thread->readNextPC() != thread->readNextNPC());
5023276Sgblack@eecs.umich.edu        }
5032SN/A    }
5042SN/A}
5052SN/A
5065250Sksewell@umich.edu/*Fault
5075222Sksewell@umich.eduBaseSimpleCPU::CacheOp(uint8_t Op, Addr EffAddr)
5085222Sksewell@umich.edu{
5095222Sksewell@umich.edu    // translate to physical address
5105222Sksewell@umich.edu    Fault fault = NoFault;
5115222Sksewell@umich.edu    int CacheID = Op & 0x3; // Lower 3 bits identify Cache
5125222Sksewell@umich.edu    int CacheOP = Op >> 2; // Upper 3 bits identify Cache Operation
5135222Sksewell@umich.edu    if(CacheID > 1)
5145222Sksewell@umich.edu      {
5155222Sksewell@umich.edu        warn("CacheOps not implemented for secondary/tertiary caches\n");
5165222Sksewell@umich.edu      }
5175222Sksewell@umich.edu    else
5185222Sksewell@umich.edu      {
5195222Sksewell@umich.edu        switch(CacheOP)
5205222Sksewell@umich.edu          { // Fill Packet Type
5215222Sksewell@umich.edu          case 0: warn("Invalidate Cache Op\n");
5225222Sksewell@umich.edu            break;
5235222Sksewell@umich.edu          case 1: warn("Index Load Tag Cache Op\n");
5245222Sksewell@umich.edu            break;
5255222Sksewell@umich.edu          case 2: warn("Index Store Tag Cache Op\n");
5265222Sksewell@umich.edu            break;
5275222Sksewell@umich.edu          case 4: warn("Hit Invalidate Cache Op\n");
5285222Sksewell@umich.edu            break;
5295222Sksewell@umich.edu          case 5: warn("Fill/Hit Writeback Invalidate Cache Op\n");
5305222Sksewell@umich.edu            break;
5315222Sksewell@umich.edu          case 6: warn("Hit Writeback\n");
5325222Sksewell@umich.edu            break;
5335222Sksewell@umich.edu          case 7: warn("Fetch & Lock Cache Op\n");
5345222Sksewell@umich.edu            break;
5355222Sksewell@umich.edu          default: warn("Unimplemented Cache Op\n");
5365222Sksewell@umich.edu          }
5375222Sksewell@umich.edu      }
5385222Sksewell@umich.edu    return fault;
5395250Sksewell@umich.edu}*/
540