atomic.cc revision 3177
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" 352623SN/A#include "mem/packet_impl.hh" 362623SN/A#include "sim/builder.hh" 372901Ssaidi@eecs.umich.edu#include "sim/system.hh" 382623SN/A 392623SN/Ausing namespace std; 402623SN/Ausing namespace TheISA; 412623SN/A 422623SN/AAtomicSimpleCPU::TickEvent::TickEvent(AtomicSimpleCPU *c) 432623SN/A : Event(&mainEventQueue, CPU_Tick_Pri), cpu(c) 442623SN/A{ 452623SN/A} 462623SN/A 472623SN/A 482623SN/Avoid 492623SN/AAtomicSimpleCPU::TickEvent::process() 502623SN/A{ 512623SN/A cpu->tick(); 522623SN/A} 532623SN/A 542623SN/Aconst char * 552623SN/AAtomicSimpleCPU::TickEvent::description() 562623SN/A{ 572623SN/A return "AtomicSimpleCPU tick event"; 582623SN/A} 592623SN/A 602856Srdreslin@umich.eduPort * 612856Srdreslin@umich.eduAtomicSimpleCPU::getPort(const std::string &if_name, int idx) 622856Srdreslin@umich.edu{ 632856Srdreslin@umich.edu if (if_name == "dcache_port") 642856Srdreslin@umich.edu return &dcachePort; 652856Srdreslin@umich.edu else if (if_name == "icache_port") 662856Srdreslin@umich.edu return &icachePort; 672856Srdreslin@umich.edu else 682856Srdreslin@umich.edu panic("No Such Port\n"); 692856Srdreslin@umich.edu} 702623SN/A 712623SN/Avoid 722623SN/AAtomicSimpleCPU::init() 732623SN/A{ 742623SN/A //Create Memory Ports (conect them up) 752856Srdreslin@umich.edu// Port *mem_dport = mem->getPort(""); 762856Srdreslin@umich.edu// dcachePort.setPeer(mem_dport); 772856Srdreslin@umich.edu// mem_dport->setPeer(&dcachePort); 782623SN/A 792856Srdreslin@umich.edu// Port *mem_iport = mem->getPort(""); 802856Srdreslin@umich.edu// icachePort.setPeer(mem_iport); 812856Srdreslin@umich.edu// mem_iport->setPeer(&icachePort); 822623SN/A 832623SN/A BaseCPU::init(); 842623SN/A#if FULL_SYSTEM 852680Sktlim@umich.edu for (int i = 0; i < threadContexts.size(); ++i) { 862680Sktlim@umich.edu ThreadContext *tc = threadContexts[i]; 872623SN/A 882623SN/A // initialize CPU, including PC 892680Sktlim@umich.edu TheISA::initCPU(tc, tc->readCpuId()); 902623SN/A } 912623SN/A#endif 922623SN/A} 932623SN/A 942623SN/Abool 952630SN/AAtomicSimpleCPU::CpuPort::recvTiming(Packet *pkt) 962623SN/A{ 972623SN/A panic("AtomicSimpleCPU doesn't expect recvAtomic callback!"); 982623SN/A return true; 992623SN/A} 1002623SN/A 1012623SN/ATick 1022630SN/AAtomicSimpleCPU::CpuPort::recvAtomic(Packet *pkt) 1032623SN/A{ 1042623SN/A panic("AtomicSimpleCPU doesn't expect recvAtomic callback!"); 1052623SN/A return curTick; 1062623SN/A} 1072623SN/A 1082623SN/Avoid 1092630SN/AAtomicSimpleCPU::CpuPort::recvFunctional(Packet *pkt) 1102623SN/A{ 1112623SN/A panic("AtomicSimpleCPU doesn't expect recvFunctional callback!"); 1122623SN/A} 1132623SN/A 1142623SN/Avoid 1152623SN/AAtomicSimpleCPU::CpuPort::recvStatusChange(Status status) 1162623SN/A{ 1172626SN/A if (status == RangeChange) 1182626SN/A return; 1192626SN/A 1202623SN/A panic("AtomicSimpleCPU doesn't expect recvStatusChange callback!"); 1212623SN/A} 1222623SN/A 1232657Ssaidi@eecs.umich.eduvoid 1242623SN/AAtomicSimpleCPU::CpuPort::recvRetry() 1252623SN/A{ 1262623SN/A panic("AtomicSimpleCPU doesn't expect recvRetry callback!"); 1272623SN/A} 1282623SN/A 1292623SN/A 1302623SN/AAtomicSimpleCPU::AtomicSimpleCPU(Params *p) 1312623SN/A : BaseSimpleCPU(p), tickEvent(this), 1322623SN/A width(p->width), simulate_stalls(p->simulate_stalls), 1332640Sstever@eecs.umich.edu icachePort(name() + "-iport", this), dcachePort(name() + "-iport", this) 1342623SN/A{ 1352623SN/A _status = Idle; 1362623SN/A 1372663Sstever@eecs.umich.edu ifetch_req = new Request(); 1383170Sstever@eecs.umich.edu ifetch_req->setThreadContext(p->cpu_id, 0); // Add thread ID if we add MT 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(); 1433170Sstever@eecs.umich.edu data_read_req->setThreadContext(p->cpu_id, 0); // Add thread ID here too 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(); 1493170Sstever@eecs.umich.edu data_write_req->setThreadContext(p->cpu_id, 0); // Add thread ID here too 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); 1643177Shsul@eecs.umich.edu Status _status = status(); 1653177Shsul@eecs.umich.edu SERIALIZE_ENUM(_status); 1663145Shsul@eecs.umich.edu BaseSimpleCPU::serialize(os); 1672623SN/A nameOut(os, csprintf("%s.tickEvent", name())); 1682623SN/A tickEvent.serialize(os); 1692623SN/A} 1702623SN/A 1712623SN/Avoid 1722623SN/AAtomicSimpleCPU::unserialize(Checkpoint *cp, const string §ion) 1732623SN/A{ 1742915Sktlim@umich.edu SimObject::State so_state; 1752915Sktlim@umich.edu UNSERIALIZE_ENUM(so_state); 1763177Shsul@eecs.umich.edu UNSERIALIZE_ENUM(_status); 1773145Shsul@eecs.umich.edu BaseSimpleCPU::unserialize(cp, section); 1782915Sktlim@umich.edu tickEvent.unserialize(cp, csprintf("%s.tickEvent", section)); 1792915Sktlim@umich.edu} 1802915Sktlim@umich.edu 1812915Sktlim@umich.eduvoid 1822915Sktlim@umich.eduAtomicSimpleCPU::resume() 1832915Sktlim@umich.edu{ 1842926Sktlim@umich.edu assert(system->getMemoryMode() == System::Atomic); 1852926Sktlim@umich.edu changeState(SimObject::Running); 1862915Sktlim@umich.edu if (thread->status() == ThreadContext::Active) { 1872915Sktlim@umich.edu if (!tickEvent.scheduled()) 1882915Sktlim@umich.edu tickEvent.schedule(curTick); 1892915Sktlim@umich.edu } 1902623SN/A} 1912623SN/A 1922623SN/Avoid 1932798Sktlim@umich.eduAtomicSimpleCPU::switchOut() 1942623SN/A{ 1952798Sktlim@umich.edu assert(status() == Running || status() == Idle); 1962798Sktlim@umich.edu _status = SwitchedOut; 1972623SN/A 1982798Sktlim@umich.edu tickEvent.squash(); 1992623SN/A} 2002623SN/A 2012623SN/A 2022623SN/Avoid 2032623SN/AAtomicSimpleCPU::takeOverFrom(BaseCPU *oldCPU) 2042623SN/A{ 2052623SN/A BaseCPU::takeOverFrom(oldCPU); 2062623SN/A 2072623SN/A assert(!tickEvent.scheduled()); 2082623SN/A 2092680Sktlim@umich.edu // if any of this CPU's ThreadContexts are active, mark the CPU as 2102623SN/A // running and schedule its tick event. 2112680Sktlim@umich.edu for (int i = 0; i < threadContexts.size(); ++i) { 2122680Sktlim@umich.edu ThreadContext *tc = threadContexts[i]; 2132680Sktlim@umich.edu if (tc->status() == ThreadContext::Active && _status != Running) { 2142623SN/A _status = Running; 2152623SN/A tickEvent.schedule(curTick); 2162623SN/A break; 2172623SN/A } 2182623SN/A } 2192623SN/A} 2202623SN/A 2212623SN/A 2222623SN/Avoid 2232623SN/AAtomicSimpleCPU::activateContext(int thread_num, int delay) 2242623SN/A{ 2252623SN/A assert(thread_num == 0); 2262683Sktlim@umich.edu assert(thread); 2272623SN/A 2282623SN/A assert(_status == Idle); 2292623SN/A assert(!tickEvent.scheduled()); 2302623SN/A 2312623SN/A notIdleFraction++; 2322623SN/A tickEvent.schedule(curTick + cycles(delay)); 2332623SN/A _status = Running; 2342623SN/A} 2352623SN/A 2362623SN/A 2372623SN/Avoid 2382623SN/AAtomicSimpleCPU::suspendContext(int thread_num) 2392623SN/A{ 2402623SN/A assert(thread_num == 0); 2412683Sktlim@umich.edu assert(thread); 2422623SN/A 2432623SN/A assert(_status == Running); 2442626SN/A 2452626SN/A // tick event may not be scheduled if this gets called from inside 2462626SN/A // an instruction's execution, e.g. "quiesce" 2472626SN/A if (tickEvent.scheduled()) 2482626SN/A tickEvent.deschedule(); 2492623SN/A 2502623SN/A notIdleFraction--; 2512623SN/A _status = Idle; 2522623SN/A} 2532623SN/A 2542623SN/A 2552623SN/Atemplate <class T> 2562623SN/AFault 2572623SN/AAtomicSimpleCPU::read(Addr addr, T &data, unsigned flags) 2582623SN/A{ 2593169Sstever@eecs.umich.edu // use the CPU's statically allocated read request and packet objects 2603169Sstever@eecs.umich.edu Request *req = data_read_req; 2613169Sstever@eecs.umich.edu Packet *pkt = data_read_pkt; 2623169Sstever@eecs.umich.edu 2633169Sstever@eecs.umich.edu req->setVirt(0, addr, sizeof(T), flags, thread->readPC()); 2642623SN/A 2652623SN/A if (traceData) { 2662623SN/A traceData->setAddr(addr); 2672623SN/A } 2682623SN/A 2692623SN/A // translate to physical address 2703169Sstever@eecs.umich.edu Fault fault = thread->translateDataReadReq(req); 2712623SN/A 2722623SN/A // Now do the access. 2732623SN/A if (fault == NoFault) { 2743169Sstever@eecs.umich.edu pkt->reinitFromRequest(); 2752623SN/A 2763169Sstever@eecs.umich.edu dcache_latency = dcachePort.sendAtomic(pkt); 2772623SN/A dcache_access = true; 2782623SN/A 2793169Sstever@eecs.umich.edu assert(pkt->result == Packet::Success); 2803169Sstever@eecs.umich.edu data = pkt->get<T>(); 2813170Sstever@eecs.umich.edu 2823170Sstever@eecs.umich.edu if (req->isLocked()) { 2833170Sstever@eecs.umich.edu TheISA::handleLockedRead(thread, req); 2843170Sstever@eecs.umich.edu } 2852623SN/A } 2862623SN/A 2872623SN/A // This will need a new way to tell if it has a dcache attached. 2883172Sstever@eecs.umich.edu if (req->isUncacheable()) 2892623SN/A recordEvent("Uncached Read"); 2902623SN/A 2912623SN/A return fault; 2922623SN/A} 2932623SN/A 2942623SN/A#ifndef DOXYGEN_SHOULD_SKIP_THIS 2952623SN/A 2962623SN/Atemplate 2972623SN/AFault 2982623SN/AAtomicSimpleCPU::read(Addr addr, uint64_t &data, unsigned flags); 2992623SN/A 3002623SN/Atemplate 3012623SN/AFault 3022623SN/AAtomicSimpleCPU::read(Addr addr, uint32_t &data, unsigned flags); 3032623SN/A 3042623SN/Atemplate 3052623SN/AFault 3062623SN/AAtomicSimpleCPU::read(Addr addr, uint16_t &data, unsigned flags); 3072623SN/A 3082623SN/Atemplate 3092623SN/AFault 3102623SN/AAtomicSimpleCPU::read(Addr addr, uint8_t &data, unsigned flags); 3112623SN/A 3122623SN/A#endif //DOXYGEN_SHOULD_SKIP_THIS 3132623SN/A 3142623SN/Atemplate<> 3152623SN/AFault 3162623SN/AAtomicSimpleCPU::read(Addr addr, double &data, unsigned flags) 3172623SN/A{ 3182623SN/A return read(addr, *(uint64_t*)&data, flags); 3192623SN/A} 3202623SN/A 3212623SN/Atemplate<> 3222623SN/AFault 3232623SN/AAtomicSimpleCPU::read(Addr addr, float &data, unsigned flags) 3242623SN/A{ 3252623SN/A return read(addr, *(uint32_t*)&data, flags); 3262623SN/A} 3272623SN/A 3282623SN/A 3292623SN/Atemplate<> 3302623SN/AFault 3312623SN/AAtomicSimpleCPU::read(Addr addr, int32_t &data, unsigned flags) 3322623SN/A{ 3332623SN/A return read(addr, (uint32_t&)data, flags); 3342623SN/A} 3352623SN/A 3362623SN/A 3372623SN/Atemplate <class T> 3382623SN/AFault 3392623SN/AAtomicSimpleCPU::write(T data, Addr addr, unsigned flags, uint64_t *res) 3402623SN/A{ 3413169Sstever@eecs.umich.edu // use the CPU's statically allocated write request and packet objects 3423169Sstever@eecs.umich.edu Request *req = data_write_req; 3433169Sstever@eecs.umich.edu Packet *pkt = data_write_pkt; 3443169Sstever@eecs.umich.edu 3453169Sstever@eecs.umich.edu req->setVirt(0, addr, sizeof(T), flags, thread->readPC()); 3462623SN/A 3472623SN/A if (traceData) { 3482623SN/A traceData->setAddr(addr); 3492623SN/A } 3502623SN/A 3512623SN/A // translate to physical address 3523169Sstever@eecs.umich.edu Fault fault = thread->translateDataWriteReq(req); 3532623SN/A 3542623SN/A // Now do the access. 3552623SN/A if (fault == NoFault) { 3563170Sstever@eecs.umich.edu bool do_access = true; // flag to suppress cache access 3572623SN/A 3583170Sstever@eecs.umich.edu if (req->isLocked()) { 3593170Sstever@eecs.umich.edu do_access = TheISA::handleLockedWrite(thread, req); 3603170Sstever@eecs.umich.edu } 3612623SN/A 3623170Sstever@eecs.umich.edu if (do_access) { 3633170Sstever@eecs.umich.edu data = htog(data); 3643170Sstever@eecs.umich.edu pkt->reinitFromRequest(); 3653170Sstever@eecs.umich.edu pkt->dataStatic(&data); 3662631SN/A 3673170Sstever@eecs.umich.edu dcache_latency = dcachePort.sendAtomic(pkt); 3683170Sstever@eecs.umich.edu dcache_access = true; 3693170Sstever@eecs.umich.edu 3703170Sstever@eecs.umich.edu assert(pkt->result == Packet::Success); 3713170Sstever@eecs.umich.edu } 3723170Sstever@eecs.umich.edu 3733170Sstever@eecs.umich.edu if (req->isLocked()) { 3743170Sstever@eecs.umich.edu uint64_t scResult = req->getScResult(); 3753170Sstever@eecs.umich.edu if (scResult != 0) { 3763170Sstever@eecs.umich.edu // clear failure counter 3773170Sstever@eecs.umich.edu thread->setStCondFailures(0); 3783170Sstever@eecs.umich.edu } 3793170Sstever@eecs.umich.edu if (res) { 3803170Sstever@eecs.umich.edu *res = req->getScResult(); 3813170Sstever@eecs.umich.edu } 3822631SN/A } 3832623SN/A } 3842623SN/A 3852623SN/A // This will need a new way to tell if it's hooked up to a cache or not. 3863172Sstever@eecs.umich.edu if (req->isUncacheable()) 3872623SN/A recordEvent("Uncached Write"); 3882623SN/A 3892623SN/A // If the write needs to have a fault on the access, consider calling 3902623SN/A // changeStatus() and changing it to "bad addr write" or something. 3912623SN/A return fault; 3922623SN/A} 3932623SN/A 3942623SN/A 3952623SN/A#ifndef DOXYGEN_SHOULD_SKIP_THIS 3962623SN/Atemplate 3972623SN/AFault 3982623SN/AAtomicSimpleCPU::write(uint64_t data, Addr addr, 3992623SN/A unsigned flags, uint64_t *res); 4002623SN/A 4012623SN/Atemplate 4022623SN/AFault 4032623SN/AAtomicSimpleCPU::write(uint32_t data, Addr addr, 4042623SN/A unsigned flags, uint64_t *res); 4052623SN/A 4062623SN/Atemplate 4072623SN/AFault 4082623SN/AAtomicSimpleCPU::write(uint16_t data, Addr addr, 4092623SN/A unsigned flags, uint64_t *res); 4102623SN/A 4112623SN/Atemplate 4122623SN/AFault 4132623SN/AAtomicSimpleCPU::write(uint8_t data, Addr addr, 4142623SN/A unsigned flags, uint64_t *res); 4152623SN/A 4162623SN/A#endif //DOXYGEN_SHOULD_SKIP_THIS 4172623SN/A 4182623SN/Atemplate<> 4192623SN/AFault 4202623SN/AAtomicSimpleCPU::write(double data, Addr addr, unsigned flags, uint64_t *res) 4212623SN/A{ 4222623SN/A return write(*(uint64_t*)&data, addr, flags, res); 4232623SN/A} 4242623SN/A 4252623SN/Atemplate<> 4262623SN/AFault 4272623SN/AAtomicSimpleCPU::write(float data, Addr addr, unsigned flags, uint64_t *res) 4282623SN/A{ 4292623SN/A return write(*(uint32_t*)&data, addr, flags, res); 4302623SN/A} 4312623SN/A 4322623SN/A 4332623SN/Atemplate<> 4342623SN/AFault 4352623SN/AAtomicSimpleCPU::write(int32_t data, Addr addr, unsigned flags, uint64_t *res) 4362623SN/A{ 4372623SN/A return write((uint32_t)data, addr, flags, res); 4382623SN/A} 4392623SN/A 4402623SN/A 4412623SN/Avoid 4422623SN/AAtomicSimpleCPU::tick() 4432623SN/A{ 4442623SN/A Tick latency = cycles(1); // instruction takes one cycle by default 4452623SN/A 4462623SN/A for (int i = 0; i < width; ++i) { 4472623SN/A numCycles++; 4482623SN/A 4492626SN/A checkForInterrupts(); 4502626SN/A 4512662Sstever@eecs.umich.edu Fault fault = setupFetchRequest(ifetch_req); 4522623SN/A 4532623SN/A if (fault == NoFault) { 4542662Sstever@eecs.umich.edu ifetch_pkt->reinitFromRequest(); 4552662Sstever@eecs.umich.edu 4562662Sstever@eecs.umich.edu Tick icache_latency = icachePort.sendAtomic(ifetch_pkt); 4572623SN/A // ifetch_req is initialized to read the instruction directly 4582623SN/A // into the CPU object's inst field. 4592623SN/A 4602623SN/A dcache_access = false; // assume no dcache access 4612623SN/A preExecute(); 4622623SN/A fault = curStaticInst->execute(this, traceData); 4632623SN/A postExecute(); 4642623SN/A 4652623SN/A if (simulate_stalls) { 4662662Sstever@eecs.umich.edu Tick icache_stall = icache_latency - cycles(1); 4672623SN/A Tick dcache_stall = 4682662Sstever@eecs.umich.edu dcache_access ? dcache_latency - cycles(1) : 0; 4692803Ssaidi@eecs.umich.edu Tick stall_cycles = (icache_stall + dcache_stall) / cycles(1); 4702803Ssaidi@eecs.umich.edu if (cycles(stall_cycles) < (icache_stall + dcache_stall)) 4712803Ssaidi@eecs.umich.edu latency += cycles(stall_cycles+1); 4722803Ssaidi@eecs.umich.edu else 4732803Ssaidi@eecs.umich.edu latency += cycles(stall_cycles); 4742623SN/A } 4752623SN/A 4762623SN/A } 4772623SN/A 4782623SN/A advancePC(fault); 4792623SN/A } 4802623SN/A 4812626SN/A if (_status != Idle) 4822626SN/A tickEvent.schedule(curTick + latency); 4832623SN/A} 4842623SN/A 4852623SN/A 4862623SN/A//////////////////////////////////////////////////////////////////////// 4872623SN/A// 4882623SN/A// AtomicSimpleCPU Simulation Object 4892623SN/A// 4902623SN/ABEGIN_DECLARE_SIM_OBJECT_PARAMS(AtomicSimpleCPU) 4912623SN/A 4922623SN/A Param<Counter> max_insts_any_thread; 4932623SN/A Param<Counter> max_insts_all_threads; 4942623SN/A Param<Counter> max_loads_any_thread; 4952623SN/A Param<Counter> max_loads_all_threads; 4963119Sktlim@umich.edu Param<Tick> progress_interval; 4972623SN/A SimObjectParam<MemObject *> mem; 4982901Ssaidi@eecs.umich.edu SimObjectParam<System *> system; 4993170Sstever@eecs.umich.edu Param<int> cpu_id; 5002623SN/A 5012623SN/A#if FULL_SYSTEM 5022623SN/A SimObjectParam<AlphaITB *> itb; 5032623SN/A SimObjectParam<AlphaDTB *> dtb; 5042623SN/A Param<Tick> profile; 5052623SN/A#else 5062623SN/A SimObjectParam<Process *> workload; 5072623SN/A#endif // FULL_SYSTEM 5082623SN/A 5092623SN/A Param<int> clock; 5102623SN/A 5112623SN/A Param<bool> defer_registration; 5122623SN/A Param<int> width; 5132623SN/A Param<bool> function_trace; 5142623SN/A Param<Tick> function_trace_start; 5152623SN/A Param<bool> simulate_stalls; 5162623SN/A 5172623SN/AEND_DECLARE_SIM_OBJECT_PARAMS(AtomicSimpleCPU) 5182623SN/A 5192623SN/ABEGIN_INIT_SIM_OBJECT_PARAMS(AtomicSimpleCPU) 5202623SN/A 5212623SN/A INIT_PARAM(max_insts_any_thread, 5222623SN/A "terminate when any thread reaches this inst count"), 5232623SN/A INIT_PARAM(max_insts_all_threads, 5242623SN/A "terminate when all threads have reached this inst count"), 5252623SN/A INIT_PARAM(max_loads_any_thread, 5262623SN/A "terminate when any thread reaches this load count"), 5272623SN/A INIT_PARAM(max_loads_all_threads, 5282623SN/A "terminate when all threads have reached this load count"), 5293119Sktlim@umich.edu INIT_PARAM(progress_interval, "Progress interval"), 5302623SN/A INIT_PARAM(mem, "memory"), 5312901Ssaidi@eecs.umich.edu INIT_PARAM(system, "system object"), 5323170Sstever@eecs.umich.edu INIT_PARAM(cpu_id, "processor ID"), 5332623SN/A 5342623SN/A#if FULL_SYSTEM 5352623SN/A INIT_PARAM(itb, "Instruction TLB"), 5362623SN/A INIT_PARAM(dtb, "Data TLB"), 5372623SN/A INIT_PARAM(profile, ""), 5382623SN/A#else 5392623SN/A INIT_PARAM(workload, "processes to run"), 5402623SN/A#endif // FULL_SYSTEM 5412623SN/A 5422623SN/A INIT_PARAM(clock, "clock speed"), 5432623SN/A INIT_PARAM(defer_registration, "defer system registration (for sampling)"), 5442623SN/A INIT_PARAM(width, "cpu width"), 5452623SN/A INIT_PARAM(function_trace, "Enable function trace"), 5462623SN/A INIT_PARAM(function_trace_start, "Cycle to start function trace"), 5472623SN/A INIT_PARAM(simulate_stalls, "Simulate cache stall cycles") 5482623SN/A 5492623SN/AEND_INIT_SIM_OBJECT_PARAMS(AtomicSimpleCPU) 5502623SN/A 5512623SN/A 5522623SN/ACREATE_SIM_OBJECT(AtomicSimpleCPU) 5532623SN/A{ 5542623SN/A AtomicSimpleCPU::Params *params = new AtomicSimpleCPU::Params(); 5552623SN/A params->name = getInstanceName(); 5562623SN/A params->numberOfThreads = 1; 5572623SN/A params->max_insts_any_thread = max_insts_any_thread; 5582623SN/A params->max_insts_all_threads = max_insts_all_threads; 5592623SN/A params->max_loads_any_thread = max_loads_any_thread; 5602623SN/A params->max_loads_all_threads = max_loads_all_threads; 5613119Sktlim@umich.edu params->progress_interval = progress_interval; 5622623SN/A params->deferRegistration = defer_registration; 5632623SN/A params->clock = clock; 5642623SN/A params->functionTrace = function_trace; 5652623SN/A params->functionTraceStart = function_trace_start; 5662623SN/A params->width = width; 5672623SN/A params->simulate_stalls = simulate_stalls; 5682623SN/A params->mem = mem; 5692901Ssaidi@eecs.umich.edu params->system = system; 5703170Sstever@eecs.umich.edu params->cpu_id = cpu_id; 5712623SN/A 5722623SN/A#if FULL_SYSTEM 5732623SN/A params->itb = itb; 5742623SN/A params->dtb = dtb; 5752623SN/A params->profile = profile; 5762623SN/A#else 5772623SN/A params->process = workload; 5782623SN/A#endif 5792623SN/A 5802623SN/A AtomicSimpleCPU *cpu = new AtomicSimpleCPU(params); 5812623SN/A return cpu; 5822623SN/A} 5832623SN/A 5842623SN/AREGISTER_SIM_OBJECT("AtomicSimpleCPU", AtomicSimpleCPU) 5852623SN/A 586