atomic.cc revision 3169
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
312623SN/A#include "arch/utility.hh"
322623SN/A#include "cpu/exetrace.hh"
332623SN/A#include "cpu/simple/atomic.hh"
342623SN/A#include "mem/packet_impl.hh"
352623SN/A#include "sim/builder.hh"
362901Ssaidi@eecs.umich.edu#include "sim/system.hh"
372623SN/A
382623SN/Ausing namespace std;
392623SN/Ausing namespace TheISA;
402623SN/A
412623SN/AAtomicSimpleCPU::TickEvent::TickEvent(AtomicSimpleCPU *c)
422623SN/A    : Event(&mainEventQueue, CPU_Tick_Pri), cpu(c)
432623SN/A{
442623SN/A}
452623SN/A
462623SN/A
472623SN/Avoid
482623SN/AAtomicSimpleCPU::TickEvent::process()
492623SN/A{
502623SN/A    cpu->tick();
512623SN/A}
522623SN/A
532623SN/Aconst char *
542623SN/AAtomicSimpleCPU::TickEvent::description()
552623SN/A{
562623SN/A    return "AtomicSimpleCPU tick event";
572623SN/A}
582623SN/A
592856Srdreslin@umich.eduPort *
602856Srdreslin@umich.eduAtomicSimpleCPU::getPort(const std::string &if_name, int idx)
612856Srdreslin@umich.edu{
622856Srdreslin@umich.edu    if (if_name == "dcache_port")
632856Srdreslin@umich.edu        return &dcachePort;
642856Srdreslin@umich.edu    else if (if_name == "icache_port")
652856Srdreslin@umich.edu        return &icachePort;
662856Srdreslin@umich.edu    else
672856Srdreslin@umich.edu        panic("No Such Port\n");
682856Srdreslin@umich.edu}
692623SN/A
702623SN/Avoid
712623SN/AAtomicSimpleCPU::init()
722623SN/A{
732623SN/A    //Create Memory Ports (conect them up)
742856Srdreslin@umich.edu//    Port *mem_dport = mem->getPort("");
752856Srdreslin@umich.edu//    dcachePort.setPeer(mem_dport);
762856Srdreslin@umich.edu//    mem_dport->setPeer(&dcachePort);
772623SN/A
782856Srdreslin@umich.edu//    Port *mem_iport = mem->getPort("");
792856Srdreslin@umich.edu//    icachePort.setPeer(mem_iport);
802856Srdreslin@umich.edu//    mem_iport->setPeer(&icachePort);
812623SN/A
822623SN/A    BaseCPU::init();
832623SN/A#if FULL_SYSTEM
842680Sktlim@umich.edu    for (int i = 0; i < threadContexts.size(); ++i) {
852680Sktlim@umich.edu        ThreadContext *tc = threadContexts[i];
862623SN/A
872623SN/A        // initialize CPU, including PC
882680Sktlim@umich.edu        TheISA::initCPU(tc, tc->readCpuId());
892623SN/A    }
902623SN/A#endif
912623SN/A}
922623SN/A
932623SN/Abool
942630SN/AAtomicSimpleCPU::CpuPort::recvTiming(Packet *pkt)
952623SN/A{
962623SN/A    panic("AtomicSimpleCPU doesn't expect recvAtomic callback!");
972623SN/A    return true;
982623SN/A}
992623SN/A
1002623SN/ATick
1012630SN/AAtomicSimpleCPU::CpuPort::recvAtomic(Packet *pkt)
1022623SN/A{
1032623SN/A    panic("AtomicSimpleCPU doesn't expect recvAtomic callback!");
1042623SN/A    return curTick;
1052623SN/A}
1062623SN/A
1072623SN/Avoid
1082630SN/AAtomicSimpleCPU::CpuPort::recvFunctional(Packet *pkt)
1092623SN/A{
1102623SN/A    panic("AtomicSimpleCPU doesn't expect recvFunctional callback!");
1112623SN/A}
1122623SN/A
1132623SN/Avoid
1142623SN/AAtomicSimpleCPU::CpuPort::recvStatusChange(Status status)
1152623SN/A{
1162626SN/A    if (status == RangeChange)
1172626SN/A        return;
1182626SN/A
1192623SN/A    panic("AtomicSimpleCPU doesn't expect recvStatusChange callback!");
1202623SN/A}
1212623SN/A
1222657Ssaidi@eecs.umich.eduvoid
1232623SN/AAtomicSimpleCPU::CpuPort::recvRetry()
1242623SN/A{
1252623SN/A    panic("AtomicSimpleCPU doesn't expect recvRetry callback!");
1262623SN/A}
1272623SN/A
1282623SN/A
1292623SN/AAtomicSimpleCPU::AtomicSimpleCPU(Params *p)
1302623SN/A    : BaseSimpleCPU(p), tickEvent(this),
1312623SN/A      width(p->width), simulate_stalls(p->simulate_stalls),
1322640Sstever@eecs.umich.edu      icachePort(name() + "-iport", this), dcachePort(name() + "-iport", this)
1332623SN/A{
1342623SN/A    _status = Idle;
1352623SN/A
1362663Sstever@eecs.umich.edu    // @todo fix me and get the real cpu id & thread number!!!
1372663Sstever@eecs.umich.edu    ifetch_req = new Request();
1382827Srdreslin@umich.edu    ifetch_req->setThreadContext(0,0); //Need CPU/Thread IDS HERE
1392641Sstever@eecs.umich.edu    ifetch_pkt = new Packet(ifetch_req, Packet::ReadReq, Packet::Broadcast);
1402623SN/A    ifetch_pkt->dataStatic(&inst);
1412623SN/A
1422663Sstever@eecs.umich.edu    data_read_req = new Request();
1432827Srdreslin@umich.edu    data_read_req->setThreadContext(0,0); //Need CPU/Thread IDS HERE
1442641Sstever@eecs.umich.edu    data_read_pkt = new Packet(data_read_req, Packet::ReadReq,
1452641Sstever@eecs.umich.edu                               Packet::Broadcast);
1462623SN/A    data_read_pkt->dataStatic(&dataReg);
1472623SN/A
1482663Sstever@eecs.umich.edu    data_write_req = new Request();
1492827Srdreslin@umich.edu    data_write_req->setThreadContext(0,0); //Need CPU/Thread IDS HERE
1502641Sstever@eecs.umich.edu    data_write_pkt = new Packet(data_write_req, Packet::WriteReq,
1512641Sstever@eecs.umich.edu                                Packet::Broadcast);
1522623SN/A}
1532623SN/A
1542623SN/A
1552623SN/AAtomicSimpleCPU::~AtomicSimpleCPU()
1562623SN/A{
1572623SN/A}
1582623SN/A
1592623SN/Avoid
1602623SN/AAtomicSimpleCPU::serialize(ostream &os)
1612623SN/A{
1622915Sktlim@umich.edu    SimObject::State so_state = SimObject::getState();
1632915Sktlim@umich.edu    SERIALIZE_ENUM(so_state);
1643145Shsul@eecs.umich.edu    BaseSimpleCPU::serialize(os);
1652623SN/A    nameOut(os, csprintf("%s.tickEvent", name()));
1662623SN/A    tickEvent.serialize(os);
1672623SN/A}
1682623SN/A
1692623SN/Avoid
1702623SN/AAtomicSimpleCPU::unserialize(Checkpoint *cp, const string &section)
1712623SN/A{
1722915Sktlim@umich.edu    SimObject::State so_state;
1732915Sktlim@umich.edu    UNSERIALIZE_ENUM(so_state);
1743145Shsul@eecs.umich.edu    BaseSimpleCPU::unserialize(cp, section);
1752915Sktlim@umich.edu    tickEvent.unserialize(cp, csprintf("%s.tickEvent", section));
1762915Sktlim@umich.edu}
1772915Sktlim@umich.edu
1782915Sktlim@umich.eduvoid
1792915Sktlim@umich.eduAtomicSimpleCPU::resume()
1802915Sktlim@umich.edu{
1812926Sktlim@umich.edu    assert(system->getMemoryMode() == System::Atomic);
1822926Sktlim@umich.edu    changeState(SimObject::Running);
1832915Sktlim@umich.edu    if (thread->status() == ThreadContext::Active) {
1842915Sktlim@umich.edu        if (!tickEvent.scheduled())
1852915Sktlim@umich.edu            tickEvent.schedule(curTick);
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;
2122623SN/A            tickEvent.schedule(curTick);
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++;
2292623SN/A    tickEvent.schedule(curTick + cycles(delay));
2302623SN/A    _status = Running;
2312623SN/A}
2322623SN/A
2332623SN/A
2342623SN/Avoid
2352623SN/AAtomicSimpleCPU::suspendContext(int thread_num)
2362623SN/A{
2372623SN/A    assert(thread_num == 0);
2382683Sktlim@umich.edu    assert(thread);
2392623SN/A
2402623SN/A    assert(_status == Running);
2412626SN/A
2422626SN/A    // tick event may not be scheduled if this gets called from inside
2432626SN/A    // an instruction's execution, e.g. "quiesce"
2442626SN/A    if (tickEvent.scheduled())
2452626SN/A        tickEvent.deschedule();
2462623SN/A
2472623SN/A    notIdleFraction--;
2482623SN/A    _status = Idle;
2492623SN/A}
2502623SN/A
2512623SN/A
2522623SN/Atemplate <class T>
2532623SN/AFault
2542623SN/AAtomicSimpleCPU::read(Addr addr, T &data, unsigned flags)
2552623SN/A{
2563169Sstever@eecs.umich.edu    // use the CPU's statically allocated read request and packet objects
2573169Sstever@eecs.umich.edu    Request *req = data_read_req;
2583169Sstever@eecs.umich.edu    Packet  *pkt = data_read_pkt;
2593169Sstever@eecs.umich.edu
2603169Sstever@eecs.umich.edu    req->setVirt(0, addr, sizeof(T), flags, thread->readPC());
2612623SN/A
2622623SN/A    if (traceData) {
2632623SN/A        traceData->setAddr(addr);
2642623SN/A    }
2652623SN/A
2662623SN/A    // translate to physical address
2673169Sstever@eecs.umich.edu    Fault fault = thread->translateDataReadReq(req);
2682623SN/A
2692623SN/A    // Now do the access.
2702623SN/A    if (fault == NoFault) {
2713169Sstever@eecs.umich.edu        pkt->reinitFromRequest();
2722623SN/A
2733169Sstever@eecs.umich.edu        dcache_latency = dcachePort.sendAtomic(pkt);
2742623SN/A        dcache_access = true;
2752623SN/A
2763169Sstever@eecs.umich.edu        assert(pkt->result == Packet::Success);
2773169Sstever@eecs.umich.edu        data = pkt->get<T>();
2782623SN/A    }
2792623SN/A
2802623SN/A    // This will need a new way to tell if it has a dcache attached.
2813169Sstever@eecs.umich.edu    if (req->getFlags() & UNCACHEABLE)
2822623SN/A        recordEvent("Uncached Read");
2832623SN/A
2842623SN/A    return fault;
2852623SN/A}
2862623SN/A
2872623SN/A#ifndef DOXYGEN_SHOULD_SKIP_THIS
2882623SN/A
2892623SN/Atemplate
2902623SN/AFault
2912623SN/AAtomicSimpleCPU::read(Addr addr, uint64_t &data, unsigned flags);
2922623SN/A
2932623SN/Atemplate
2942623SN/AFault
2952623SN/AAtomicSimpleCPU::read(Addr addr, uint32_t &data, unsigned flags);
2962623SN/A
2972623SN/Atemplate
2982623SN/AFault
2992623SN/AAtomicSimpleCPU::read(Addr addr, uint16_t &data, unsigned flags);
3002623SN/A
3012623SN/Atemplate
3022623SN/AFault
3032623SN/AAtomicSimpleCPU::read(Addr addr, uint8_t &data, unsigned flags);
3042623SN/A
3052623SN/A#endif //DOXYGEN_SHOULD_SKIP_THIS
3062623SN/A
3072623SN/Atemplate<>
3082623SN/AFault
3092623SN/AAtomicSimpleCPU::read(Addr addr, double &data, unsigned flags)
3102623SN/A{
3112623SN/A    return read(addr, *(uint64_t*)&data, flags);
3122623SN/A}
3132623SN/A
3142623SN/Atemplate<>
3152623SN/AFault
3162623SN/AAtomicSimpleCPU::read(Addr addr, float &data, unsigned flags)
3172623SN/A{
3182623SN/A    return read(addr, *(uint32_t*)&data, flags);
3192623SN/A}
3202623SN/A
3212623SN/A
3222623SN/Atemplate<>
3232623SN/AFault
3242623SN/AAtomicSimpleCPU::read(Addr addr, int32_t &data, unsigned flags)
3252623SN/A{
3262623SN/A    return read(addr, (uint32_t&)data, flags);
3272623SN/A}
3282623SN/A
3292623SN/A
3302623SN/Atemplate <class T>
3312623SN/AFault
3322623SN/AAtomicSimpleCPU::write(T data, Addr addr, unsigned flags, uint64_t *res)
3332623SN/A{
3343169Sstever@eecs.umich.edu    // use the CPU's statically allocated write request and packet objects
3353169Sstever@eecs.umich.edu    Request *req = data_write_req;
3363169Sstever@eecs.umich.edu    Packet  *pkt = data_write_pkt;
3373169Sstever@eecs.umich.edu
3383169Sstever@eecs.umich.edu    req->setVirt(0, addr, sizeof(T), flags, thread->readPC());
3392623SN/A
3402623SN/A    if (traceData) {
3412623SN/A        traceData->setAddr(addr);
3422623SN/A    }
3432623SN/A
3442623SN/A    // translate to physical address
3453169Sstever@eecs.umich.edu    Fault fault = thread->translateDataWriteReq(req);
3462623SN/A
3472623SN/A    // Now do the access.
3482623SN/A    if (fault == NoFault) {
3492623SN/A        data = htog(data);
3503169Sstever@eecs.umich.edu        pkt->reinitFromRequest();
3513169Sstever@eecs.umich.edu        pkt->dataStatic(&data);
3522623SN/A
3533169Sstever@eecs.umich.edu        dcache_latency = dcachePort.sendAtomic(pkt);
3542623SN/A        dcache_access = true;
3552623SN/A
3563169Sstever@eecs.umich.edu        assert(pkt->result == Packet::Success);
3572631SN/A
3583169Sstever@eecs.umich.edu        if (res && req->getFlags() & LOCKED) {
3593169Sstever@eecs.umich.edu            *res = req->getScResult();
3602631SN/A        }
3612623SN/A    }
3622623SN/A
3632623SN/A    // This will need a new way to tell if it's hooked up to a cache or not.
3643169Sstever@eecs.umich.edu    if (req->getFlags() & UNCACHEABLE)
3652623SN/A        recordEvent("Uncached Write");
3662623SN/A
3672623SN/A    // If the write needs to have a fault on the access, consider calling
3682623SN/A    // changeStatus() and changing it to "bad addr write" or something.
3692623SN/A    return fault;
3702623SN/A}
3712623SN/A
3722623SN/A
3732623SN/A#ifndef DOXYGEN_SHOULD_SKIP_THIS
3742623SN/Atemplate
3752623SN/AFault
3762623SN/AAtomicSimpleCPU::write(uint64_t data, Addr addr,
3772623SN/A                       unsigned flags, uint64_t *res);
3782623SN/A
3792623SN/Atemplate
3802623SN/AFault
3812623SN/AAtomicSimpleCPU::write(uint32_t data, Addr addr,
3822623SN/A                       unsigned flags, uint64_t *res);
3832623SN/A
3842623SN/Atemplate
3852623SN/AFault
3862623SN/AAtomicSimpleCPU::write(uint16_t data, Addr addr,
3872623SN/A                       unsigned flags, uint64_t *res);
3882623SN/A
3892623SN/Atemplate
3902623SN/AFault
3912623SN/AAtomicSimpleCPU::write(uint8_t data, Addr addr,
3922623SN/A                       unsigned flags, uint64_t *res);
3932623SN/A
3942623SN/A#endif //DOXYGEN_SHOULD_SKIP_THIS
3952623SN/A
3962623SN/Atemplate<>
3972623SN/AFault
3982623SN/AAtomicSimpleCPU::write(double data, Addr addr, unsigned flags, uint64_t *res)
3992623SN/A{
4002623SN/A    return write(*(uint64_t*)&data, addr, flags, res);
4012623SN/A}
4022623SN/A
4032623SN/Atemplate<>
4042623SN/AFault
4052623SN/AAtomicSimpleCPU::write(float data, Addr addr, unsigned flags, uint64_t *res)
4062623SN/A{
4072623SN/A    return write(*(uint32_t*)&data, addr, flags, res);
4082623SN/A}
4092623SN/A
4102623SN/A
4112623SN/Atemplate<>
4122623SN/AFault
4132623SN/AAtomicSimpleCPU::write(int32_t data, Addr addr, unsigned flags, uint64_t *res)
4142623SN/A{
4152623SN/A    return write((uint32_t)data, addr, flags, res);
4162623SN/A}
4172623SN/A
4182623SN/A
4192623SN/Avoid
4202623SN/AAtomicSimpleCPU::tick()
4212623SN/A{
4222623SN/A    Tick latency = cycles(1); // instruction takes one cycle by default
4232623SN/A
4242623SN/A    for (int i = 0; i < width; ++i) {
4252623SN/A        numCycles++;
4262623SN/A
4272626SN/A        checkForInterrupts();
4282626SN/A
4292662Sstever@eecs.umich.edu        Fault fault = setupFetchRequest(ifetch_req);
4302623SN/A
4312623SN/A        if (fault == NoFault) {
4322662Sstever@eecs.umich.edu            ifetch_pkt->reinitFromRequest();
4332662Sstever@eecs.umich.edu
4342662Sstever@eecs.umich.edu            Tick icache_latency = icachePort.sendAtomic(ifetch_pkt);
4352623SN/A            // ifetch_req is initialized to read the instruction directly
4362623SN/A            // into the CPU object's inst field.
4372623SN/A
4382623SN/A            dcache_access = false; // assume no dcache access
4392623SN/A            preExecute();
4402623SN/A            fault = curStaticInst->execute(this, traceData);
4412623SN/A            postExecute();
4422623SN/A
4432623SN/A            if (simulate_stalls) {
4442662Sstever@eecs.umich.edu                Tick icache_stall = icache_latency - cycles(1);
4452623SN/A                Tick dcache_stall =
4462662Sstever@eecs.umich.edu                    dcache_access ? dcache_latency - cycles(1) : 0;
4472803Ssaidi@eecs.umich.edu                Tick stall_cycles = (icache_stall + dcache_stall) / cycles(1);
4482803Ssaidi@eecs.umich.edu                if (cycles(stall_cycles) < (icache_stall + dcache_stall))
4492803Ssaidi@eecs.umich.edu                    latency += cycles(stall_cycles+1);
4502803Ssaidi@eecs.umich.edu                else
4512803Ssaidi@eecs.umich.edu                    latency += cycles(stall_cycles);
4522623SN/A            }
4532623SN/A
4542623SN/A        }
4552623SN/A
4562623SN/A        advancePC(fault);
4572623SN/A    }
4582623SN/A
4592626SN/A    if (_status != Idle)
4602626SN/A        tickEvent.schedule(curTick + latency);
4612623SN/A}
4622623SN/A
4632623SN/A
4642623SN/A////////////////////////////////////////////////////////////////////////
4652623SN/A//
4662623SN/A//  AtomicSimpleCPU Simulation Object
4672623SN/A//
4682623SN/ABEGIN_DECLARE_SIM_OBJECT_PARAMS(AtomicSimpleCPU)
4692623SN/A
4702623SN/A    Param<Counter> max_insts_any_thread;
4712623SN/A    Param<Counter> max_insts_all_threads;
4722623SN/A    Param<Counter> max_loads_any_thread;
4732623SN/A    Param<Counter> max_loads_all_threads;
4743119Sktlim@umich.edu    Param<Tick> progress_interval;
4752623SN/A    SimObjectParam<MemObject *> mem;
4762901Ssaidi@eecs.umich.edu    SimObjectParam<System *> system;
4772623SN/A
4782623SN/A#if FULL_SYSTEM
4792623SN/A    SimObjectParam<AlphaITB *> itb;
4802623SN/A    SimObjectParam<AlphaDTB *> dtb;
4812623SN/A    Param<int> cpu_id;
4822623SN/A    Param<Tick> profile;
4832623SN/A#else
4842623SN/A    SimObjectParam<Process *> workload;
4852623SN/A#endif // FULL_SYSTEM
4862623SN/A
4872623SN/A    Param<int> clock;
4882623SN/A
4892623SN/A    Param<bool> defer_registration;
4902623SN/A    Param<int> width;
4912623SN/A    Param<bool> function_trace;
4922623SN/A    Param<Tick> function_trace_start;
4932623SN/A    Param<bool> simulate_stalls;
4942623SN/A
4952623SN/AEND_DECLARE_SIM_OBJECT_PARAMS(AtomicSimpleCPU)
4962623SN/A
4972623SN/ABEGIN_INIT_SIM_OBJECT_PARAMS(AtomicSimpleCPU)
4982623SN/A
4992623SN/A    INIT_PARAM(max_insts_any_thread,
5002623SN/A               "terminate when any thread reaches this inst count"),
5012623SN/A    INIT_PARAM(max_insts_all_threads,
5022623SN/A               "terminate when all threads have reached this inst count"),
5032623SN/A    INIT_PARAM(max_loads_any_thread,
5042623SN/A               "terminate when any thread reaches this load count"),
5052623SN/A    INIT_PARAM(max_loads_all_threads,
5062623SN/A               "terminate when all threads have reached this load count"),
5073119Sktlim@umich.edu    INIT_PARAM(progress_interval, "Progress interval"),
5082623SN/A    INIT_PARAM(mem, "memory"),
5092901Ssaidi@eecs.umich.edu    INIT_PARAM(system, "system object"),
5102623SN/A
5112623SN/A#if FULL_SYSTEM
5122623SN/A    INIT_PARAM(itb, "Instruction TLB"),
5132623SN/A    INIT_PARAM(dtb, "Data TLB"),
5142623SN/A    INIT_PARAM(cpu_id, "processor ID"),
5152623SN/A    INIT_PARAM(profile, ""),
5162623SN/A#else
5172623SN/A    INIT_PARAM(workload, "processes to run"),
5182623SN/A#endif // FULL_SYSTEM
5192623SN/A
5202623SN/A    INIT_PARAM(clock, "clock speed"),
5212623SN/A    INIT_PARAM(defer_registration, "defer system registration (for sampling)"),
5222623SN/A    INIT_PARAM(width, "cpu width"),
5232623SN/A    INIT_PARAM(function_trace, "Enable function trace"),
5242623SN/A    INIT_PARAM(function_trace_start, "Cycle to start function trace"),
5252623SN/A    INIT_PARAM(simulate_stalls, "Simulate cache stall cycles")
5262623SN/A
5272623SN/AEND_INIT_SIM_OBJECT_PARAMS(AtomicSimpleCPU)
5282623SN/A
5292623SN/A
5302623SN/ACREATE_SIM_OBJECT(AtomicSimpleCPU)
5312623SN/A{
5322623SN/A    AtomicSimpleCPU::Params *params = new AtomicSimpleCPU::Params();
5332623SN/A    params->name = getInstanceName();
5342623SN/A    params->numberOfThreads = 1;
5352623SN/A    params->max_insts_any_thread = max_insts_any_thread;
5362623SN/A    params->max_insts_all_threads = max_insts_all_threads;
5372623SN/A    params->max_loads_any_thread = max_loads_any_thread;
5382623SN/A    params->max_loads_all_threads = max_loads_all_threads;
5393119Sktlim@umich.edu    params->progress_interval = progress_interval;
5402623SN/A    params->deferRegistration = defer_registration;
5412623SN/A    params->clock = clock;
5422623SN/A    params->functionTrace = function_trace;
5432623SN/A    params->functionTraceStart = function_trace_start;
5442623SN/A    params->width = width;
5452623SN/A    params->simulate_stalls = simulate_stalls;
5462623SN/A    params->mem = mem;
5472901Ssaidi@eecs.umich.edu    params->system = system;
5482623SN/A
5492623SN/A#if FULL_SYSTEM
5502623SN/A    params->itb = itb;
5512623SN/A    params->dtb = dtb;
5522623SN/A    params->cpu_id = cpu_id;
5532623SN/A    params->profile = profile;
5542623SN/A#else
5552623SN/A    params->process = workload;
5562623SN/A#endif
5572623SN/A
5582623SN/A    AtomicSimpleCPU *cpu = new AtomicSimpleCPU(params);
5592623SN/A    return cpu;
5602623SN/A}
5612623SN/A
5622623SN/AREGISTER_SIM_OBJECT("AtomicSimpleCPU", AtomicSimpleCPU)
5632623SN/A
564