timing.cc revision 2839
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/timing.hh" 342623SN/A#include "mem/packet_impl.hh" 352623SN/A#include "sim/builder.hh" 362623SN/A 372623SN/Ausing namespace std; 382623SN/Ausing namespace TheISA; 392623SN/A 402623SN/A 412623SN/Avoid 422623SN/ATimingSimpleCPU::init() 432623SN/A{ 442623SN/A //Create Memory Ports (conect them up) 452623SN/A Port *mem_dport = mem->getPort(""); 462623SN/A dcachePort.setPeer(mem_dport); 472623SN/A mem_dport->setPeer(&dcachePort); 482623SN/A 492623SN/A Port *mem_iport = mem->getPort(""); 502623SN/A icachePort.setPeer(mem_iport); 512623SN/A mem_iport->setPeer(&icachePort); 522623SN/A 532623SN/A BaseCPU::init(); 542623SN/A#if FULL_SYSTEM 552680Sktlim@umich.edu for (int i = 0; i < threadContexts.size(); ++i) { 562680Sktlim@umich.edu ThreadContext *tc = threadContexts[i]; 572623SN/A 582623SN/A // initialize CPU, including PC 592680Sktlim@umich.edu TheISA::initCPU(tc, tc->readCpuId()); 602623SN/A } 612623SN/A#endif 622623SN/A} 632623SN/A 642623SN/ATick 652630SN/ATimingSimpleCPU::CpuPort::recvAtomic(Packet *pkt) 662623SN/A{ 672623SN/A panic("TimingSimpleCPU doesn't expect recvAtomic callback!"); 682623SN/A return curTick; 692623SN/A} 702623SN/A 712623SN/Avoid 722630SN/ATimingSimpleCPU::CpuPort::recvFunctional(Packet *pkt) 732623SN/A{ 742623SN/A panic("TimingSimpleCPU doesn't expect recvFunctional callback!"); 752623SN/A} 762623SN/A 772623SN/Avoid 782623SN/ATimingSimpleCPU::CpuPort::recvStatusChange(Status status) 792623SN/A{ 802631SN/A if (status == RangeChange) 812631SN/A return; 822631SN/A 832623SN/A panic("TimingSimpleCPU doesn't expect recvStatusChange callback!"); 842623SN/A} 852623SN/A 862623SN/ATimingSimpleCPU::TimingSimpleCPU(Params *p) 872623SN/A : BaseSimpleCPU(p), icachePort(this), dcachePort(this) 882623SN/A{ 892623SN/A _status = Idle; 902623SN/A ifetch_pkt = dcache_pkt = NULL; 912839Sktlim@umich.edu drainEvent = NULL; 922798Sktlim@umich.edu state = SimObject::Timing; 932623SN/A} 942623SN/A 952623SN/A 962623SN/ATimingSimpleCPU::~TimingSimpleCPU() 972623SN/A{ 982623SN/A} 992623SN/A 1002623SN/Avoid 1012623SN/ATimingSimpleCPU::serialize(ostream &os) 1022623SN/A{ 1032798Sktlim@umich.edu SERIALIZE_ENUM(_status); 1042623SN/A BaseSimpleCPU::serialize(os); 1052623SN/A} 1062623SN/A 1072623SN/Avoid 1082623SN/ATimingSimpleCPU::unserialize(Checkpoint *cp, const string §ion) 1092623SN/A{ 1102798Sktlim@umich.edu UNSERIALIZE_ENUM(_status); 1112623SN/A BaseSimpleCPU::unserialize(cp, section); 1122798Sktlim@umich.edu} 1132798Sktlim@umich.edu 1142798Sktlim@umich.edubool 1152839Sktlim@umich.eduTimingSimpleCPU::drain(Event *drain_event) 1162798Sktlim@umich.edu{ 1172839Sktlim@umich.edu // TimingSimpleCPU is ready to drain if it's not waiting for 1182798Sktlim@umich.edu // an access to complete. 1192798Sktlim@umich.edu if (status() == Idle || status() == Running || status() == SwitchedOut) { 1202839Sktlim@umich.edu changeState(SimObject::DrainedTiming); 1212798Sktlim@umich.edu return false; 1222798Sktlim@umich.edu } else { 1232839Sktlim@umich.edu changeState(SimObject::Draining); 1242839Sktlim@umich.edu drainEvent = drain_event; 1252798Sktlim@umich.edu return true; 1262798Sktlim@umich.edu } 1272623SN/A} 1282623SN/A 1292623SN/Avoid 1302798Sktlim@umich.eduTimingSimpleCPU::resume() 1312623SN/A{ 1322798Sktlim@umich.edu if (_status != SwitchedOut && _status != Idle) { 1332798Sktlim@umich.edu Event *e = 1342798Sktlim@umich.edu new EventWrapper<TimingSimpleCPU, &TimingSimpleCPU::fetch>(this, true); 1352798Sktlim@umich.edu e->schedule(curTick); 1362623SN/A } 1372798Sktlim@umich.edu} 1382798Sktlim@umich.edu 1392798Sktlim@umich.eduvoid 1402798Sktlim@umich.eduTimingSimpleCPU::setMemoryMode(State new_mode) 1412798Sktlim@umich.edu{ 1422798Sktlim@umich.edu assert(new_mode == SimObject::Timing); 1432798Sktlim@umich.edu} 1442798Sktlim@umich.edu 1452798Sktlim@umich.eduvoid 1462798Sktlim@umich.eduTimingSimpleCPU::switchOut() 1472798Sktlim@umich.edu{ 1482798Sktlim@umich.edu assert(status() == Running || status() == Idle); 1492798Sktlim@umich.edu _status = SwitchedOut; 1502623SN/A} 1512623SN/A 1522623SN/A 1532623SN/Avoid 1542623SN/ATimingSimpleCPU::takeOverFrom(BaseCPU *oldCPU) 1552623SN/A{ 1562623SN/A BaseCPU::takeOverFrom(oldCPU); 1572623SN/A 1582680Sktlim@umich.edu // if any of this CPU's ThreadContexts are active, mark the CPU as 1592623SN/A // running and schedule its tick event. 1602680Sktlim@umich.edu for (int i = 0; i < threadContexts.size(); ++i) { 1612680Sktlim@umich.edu ThreadContext *tc = threadContexts[i]; 1622680Sktlim@umich.edu if (tc->status() == ThreadContext::Active && _status != Running) { 1632623SN/A _status = Running; 1642623SN/A break; 1652623SN/A } 1662623SN/A } 1672623SN/A} 1682623SN/A 1692623SN/A 1702623SN/Avoid 1712623SN/ATimingSimpleCPU::activateContext(int thread_num, int delay) 1722623SN/A{ 1732623SN/A assert(thread_num == 0); 1742683Sktlim@umich.edu assert(thread); 1752623SN/A 1762623SN/A assert(_status == Idle); 1772623SN/A 1782623SN/A notIdleFraction++; 1792623SN/A _status = Running; 1802623SN/A // kick things off by initiating the fetch of the next instruction 1812623SN/A Event *e = 1822623SN/A new EventWrapper<TimingSimpleCPU, &TimingSimpleCPU::fetch>(this, true); 1832623SN/A e->schedule(curTick + cycles(delay)); 1842623SN/A} 1852623SN/A 1862623SN/A 1872623SN/Avoid 1882623SN/ATimingSimpleCPU::suspendContext(int thread_num) 1892623SN/A{ 1902623SN/A assert(thread_num == 0); 1912683Sktlim@umich.edu assert(thread); 1922623SN/A 1932644Sstever@eecs.umich.edu assert(_status == Running); 1942623SN/A 1952644Sstever@eecs.umich.edu // just change status to Idle... if status != Running, 1962644Sstever@eecs.umich.edu // completeInst() will not initiate fetch of next instruction. 1972623SN/A 1982623SN/A notIdleFraction--; 1992623SN/A _status = Idle; 2002623SN/A} 2012623SN/A 2022623SN/A 2032623SN/Atemplate <class T> 2042623SN/AFault 2052623SN/ATimingSimpleCPU::read(Addr addr, T &data, unsigned flags) 2062623SN/A{ 2072663Sstever@eecs.umich.edu // need to fill in CPU & thread IDs here 2082663Sstever@eecs.umich.edu Request *data_read_req = new Request(); 2092835Srdreslin@umich.edu data_read_req->setThreadContext(0,0); //Need CPU/Thread IDS HERE 2102683Sktlim@umich.edu data_read_req->setVirt(0, addr, sizeof(T), flags, thread->readPC()); 2112623SN/A 2122623SN/A if (traceData) { 2132623SN/A traceData->setAddr(data_read_req->getVaddr()); 2142623SN/A } 2152623SN/A 2162623SN/A // translate to physical address 2172683Sktlim@umich.edu Fault fault = thread->translateDataReadReq(data_read_req); 2182623SN/A 2192623SN/A // Now do the access. 2202623SN/A if (fault == NoFault) { 2212641Sstever@eecs.umich.edu Packet *data_read_pkt = 2222641Sstever@eecs.umich.edu new Packet(data_read_req, Packet::ReadReq, Packet::Broadcast); 2232623SN/A data_read_pkt->dataDynamic<T>(new T); 2242623SN/A 2252630SN/A if (!dcachePort.sendTiming(data_read_pkt)) { 2262623SN/A _status = DcacheRetry; 2272623SN/A dcache_pkt = data_read_pkt; 2282623SN/A } else { 2292623SN/A _status = DcacheWaitResponse; 2302623SN/A dcache_pkt = NULL; 2312623SN/A } 2322623SN/A } 2332623SN/A 2342623SN/A // This will need a new way to tell if it has a dcache attached. 2352623SN/A if (data_read_req->getFlags() & UNCACHEABLE) 2362623SN/A recordEvent("Uncached Read"); 2372623SN/A 2382623SN/A return fault; 2392623SN/A} 2402623SN/A 2412623SN/A#ifndef DOXYGEN_SHOULD_SKIP_THIS 2422623SN/A 2432623SN/Atemplate 2442623SN/AFault 2452623SN/ATimingSimpleCPU::read(Addr addr, uint64_t &data, unsigned flags); 2462623SN/A 2472623SN/Atemplate 2482623SN/AFault 2492623SN/ATimingSimpleCPU::read(Addr addr, uint32_t &data, unsigned flags); 2502623SN/A 2512623SN/Atemplate 2522623SN/AFault 2532623SN/ATimingSimpleCPU::read(Addr addr, uint16_t &data, unsigned flags); 2542623SN/A 2552623SN/Atemplate 2562623SN/AFault 2572623SN/ATimingSimpleCPU::read(Addr addr, uint8_t &data, unsigned flags); 2582623SN/A 2592623SN/A#endif //DOXYGEN_SHOULD_SKIP_THIS 2602623SN/A 2612623SN/Atemplate<> 2622623SN/AFault 2632623SN/ATimingSimpleCPU::read(Addr addr, double &data, unsigned flags) 2642623SN/A{ 2652623SN/A return read(addr, *(uint64_t*)&data, flags); 2662623SN/A} 2672623SN/A 2682623SN/Atemplate<> 2692623SN/AFault 2702623SN/ATimingSimpleCPU::read(Addr addr, float &data, unsigned flags) 2712623SN/A{ 2722623SN/A return read(addr, *(uint32_t*)&data, flags); 2732623SN/A} 2742623SN/A 2752623SN/A 2762623SN/Atemplate<> 2772623SN/AFault 2782623SN/ATimingSimpleCPU::read(Addr addr, int32_t &data, unsigned flags) 2792623SN/A{ 2802623SN/A return read(addr, (uint32_t&)data, flags); 2812623SN/A} 2822623SN/A 2832623SN/A 2842623SN/Atemplate <class T> 2852623SN/AFault 2862623SN/ATimingSimpleCPU::write(T data, Addr addr, unsigned flags, uint64_t *res) 2872623SN/A{ 2882663Sstever@eecs.umich.edu // need to fill in CPU & thread IDs here 2892663Sstever@eecs.umich.edu Request *data_write_req = new Request(); 2902835Srdreslin@umich.edu data_write_req->setThreadContext(0,0); //Need CPU/Thread IDS HERE 2912683Sktlim@umich.edu data_write_req->setVirt(0, addr, sizeof(T), flags, thread->readPC()); 2922623SN/A 2932623SN/A // translate to physical address 2942683Sktlim@umich.edu Fault fault = thread->translateDataWriteReq(data_write_req); 2952623SN/A // Now do the access. 2962623SN/A if (fault == NoFault) { 2972641Sstever@eecs.umich.edu Packet *data_write_pkt = 2982641Sstever@eecs.umich.edu new Packet(data_write_req, Packet::WriteReq, Packet::Broadcast); 2992623SN/A data_write_pkt->allocate(); 3002623SN/A data_write_pkt->set(data); 3012623SN/A 3022630SN/A if (!dcachePort.sendTiming(data_write_pkt)) { 3032623SN/A _status = DcacheRetry; 3042623SN/A dcache_pkt = data_write_pkt; 3052623SN/A } else { 3062623SN/A _status = DcacheWaitResponse; 3072623SN/A dcache_pkt = NULL; 3082623SN/A } 3092623SN/A } 3102623SN/A 3112623SN/A // This will need a new way to tell if it's hooked up to a cache or not. 3122623SN/A if (data_write_req->getFlags() & UNCACHEABLE) 3132623SN/A recordEvent("Uncached Write"); 3142623SN/A 3152623SN/A // If the write needs to have a fault on the access, consider calling 3162623SN/A // changeStatus() and changing it to "bad addr write" or something. 3172623SN/A return fault; 3182623SN/A} 3192623SN/A 3202623SN/A 3212623SN/A#ifndef DOXYGEN_SHOULD_SKIP_THIS 3222623SN/Atemplate 3232623SN/AFault 3242623SN/ATimingSimpleCPU::write(uint64_t data, Addr addr, 3252623SN/A unsigned flags, uint64_t *res); 3262623SN/A 3272623SN/Atemplate 3282623SN/AFault 3292623SN/ATimingSimpleCPU::write(uint32_t data, Addr addr, 3302623SN/A unsigned flags, uint64_t *res); 3312623SN/A 3322623SN/Atemplate 3332623SN/AFault 3342623SN/ATimingSimpleCPU::write(uint16_t data, Addr addr, 3352623SN/A unsigned flags, uint64_t *res); 3362623SN/A 3372623SN/Atemplate 3382623SN/AFault 3392623SN/ATimingSimpleCPU::write(uint8_t data, Addr addr, 3402623SN/A unsigned flags, uint64_t *res); 3412623SN/A 3422623SN/A#endif //DOXYGEN_SHOULD_SKIP_THIS 3432623SN/A 3442623SN/Atemplate<> 3452623SN/AFault 3462623SN/ATimingSimpleCPU::write(double data, Addr addr, unsigned flags, uint64_t *res) 3472623SN/A{ 3482623SN/A return write(*(uint64_t*)&data, addr, flags, res); 3492623SN/A} 3502623SN/A 3512623SN/Atemplate<> 3522623SN/AFault 3532623SN/ATimingSimpleCPU::write(float data, Addr addr, unsigned flags, uint64_t *res) 3542623SN/A{ 3552623SN/A return write(*(uint32_t*)&data, addr, flags, res); 3562623SN/A} 3572623SN/A 3582623SN/A 3592623SN/Atemplate<> 3602623SN/AFault 3612623SN/ATimingSimpleCPU::write(int32_t data, Addr addr, unsigned flags, uint64_t *res) 3622623SN/A{ 3632623SN/A return write((uint32_t)data, addr, flags, res); 3642623SN/A} 3652623SN/A 3662623SN/A 3672623SN/Avoid 3682623SN/ATimingSimpleCPU::fetch() 3692623SN/A{ 3702631SN/A checkForInterrupts(); 3712631SN/A 3722663Sstever@eecs.umich.edu // need to fill in CPU & thread IDs here 3732663Sstever@eecs.umich.edu Request *ifetch_req = new Request(); 3742835Srdreslin@umich.edu ifetch_req->setThreadContext(0,0); //Need CPU/Thread IDS HERE 3752662Sstever@eecs.umich.edu Fault fault = setupFetchRequest(ifetch_req); 3762623SN/A 3772641Sstever@eecs.umich.edu ifetch_pkt = new Packet(ifetch_req, Packet::ReadReq, Packet::Broadcast); 3782623SN/A ifetch_pkt->dataStatic(&inst); 3792623SN/A 3802623SN/A if (fault == NoFault) { 3812630SN/A if (!icachePort.sendTiming(ifetch_pkt)) { 3822623SN/A // Need to wait for retry 3832623SN/A _status = IcacheRetry; 3842623SN/A } else { 3852623SN/A // Need to wait for cache to respond 3862623SN/A _status = IcacheWaitResponse; 3872623SN/A // ownership of packet transferred to memory system 3882623SN/A ifetch_pkt = NULL; 3892623SN/A } 3902623SN/A } else { 3912644Sstever@eecs.umich.edu // fetch fault: advance directly to next instruction (fault handler) 3922644Sstever@eecs.umich.edu advanceInst(fault); 3932623SN/A } 3942623SN/A} 3952623SN/A 3962623SN/A 3972623SN/Avoid 3982644Sstever@eecs.umich.eduTimingSimpleCPU::advanceInst(Fault fault) 3992623SN/A{ 4002623SN/A advancePC(fault); 4012623SN/A 4022631SN/A if (_status == Running) { 4032631SN/A // kick off fetch of next instruction... callback from icache 4042631SN/A // response will cause that instruction to be executed, 4052631SN/A // keeping the CPU running. 4062631SN/A fetch(); 4072631SN/A } 4082623SN/A} 4092623SN/A 4102623SN/A 4112623SN/Avoid 4122644Sstever@eecs.umich.eduTimingSimpleCPU::completeIfetch(Packet *pkt) 4132623SN/A{ 4142623SN/A // received a response from the icache: execute the received 4152623SN/A // instruction 4162644Sstever@eecs.umich.edu assert(pkt->result == Packet::Success); 4172623SN/A assert(_status == IcacheWaitResponse); 4182798Sktlim@umich.edu 4192623SN/A _status = Running; 4202644Sstever@eecs.umich.edu 4212644Sstever@eecs.umich.edu delete pkt->req; 4222644Sstever@eecs.umich.edu delete pkt; 4232644Sstever@eecs.umich.edu 4242839Sktlim@umich.edu if (getState() == SimObject::Draining) { 4252839Sktlim@umich.edu completeDrain(); 4262798Sktlim@umich.edu return; 4272798Sktlim@umich.edu } 4282798Sktlim@umich.edu 4292623SN/A preExecute(); 4302644Sstever@eecs.umich.edu if (curStaticInst->isMemRef() && !curStaticInst->isDataPrefetch()) { 4312623SN/A // load or store: just send to dcache 4322623SN/A Fault fault = curStaticInst->initiateAcc(this, traceData); 4332644Sstever@eecs.umich.edu if (fault == NoFault) { 4342644Sstever@eecs.umich.edu // successfully initiated access: instruction will 4352644Sstever@eecs.umich.edu // complete in dcache response callback 4362644Sstever@eecs.umich.edu assert(_status == DcacheWaitResponse); 4372644Sstever@eecs.umich.edu } else { 4382644Sstever@eecs.umich.edu // fault: complete now to invoke fault handler 4392644Sstever@eecs.umich.edu postExecute(); 4402644Sstever@eecs.umich.edu advanceInst(fault); 4412644Sstever@eecs.umich.edu } 4422623SN/A } else { 4432623SN/A // non-memory instruction: execute completely now 4442623SN/A Fault fault = curStaticInst->execute(this, traceData); 4452644Sstever@eecs.umich.edu postExecute(); 4462644Sstever@eecs.umich.edu advanceInst(fault); 4472623SN/A } 4482623SN/A} 4492623SN/A 4502623SN/A 4512623SN/Abool 4522630SN/ATimingSimpleCPU::IcachePort::recvTiming(Packet *pkt) 4532623SN/A{ 4542644Sstever@eecs.umich.edu cpu->completeIfetch(pkt); 4552623SN/A return true; 4562623SN/A} 4572623SN/A 4582657Ssaidi@eecs.umich.eduvoid 4592623SN/ATimingSimpleCPU::IcachePort::recvRetry() 4602623SN/A{ 4612623SN/A // we shouldn't get a retry unless we have a packet that we're 4622623SN/A // waiting to transmit 4632623SN/A assert(cpu->ifetch_pkt != NULL); 4642623SN/A assert(cpu->_status == IcacheRetry); 4652623SN/A Packet *tmp = cpu->ifetch_pkt; 4662657Ssaidi@eecs.umich.edu if (sendTiming(tmp)) { 4672657Ssaidi@eecs.umich.edu cpu->_status = IcacheWaitResponse; 4682657Ssaidi@eecs.umich.edu cpu->ifetch_pkt = NULL; 4692657Ssaidi@eecs.umich.edu } 4702623SN/A} 4712623SN/A 4722623SN/Avoid 4732623SN/ATimingSimpleCPU::completeDataAccess(Packet *pkt) 4742623SN/A{ 4752623SN/A // received a response from the dcache: complete the load or store 4762623SN/A // instruction 4772641Sstever@eecs.umich.edu assert(pkt->result == Packet::Success); 4782623SN/A assert(_status == DcacheWaitResponse); 4792623SN/A _status = Running; 4802623SN/A 4812839Sktlim@umich.edu if (getState() == SimObject::Draining) { 4822839Sktlim@umich.edu completeDrain(); 4832798Sktlim@umich.edu 4842798Sktlim@umich.edu delete pkt->req; 4852798Sktlim@umich.edu delete pkt; 4862798Sktlim@umich.edu 4872798Sktlim@umich.edu return; 4882798Sktlim@umich.edu } 4892798Sktlim@umich.edu 4902623SN/A Fault fault = curStaticInst->completeAcc(pkt, this, traceData); 4912623SN/A 4922644Sstever@eecs.umich.edu delete pkt->req; 4932644Sstever@eecs.umich.edu delete pkt; 4942644Sstever@eecs.umich.edu 4952644Sstever@eecs.umich.edu postExecute(); 4962644Sstever@eecs.umich.edu advanceInst(fault); 4972623SN/A} 4982623SN/A 4992623SN/A 5002798Sktlim@umich.eduvoid 5012839Sktlim@umich.eduTimingSimpleCPU::completeDrain() 5022798Sktlim@umich.edu{ 5032839Sktlim@umich.edu DPRINTF(Config, "Done draining\n"); 5042839Sktlim@umich.edu changeState(SimObject::DrainedTiming); 5052839Sktlim@umich.edu drainEvent->process(); 5062798Sktlim@umich.edu} 5072623SN/A 5082623SN/Abool 5092630SN/ATimingSimpleCPU::DcachePort::recvTiming(Packet *pkt) 5102623SN/A{ 5112630SN/A cpu->completeDataAccess(pkt); 5122623SN/A return true; 5132623SN/A} 5142623SN/A 5152657Ssaidi@eecs.umich.eduvoid 5162623SN/ATimingSimpleCPU::DcachePort::recvRetry() 5172623SN/A{ 5182623SN/A // we shouldn't get a retry unless we have a packet that we're 5192623SN/A // waiting to transmit 5202623SN/A assert(cpu->dcache_pkt != NULL); 5212623SN/A assert(cpu->_status == DcacheRetry); 5222623SN/A Packet *tmp = cpu->dcache_pkt; 5232657Ssaidi@eecs.umich.edu if (sendTiming(tmp)) { 5242657Ssaidi@eecs.umich.edu cpu->_status = DcacheWaitResponse; 5252657Ssaidi@eecs.umich.edu cpu->dcache_pkt = NULL; 5262657Ssaidi@eecs.umich.edu } 5272623SN/A} 5282623SN/A 5292623SN/A 5302623SN/A//////////////////////////////////////////////////////////////////////// 5312623SN/A// 5322623SN/A// TimingSimpleCPU Simulation Object 5332623SN/A// 5342623SN/ABEGIN_DECLARE_SIM_OBJECT_PARAMS(TimingSimpleCPU) 5352623SN/A 5362623SN/A Param<Counter> max_insts_any_thread; 5372623SN/A Param<Counter> max_insts_all_threads; 5382623SN/A Param<Counter> max_loads_any_thread; 5392623SN/A Param<Counter> max_loads_all_threads; 5402623SN/A SimObjectParam<MemObject *> mem; 5412623SN/A 5422623SN/A#if FULL_SYSTEM 5432623SN/A SimObjectParam<AlphaITB *> itb; 5442623SN/A SimObjectParam<AlphaDTB *> dtb; 5452623SN/A SimObjectParam<System *> system; 5462623SN/A Param<int> cpu_id; 5472623SN/A Param<Tick> profile; 5482623SN/A#else 5492623SN/A SimObjectParam<Process *> workload; 5502623SN/A#endif // FULL_SYSTEM 5512623SN/A 5522623SN/A Param<int> clock; 5532623SN/A 5542623SN/A Param<bool> defer_registration; 5552623SN/A Param<int> width; 5562623SN/A Param<bool> function_trace; 5572623SN/A Param<Tick> function_trace_start; 5582623SN/A Param<bool> simulate_stalls; 5592623SN/A 5602623SN/AEND_DECLARE_SIM_OBJECT_PARAMS(TimingSimpleCPU) 5612623SN/A 5622623SN/ABEGIN_INIT_SIM_OBJECT_PARAMS(TimingSimpleCPU) 5632623SN/A 5642623SN/A INIT_PARAM(max_insts_any_thread, 5652623SN/A "terminate when any thread reaches this inst count"), 5662623SN/A INIT_PARAM(max_insts_all_threads, 5672623SN/A "terminate when all threads have reached this inst count"), 5682623SN/A INIT_PARAM(max_loads_any_thread, 5692623SN/A "terminate when any thread reaches this load count"), 5702623SN/A INIT_PARAM(max_loads_all_threads, 5712623SN/A "terminate when all threads have reached this load count"), 5722623SN/A INIT_PARAM(mem, "memory"), 5732623SN/A 5742623SN/A#if FULL_SYSTEM 5752623SN/A INIT_PARAM(itb, "Instruction TLB"), 5762623SN/A INIT_PARAM(dtb, "Data TLB"), 5772623SN/A INIT_PARAM(system, "system object"), 5782623SN/A INIT_PARAM(cpu_id, "processor ID"), 5792623SN/A INIT_PARAM(profile, ""), 5802623SN/A#else 5812623SN/A INIT_PARAM(workload, "processes to run"), 5822623SN/A#endif // FULL_SYSTEM 5832623SN/A 5842623SN/A INIT_PARAM(clock, "clock speed"), 5852623SN/A INIT_PARAM(defer_registration, "defer system registration (for sampling)"), 5862623SN/A INIT_PARAM(width, "cpu width"), 5872623SN/A INIT_PARAM(function_trace, "Enable function trace"), 5882623SN/A INIT_PARAM(function_trace_start, "Cycle to start function trace"), 5892623SN/A INIT_PARAM(simulate_stalls, "Simulate cache stall cycles") 5902623SN/A 5912623SN/AEND_INIT_SIM_OBJECT_PARAMS(TimingSimpleCPU) 5922623SN/A 5932623SN/A 5942623SN/ACREATE_SIM_OBJECT(TimingSimpleCPU) 5952623SN/A{ 5962623SN/A TimingSimpleCPU::Params *params = new TimingSimpleCPU::Params(); 5972623SN/A params->name = getInstanceName(); 5982623SN/A params->numberOfThreads = 1; 5992623SN/A params->max_insts_any_thread = max_insts_any_thread; 6002623SN/A params->max_insts_all_threads = max_insts_all_threads; 6012623SN/A params->max_loads_any_thread = max_loads_any_thread; 6022623SN/A params->max_loads_all_threads = max_loads_all_threads; 6032623SN/A params->deferRegistration = defer_registration; 6042623SN/A params->clock = clock; 6052623SN/A params->functionTrace = function_trace; 6062623SN/A params->functionTraceStart = function_trace_start; 6072623SN/A params->mem = mem; 6082623SN/A 6092623SN/A#if FULL_SYSTEM 6102623SN/A params->itb = itb; 6112623SN/A params->dtb = dtb; 6122623SN/A params->system = system; 6132623SN/A params->cpu_id = cpu_id; 6142623SN/A params->profile = profile; 6152623SN/A#else 6162623SN/A params->process = workload; 6172623SN/A#endif 6182623SN/A 6192623SN/A TimingSimpleCPU *cpu = new TimingSimpleCPU(params); 6202623SN/A return cpu; 6212623SN/A} 6222623SN/A 6232623SN/AREGISTER_SIM_OBJECT("TimingSimpleCPU", TimingSimpleCPU) 6242623SN/A 625