atomic.cc revision 3617
12623SN/A/*
22623SN/A * Copyright (c) 2002-2005 The Regents of The University of Michigan
32623SN/A * All rights reserved.
42623SN/A *
52623SN/A * Redistribution and use in source and binary forms, with or without
62623SN/A * modification, are permitted provided that the following conditions are
72623SN/A * met: redistributions of source code must retain the above copyright
82623SN/A * notice, this list of conditions and the following disclaimer;
92623SN/A * redistributions in binary form must reproduce the above copyright
102623SN/A * notice, this list of conditions and the following disclaimer in the
112623SN/A * documentation and/or other materials provided with the distribution;
122623SN/A * neither the name of the copyright holders nor the names of its
132623SN/A * contributors may be used to endorse or promote products derived from
142623SN/A * this software without specific prior written permission.
152623SN/A *
162623SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172623SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182623SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192623SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202623SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212623SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222623SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232623SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242623SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252623SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262623SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * Authors: Steve Reinhardt
292623SN/A */
302623SN/A
313170Sstever@eecs.umich.edu#include "arch/locked_mem.hh"
322623SN/A#include "arch/utility.hh"
332623SN/A#include "cpu/exetrace.hh"
342623SN/A#include "cpu/simple/atomic.hh"
353348Sbinkertn@umich.edu#include "mem/packet.hh"
363348Sbinkertn@umich.edu#include "mem/packet_access.hh"
372623SN/A#include "sim/builder.hh"
382901Ssaidi@eecs.umich.edu#include "sim/system.hh"
392623SN/A
402623SN/Ausing namespace std;
412623SN/Ausing namespace TheISA;
422623SN/A
432623SN/AAtomicSimpleCPU::TickEvent::TickEvent(AtomicSimpleCPU *c)
442623SN/A    : Event(&mainEventQueue, CPU_Tick_Pri), cpu(c)
452623SN/A{
462623SN/A}
472623SN/A
482623SN/A
492623SN/Avoid
502623SN/AAtomicSimpleCPU::TickEvent::process()
512623SN/A{
522623SN/A    cpu->tick();
532623SN/A}
542623SN/A
552623SN/Aconst char *
562623SN/AAtomicSimpleCPU::TickEvent::description()
572623SN/A{
582623SN/A    return "AtomicSimpleCPU tick event";
592623SN/A}
602623SN/A
612856Srdreslin@umich.eduPort *
622856Srdreslin@umich.eduAtomicSimpleCPU::getPort(const std::string &if_name, int idx)
632856Srdreslin@umich.edu{
642856Srdreslin@umich.edu    if (if_name == "dcache_port")
652856Srdreslin@umich.edu        return &dcachePort;
662856Srdreslin@umich.edu    else if (if_name == "icache_port")
672856Srdreslin@umich.edu        return &icachePort;
682856Srdreslin@umich.edu    else
692856Srdreslin@umich.edu        panic("No Such Port\n");
702856Srdreslin@umich.edu}
712623SN/A
722623SN/Avoid
732623SN/AAtomicSimpleCPU::init()
742623SN/A{
752623SN/A    BaseCPU::init();
762623SN/A#if FULL_SYSTEM
772680Sktlim@umich.edu    for (int i = 0; i < threadContexts.size(); ++i) {
782680Sktlim@umich.edu        ThreadContext *tc = threadContexts[i];
792623SN/A
802623SN/A        // initialize CPU, including PC
812680Sktlim@umich.edu        TheISA::initCPU(tc, tc->readCpuId());
822623SN/A    }
832623SN/A#endif
842623SN/A}
852623SN/A
862623SN/Abool
873349Sbinkertn@umich.eduAtomicSimpleCPU::CpuPort::recvTiming(PacketPtr pkt)
882623SN/A{
893184Srdreslin@umich.edu    panic("AtomicSimpleCPU doesn't expect recvTiming callback!");
902623SN/A    return true;
912623SN/A}
922623SN/A
932623SN/ATick
943349Sbinkertn@umich.eduAtomicSimpleCPU::CpuPort::recvAtomic(PacketPtr pkt)
952623SN/A{
963310Srdreslin@umich.edu    //Snooping a coherence request, just return
972623SN/A    return curTick;
982623SN/A}
992623SN/A
1002623SN/Avoid
1013349Sbinkertn@umich.eduAtomicSimpleCPU::CpuPort::recvFunctional(PacketPtr pkt)
1022623SN/A{
1033184Srdreslin@umich.edu    //No internal storage to update, just return
1043184Srdreslin@umich.edu    return;
1052623SN/A}
1062623SN/A
1072623SN/Avoid
1082623SN/AAtomicSimpleCPU::CpuPort::recvStatusChange(Status status)
1092623SN/A{
1102626SN/A    if (status == RangeChange)
1112626SN/A        return;
1122626SN/A
1132623SN/A    panic("AtomicSimpleCPU doesn't expect recvStatusChange callback!");
1142623SN/A}
1152623SN/A
1162657Ssaidi@eecs.umich.eduvoid
1172623SN/AAtomicSimpleCPU::CpuPort::recvRetry()
1182623SN/A{
1192623SN/A    panic("AtomicSimpleCPU doesn't expect recvRetry callback!");
1202623SN/A}
1212623SN/A
1222623SN/A
1232623SN/AAtomicSimpleCPU::AtomicSimpleCPU(Params *p)
1242623SN/A    : BaseSimpleCPU(p), tickEvent(this),
1252623SN/A      width(p->width), simulate_stalls(p->simulate_stalls),
1262640Sstever@eecs.umich.edu      icachePort(name() + "-iport", this), dcachePort(name() + "-iport", this)
1272623SN/A{
1282623SN/A    _status = Idle;
1292623SN/A
1302663Sstever@eecs.umich.edu    ifetch_req = new Request();
1313170Sstever@eecs.umich.edu    ifetch_req->setThreadContext(p->cpu_id, 0); // Add thread ID if we add MT
1322641Sstever@eecs.umich.edu    ifetch_pkt = new Packet(ifetch_req, Packet::ReadReq, Packet::Broadcast);
1332623SN/A    ifetch_pkt->dataStatic(&inst);
1342623SN/A
1352663Sstever@eecs.umich.edu    data_read_req = new Request();
1363170Sstever@eecs.umich.edu    data_read_req->setThreadContext(p->cpu_id, 0); // Add thread ID here too
1372641Sstever@eecs.umich.edu    data_read_pkt = new Packet(data_read_req, Packet::ReadReq,
1382641Sstever@eecs.umich.edu                               Packet::Broadcast);
1392623SN/A    data_read_pkt->dataStatic(&dataReg);
1402623SN/A
1412663Sstever@eecs.umich.edu    data_write_req = new Request();
1423170Sstever@eecs.umich.edu    data_write_req->setThreadContext(p->cpu_id, 0); // Add thread ID here too
1432641Sstever@eecs.umich.edu    data_write_pkt = new Packet(data_write_req, Packet::WriteReq,
1442641Sstever@eecs.umich.edu                                Packet::Broadcast);
1452623SN/A}
1462623SN/A
1472623SN/A
1482623SN/AAtomicSimpleCPU::~AtomicSimpleCPU()
1492623SN/A{
1502623SN/A}
1512623SN/A
1522623SN/Avoid
1532623SN/AAtomicSimpleCPU::serialize(ostream &os)
1542623SN/A{
1552915Sktlim@umich.edu    SimObject::State so_state = SimObject::getState();
1562915Sktlim@umich.edu    SERIALIZE_ENUM(so_state);
1573177Shsul@eecs.umich.edu    Status _status = status();
1583177Shsul@eecs.umich.edu    SERIALIZE_ENUM(_status);
1593145Shsul@eecs.umich.edu    BaseSimpleCPU::serialize(os);
1602623SN/A    nameOut(os, csprintf("%s.tickEvent", name()));
1612623SN/A    tickEvent.serialize(os);
1622623SN/A}
1632623SN/A
1642623SN/Avoid
1652623SN/AAtomicSimpleCPU::unserialize(Checkpoint *cp, const string &section)
1662623SN/A{
1672915Sktlim@umich.edu    SimObject::State so_state;
1682915Sktlim@umich.edu    UNSERIALIZE_ENUM(so_state);
1693177Shsul@eecs.umich.edu    UNSERIALIZE_ENUM(_status);
1703145Shsul@eecs.umich.edu    BaseSimpleCPU::unserialize(cp, section);
1712915Sktlim@umich.edu    tickEvent.unserialize(cp, csprintf("%s.tickEvent", section));
1722915Sktlim@umich.edu}
1732915Sktlim@umich.edu
1742915Sktlim@umich.eduvoid
1752915Sktlim@umich.eduAtomicSimpleCPU::resume()
1762915Sktlim@umich.edu{
1773324Shsul@eecs.umich.edu    if (_status != SwitchedOut && _status != Idle) {
1783201Shsul@eecs.umich.edu        assert(system->getMemoryMode() == System::Atomic);
1793324Shsul@eecs.umich.edu
1803324Shsul@eecs.umich.edu        changeState(SimObject::Running);
1813324Shsul@eecs.umich.edu        if (thread->status() == ThreadContext::Active) {
1823431Sgblack@eecs.umich.edu            if (!tickEvent.scheduled()) {
1833495Sktlim@umich.edu                tickEvent.schedule(nextCycle());
1843431Sgblack@eecs.umich.edu            }
1853324Shsul@eecs.umich.edu        }
1862915Sktlim@umich.edu    }
1872623SN/A}
1882623SN/A
1892623SN/Avoid
1902798Sktlim@umich.eduAtomicSimpleCPU::switchOut()
1912623SN/A{
1922798Sktlim@umich.edu    assert(status() == Running || status() == Idle);
1932798Sktlim@umich.edu    _status = SwitchedOut;
1942623SN/A
1952798Sktlim@umich.edu    tickEvent.squash();
1962623SN/A}
1972623SN/A
1982623SN/A
1992623SN/Avoid
2002623SN/AAtomicSimpleCPU::takeOverFrom(BaseCPU *oldCPU)
2012623SN/A{
2022623SN/A    BaseCPU::takeOverFrom(oldCPU);
2032623SN/A
2042623SN/A    assert(!tickEvent.scheduled());
2052623SN/A
2062680Sktlim@umich.edu    // if any of this CPU's ThreadContexts are active, mark the CPU as
2072623SN/A    // running and schedule its tick event.
2082680Sktlim@umich.edu    for (int i = 0; i < threadContexts.size(); ++i) {
2092680Sktlim@umich.edu        ThreadContext *tc = threadContexts[i];
2102680Sktlim@umich.edu        if (tc->status() == ThreadContext::Active && _status != Running) {
2112623SN/A            _status = Running;
2123495Sktlim@umich.edu            tickEvent.schedule(nextCycle());
2132623SN/A            break;
2142623SN/A        }
2152623SN/A    }
2162623SN/A}
2172623SN/A
2182623SN/A
2192623SN/Avoid
2202623SN/AAtomicSimpleCPU::activateContext(int thread_num, int delay)
2212623SN/A{
2222623SN/A    assert(thread_num == 0);
2232683Sktlim@umich.edu    assert(thread);
2242623SN/A
2252623SN/A    assert(_status == Idle);
2262623SN/A    assert(!tickEvent.scheduled());
2272623SN/A
2282623SN/A    notIdleFraction++;
2293430Sgblack@eecs.umich.edu    //Make sure ticks are still on multiples of cycles
2303495Sktlim@umich.edu    tickEvent.schedule(nextCycle(curTick + cycles(delay)));
2312623SN/A    _status = Running;
2322623SN/A}
2332623SN/A
2342623SN/A
2352623SN/Avoid
2362623SN/AAtomicSimpleCPU::suspendContext(int thread_num)
2372623SN/A{
2382623SN/A    assert(thread_num == 0);
2392683Sktlim@umich.edu    assert(thread);
2402623SN/A
2412623SN/A    assert(_status == Running);
2422626SN/A
2432626SN/A    // tick event may not be scheduled if this gets called from inside
2442626SN/A    // an instruction's execution, e.g. "quiesce"
2452626SN/A    if (tickEvent.scheduled())
2462626SN/A        tickEvent.deschedule();
2472623SN/A
2482623SN/A    notIdleFraction--;
2492623SN/A    _status = Idle;
2502623SN/A}
2512623SN/A
2522623SN/A
2532623SN/Atemplate <class T>
2542623SN/AFault
2552623SN/AAtomicSimpleCPU::read(Addr addr, T &data, unsigned flags)
2562623SN/A{
2573169Sstever@eecs.umich.edu    // use the CPU's statically allocated read request and packet objects
2583169Sstever@eecs.umich.edu    Request *req = data_read_req;
2593349Sbinkertn@umich.edu    PacketPtr pkt = data_read_pkt;
2603169Sstever@eecs.umich.edu
2613169Sstever@eecs.umich.edu    req->setVirt(0, addr, sizeof(T), flags, thread->readPC());
2622623SN/A
2632623SN/A    if (traceData) {
2642623SN/A        traceData->setAddr(addr);
2652623SN/A    }
2662623SN/A
2672623SN/A    // translate to physical address
2683169Sstever@eecs.umich.edu    Fault fault = thread->translateDataReadReq(req);
2692623SN/A
2702623SN/A    // Now do the access.
2712623SN/A    if (fault == NoFault) {
2723169Sstever@eecs.umich.edu        pkt->reinitFromRequest();
2732623SN/A
2743169Sstever@eecs.umich.edu        dcache_latency = dcachePort.sendAtomic(pkt);
2752623SN/A        dcache_access = true;
2762623SN/A
2773169Sstever@eecs.umich.edu        assert(pkt->result == Packet::Success);
2783169Sstever@eecs.umich.edu        data = pkt->get<T>();
2793170Sstever@eecs.umich.edu
2803170Sstever@eecs.umich.edu        if (req->isLocked()) {
2813170Sstever@eecs.umich.edu            TheISA::handleLockedRead(thread, req);
2823170Sstever@eecs.umich.edu        }
2832623SN/A    }
2842623SN/A
2852623SN/A    // This will need a new way to tell if it has a dcache attached.
2863172Sstever@eecs.umich.edu    if (req->isUncacheable())
2872623SN/A        recordEvent("Uncached Read");
2882623SN/A
2892623SN/A    return fault;
2902623SN/A}
2912623SN/A
2922623SN/A#ifndef DOXYGEN_SHOULD_SKIP_THIS
2932623SN/A
2942623SN/Atemplate
2952623SN/AFault
2962623SN/AAtomicSimpleCPU::read(Addr addr, uint64_t &data, unsigned flags);
2972623SN/A
2982623SN/Atemplate
2992623SN/AFault
3002623SN/AAtomicSimpleCPU::read(Addr addr, uint32_t &data, unsigned flags);
3012623SN/A
3022623SN/Atemplate
3032623SN/AFault
3042623SN/AAtomicSimpleCPU::read(Addr addr, uint16_t &data, unsigned flags);
3052623SN/A
3062623SN/Atemplate
3072623SN/AFault
3082623SN/AAtomicSimpleCPU::read(Addr addr, uint8_t &data, unsigned flags);
3092623SN/A
3102623SN/A#endif //DOXYGEN_SHOULD_SKIP_THIS
3112623SN/A
3122623SN/Atemplate<>
3132623SN/AFault
3142623SN/AAtomicSimpleCPU::read(Addr addr, double &data, unsigned flags)
3152623SN/A{
3162623SN/A    return read(addr, *(uint64_t*)&data, flags);
3172623SN/A}
3182623SN/A
3192623SN/Atemplate<>
3202623SN/AFault
3212623SN/AAtomicSimpleCPU::read(Addr addr, float &data, unsigned flags)
3222623SN/A{
3232623SN/A    return read(addr, *(uint32_t*)&data, flags);
3242623SN/A}
3252623SN/A
3262623SN/A
3272623SN/Atemplate<>
3282623SN/AFault
3292623SN/AAtomicSimpleCPU::read(Addr addr, int32_t &data, unsigned flags)
3302623SN/A{
3312623SN/A    return read(addr, (uint32_t&)data, flags);
3322623SN/A}
3332623SN/A
3342623SN/A
3352623SN/Atemplate <class T>
3362623SN/AFault
3372623SN/AAtomicSimpleCPU::write(T data, Addr addr, unsigned flags, uint64_t *res)
3382623SN/A{
3393169Sstever@eecs.umich.edu    // use the CPU's statically allocated write request and packet objects
3403169Sstever@eecs.umich.edu    Request *req = data_write_req;
3413349Sbinkertn@umich.edu    PacketPtr pkt = data_write_pkt;
3423169Sstever@eecs.umich.edu
3433169Sstever@eecs.umich.edu    req->setVirt(0, addr, sizeof(T), flags, thread->readPC());
3442623SN/A
3452623SN/A    if (traceData) {
3462623SN/A        traceData->setAddr(addr);
3472623SN/A    }
3482623SN/A
3492623SN/A    // translate to physical address
3503169Sstever@eecs.umich.edu    Fault fault = thread->translateDataWriteReq(req);
3512623SN/A
3522623SN/A    // Now do the access.
3532623SN/A    if (fault == NoFault) {
3543170Sstever@eecs.umich.edu        bool do_access = true;  // flag to suppress cache access
3552623SN/A
3563170Sstever@eecs.umich.edu        if (req->isLocked()) {
3573170Sstever@eecs.umich.edu            do_access = TheISA::handleLockedWrite(thread, req);
3583170Sstever@eecs.umich.edu        }
3592623SN/A
3603170Sstever@eecs.umich.edu        if (do_access) {
3613170Sstever@eecs.umich.edu            data = htog(data);
3623170Sstever@eecs.umich.edu            pkt->reinitFromRequest();
3633170Sstever@eecs.umich.edu            pkt->dataStatic(&data);
3642631SN/A
3653170Sstever@eecs.umich.edu            dcache_latency = dcachePort.sendAtomic(pkt);
3663170Sstever@eecs.umich.edu            dcache_access = true;
3673170Sstever@eecs.umich.edu
3683170Sstever@eecs.umich.edu            assert(pkt->result == Packet::Success);
3693170Sstever@eecs.umich.edu        }
3703170Sstever@eecs.umich.edu
3713170Sstever@eecs.umich.edu        if (req->isLocked()) {
3723170Sstever@eecs.umich.edu            uint64_t scResult = req->getScResult();
3733170Sstever@eecs.umich.edu            if (scResult != 0) {
3743170Sstever@eecs.umich.edu                // clear failure counter
3753170Sstever@eecs.umich.edu                thread->setStCondFailures(0);
3763170Sstever@eecs.umich.edu            }
3773170Sstever@eecs.umich.edu            if (res) {
3783170Sstever@eecs.umich.edu                *res = req->getScResult();
3793170Sstever@eecs.umich.edu            }
3802631SN/A        }
3812623SN/A    }
3822623SN/A
3832623SN/A    // This will need a new way to tell if it's hooked up to a cache or not.
3843172Sstever@eecs.umich.edu    if (req->isUncacheable())
3852623SN/A        recordEvent("Uncached Write");
3862623SN/A
3872623SN/A    // If the write needs to have a fault on the access, consider calling
3882623SN/A    // changeStatus() and changing it to "bad addr write" or something.
3892623SN/A    return fault;
3902623SN/A}
3912623SN/A
3922623SN/A
3932623SN/A#ifndef DOXYGEN_SHOULD_SKIP_THIS
3942623SN/Atemplate
3952623SN/AFault
3962623SN/AAtomicSimpleCPU::write(uint64_t data, Addr addr,
3972623SN/A                       unsigned flags, uint64_t *res);
3982623SN/A
3992623SN/Atemplate
4002623SN/AFault
4012623SN/AAtomicSimpleCPU::write(uint32_t data, Addr addr,
4022623SN/A                       unsigned flags, uint64_t *res);
4032623SN/A
4042623SN/Atemplate
4052623SN/AFault
4062623SN/AAtomicSimpleCPU::write(uint16_t data, Addr addr,
4072623SN/A                       unsigned flags, uint64_t *res);
4082623SN/A
4092623SN/Atemplate
4102623SN/AFault
4112623SN/AAtomicSimpleCPU::write(uint8_t data, Addr addr,
4122623SN/A                       unsigned flags, uint64_t *res);
4132623SN/A
4142623SN/A#endif //DOXYGEN_SHOULD_SKIP_THIS
4152623SN/A
4162623SN/Atemplate<>
4172623SN/AFault
4182623SN/AAtomicSimpleCPU::write(double data, Addr addr, unsigned flags, uint64_t *res)
4192623SN/A{
4202623SN/A    return write(*(uint64_t*)&data, addr, flags, res);
4212623SN/A}
4222623SN/A
4232623SN/Atemplate<>
4242623SN/AFault
4252623SN/AAtomicSimpleCPU::write(float data, Addr addr, unsigned flags, uint64_t *res)
4262623SN/A{
4272623SN/A    return write(*(uint32_t*)&data, addr, flags, res);
4282623SN/A}
4292623SN/A
4302623SN/A
4312623SN/Atemplate<>
4322623SN/AFault
4332623SN/AAtomicSimpleCPU::write(int32_t data, Addr addr, unsigned flags, uint64_t *res)
4342623SN/A{
4352623SN/A    return write((uint32_t)data, addr, flags, res);
4362623SN/A}
4372623SN/A
4382623SN/A
4392623SN/Avoid
4402623SN/AAtomicSimpleCPU::tick()
4412623SN/A{
4422623SN/A    Tick latency = cycles(1); // instruction takes one cycle by default
4432623SN/A
4442623SN/A    for (int i = 0; i < width; ++i) {
4452623SN/A        numCycles++;
4462623SN/A
4473387Sgblack@eecs.umich.edu        if (!curStaticInst || !curStaticInst->isDelayedCommit())
4483387Sgblack@eecs.umich.edu            checkForInterrupts();
4492626SN/A
4502662Sstever@eecs.umich.edu        Fault fault = setupFetchRequest(ifetch_req);
4512623SN/A
4522623SN/A        if (fault == NoFault) {
4532662Sstever@eecs.umich.edu            ifetch_pkt->reinitFromRequest();
4542662Sstever@eecs.umich.edu
4552662Sstever@eecs.umich.edu            Tick icache_latency = icachePort.sendAtomic(ifetch_pkt);
4562623SN/A            // ifetch_req is initialized to read the instruction directly
4572623SN/A            // into the CPU object's inst field.
4582623SN/A
4592623SN/A            dcache_access = false; // assume no dcache access
4602623SN/A            preExecute();
4612623SN/A            fault = curStaticInst->execute(this, traceData);
4622623SN/A            postExecute();
4632623SN/A
4642623SN/A            if (simulate_stalls) {
4652662Sstever@eecs.umich.edu                Tick icache_stall = icache_latency - cycles(1);
4662623SN/A                Tick dcache_stall =
4672662Sstever@eecs.umich.edu                    dcache_access ? dcache_latency - cycles(1) : 0;
4682803Ssaidi@eecs.umich.edu                Tick stall_cycles = (icache_stall + dcache_stall) / cycles(1);
4692803Ssaidi@eecs.umich.edu                if (cycles(stall_cycles) < (icache_stall + dcache_stall))
4702803Ssaidi@eecs.umich.edu                    latency += cycles(stall_cycles+1);
4712803Ssaidi@eecs.umich.edu                else
4722803Ssaidi@eecs.umich.edu                    latency += cycles(stall_cycles);
4732623SN/A            }
4742623SN/A
4752623SN/A        }
4762623SN/A
4772623SN/A        advancePC(fault);
4782623SN/A    }
4792623SN/A
4802626SN/A    if (_status != Idle)
4812626SN/A        tickEvent.schedule(curTick + latency);
4822623SN/A}
4832623SN/A
4842623SN/A
4852623SN/A////////////////////////////////////////////////////////////////////////
4862623SN/A//
4872623SN/A//  AtomicSimpleCPU Simulation Object
4882623SN/A//
4892623SN/ABEGIN_DECLARE_SIM_OBJECT_PARAMS(AtomicSimpleCPU)
4902623SN/A
4912623SN/A    Param<Counter> max_insts_any_thread;
4922623SN/A    Param<Counter> max_insts_all_threads;
4932623SN/A    Param<Counter> max_loads_any_thread;
4942623SN/A    Param<Counter> max_loads_all_threads;
4953119Sktlim@umich.edu    Param<Tick> progress_interval;
4962901Ssaidi@eecs.umich.edu    SimObjectParam<System *> system;
4973170Sstever@eecs.umich.edu    Param<int> cpu_id;
4982623SN/A
4992623SN/A#if FULL_SYSTEM
5003453Sgblack@eecs.umich.edu    SimObjectParam<TheISA::ITB *> itb;
5013453Sgblack@eecs.umich.edu    SimObjectParam<TheISA::DTB *> dtb;
5022623SN/A    Param<Tick> profile;
5033617Sbinkertn@umich.edu
5043617Sbinkertn@umich.edu    Param<bool> do_quiesce;
5053617Sbinkertn@umich.edu    Param<bool> do_checkpoint_insts;
5063617Sbinkertn@umich.edu    Param<bool> do_statistics_insts;
5072623SN/A#else
5082623SN/A    SimObjectParam<Process *> workload;
5092623SN/A#endif // FULL_SYSTEM
5102623SN/A
5112623SN/A    Param<int> clock;
5122623SN/A
5132623SN/A    Param<bool> defer_registration;
5142623SN/A    Param<int> width;
5152623SN/A    Param<bool> function_trace;
5162623SN/A    Param<Tick> function_trace_start;
5172623SN/A    Param<bool> simulate_stalls;
5182623SN/A
5192623SN/AEND_DECLARE_SIM_OBJECT_PARAMS(AtomicSimpleCPU)
5202623SN/A
5212623SN/ABEGIN_INIT_SIM_OBJECT_PARAMS(AtomicSimpleCPU)
5222623SN/A
5232623SN/A    INIT_PARAM(max_insts_any_thread,
5242623SN/A               "terminate when any thread reaches this inst count"),
5252623SN/A    INIT_PARAM(max_insts_all_threads,
5262623SN/A               "terminate when all threads have reached this inst count"),
5272623SN/A    INIT_PARAM(max_loads_any_thread,
5282623SN/A               "terminate when any thread reaches this load count"),
5292623SN/A    INIT_PARAM(max_loads_all_threads,
5302623SN/A               "terminate when all threads have reached this load count"),
5313119Sktlim@umich.edu    INIT_PARAM(progress_interval, "Progress interval"),
5322901Ssaidi@eecs.umich.edu    INIT_PARAM(system, "system object"),
5333170Sstever@eecs.umich.edu    INIT_PARAM(cpu_id, "processor ID"),
5342623SN/A
5352623SN/A#if FULL_SYSTEM
5362623SN/A    INIT_PARAM(itb, "Instruction TLB"),
5372623SN/A    INIT_PARAM(dtb, "Data TLB"),
5382623SN/A    INIT_PARAM(profile, ""),
5393617Sbinkertn@umich.edu    INIT_PARAM(do_quiesce, ""),
5403617Sbinkertn@umich.edu    INIT_PARAM(do_checkpoint_insts, ""),
5413617Sbinkertn@umich.edu    INIT_PARAM(do_statistics_insts, ""),
5422623SN/A#else
5432623SN/A    INIT_PARAM(workload, "processes to run"),
5442623SN/A#endif // FULL_SYSTEM
5452623SN/A
5462623SN/A    INIT_PARAM(clock, "clock speed"),
5472623SN/A    INIT_PARAM(defer_registration, "defer system registration (for sampling)"),
5482623SN/A    INIT_PARAM(width, "cpu width"),
5492623SN/A    INIT_PARAM(function_trace, "Enable function trace"),
5502623SN/A    INIT_PARAM(function_trace_start, "Cycle to start function trace"),
5512623SN/A    INIT_PARAM(simulate_stalls, "Simulate cache stall cycles")
5522623SN/A
5532623SN/AEND_INIT_SIM_OBJECT_PARAMS(AtomicSimpleCPU)
5542623SN/A
5552623SN/A
5562623SN/ACREATE_SIM_OBJECT(AtomicSimpleCPU)
5572623SN/A{
5582623SN/A    AtomicSimpleCPU::Params *params = new AtomicSimpleCPU::Params();
5592623SN/A    params->name = getInstanceName();
5602623SN/A    params->numberOfThreads = 1;
5612623SN/A    params->max_insts_any_thread = max_insts_any_thread;
5622623SN/A    params->max_insts_all_threads = max_insts_all_threads;
5632623SN/A    params->max_loads_any_thread = max_loads_any_thread;
5642623SN/A    params->max_loads_all_threads = max_loads_all_threads;
5653119Sktlim@umich.edu    params->progress_interval = progress_interval;
5662623SN/A    params->deferRegistration = defer_registration;
5672623SN/A    params->clock = clock;
5682623SN/A    params->functionTrace = function_trace;
5692623SN/A    params->functionTraceStart = function_trace_start;
5702623SN/A    params->width = width;
5712623SN/A    params->simulate_stalls = simulate_stalls;
5722901Ssaidi@eecs.umich.edu    params->system = system;
5733170Sstever@eecs.umich.edu    params->cpu_id = cpu_id;
5742623SN/A
5752623SN/A#if FULL_SYSTEM
5762623SN/A    params->itb = itb;
5772623SN/A    params->dtb = dtb;
5782623SN/A    params->profile = profile;
5793617Sbinkertn@umich.edu    params->do_quiesce = do_quiesce;
5803617Sbinkertn@umich.edu    params->do_checkpoint_insts = do_checkpoint_insts;
5813617Sbinkertn@umich.edu    params->do_statistics_insts = do_statistics_insts;
5822623SN/A#else
5832623SN/A    params->process = workload;
5842623SN/A#endif
5852623SN/A
5862623SN/A    AtomicSimpleCPU *cpu = new AtomicSimpleCPU(params);
5872623SN/A    return cpu;
5882623SN/A}
5892623SN/A
5902623SN/AREGISTER_SIM_OBJECT("AtomicSimpleCPU", AtomicSimpleCPU)
5912623SN/A
592