atomic.cc revision 5487
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"
323806Ssaidi@eecs.umich.edu#include "arch/mmaped_ipr.hh"
332623SN/A#include "arch/utility.hh"
344040Ssaidi@eecs.umich.edu#include "base/bigint.hh"
352623SN/A#include "cpu/exetrace.hh"
362623SN/A#include "cpu/simple/atomic.hh"
373348Sbinkertn@umich.edu#include "mem/packet.hh"
383348Sbinkertn@umich.edu#include "mem/packet_access.hh"
394762Snate@binkert.org#include "params/AtomicSimpleCPU.hh"
402901Ssaidi@eecs.umich.edu#include "sim/system.hh"
412623SN/A
422623SN/Ausing namespace std;
432623SN/Ausing namespace TheISA;
442623SN/A
452623SN/AAtomicSimpleCPU::TickEvent::TickEvent(AtomicSimpleCPU *c)
462623SN/A    : Event(&mainEventQueue, CPU_Tick_Pri), cpu(c)
472623SN/A{
482623SN/A}
492623SN/A
502623SN/A
512623SN/Avoid
522623SN/AAtomicSimpleCPU::TickEvent::process()
532623SN/A{
542623SN/A    cpu->tick();
552623SN/A}
562623SN/A
572623SN/Aconst char *
585336Shines@cs.fsu.eduAtomicSimpleCPU::TickEvent::description() const
592623SN/A{
604873Sstever@eecs.umich.edu    return "AtomicSimpleCPU tick";
612623SN/A}
622623SN/A
632856Srdreslin@umich.eduPort *
642856Srdreslin@umich.eduAtomicSimpleCPU::getPort(const std::string &if_name, int idx)
652856Srdreslin@umich.edu{
662856Srdreslin@umich.edu    if (if_name == "dcache_port")
672856Srdreslin@umich.edu        return &dcachePort;
682856Srdreslin@umich.edu    else if (if_name == "icache_port")
692856Srdreslin@umich.edu        return &icachePort;
704968Sacolyte@umich.edu    else if (if_name == "physmem_port") {
714968Sacolyte@umich.edu        hasPhysMemPort = true;
724968Sacolyte@umich.edu        return &physmemPort;
734968Sacolyte@umich.edu    }
742856Srdreslin@umich.edu    else
752856Srdreslin@umich.edu        panic("No Such Port\n");
762856Srdreslin@umich.edu}
772623SN/A
782623SN/Avoid
792623SN/AAtomicSimpleCPU::init()
802623SN/A{
812623SN/A    BaseCPU::init();
825310Ssaidi@eecs.umich.edu    cpuId = tc->readCpuId();
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
885310Ssaidi@eecs.umich.edu        TheISA::initCPU(tc, cpuId);
892623SN/A    }
902623SN/A#endif
914968Sacolyte@umich.edu    if (hasPhysMemPort) {
924968Sacolyte@umich.edu        bool snoop = false;
934968Sacolyte@umich.edu        AddrRangeList pmAddrList;
944968Sacolyte@umich.edu        physmemPort.getPeerAddressRanges(pmAddrList, snoop);
954968Sacolyte@umich.edu        physMemAddr = *pmAddrList.begin();
964968Sacolyte@umich.edu    }
975310Ssaidi@eecs.umich.edu    ifetch_req.setThreadContext(cpuId, 0); // Add thread ID if we add MT
985310Ssaidi@eecs.umich.edu    data_read_req.setThreadContext(cpuId, 0); // Add thread ID here too
995310Ssaidi@eecs.umich.edu    data_write_req.setThreadContext(cpuId, 0); // Add thread ID here too
1002623SN/A}
1012623SN/A
1022623SN/Abool
1033349Sbinkertn@umich.eduAtomicSimpleCPU::CpuPort::recvTiming(PacketPtr pkt)
1042623SN/A{
1053184Srdreslin@umich.edu    panic("AtomicSimpleCPU doesn't expect recvTiming callback!");
1062623SN/A    return true;
1072623SN/A}
1082623SN/A
1092623SN/ATick
1103349Sbinkertn@umich.eduAtomicSimpleCPU::CpuPort::recvAtomic(PacketPtr pkt)
1112623SN/A{
1123310Srdreslin@umich.edu    //Snooping a coherence request, just return
1133649Srdreslin@umich.edu    return 0;
1142623SN/A}
1152623SN/A
1162623SN/Avoid
1173349Sbinkertn@umich.eduAtomicSimpleCPU::CpuPort::recvFunctional(PacketPtr pkt)
1182623SN/A{
1193184Srdreslin@umich.edu    //No internal storage to update, just return
1203184Srdreslin@umich.edu    return;
1212623SN/A}
1222623SN/A
1232623SN/Avoid
1242623SN/AAtomicSimpleCPU::CpuPort::recvStatusChange(Status status)
1252623SN/A{
1263647Srdreslin@umich.edu    if (status == RangeChange) {
1273647Srdreslin@umich.edu        if (!snoopRangeSent) {
1283647Srdreslin@umich.edu            snoopRangeSent = true;
1293647Srdreslin@umich.edu            sendStatusChange(Port::RangeChange);
1303647Srdreslin@umich.edu        }
1312626SN/A        return;
1323647Srdreslin@umich.edu    }
1332626SN/A
1342623SN/A    panic("AtomicSimpleCPU doesn't expect recvStatusChange callback!");
1352623SN/A}
1362623SN/A
1372657Ssaidi@eecs.umich.eduvoid
1382623SN/AAtomicSimpleCPU::CpuPort::recvRetry()
1392623SN/A{
1402623SN/A    panic("AtomicSimpleCPU doesn't expect recvRetry callback!");
1412623SN/A}
1422623SN/A
1434192Sktlim@umich.eduvoid
1444192Sktlim@umich.eduAtomicSimpleCPU::DcachePort::setPeer(Port *port)
1454192Sktlim@umich.edu{
1464192Sktlim@umich.edu    Port::setPeer(port);
1474192Sktlim@umich.edu
1484192Sktlim@umich.edu#if FULL_SYSTEM
1494192Sktlim@umich.edu    // Update the ThreadContext's memory ports (Functional/Virtual
1504192Sktlim@umich.edu    // Ports)
1514192Sktlim@umich.edu    cpu->tcBase()->connectMemPorts();
1524192Sktlim@umich.edu#endif
1534192Sktlim@umich.edu}
1542623SN/A
1552623SN/AAtomicSimpleCPU::AtomicSimpleCPU(Params *p)
1565487Snate@binkert.org    : BaseSimpleCPU(p), tickEvent(this), width(p->width),
1575487Snate@binkert.org      simulate_data_stalls(p->simulate_data_stalls),
1585487Snate@binkert.org      simulate_inst_stalls(p->simulate_inst_stalls),
1594968Sacolyte@umich.edu      icachePort(name() + "-iport", this), dcachePort(name() + "-iport", this),
1604968Sacolyte@umich.edu      physmemPort(name() + "-iport", this), hasPhysMemPort(false)
1612623SN/A{
1622623SN/A    _status = Idle;
1632623SN/A
1643647Srdreslin@umich.edu    icachePort.snoopRangeSent = false;
1653647Srdreslin@umich.edu    dcachePort.snoopRangeSent = false;
1663647Srdreslin@umich.edu
1672623SN/A}
1682623SN/A
1692623SN/A
1702623SN/AAtomicSimpleCPU::~AtomicSimpleCPU()
1712623SN/A{
1722623SN/A}
1732623SN/A
1742623SN/Avoid
1752623SN/AAtomicSimpleCPU::serialize(ostream &os)
1762623SN/A{
1772915Sktlim@umich.edu    SimObject::State so_state = SimObject::getState();
1782915Sktlim@umich.edu    SERIALIZE_ENUM(so_state);
1793177Shsul@eecs.umich.edu    Status _status = status();
1803177Shsul@eecs.umich.edu    SERIALIZE_ENUM(_status);
1813145Shsul@eecs.umich.edu    BaseSimpleCPU::serialize(os);
1822623SN/A    nameOut(os, csprintf("%s.tickEvent", name()));
1832623SN/A    tickEvent.serialize(os);
1842623SN/A}
1852623SN/A
1862623SN/Avoid
1872623SN/AAtomicSimpleCPU::unserialize(Checkpoint *cp, const string &section)
1882623SN/A{
1892915Sktlim@umich.edu    SimObject::State so_state;
1902915Sktlim@umich.edu    UNSERIALIZE_ENUM(so_state);
1913177Shsul@eecs.umich.edu    UNSERIALIZE_ENUM(_status);
1923145Shsul@eecs.umich.edu    BaseSimpleCPU::unserialize(cp, section);
1932915Sktlim@umich.edu    tickEvent.unserialize(cp, csprintf("%s.tickEvent", section));
1942915Sktlim@umich.edu}
1952915Sktlim@umich.edu
1962915Sktlim@umich.eduvoid
1972915Sktlim@umich.eduAtomicSimpleCPU::resume()
1982915Sktlim@umich.edu{
1995220Ssaidi@eecs.umich.edu    if (_status == Idle || _status == SwitchedOut)
2005220Ssaidi@eecs.umich.edu        return;
2015220Ssaidi@eecs.umich.edu
2024940Snate@binkert.org    DPRINTF(SimpleCPU, "Resume\n");
2035220Ssaidi@eecs.umich.edu    assert(system->getMemoryMode() == Enums::atomic);
2043324Shsul@eecs.umich.edu
2055220Ssaidi@eecs.umich.edu    changeState(SimObject::Running);
2065220Ssaidi@eecs.umich.edu    if (thread->status() == ThreadContext::Active) {
2075220Ssaidi@eecs.umich.edu        if (!tickEvent.scheduled()) {
2085220Ssaidi@eecs.umich.edu            tickEvent.schedule(nextCycle());
2093324Shsul@eecs.umich.edu        }
2102915Sktlim@umich.edu    }
2112623SN/A}
2122623SN/A
2132623SN/Avoid
2142798Sktlim@umich.eduAtomicSimpleCPU::switchOut()
2152623SN/A{
2162798Sktlim@umich.edu    assert(status() == Running || status() == Idle);
2172798Sktlim@umich.edu    _status = SwitchedOut;
2182623SN/A
2192798Sktlim@umich.edu    tickEvent.squash();
2202623SN/A}
2212623SN/A
2222623SN/A
2232623SN/Avoid
2242623SN/AAtomicSimpleCPU::takeOverFrom(BaseCPU *oldCPU)
2252623SN/A{
2264192Sktlim@umich.edu    BaseCPU::takeOverFrom(oldCPU, &icachePort, &dcachePort);
2272623SN/A
2282623SN/A    assert(!tickEvent.scheduled());
2292623SN/A
2302680Sktlim@umich.edu    // if any of this CPU's ThreadContexts are active, mark the CPU as
2312623SN/A    // running and schedule its tick event.
2322680Sktlim@umich.edu    for (int i = 0; i < threadContexts.size(); ++i) {
2332680Sktlim@umich.edu        ThreadContext *tc = threadContexts[i];
2342680Sktlim@umich.edu        if (tc->status() == ThreadContext::Active && _status != Running) {
2352623SN/A            _status = Running;
2363495Sktlim@umich.edu            tickEvent.schedule(nextCycle());
2372623SN/A            break;
2382623SN/A        }
2392623SN/A    }
2403512Sktlim@umich.edu    if (_status != Running) {
2413512Sktlim@umich.edu        _status = Idle;
2423512Sktlim@umich.edu    }
2435169Ssaidi@eecs.umich.edu    assert(threadContexts.size() == 1);
2445169Ssaidi@eecs.umich.edu    cpuId = tc->readCpuId();
2455310Ssaidi@eecs.umich.edu    ifetch_req.setThreadContext(cpuId, 0); // Add thread ID if we add MT
2465310Ssaidi@eecs.umich.edu    data_read_req.setThreadContext(cpuId, 0); // Add thread ID here too
2475310Ssaidi@eecs.umich.edu    data_write_req.setThreadContext(cpuId, 0); // Add thread ID here too
2482623SN/A}
2492623SN/A
2502623SN/A
2512623SN/Avoid
2522623SN/AAtomicSimpleCPU::activateContext(int thread_num, int delay)
2532623SN/A{
2544940Snate@binkert.org    DPRINTF(SimpleCPU, "ActivateContext %d (%d cycles)\n", thread_num, delay);
2554940Snate@binkert.org
2562623SN/A    assert(thread_num == 0);
2572683Sktlim@umich.edu    assert(thread);
2582623SN/A
2592623SN/A    assert(_status == Idle);
2602623SN/A    assert(!tickEvent.scheduled());
2612623SN/A
2622623SN/A    notIdleFraction++;
2635101Ssaidi@eecs.umich.edu    numCycles += tickToCycles(thread->lastActivate - thread->lastSuspend);
2643686Sktlim@umich.edu
2653430Sgblack@eecs.umich.edu    //Make sure ticks are still on multiples of cycles
2665100Ssaidi@eecs.umich.edu    tickEvent.schedule(nextCycle(curTick + ticks(delay)));
2672623SN/A    _status = Running;
2682623SN/A}
2692623SN/A
2702623SN/A
2712623SN/Avoid
2722623SN/AAtomicSimpleCPU::suspendContext(int thread_num)
2732623SN/A{
2744940Snate@binkert.org    DPRINTF(SimpleCPU, "SuspendContext %d\n", thread_num);
2754940Snate@binkert.org
2762623SN/A    assert(thread_num == 0);
2772683Sktlim@umich.edu    assert(thread);
2782623SN/A
2792623SN/A    assert(_status == Running);
2802626SN/A
2812626SN/A    // tick event may not be scheduled if this gets called from inside
2822626SN/A    // an instruction's execution, e.g. "quiesce"
2832626SN/A    if (tickEvent.scheduled())
2842626SN/A        tickEvent.deschedule();
2852623SN/A
2862623SN/A    notIdleFraction--;
2872623SN/A    _status = Idle;
2882623SN/A}
2892623SN/A
2902623SN/A
2912623SN/Atemplate <class T>
2922623SN/AFault
2932623SN/AAtomicSimpleCPU::read(Addr addr, T &data, unsigned flags)
2942623SN/A{
2953169Sstever@eecs.umich.edu    // use the CPU's statically allocated read request and packet objects
2964870Sstever@eecs.umich.edu    Request *req = &data_read_req;
2972623SN/A
2982623SN/A    if (traceData) {
2992623SN/A        traceData->setAddr(addr);
3002623SN/A    }
3012623SN/A
3024999Sgblack@eecs.umich.edu    //The block size of our peer.
3034999Sgblack@eecs.umich.edu    int blockSize = dcachePort.peerBlockSize();
3044999Sgblack@eecs.umich.edu    //The size of the data we're trying to read.
3054999Sgblack@eecs.umich.edu    int dataSize = sizeof(T);
3062623SN/A
3074999Sgblack@eecs.umich.edu    uint8_t * dataPtr = (uint8_t *)&data;
3082623SN/A
3094999Sgblack@eecs.umich.edu    //The address of the second part of this access if it needs to be split
3104999Sgblack@eecs.umich.edu    //across a cache line boundary.
3114999Sgblack@eecs.umich.edu    Addr secondAddr = roundDown(addr + dataSize - 1, blockSize);
3124999Sgblack@eecs.umich.edu
3134999Sgblack@eecs.umich.edu    if(secondAddr > addr)
3144999Sgblack@eecs.umich.edu        dataSize = secondAddr - addr;
3154999Sgblack@eecs.umich.edu
3164999Sgblack@eecs.umich.edu    dcache_latency = 0;
3174999Sgblack@eecs.umich.edu
3184999Sgblack@eecs.umich.edu    while(1) {
3194999Sgblack@eecs.umich.edu        req->setVirt(0, addr, dataSize, flags, thread->readPC());
3204999Sgblack@eecs.umich.edu
3214999Sgblack@eecs.umich.edu        // translate to physical address
3224999Sgblack@eecs.umich.edu        Fault fault = thread->translateDataReadReq(req);
3234999Sgblack@eecs.umich.edu
3244999Sgblack@eecs.umich.edu        // Now do the access.
3254999Sgblack@eecs.umich.edu        if (fault == NoFault) {
3264999Sgblack@eecs.umich.edu            Packet pkt = Packet(req,
3274999Sgblack@eecs.umich.edu                    req->isLocked() ? MemCmd::LoadLockedReq : MemCmd::ReadReq,
3284999Sgblack@eecs.umich.edu                    Packet::Broadcast);
3294999Sgblack@eecs.umich.edu            pkt.dataStatic(dataPtr);
3304999Sgblack@eecs.umich.edu
3314999Sgblack@eecs.umich.edu            if (req->isMmapedIpr())
3324999Sgblack@eecs.umich.edu                dcache_latency += TheISA::handleIprRead(thread->getTC(), &pkt);
3334999Sgblack@eecs.umich.edu            else {
3344999Sgblack@eecs.umich.edu                if (hasPhysMemPort && pkt.getAddr() == physMemAddr)
3354999Sgblack@eecs.umich.edu                    dcache_latency += physmemPort.sendAtomic(&pkt);
3364999Sgblack@eecs.umich.edu                else
3374999Sgblack@eecs.umich.edu                    dcache_latency += dcachePort.sendAtomic(&pkt);
3384999Sgblack@eecs.umich.edu            }
3394999Sgblack@eecs.umich.edu            dcache_access = true;
3405012Sgblack@eecs.umich.edu
3414999Sgblack@eecs.umich.edu            assert(!pkt.isError());
3424999Sgblack@eecs.umich.edu
3434999Sgblack@eecs.umich.edu            if (req->isLocked()) {
3444999Sgblack@eecs.umich.edu                TheISA::handleLockedRead(thread, req);
3454999Sgblack@eecs.umich.edu            }
3464968Sacolyte@umich.edu        }
3474986Ssaidi@eecs.umich.edu
3484999Sgblack@eecs.umich.edu        // This will need a new way to tell if it has a dcache attached.
3494999Sgblack@eecs.umich.edu        if (req->isUncacheable())
3504999Sgblack@eecs.umich.edu            recordEvent("Uncached Read");
3514762Snate@binkert.org
3524999Sgblack@eecs.umich.edu        //If there's a fault, return it
3534999Sgblack@eecs.umich.edu        if (fault != NoFault)
3544999Sgblack@eecs.umich.edu            return fault;
3554999Sgblack@eecs.umich.edu        //If we don't need to access a second cache line, stop now.
3564999Sgblack@eecs.umich.edu        if (secondAddr <= addr)
3574999Sgblack@eecs.umich.edu        {
3584999Sgblack@eecs.umich.edu            data = gtoh(data);
3595408Sgblack@eecs.umich.edu            if (traceData) {
3605408Sgblack@eecs.umich.edu                traceData->setData(data);
3615408Sgblack@eecs.umich.edu            }
3624999Sgblack@eecs.umich.edu            return fault;
3634968Sacolyte@umich.edu        }
3643170Sstever@eecs.umich.edu
3654999Sgblack@eecs.umich.edu        /*
3664999Sgblack@eecs.umich.edu         * Set up for accessing the second cache line.
3674999Sgblack@eecs.umich.edu         */
3684999Sgblack@eecs.umich.edu
3694999Sgblack@eecs.umich.edu        //Move the pointer we're reading into to the correct location.
3704999Sgblack@eecs.umich.edu        dataPtr += dataSize;
3714999Sgblack@eecs.umich.edu        //Adjust the size to get the remaining bytes.
3724999Sgblack@eecs.umich.edu        dataSize = addr + sizeof(T) - secondAddr;
3734999Sgblack@eecs.umich.edu        //And access the right address.
3744999Sgblack@eecs.umich.edu        addr = secondAddr;
3752623SN/A    }
3762623SN/A}
3772623SN/A
3785177Sgblack@eecs.umich.eduFault
3795177Sgblack@eecs.umich.eduAtomicSimpleCPU::translateDataReadAddr(Addr vaddr, Addr & paddr,
3805177Sgblack@eecs.umich.edu        int size, unsigned flags)
3815177Sgblack@eecs.umich.edu{
3825177Sgblack@eecs.umich.edu    // use the CPU's statically allocated read request and packet objects
3835177Sgblack@eecs.umich.edu    Request *req = &data_read_req;
3845177Sgblack@eecs.umich.edu
3855177Sgblack@eecs.umich.edu    if (traceData) {
3865177Sgblack@eecs.umich.edu        traceData->setAddr(vaddr);
3875177Sgblack@eecs.umich.edu    }
3885177Sgblack@eecs.umich.edu
3895177Sgblack@eecs.umich.edu    //The block size of our peer.
3905177Sgblack@eecs.umich.edu    int blockSize = dcachePort.peerBlockSize();
3915177Sgblack@eecs.umich.edu    //The size of the data we're trying to read.
3925177Sgblack@eecs.umich.edu    int dataSize = size;
3935177Sgblack@eecs.umich.edu
3945177Sgblack@eecs.umich.edu    bool firstTimeThrough = true;
3955177Sgblack@eecs.umich.edu
3965177Sgblack@eecs.umich.edu    //The address of the second part of this access if it needs to be split
3975177Sgblack@eecs.umich.edu    //across a cache line boundary.
3985177Sgblack@eecs.umich.edu    Addr secondAddr = roundDown(vaddr + dataSize - 1, blockSize);
3995177Sgblack@eecs.umich.edu
4005177Sgblack@eecs.umich.edu    if(secondAddr > vaddr)
4015177Sgblack@eecs.umich.edu        dataSize = secondAddr - vaddr;
4025177Sgblack@eecs.umich.edu
4035177Sgblack@eecs.umich.edu    while(1) {
4045177Sgblack@eecs.umich.edu        req->setVirt(0, vaddr, dataSize, flags, thread->readPC());
4055177Sgblack@eecs.umich.edu
4065177Sgblack@eecs.umich.edu        // translate to physical address
4075177Sgblack@eecs.umich.edu        Fault fault = thread->translateDataReadReq(req);
4085177Sgblack@eecs.umich.edu
4095177Sgblack@eecs.umich.edu        //If there's a fault, return it
4105177Sgblack@eecs.umich.edu        if (fault != NoFault)
4115177Sgblack@eecs.umich.edu            return fault;
4125177Sgblack@eecs.umich.edu
4135177Sgblack@eecs.umich.edu        if (firstTimeThrough) {
4145177Sgblack@eecs.umich.edu            paddr = req->getPaddr();
4155177Sgblack@eecs.umich.edu            firstTimeThrough = false;
4165177Sgblack@eecs.umich.edu        }
4175177Sgblack@eecs.umich.edu
4185177Sgblack@eecs.umich.edu        //If we don't need to access a second cache line, stop now.
4195177Sgblack@eecs.umich.edu        if (secondAddr <= vaddr)
4205177Sgblack@eecs.umich.edu            return fault;
4215177Sgblack@eecs.umich.edu
4225177Sgblack@eecs.umich.edu        /*
4235177Sgblack@eecs.umich.edu         * Set up for accessing the second cache line.
4245177Sgblack@eecs.umich.edu         */
4255177Sgblack@eecs.umich.edu
4265177Sgblack@eecs.umich.edu        //Adjust the size to get the remaining bytes.
4275177Sgblack@eecs.umich.edu        dataSize = vaddr + size - secondAddr;
4285177Sgblack@eecs.umich.edu        //And access the right address.
4295177Sgblack@eecs.umich.edu        vaddr = secondAddr;
4305177Sgblack@eecs.umich.edu    }
4315177Sgblack@eecs.umich.edu}
4325177Sgblack@eecs.umich.edu
4332623SN/A#ifndef DOXYGEN_SHOULD_SKIP_THIS
4342623SN/A
4352623SN/Atemplate
4362623SN/AFault
4374115Ssaidi@eecs.umich.eduAtomicSimpleCPU::read(Addr addr, Twin32_t &data, unsigned flags);
4384115Ssaidi@eecs.umich.edu
4394115Ssaidi@eecs.umich.edutemplate
4404115Ssaidi@eecs.umich.eduFault
4414040Ssaidi@eecs.umich.eduAtomicSimpleCPU::read(Addr addr, Twin64_t &data, unsigned flags);
4424040Ssaidi@eecs.umich.edu
4434040Ssaidi@eecs.umich.edutemplate
4444040Ssaidi@eecs.umich.eduFault
4452623SN/AAtomicSimpleCPU::read(Addr addr, uint64_t &data, unsigned flags);
4462623SN/A
4472623SN/Atemplate
4482623SN/AFault
4492623SN/AAtomicSimpleCPU::read(Addr addr, uint32_t &data, unsigned flags);
4502623SN/A
4512623SN/Atemplate
4522623SN/AFault
4532623SN/AAtomicSimpleCPU::read(Addr addr, uint16_t &data, unsigned flags);
4542623SN/A
4552623SN/Atemplate
4562623SN/AFault
4572623SN/AAtomicSimpleCPU::read(Addr addr, uint8_t &data, unsigned flags);
4582623SN/A
4592623SN/A#endif //DOXYGEN_SHOULD_SKIP_THIS
4602623SN/A
4612623SN/Atemplate<>
4622623SN/AFault
4632623SN/AAtomicSimpleCPU::read(Addr addr, double &data, unsigned flags)
4642623SN/A{
4652623SN/A    return read(addr, *(uint64_t*)&data, flags);
4662623SN/A}
4672623SN/A
4682623SN/Atemplate<>
4692623SN/AFault
4702623SN/AAtomicSimpleCPU::read(Addr addr, float &data, unsigned flags)
4712623SN/A{
4722623SN/A    return read(addr, *(uint32_t*)&data, flags);
4732623SN/A}
4742623SN/A
4752623SN/A
4762623SN/Atemplate<>
4772623SN/AFault
4782623SN/AAtomicSimpleCPU::read(Addr addr, int32_t &data, unsigned flags)
4792623SN/A{
4802623SN/A    return read(addr, (uint32_t&)data, flags);
4812623SN/A}
4822623SN/A
4832623SN/A
4842623SN/Atemplate <class T>
4852623SN/AFault
4862623SN/AAtomicSimpleCPU::write(T data, Addr addr, unsigned flags, uint64_t *res)
4872623SN/A{
4883169Sstever@eecs.umich.edu    // use the CPU's statically allocated write request and packet objects
4894870Sstever@eecs.umich.edu    Request *req = &data_write_req;
4902623SN/A
4912623SN/A    if (traceData) {
4922623SN/A        traceData->setAddr(addr);
4932623SN/A    }
4942623SN/A
4954999Sgblack@eecs.umich.edu    //The block size of our peer.
4964999Sgblack@eecs.umich.edu    int blockSize = dcachePort.peerBlockSize();
4974999Sgblack@eecs.umich.edu    //The size of the data we're trying to read.
4984999Sgblack@eecs.umich.edu    int dataSize = sizeof(T);
4992623SN/A
5004999Sgblack@eecs.umich.edu    uint8_t * dataPtr = (uint8_t *)&data;
5012623SN/A
5024999Sgblack@eecs.umich.edu    //The address of the second part of this access if it needs to be split
5034999Sgblack@eecs.umich.edu    //across a cache line boundary.
5044999Sgblack@eecs.umich.edu    Addr secondAddr = roundDown(addr + dataSize - 1, blockSize);
5054999Sgblack@eecs.umich.edu
5064999Sgblack@eecs.umich.edu    if(secondAddr > addr)
5074999Sgblack@eecs.umich.edu        dataSize = secondAddr - addr;
5084999Sgblack@eecs.umich.edu
5094999Sgblack@eecs.umich.edu    dcache_latency = 0;
5104999Sgblack@eecs.umich.edu
5114999Sgblack@eecs.umich.edu    while(1) {
5124999Sgblack@eecs.umich.edu        req->setVirt(0, addr, dataSize, flags, thread->readPC());
5134999Sgblack@eecs.umich.edu
5144999Sgblack@eecs.umich.edu        // translate to physical address
5154999Sgblack@eecs.umich.edu        Fault fault = thread->translateDataWriteReq(req);
5164999Sgblack@eecs.umich.edu
5174999Sgblack@eecs.umich.edu        // Now do the access.
5184999Sgblack@eecs.umich.edu        if (fault == NoFault) {
5194999Sgblack@eecs.umich.edu            MemCmd cmd = MemCmd::WriteReq; // default
5204999Sgblack@eecs.umich.edu            bool do_access = true;  // flag to suppress cache access
5214999Sgblack@eecs.umich.edu
5224999Sgblack@eecs.umich.edu            if (req->isLocked()) {
5234999Sgblack@eecs.umich.edu                cmd = MemCmd::StoreCondReq;
5244999Sgblack@eecs.umich.edu                do_access = TheISA::handleLockedWrite(thread, req);
5254999Sgblack@eecs.umich.edu            } else if (req->isSwap()) {
5264999Sgblack@eecs.umich.edu                cmd = MemCmd::SwapReq;
5274999Sgblack@eecs.umich.edu                if (req->isCondSwap()) {
5284999Sgblack@eecs.umich.edu                    assert(res);
5294999Sgblack@eecs.umich.edu                    req->setExtraData(*res);
5304999Sgblack@eecs.umich.edu                }
5314999Sgblack@eecs.umich.edu            }
5324999Sgblack@eecs.umich.edu
5334999Sgblack@eecs.umich.edu            if (do_access) {
5344999Sgblack@eecs.umich.edu                Packet pkt = Packet(req, cmd, Packet::Broadcast);
5354999Sgblack@eecs.umich.edu                pkt.dataStatic(dataPtr);
5364999Sgblack@eecs.umich.edu
5374999Sgblack@eecs.umich.edu                if (req->isMmapedIpr()) {
5384999Sgblack@eecs.umich.edu                    dcache_latency +=
5394999Sgblack@eecs.umich.edu                        TheISA::handleIprWrite(thread->getTC(), &pkt);
5404999Sgblack@eecs.umich.edu                } else {
5414999Sgblack@eecs.umich.edu                    //XXX This needs to be outside of the loop in order to
5424999Sgblack@eecs.umich.edu                    //work properly for cache line boundary crossing
5434999Sgblack@eecs.umich.edu                    //accesses in transendian simulations.
5444999Sgblack@eecs.umich.edu                    data = htog(data);
5454999Sgblack@eecs.umich.edu                    if (hasPhysMemPort && pkt.getAddr() == physMemAddr)
5464999Sgblack@eecs.umich.edu                        dcache_latency += physmemPort.sendAtomic(&pkt);
5474999Sgblack@eecs.umich.edu                    else
5484999Sgblack@eecs.umich.edu                        dcache_latency += dcachePort.sendAtomic(&pkt);
5494999Sgblack@eecs.umich.edu                }
5504999Sgblack@eecs.umich.edu                dcache_access = true;
5514999Sgblack@eecs.umich.edu                assert(!pkt.isError());
5524999Sgblack@eecs.umich.edu
5534999Sgblack@eecs.umich.edu                if (req->isSwap()) {
5544999Sgblack@eecs.umich.edu                    assert(res);
5554999Sgblack@eecs.umich.edu                    *res = pkt.get<T>();
5564999Sgblack@eecs.umich.edu                }
5574999Sgblack@eecs.umich.edu            }
5584999Sgblack@eecs.umich.edu
5594999Sgblack@eecs.umich.edu            if (res && !req->isSwap()) {
5604999Sgblack@eecs.umich.edu                *res = req->getExtraData();
5614878Sstever@eecs.umich.edu            }
5624040Ssaidi@eecs.umich.edu        }
5634040Ssaidi@eecs.umich.edu
5644999Sgblack@eecs.umich.edu        // This will need a new way to tell if it's hooked up to a cache or not.
5654999Sgblack@eecs.umich.edu        if (req->isUncacheable())
5664999Sgblack@eecs.umich.edu            recordEvent("Uncached Write");
5672631SN/A
5684999Sgblack@eecs.umich.edu        //If there's a fault or we don't need to access a second cache line,
5694999Sgblack@eecs.umich.edu        //stop now.
5704999Sgblack@eecs.umich.edu        if (fault != NoFault || secondAddr <= addr)
5714999Sgblack@eecs.umich.edu        {
5724999Sgblack@eecs.umich.edu            // If the write needs to have a fault on the access, consider
5734999Sgblack@eecs.umich.edu            // calling changeStatus() and changing it to "bad addr write"
5744999Sgblack@eecs.umich.edu            // or something.
5755408Sgblack@eecs.umich.edu            if (traceData) {
5765408Sgblack@eecs.umich.edu                traceData->setData(data);
5775408Sgblack@eecs.umich.edu            }
5784999Sgblack@eecs.umich.edu            return fault;
5793170Sstever@eecs.umich.edu        }
5803170Sstever@eecs.umich.edu
5814999Sgblack@eecs.umich.edu        /*
5824999Sgblack@eecs.umich.edu         * Set up for accessing the second cache line.
5834999Sgblack@eecs.umich.edu         */
5844999Sgblack@eecs.umich.edu
5854999Sgblack@eecs.umich.edu        //Move the pointer we're reading into to the correct location.
5864999Sgblack@eecs.umich.edu        dataPtr += dataSize;
5874999Sgblack@eecs.umich.edu        //Adjust the size to get the remaining bytes.
5884999Sgblack@eecs.umich.edu        dataSize = addr + sizeof(T) - secondAddr;
5894999Sgblack@eecs.umich.edu        //And access the right address.
5904999Sgblack@eecs.umich.edu        addr = secondAddr;
5912623SN/A    }
5922623SN/A}
5932623SN/A
5945177Sgblack@eecs.umich.eduFault
5955177Sgblack@eecs.umich.eduAtomicSimpleCPU::translateDataWriteAddr(Addr vaddr, Addr &paddr,
5965177Sgblack@eecs.umich.edu        int size, unsigned flags)
5975177Sgblack@eecs.umich.edu{
5985177Sgblack@eecs.umich.edu    // use the CPU's statically allocated write request and packet objects
5995177Sgblack@eecs.umich.edu    Request *req = &data_write_req;
6005177Sgblack@eecs.umich.edu
6015177Sgblack@eecs.umich.edu    if (traceData) {
6025177Sgblack@eecs.umich.edu        traceData->setAddr(vaddr);
6035177Sgblack@eecs.umich.edu    }
6045177Sgblack@eecs.umich.edu
6055177Sgblack@eecs.umich.edu    //The block size of our peer.
6065177Sgblack@eecs.umich.edu    int blockSize = dcachePort.peerBlockSize();
6075177Sgblack@eecs.umich.edu
6085177Sgblack@eecs.umich.edu    //The address of the second part of this access if it needs to be split
6095177Sgblack@eecs.umich.edu    //across a cache line boundary.
6105177Sgblack@eecs.umich.edu    Addr secondAddr = roundDown(vaddr + size - 1, blockSize);
6115177Sgblack@eecs.umich.edu
6125177Sgblack@eecs.umich.edu    //The size of the data we're trying to read.
6135177Sgblack@eecs.umich.edu    int dataSize = size;
6145177Sgblack@eecs.umich.edu
6155177Sgblack@eecs.umich.edu    bool firstTimeThrough = true;
6165177Sgblack@eecs.umich.edu
6175177Sgblack@eecs.umich.edu    if(secondAddr > vaddr)
6185177Sgblack@eecs.umich.edu        dataSize = secondAddr - vaddr;
6195177Sgblack@eecs.umich.edu
6205177Sgblack@eecs.umich.edu    dcache_latency = 0;
6215177Sgblack@eecs.umich.edu
6225177Sgblack@eecs.umich.edu    while(1) {
6235278Sgblack@eecs.umich.edu        req->setVirt(0, vaddr, dataSize, flags, thread->readPC());
6245177Sgblack@eecs.umich.edu
6255177Sgblack@eecs.umich.edu        // translate to physical address
6265177Sgblack@eecs.umich.edu        Fault fault = thread->translateDataWriteReq(req);
6275177Sgblack@eecs.umich.edu
6285177Sgblack@eecs.umich.edu        //If there's a fault or we don't need to access a second cache line,
6295177Sgblack@eecs.umich.edu        //stop now.
6305177Sgblack@eecs.umich.edu        if (fault != NoFault)
6315177Sgblack@eecs.umich.edu            return fault;
6325177Sgblack@eecs.umich.edu
6335177Sgblack@eecs.umich.edu        if (firstTimeThrough) {
6345177Sgblack@eecs.umich.edu            paddr = req->getPaddr();
6355177Sgblack@eecs.umich.edu            firstTimeThrough = false;
6365177Sgblack@eecs.umich.edu        }
6375177Sgblack@eecs.umich.edu
6385177Sgblack@eecs.umich.edu        if (secondAddr <= vaddr)
6395177Sgblack@eecs.umich.edu            return fault;
6405177Sgblack@eecs.umich.edu
6415177Sgblack@eecs.umich.edu        /*
6425177Sgblack@eecs.umich.edu         * Set up for accessing the second cache line.
6435177Sgblack@eecs.umich.edu         */
6445177Sgblack@eecs.umich.edu
6455177Sgblack@eecs.umich.edu        //Adjust the size to get the remaining bytes.
6465177Sgblack@eecs.umich.edu        dataSize = vaddr + size - secondAddr;
6475177Sgblack@eecs.umich.edu        //And access the right address.
6485177Sgblack@eecs.umich.edu        vaddr = secondAddr;
6495177Sgblack@eecs.umich.edu    }
6505177Sgblack@eecs.umich.edu}
6515177Sgblack@eecs.umich.edu
6522623SN/A
6532623SN/A#ifndef DOXYGEN_SHOULD_SKIP_THIS
6544224Sgblack@eecs.umich.edu
6554224Sgblack@eecs.umich.edutemplate
6564224Sgblack@eecs.umich.eduFault
6574224Sgblack@eecs.umich.eduAtomicSimpleCPU::write(Twin32_t data, Addr addr,
6584224Sgblack@eecs.umich.edu                       unsigned flags, uint64_t *res);
6594224Sgblack@eecs.umich.edu
6604224Sgblack@eecs.umich.edutemplate
6614224Sgblack@eecs.umich.eduFault
6624224Sgblack@eecs.umich.eduAtomicSimpleCPU::write(Twin64_t data, Addr addr,
6634224Sgblack@eecs.umich.edu                       unsigned flags, uint64_t *res);
6644224Sgblack@eecs.umich.edu
6652623SN/Atemplate
6662623SN/AFault
6672623SN/AAtomicSimpleCPU::write(uint64_t data, Addr addr,
6682623SN/A                       unsigned flags, uint64_t *res);
6692623SN/A
6702623SN/Atemplate
6712623SN/AFault
6722623SN/AAtomicSimpleCPU::write(uint32_t data, Addr addr,
6732623SN/A                       unsigned flags, uint64_t *res);
6742623SN/A
6752623SN/Atemplate
6762623SN/AFault
6772623SN/AAtomicSimpleCPU::write(uint16_t data, Addr addr,
6782623SN/A                       unsigned flags, uint64_t *res);
6792623SN/A
6802623SN/Atemplate
6812623SN/AFault
6822623SN/AAtomicSimpleCPU::write(uint8_t data, Addr addr,
6832623SN/A                       unsigned flags, uint64_t *res);
6842623SN/A
6852623SN/A#endif //DOXYGEN_SHOULD_SKIP_THIS
6862623SN/A
6872623SN/Atemplate<>
6882623SN/AFault
6892623SN/AAtomicSimpleCPU::write(double data, Addr addr, unsigned flags, uint64_t *res)
6902623SN/A{
6912623SN/A    return write(*(uint64_t*)&data, addr, flags, res);
6922623SN/A}
6932623SN/A
6942623SN/Atemplate<>
6952623SN/AFault
6962623SN/AAtomicSimpleCPU::write(float data, Addr addr, unsigned flags, uint64_t *res)
6972623SN/A{
6982623SN/A    return write(*(uint32_t*)&data, addr, flags, res);
6992623SN/A}
7002623SN/A
7012623SN/A
7022623SN/Atemplate<>
7032623SN/AFault
7042623SN/AAtomicSimpleCPU::write(int32_t data, Addr addr, unsigned flags, uint64_t *res)
7052623SN/A{
7062623SN/A    return write((uint32_t)data, addr, flags, res);
7072623SN/A}
7082623SN/A
7092623SN/A
7102623SN/Avoid
7112623SN/AAtomicSimpleCPU::tick()
7122623SN/A{
7134940Snate@binkert.org    DPRINTF(SimpleCPU, "Tick\n");
7144940Snate@binkert.org
7155487Snate@binkert.org    Tick latency = 0;
7162623SN/A
7172623SN/A    for (int i = 0; i < width; ++i) {
7182623SN/A        numCycles++;
7192623SN/A
7203387Sgblack@eecs.umich.edu        if (!curStaticInst || !curStaticInst->isDelayedCommit())
7213387Sgblack@eecs.umich.edu            checkForInterrupts();
7222626SN/A
7235348Ssaidi@eecs.umich.edu        checkPcEventQueue();
7245348Ssaidi@eecs.umich.edu
7254870Sstever@eecs.umich.edu        Fault fault = setupFetchRequest(&ifetch_req);
7262623SN/A
7272623SN/A        if (fault == NoFault) {
7284182Sgblack@eecs.umich.edu            Tick icache_latency = 0;
7294182Sgblack@eecs.umich.edu            bool icache_access = false;
7304182Sgblack@eecs.umich.edu            dcache_access = false; // assume no dcache access
7312662Sstever@eecs.umich.edu
7324182Sgblack@eecs.umich.edu            //Fetch more instruction memory if necessary
7334593Sgblack@eecs.umich.edu            //if(predecoder.needMoreBytes())
7344593Sgblack@eecs.umich.edu            //{
7354182Sgblack@eecs.umich.edu                icache_access = true;
7364870Sstever@eecs.umich.edu                Packet ifetch_pkt = Packet(&ifetch_req, MemCmd::ReadReq,
7374870Sstever@eecs.umich.edu                                           Packet::Broadcast);
7384870Sstever@eecs.umich.edu                ifetch_pkt.dataStatic(&inst);
7392623SN/A
7404968Sacolyte@umich.edu                if (hasPhysMemPort && ifetch_pkt.getAddr() == physMemAddr)
7414968Sacolyte@umich.edu                    icache_latency = physmemPort.sendAtomic(&ifetch_pkt);
7424968Sacolyte@umich.edu                else
7434968Sacolyte@umich.edu                    icache_latency = icachePort.sendAtomic(&ifetch_pkt);
7444968Sacolyte@umich.edu
7454986Ssaidi@eecs.umich.edu                assert(!ifetch_pkt.isError());
7464968Sacolyte@umich.edu
7474182Sgblack@eecs.umich.edu                // ifetch_req is initialized to read the instruction directly
7484182Sgblack@eecs.umich.edu                // into the CPU object's inst field.
7494593Sgblack@eecs.umich.edu            //}
7504182Sgblack@eecs.umich.edu
7512623SN/A            preExecute();
7523814Ssaidi@eecs.umich.edu
7535001Sgblack@eecs.umich.edu            if (curStaticInst) {
7544182Sgblack@eecs.umich.edu                fault = curStaticInst->execute(this, traceData);
7554998Sgblack@eecs.umich.edu
7564998Sgblack@eecs.umich.edu                // keep an instruction count
7574998Sgblack@eecs.umich.edu                if (fault == NoFault)
7584998Sgblack@eecs.umich.edu                    countInst();
7595001Sgblack@eecs.umich.edu                else if (traceData) {
7605001Sgblack@eecs.umich.edu                    // If there was a fault, we should trace this instruction.
7615001Sgblack@eecs.umich.edu                    delete traceData;
7625001Sgblack@eecs.umich.edu                    traceData = NULL;
7635001Sgblack@eecs.umich.edu                }
7644998Sgblack@eecs.umich.edu
7654182Sgblack@eecs.umich.edu                postExecute();
7664182Sgblack@eecs.umich.edu            }
7672623SN/A
7683814Ssaidi@eecs.umich.edu            // @todo remove me after debugging with legion done
7694539Sgblack@eecs.umich.edu            if (curStaticInst && (!curStaticInst->isMicroop() ||
7704539Sgblack@eecs.umich.edu                        curStaticInst->isFirstMicroop()))
7713814Ssaidi@eecs.umich.edu                instCnt++;
7723814Ssaidi@eecs.umich.edu
7735487Snate@binkert.org            Tick stall_ticks = 0;
7745487Snate@binkert.org            if (simulate_inst_stalls && icache_access)
7755487Snate@binkert.org                stall_ticks += icache_latency;
7765487Snate@binkert.org
7775487Snate@binkert.org            if (simulate_data_stalls && dcache_access)
7785487Snate@binkert.org                stall_ticks += dcache_latency;
7795487Snate@binkert.org
7805487Snate@binkert.org            if (stall_ticks) {
7815487Snate@binkert.org                Tick stall_cycles = stall_ticks / ticks(1);
7825487Snate@binkert.org                Tick aligned_stall_ticks = ticks(stall_cycles);
7835487Snate@binkert.org
7845487Snate@binkert.org                if (aligned_stall_ticks < stall_ticks)
7855487Snate@binkert.org                    aligned_stall_ticks += 1;
7865487Snate@binkert.org
7875487Snate@binkert.org                latency += aligned_stall_ticks;
7882623SN/A            }
7892623SN/A
7902623SN/A        }
7914377Sgblack@eecs.umich.edu        if(fault != NoFault || !stayAtPC)
7924182Sgblack@eecs.umich.edu            advancePC(fault);
7932623SN/A    }
7942623SN/A
7955487Snate@binkert.org    // instruction takes at least one cycle
7965487Snate@binkert.org    if (latency < ticks(1))
7975487Snate@binkert.org        latency = ticks(1);
7985487Snate@binkert.org
7992626SN/A    if (_status != Idle)
8002626SN/A        tickEvent.schedule(curTick + latency);
8012623SN/A}
8022623SN/A
8032623SN/A
8045315Sstever@gmail.comvoid
8055315Sstever@gmail.comAtomicSimpleCPU::printAddr(Addr a)
8065315Sstever@gmail.com{
8075315Sstever@gmail.com    dcachePort.printAddr(a);
8085315Sstever@gmail.com}
8095315Sstever@gmail.com
8105315Sstever@gmail.com
8112623SN/A////////////////////////////////////////////////////////////////////////
8122623SN/A//
8132623SN/A//  AtomicSimpleCPU Simulation Object
8142623SN/A//
8154762Snate@binkert.orgAtomicSimpleCPU *
8164762Snate@binkert.orgAtomicSimpleCPUParams::create()
8172623SN/A{
8182623SN/A    AtomicSimpleCPU::Params *params = new AtomicSimpleCPU::Params();
8194762Snate@binkert.org    params->name = name;
8202623SN/A    params->numberOfThreads = 1;
8212623SN/A    params->max_insts_any_thread = max_insts_any_thread;
8222623SN/A    params->max_insts_all_threads = max_insts_all_threads;
8232623SN/A    params->max_loads_any_thread = max_loads_any_thread;
8242623SN/A    params->max_loads_all_threads = max_loads_all_threads;
8253119Sktlim@umich.edu    params->progress_interval = progress_interval;
8262623SN/A    params->deferRegistration = defer_registration;
8273661Srdreslin@umich.edu    params->phase = phase;
8282623SN/A    params->clock = clock;
8292623SN/A    params->functionTrace = function_trace;
8302623SN/A    params->functionTraceStart = function_trace_start;
8312623SN/A    params->width = width;
8325487Snate@binkert.org    params->simulate_data_stalls = simulate_data_stalls;
8335487Snate@binkert.org    params->simulate_inst_stalls = simulate_inst_stalls;
8342901Ssaidi@eecs.umich.edu    params->system = system;
8353170Sstever@eecs.umich.edu    params->cpu_id = cpu_id;
8364776Sgblack@eecs.umich.edu    params->tracer = tracer;
8372623SN/A
8382623SN/A    params->itb = itb;
8392623SN/A    params->dtb = dtb;
8404997Sgblack@eecs.umich.edu#if FULL_SYSTEM
8412623SN/A    params->profile = profile;
8423617Sbinkertn@umich.edu    params->do_quiesce = do_quiesce;
8433617Sbinkertn@umich.edu    params->do_checkpoint_insts = do_checkpoint_insts;
8443617Sbinkertn@umich.edu    params->do_statistics_insts = do_statistics_insts;
8452623SN/A#else
8464762Snate@binkert.org    if (workload.size() != 1)
8474762Snate@binkert.org        panic("only one workload allowed");
8484762Snate@binkert.org    params->process = workload[0];
8492623SN/A#endif
8502623SN/A
8512623SN/A    AtomicSimpleCPU *cpu = new AtomicSimpleCPU(params);
8522623SN/A    return cpu;
8532623SN/A}
854