timing.cc revision 2663
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.
272623SN/A */
282623SN/A
292623SN/A#include "arch/utility.hh"
302623SN/A#include "cpu/exetrace.hh"
312623SN/A#include "cpu/simple/timing.hh"
322623SN/A#include "mem/packet_impl.hh"
332623SN/A#include "sim/builder.hh"
342623SN/A
352623SN/Ausing namespace std;
362623SN/Ausing namespace TheISA;
372623SN/A
382623SN/A
392623SN/Avoid
402623SN/ATimingSimpleCPU::init()
412623SN/A{
422623SN/A    //Create Memory Ports (conect them up)
432623SN/A    Port *mem_dport = mem->getPort("");
442623SN/A    dcachePort.setPeer(mem_dport);
452623SN/A    mem_dport->setPeer(&dcachePort);
462623SN/A
472623SN/A    Port *mem_iport = mem->getPort("");
482623SN/A    icachePort.setPeer(mem_iport);
492623SN/A    mem_iport->setPeer(&icachePort);
502623SN/A
512623SN/A    BaseCPU::init();
522623SN/A#if FULL_SYSTEM
532623SN/A    for (int i = 0; i < execContexts.size(); ++i) {
542623SN/A        ExecContext *xc = execContexts[i];
552623SN/A
562623SN/A        // initialize CPU, including PC
572623SN/A        TheISA::initCPU(xc, xc->readCpuId());
582623SN/A    }
592623SN/A#endif
602623SN/A}
612623SN/A
622623SN/ATick
632630SN/ATimingSimpleCPU::CpuPort::recvAtomic(Packet *pkt)
642623SN/A{
652623SN/A    panic("TimingSimpleCPU doesn't expect recvAtomic callback!");
662623SN/A    return curTick;
672623SN/A}
682623SN/A
692623SN/Avoid
702630SN/ATimingSimpleCPU::CpuPort::recvFunctional(Packet *pkt)
712623SN/A{
722623SN/A    panic("TimingSimpleCPU doesn't expect recvFunctional callback!");
732623SN/A}
742623SN/A
752623SN/Avoid
762623SN/ATimingSimpleCPU::CpuPort::recvStatusChange(Status status)
772623SN/A{
782631SN/A    if (status == RangeChange)
792631SN/A        return;
802631SN/A
812623SN/A    panic("TimingSimpleCPU doesn't expect recvStatusChange callback!");
822623SN/A}
832623SN/A
842623SN/ATimingSimpleCPU::TimingSimpleCPU(Params *p)
852623SN/A    : BaseSimpleCPU(p), icachePort(this), dcachePort(this)
862623SN/A{
872623SN/A    _status = Idle;
882623SN/A    ifetch_pkt = dcache_pkt = NULL;
892623SN/A}
902623SN/A
912623SN/A
922623SN/ATimingSimpleCPU::~TimingSimpleCPU()
932623SN/A{
942623SN/A}
952623SN/A
962623SN/Avoid
972623SN/ATimingSimpleCPU::serialize(ostream &os)
982623SN/A{
992623SN/A    BaseSimpleCPU::serialize(os);
1002623SN/A    SERIALIZE_ENUM(_status);
1012623SN/A}
1022623SN/A
1032623SN/Avoid
1042623SN/ATimingSimpleCPU::unserialize(Checkpoint *cp, const string &section)
1052623SN/A{
1062623SN/A    BaseSimpleCPU::unserialize(cp, section);
1072623SN/A    UNSERIALIZE_ENUM(_status);
1082623SN/A}
1092623SN/A
1102623SN/Avoid
1112623SN/ATimingSimpleCPU::switchOut(Sampler *s)
1122623SN/A{
1132623SN/A    sampler = s;
1142623SN/A    if (status() == Running) {
1152623SN/A        _status = SwitchedOut;
1162623SN/A    }
1172623SN/A    sampler->signalSwitched();
1182623SN/A}
1192623SN/A
1202623SN/A
1212623SN/Avoid
1222623SN/ATimingSimpleCPU::takeOverFrom(BaseCPU *oldCPU)
1232623SN/A{
1242623SN/A    BaseCPU::takeOverFrom(oldCPU);
1252623SN/A
1262623SN/A    // if any of this CPU's ExecContexts are active, mark the CPU as
1272623SN/A    // running and schedule its tick event.
1282623SN/A    for (int i = 0; i < execContexts.size(); ++i) {
1292623SN/A        ExecContext *xc = execContexts[i];
1302623SN/A        if (xc->status() == ExecContext::Active && _status != Running) {
1312623SN/A            _status = Running;
1322623SN/A            break;
1332623SN/A        }
1342623SN/A    }
1352623SN/A}
1362623SN/A
1372623SN/A
1382623SN/Avoid
1392623SN/ATimingSimpleCPU::activateContext(int thread_num, int delay)
1402623SN/A{
1412623SN/A    assert(thread_num == 0);
1422623SN/A    assert(cpuXC);
1432623SN/A
1442623SN/A    assert(_status == Idle);
1452623SN/A
1462623SN/A    notIdleFraction++;
1472623SN/A    _status = Running;
1482623SN/A    // kick things off by initiating the fetch of the next instruction
1492623SN/A    Event *e =
1502623SN/A        new EventWrapper<TimingSimpleCPU, &TimingSimpleCPU::fetch>(this, true);
1512623SN/A    e->schedule(curTick + cycles(delay));
1522623SN/A}
1532623SN/A
1542623SN/A
1552623SN/Avoid
1562623SN/ATimingSimpleCPU::suspendContext(int thread_num)
1572623SN/A{
1582623SN/A    assert(thread_num == 0);
1592623SN/A    assert(cpuXC);
1602623SN/A
1612644Sstever@eecs.umich.edu    assert(_status == Running);
1622623SN/A
1632644Sstever@eecs.umich.edu    // just change status to Idle... if status != Running,
1642644Sstever@eecs.umich.edu    // completeInst() will not initiate fetch of next instruction.
1652623SN/A
1662623SN/A    notIdleFraction--;
1672623SN/A    _status = Idle;
1682623SN/A}
1692623SN/A
1702623SN/A
1712623SN/Atemplate <class T>
1722623SN/AFault
1732623SN/ATimingSimpleCPU::read(Addr addr, T &data, unsigned flags)
1742623SN/A{
1752663Sstever@eecs.umich.edu    // need to fill in CPU & thread IDs here
1762663Sstever@eecs.umich.edu    Request *data_read_req = new Request();
1772623SN/A
1782663Sstever@eecs.umich.edu    data_read_req->setVirt(0, addr, sizeof(T), flags, cpuXC->readPC());
1792623SN/A
1802623SN/A    if (traceData) {
1812623SN/A        traceData->setAddr(data_read_req->getVaddr());
1822623SN/A    }
1832623SN/A
1842623SN/A   // translate to physical address
1852623SN/A    Fault fault = cpuXC->translateDataReadReq(data_read_req);
1862623SN/A
1872623SN/A    // Now do the access.
1882623SN/A    if (fault == NoFault) {
1892641Sstever@eecs.umich.edu        Packet *data_read_pkt =
1902641Sstever@eecs.umich.edu            new Packet(data_read_req, Packet::ReadReq, Packet::Broadcast);
1912623SN/A        data_read_pkt->dataDynamic<T>(new T);
1922623SN/A
1932630SN/A        if (!dcachePort.sendTiming(data_read_pkt)) {
1942623SN/A            _status = DcacheRetry;
1952623SN/A            dcache_pkt = data_read_pkt;
1962623SN/A        } else {
1972623SN/A            _status = DcacheWaitResponse;
1982623SN/A            dcache_pkt = NULL;
1992623SN/A        }
2002623SN/A    }
2012623SN/A
2022623SN/A    // This will need a new way to tell if it has a dcache attached.
2032623SN/A    if (data_read_req->getFlags() & UNCACHEABLE)
2042623SN/A        recordEvent("Uncached Read");
2052623SN/A
2062623SN/A    return fault;
2072623SN/A}
2082623SN/A
2092623SN/A#ifndef DOXYGEN_SHOULD_SKIP_THIS
2102623SN/A
2112623SN/Atemplate
2122623SN/AFault
2132623SN/ATimingSimpleCPU::read(Addr addr, uint64_t &data, unsigned flags);
2142623SN/A
2152623SN/Atemplate
2162623SN/AFault
2172623SN/ATimingSimpleCPU::read(Addr addr, uint32_t &data, unsigned flags);
2182623SN/A
2192623SN/Atemplate
2202623SN/AFault
2212623SN/ATimingSimpleCPU::read(Addr addr, uint16_t &data, unsigned flags);
2222623SN/A
2232623SN/Atemplate
2242623SN/AFault
2252623SN/ATimingSimpleCPU::read(Addr addr, uint8_t &data, unsigned flags);
2262623SN/A
2272623SN/A#endif //DOXYGEN_SHOULD_SKIP_THIS
2282623SN/A
2292623SN/Atemplate<>
2302623SN/AFault
2312623SN/ATimingSimpleCPU::read(Addr addr, double &data, unsigned flags)
2322623SN/A{
2332623SN/A    return read(addr, *(uint64_t*)&data, flags);
2342623SN/A}
2352623SN/A
2362623SN/Atemplate<>
2372623SN/AFault
2382623SN/ATimingSimpleCPU::read(Addr addr, float &data, unsigned flags)
2392623SN/A{
2402623SN/A    return read(addr, *(uint32_t*)&data, flags);
2412623SN/A}
2422623SN/A
2432623SN/A
2442623SN/Atemplate<>
2452623SN/AFault
2462623SN/ATimingSimpleCPU::read(Addr addr, int32_t &data, unsigned flags)
2472623SN/A{
2482623SN/A    return read(addr, (uint32_t&)data, flags);
2492623SN/A}
2502623SN/A
2512623SN/A
2522623SN/Atemplate <class T>
2532623SN/AFault
2542623SN/ATimingSimpleCPU::write(T data, Addr addr, unsigned flags, uint64_t *res)
2552623SN/A{
2562663Sstever@eecs.umich.edu    // need to fill in CPU & thread IDs here
2572663Sstever@eecs.umich.edu    Request *data_write_req = new Request();
2582663Sstever@eecs.umich.edu    data_write_req->setVirt(0, addr, sizeof(T), flags, cpuXC->readPC());
2592623SN/A
2602623SN/A    // translate to physical address
2612623SN/A    Fault fault = cpuXC->translateDataWriteReq(data_write_req);
2622623SN/A    // Now do the access.
2632623SN/A    if (fault == NoFault) {
2642641Sstever@eecs.umich.edu        Packet *data_write_pkt =
2652641Sstever@eecs.umich.edu            new Packet(data_write_req, Packet::WriteReq, Packet::Broadcast);
2662623SN/A        data_write_pkt->allocate();
2672623SN/A        data_write_pkt->set(data);
2682623SN/A
2692630SN/A        if (!dcachePort.sendTiming(data_write_pkt)) {
2702623SN/A            _status = DcacheRetry;
2712623SN/A            dcache_pkt = data_write_pkt;
2722623SN/A        } else {
2732623SN/A            _status = DcacheWaitResponse;
2742623SN/A            dcache_pkt = NULL;
2752623SN/A        }
2762623SN/A    }
2772623SN/A
2782623SN/A    // This will need a new way to tell if it's hooked up to a cache or not.
2792623SN/A    if (data_write_req->getFlags() & UNCACHEABLE)
2802623SN/A        recordEvent("Uncached Write");
2812623SN/A
2822623SN/A    // If the write needs to have a fault on the access, consider calling
2832623SN/A    // changeStatus() and changing it to "bad addr write" or something.
2842623SN/A    return fault;
2852623SN/A}
2862623SN/A
2872623SN/A
2882623SN/A#ifndef DOXYGEN_SHOULD_SKIP_THIS
2892623SN/Atemplate
2902623SN/AFault
2912623SN/ATimingSimpleCPU::write(uint64_t data, Addr addr,
2922623SN/A                       unsigned flags, uint64_t *res);
2932623SN/A
2942623SN/Atemplate
2952623SN/AFault
2962623SN/ATimingSimpleCPU::write(uint32_t data, Addr addr,
2972623SN/A                       unsigned flags, uint64_t *res);
2982623SN/A
2992623SN/Atemplate
3002623SN/AFault
3012623SN/ATimingSimpleCPU::write(uint16_t data, Addr addr,
3022623SN/A                       unsigned flags, uint64_t *res);
3032623SN/A
3042623SN/Atemplate
3052623SN/AFault
3062623SN/ATimingSimpleCPU::write(uint8_t data, Addr addr,
3072623SN/A                       unsigned flags, uint64_t *res);
3082623SN/A
3092623SN/A#endif //DOXYGEN_SHOULD_SKIP_THIS
3102623SN/A
3112623SN/Atemplate<>
3122623SN/AFault
3132623SN/ATimingSimpleCPU::write(double data, Addr addr, unsigned flags, uint64_t *res)
3142623SN/A{
3152623SN/A    return write(*(uint64_t*)&data, addr, flags, res);
3162623SN/A}
3172623SN/A
3182623SN/Atemplate<>
3192623SN/AFault
3202623SN/ATimingSimpleCPU::write(float data, Addr addr, unsigned flags, uint64_t *res)
3212623SN/A{
3222623SN/A    return write(*(uint32_t*)&data, addr, flags, res);
3232623SN/A}
3242623SN/A
3252623SN/A
3262623SN/Atemplate<>
3272623SN/AFault
3282623SN/ATimingSimpleCPU::write(int32_t data, Addr addr, unsigned flags, uint64_t *res)
3292623SN/A{
3302623SN/A    return write((uint32_t)data, addr, flags, res);
3312623SN/A}
3322623SN/A
3332623SN/A
3342623SN/Avoid
3352623SN/ATimingSimpleCPU::fetch()
3362623SN/A{
3372631SN/A    checkForInterrupts();
3382631SN/A
3392663Sstever@eecs.umich.edu    // need to fill in CPU & thread IDs here
3402663Sstever@eecs.umich.edu    Request *ifetch_req = new Request();
3412662Sstever@eecs.umich.edu    Fault fault = setupFetchRequest(ifetch_req);
3422623SN/A
3432641Sstever@eecs.umich.edu    ifetch_pkt = new Packet(ifetch_req, Packet::ReadReq, Packet::Broadcast);
3442623SN/A    ifetch_pkt->dataStatic(&inst);
3452623SN/A
3462623SN/A    if (fault == NoFault) {
3472630SN/A        if (!icachePort.sendTiming(ifetch_pkt)) {
3482623SN/A            // Need to wait for retry
3492623SN/A            _status = IcacheRetry;
3502623SN/A        } else {
3512623SN/A            // Need to wait for cache to respond
3522623SN/A            _status = IcacheWaitResponse;
3532623SN/A            // ownership of packet transferred to memory system
3542623SN/A            ifetch_pkt = NULL;
3552623SN/A        }
3562623SN/A    } else {
3572644Sstever@eecs.umich.edu        // fetch fault: advance directly to next instruction (fault handler)
3582644Sstever@eecs.umich.edu        advanceInst(fault);
3592623SN/A    }
3602623SN/A}
3612623SN/A
3622623SN/A
3632623SN/Avoid
3642644Sstever@eecs.umich.eduTimingSimpleCPU::advanceInst(Fault fault)
3652623SN/A{
3662623SN/A    advancePC(fault);
3672623SN/A
3682631SN/A    if (_status == Running) {
3692631SN/A        // kick off fetch of next instruction... callback from icache
3702631SN/A        // response will cause that instruction to be executed,
3712631SN/A        // keeping the CPU running.
3722631SN/A        fetch();
3732631SN/A    }
3742623SN/A}
3752623SN/A
3762623SN/A
3772623SN/Avoid
3782644Sstever@eecs.umich.eduTimingSimpleCPU::completeIfetch(Packet *pkt)
3792623SN/A{
3802623SN/A    // received a response from the icache: execute the received
3812623SN/A    // instruction
3822644Sstever@eecs.umich.edu    assert(pkt->result == Packet::Success);
3832623SN/A    assert(_status == IcacheWaitResponse);
3842623SN/A    _status = Running;
3852644Sstever@eecs.umich.edu
3862644Sstever@eecs.umich.edu    delete pkt->req;
3872644Sstever@eecs.umich.edu    delete pkt;
3882644Sstever@eecs.umich.edu
3892623SN/A    preExecute();
3902644Sstever@eecs.umich.edu    if (curStaticInst->isMemRef() && !curStaticInst->isDataPrefetch()) {
3912623SN/A        // load or store: just send to dcache
3922623SN/A        Fault fault = curStaticInst->initiateAcc(this, traceData);
3932644Sstever@eecs.umich.edu        if (fault == NoFault) {
3942644Sstever@eecs.umich.edu            // successfully initiated access: instruction will
3952644Sstever@eecs.umich.edu            // complete in dcache response callback
3962644Sstever@eecs.umich.edu            assert(_status == DcacheWaitResponse);
3972644Sstever@eecs.umich.edu        } else {
3982644Sstever@eecs.umich.edu            // fault: complete now to invoke fault handler
3992644Sstever@eecs.umich.edu            postExecute();
4002644Sstever@eecs.umich.edu            advanceInst(fault);
4012644Sstever@eecs.umich.edu        }
4022623SN/A    } else {
4032623SN/A        // non-memory instruction: execute completely now
4042623SN/A        Fault fault = curStaticInst->execute(this, traceData);
4052644Sstever@eecs.umich.edu        postExecute();
4062644Sstever@eecs.umich.edu        advanceInst(fault);
4072623SN/A    }
4082623SN/A}
4092623SN/A
4102623SN/A
4112623SN/Abool
4122630SN/ATimingSimpleCPU::IcachePort::recvTiming(Packet *pkt)
4132623SN/A{
4142644Sstever@eecs.umich.edu    cpu->completeIfetch(pkt);
4152623SN/A    return true;
4162623SN/A}
4172623SN/A
4182657Ssaidi@eecs.umich.eduvoid
4192623SN/ATimingSimpleCPU::IcachePort::recvRetry()
4202623SN/A{
4212623SN/A    // we shouldn't get a retry unless we have a packet that we're
4222623SN/A    // waiting to transmit
4232623SN/A    assert(cpu->ifetch_pkt != NULL);
4242623SN/A    assert(cpu->_status == IcacheRetry);
4252623SN/A    Packet *tmp = cpu->ifetch_pkt;
4262657Ssaidi@eecs.umich.edu    if (sendTiming(tmp)) {
4272657Ssaidi@eecs.umich.edu        cpu->_status = IcacheWaitResponse;
4282657Ssaidi@eecs.umich.edu        cpu->ifetch_pkt = NULL;
4292657Ssaidi@eecs.umich.edu    }
4302623SN/A}
4312623SN/A
4322623SN/Avoid
4332623SN/ATimingSimpleCPU::completeDataAccess(Packet *pkt)
4342623SN/A{
4352623SN/A    // received a response from the dcache: complete the load or store
4362623SN/A    // instruction
4372641Sstever@eecs.umich.edu    assert(pkt->result == Packet::Success);
4382623SN/A    assert(_status == DcacheWaitResponse);
4392623SN/A    _status = Running;
4402623SN/A
4412623SN/A    Fault fault = curStaticInst->completeAcc(pkt, this, traceData);
4422623SN/A
4432644Sstever@eecs.umich.edu    delete pkt->req;
4442644Sstever@eecs.umich.edu    delete pkt;
4452644Sstever@eecs.umich.edu
4462644Sstever@eecs.umich.edu    postExecute();
4472644Sstever@eecs.umich.edu    advanceInst(fault);
4482623SN/A}
4492623SN/A
4502623SN/A
4512623SN/A
4522623SN/Abool
4532630SN/ATimingSimpleCPU::DcachePort::recvTiming(Packet *pkt)
4542623SN/A{
4552630SN/A    cpu->completeDataAccess(pkt);
4562623SN/A    return true;
4572623SN/A}
4582623SN/A
4592657Ssaidi@eecs.umich.eduvoid
4602623SN/ATimingSimpleCPU::DcachePort::recvRetry()
4612623SN/A{
4622623SN/A    // we shouldn't get a retry unless we have a packet that we're
4632623SN/A    // waiting to transmit
4642623SN/A    assert(cpu->dcache_pkt != NULL);
4652623SN/A    assert(cpu->_status == DcacheRetry);
4662623SN/A    Packet *tmp = cpu->dcache_pkt;
4672657Ssaidi@eecs.umich.edu    if (sendTiming(tmp)) {
4682657Ssaidi@eecs.umich.edu        cpu->_status = DcacheWaitResponse;
4692657Ssaidi@eecs.umich.edu        cpu->dcache_pkt = NULL;
4702657Ssaidi@eecs.umich.edu    }
4712623SN/A}
4722623SN/A
4732623SN/A
4742623SN/A////////////////////////////////////////////////////////////////////////
4752623SN/A//
4762623SN/A//  TimingSimpleCPU Simulation Object
4772623SN/A//
4782623SN/ABEGIN_DECLARE_SIM_OBJECT_PARAMS(TimingSimpleCPU)
4792623SN/A
4802623SN/A    Param<Counter> max_insts_any_thread;
4812623SN/A    Param<Counter> max_insts_all_threads;
4822623SN/A    Param<Counter> max_loads_any_thread;
4832623SN/A    Param<Counter> max_loads_all_threads;
4842623SN/A    SimObjectParam<MemObject *> mem;
4852623SN/A
4862623SN/A#if FULL_SYSTEM
4872623SN/A    SimObjectParam<AlphaITB *> itb;
4882623SN/A    SimObjectParam<AlphaDTB *> dtb;
4892623SN/A    SimObjectParam<System *> system;
4902623SN/A    Param<int> cpu_id;
4912623SN/A    Param<Tick> profile;
4922623SN/A#else
4932623SN/A    SimObjectParam<Process *> workload;
4942623SN/A#endif // FULL_SYSTEM
4952623SN/A
4962623SN/A    Param<int> clock;
4972623SN/A
4982623SN/A    Param<bool> defer_registration;
4992623SN/A    Param<int> width;
5002623SN/A    Param<bool> function_trace;
5012623SN/A    Param<Tick> function_trace_start;
5022623SN/A    Param<bool> simulate_stalls;
5032623SN/A
5042623SN/AEND_DECLARE_SIM_OBJECT_PARAMS(TimingSimpleCPU)
5052623SN/A
5062623SN/ABEGIN_INIT_SIM_OBJECT_PARAMS(TimingSimpleCPU)
5072623SN/A
5082623SN/A    INIT_PARAM(max_insts_any_thread,
5092623SN/A               "terminate when any thread reaches this inst count"),
5102623SN/A    INIT_PARAM(max_insts_all_threads,
5112623SN/A               "terminate when all threads have reached this inst count"),
5122623SN/A    INIT_PARAM(max_loads_any_thread,
5132623SN/A               "terminate when any thread reaches this load count"),
5142623SN/A    INIT_PARAM(max_loads_all_threads,
5152623SN/A               "terminate when all threads have reached this load count"),
5162623SN/A    INIT_PARAM(mem, "memory"),
5172623SN/A
5182623SN/A#if FULL_SYSTEM
5192623SN/A    INIT_PARAM(itb, "Instruction TLB"),
5202623SN/A    INIT_PARAM(dtb, "Data TLB"),
5212623SN/A    INIT_PARAM(system, "system object"),
5222623SN/A    INIT_PARAM(cpu_id, "processor ID"),
5232623SN/A    INIT_PARAM(profile, ""),
5242623SN/A#else
5252623SN/A    INIT_PARAM(workload, "processes to run"),
5262623SN/A#endif // FULL_SYSTEM
5272623SN/A
5282623SN/A    INIT_PARAM(clock, "clock speed"),
5292623SN/A    INIT_PARAM(defer_registration, "defer system registration (for sampling)"),
5302623SN/A    INIT_PARAM(width, "cpu width"),
5312623SN/A    INIT_PARAM(function_trace, "Enable function trace"),
5322623SN/A    INIT_PARAM(function_trace_start, "Cycle to start function trace"),
5332623SN/A    INIT_PARAM(simulate_stalls, "Simulate cache stall cycles")
5342623SN/A
5352623SN/AEND_INIT_SIM_OBJECT_PARAMS(TimingSimpleCPU)
5362623SN/A
5372623SN/A
5382623SN/ACREATE_SIM_OBJECT(TimingSimpleCPU)
5392623SN/A{
5402623SN/A    TimingSimpleCPU::Params *params = new TimingSimpleCPU::Params();
5412623SN/A    params->name = getInstanceName();
5422623SN/A    params->numberOfThreads = 1;
5432623SN/A    params->max_insts_any_thread = max_insts_any_thread;
5442623SN/A    params->max_insts_all_threads = max_insts_all_threads;
5452623SN/A    params->max_loads_any_thread = max_loads_any_thread;
5462623SN/A    params->max_loads_all_threads = max_loads_all_threads;
5472623SN/A    params->deferRegistration = defer_registration;
5482623SN/A    params->clock = clock;
5492623SN/A    params->functionTrace = function_trace;
5502623SN/A    params->functionTraceStart = function_trace_start;
5512623SN/A    params->mem = mem;
5522623SN/A
5532623SN/A#if FULL_SYSTEM
5542623SN/A    params->itb = itb;
5552623SN/A    params->dtb = dtb;
5562623SN/A    params->system = system;
5572623SN/A    params->cpu_id = cpu_id;
5582623SN/A    params->profile = profile;
5592623SN/A#else
5602623SN/A    params->process = workload;
5612623SN/A#endif
5622623SN/A
5632623SN/A    TimingSimpleCPU *cpu = new TimingSimpleCPU(params);
5642623SN/A    return cpu;
5652623SN/A}
5662623SN/A
5672623SN/AREGISTER_SIM_OBJECT("TimingSimpleCPU", TimingSimpleCPU)
5682623SN/A
569