cpu.cc revision 12127
11689SN/A/* 212109SRekai.GonzalezAlberquilla@arm.com * Copyright (c) 2011-2012, 2014, 2016 ARM Limited 39916Ssteve.reinhardt@amd.com * Copyright (c) 2013 Advanced Micro Devices, Inc. 48707Sandreas.hansson@arm.com * All rights reserved 58707Sandreas.hansson@arm.com * 68707Sandreas.hansson@arm.com * The license below extends only to copyright in the software and shall 78707Sandreas.hansson@arm.com * not be construed as granting a license to any other intellectual 88707Sandreas.hansson@arm.com * property including but not limited to intellectual property relating 98707Sandreas.hansson@arm.com * to a hardware implementation of the functionality of the software 108707Sandreas.hansson@arm.com * licensed hereunder. You may use the software subject to the license 118707Sandreas.hansson@arm.com * terms below provided that you ensure that this notice is replicated 128707Sandreas.hansson@arm.com * unmodified and in its entirety in all distributions of the software, 138707Sandreas.hansson@arm.com * modified or unmodified, in source code or in binary form. 148707Sandreas.hansson@arm.com * 152325SN/A * Copyright (c) 2004-2006 The Regents of The University of Michigan 167897Shestness@cs.utexas.edu * Copyright (c) 2011 Regents of the University of California 171689SN/A * All rights reserved. 181689SN/A * 191689SN/A * Redistribution and use in source and binary forms, with or without 201689SN/A * modification, are permitted provided that the following conditions are 211689SN/A * met: redistributions of source code must retain the above copyright 221689SN/A * notice, this list of conditions and the following disclaimer; 231689SN/A * redistributions in binary form must reproduce the above copyright 241689SN/A * notice, this list of conditions and the following disclaimer in the 251689SN/A * documentation and/or other materials provided with the distribution; 261689SN/A * neither the name of the copyright holders nor the names of its 271689SN/A * contributors may be used to endorse or promote products derived from 281689SN/A * this software without specific prior written permission. 291689SN/A * 301689SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 311689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 321689SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 331689SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 341689SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 351689SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 361689SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 371689SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 381689SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 391689SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 401689SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 412665Ssaidi@eecs.umich.edu * 422665Ssaidi@eecs.umich.edu * Authors: Kevin Lim 432756Sksewell@umich.edu * Korey Sewell 447897Shestness@cs.utexas.edu * Rick Strong 451689SN/A */ 461689SN/A 4711793Sbrandon.potter@amd.com#include "cpu/o3/cpu.hh" 4811793Sbrandon.potter@amd.com 4912109SRekai.GonzalezAlberquilla@arm.com#include "arch/generic/traits.hh" 508779Sgblack@eecs.umich.edu#include "arch/kernel_stats.hh" 516658Snate@binkert.org#include "config/the_isa.hh" 5211793Sbrandon.potter@amd.com#include "cpu/activity.hh" 538887Sgeoffrey.blake@arm.com#include "cpu/checker/cpu.hh" 548887Sgeoffrey.blake@arm.com#include "cpu/checker/thread_context.hh" 558229Snate@binkert.org#include "cpu/o3/isa_specific.hh" 568229Snate@binkert.org#include "cpu/o3/thread_context.hh" 578779Sgblack@eecs.umich.edu#include "cpu/quiesce_event.hh" 584762Snate@binkert.org#include "cpu/simple_thread.hh" 594762Snate@binkert.org#include "cpu/thread_context.hh" 608232Snate@binkert.org#include "debug/Activity.hh" 619152Satgutier@umich.edu#include "debug/Drain.hh" 628232Snate@binkert.org#include "debug/O3CPU.hh" 638232Snate@binkert.org#include "debug/Quiesce.hh" 644762Snate@binkert.org#include "enums/MemoryMode.hh" 654762Snate@binkert.org#include "sim/core.hh" 668793Sgblack@eecs.umich.edu#include "sim/full_system.hh" 678779Sgblack@eecs.umich.edu#include "sim/process.hh" 684762Snate@binkert.org#include "sim/stat_control.hh" 698460SAli.Saidi@ARM.com#include "sim/system.hh" 704762Snate@binkert.org 715702Ssaidi@eecs.umich.edu#if THE_ISA == ALPHA_ISA 725702Ssaidi@eecs.umich.edu#include "arch/alpha/osfpal.hh" 738232Snate@binkert.org#include "debug/Activity.hh" 7411793Sbrandon.potter@amd.com 755702Ssaidi@eecs.umich.edu#endif 765702Ssaidi@eecs.umich.edu 778737Skoansin.tan@gmail.comstruct BaseCPUParams; 785529Snate@binkert.org 792669Sktlim@umich.eduusing namespace TheISA; 806221Snate@binkert.orgusing namespace std; 811060SN/A 825529Snate@binkert.orgBaseO3CPU::BaseO3CPU(BaseCPUParams *params) 835712Shsul@eecs.umich.edu : BaseCPU(params) 841060SN/A{ 851060SN/A} 861060SN/A 872292SN/Avoid 882733Sktlim@umich.eduBaseO3CPU::regStats() 892292SN/A{ 902292SN/A BaseCPU::regStats(); 912292SN/A} 922292SN/A 938707Sandreas.hansson@arm.comtemplate<class Impl> 948707Sandreas.hansson@arm.combool 958975Sandreas.hansson@arm.comFullO3CPU<Impl>::IcachePort::recvTimingResp(PacketPtr pkt) 968707Sandreas.hansson@arm.com{ 978707Sandreas.hansson@arm.com DPRINTF(O3CPU, "Fetch unit received timing\n"); 9811284Sandreas.hansson@arm.com // We shouldn't ever get a cacheable block in Modified state 9910821Sandreas.hansson@arm.com assert(pkt->req->isUncacheable() || 10011284Sandreas.hansson@arm.com !(pkt->cacheResponding() && !pkt->hasSharers())); 1018948Sandreas.hansson@arm.com fetch->processCacheCompletion(pkt); 1028707Sandreas.hansson@arm.com 1038707Sandreas.hansson@arm.com return true; 1048707Sandreas.hansson@arm.com} 1058707Sandreas.hansson@arm.com 1068707Sandreas.hansson@arm.comtemplate<class Impl> 1078707Sandreas.hansson@arm.comvoid 10810713Sandreas.hansson@arm.comFullO3CPU<Impl>::IcachePort::recvReqRetry() 1098707Sandreas.hansson@arm.com{ 11010713Sandreas.hansson@arm.com fetch->recvReqRetry(); 1118707Sandreas.hansson@arm.com} 1128707Sandreas.hansson@arm.com 1138707Sandreas.hansson@arm.comtemplate <class Impl> 1148707Sandreas.hansson@arm.combool 1158975Sandreas.hansson@arm.comFullO3CPU<Impl>::DcachePort::recvTimingResp(PacketPtr pkt) 1168707Sandreas.hansson@arm.com{ 1178975Sandreas.hansson@arm.com return lsq->recvTimingResp(pkt); 1188707Sandreas.hansson@arm.com} 1198707Sandreas.hansson@arm.com 1208707Sandreas.hansson@arm.comtemplate <class Impl> 1218975Sandreas.hansson@arm.comvoid 1228975Sandreas.hansson@arm.comFullO3CPU<Impl>::DcachePort::recvTimingSnoopReq(PacketPtr pkt) 1238948Sandreas.hansson@arm.com{ 12411148Smitch.hayenga@arm.com for (ThreadID tid = 0; tid < cpu->numThreads; tid++) { 12511148Smitch.hayenga@arm.com if (cpu->getCpuAddrMonitor(tid)->doMonitor(pkt)) { 12611151Smitch.hayenga@arm.com cpu->wakeup(tid); 12711148Smitch.hayenga@arm.com } 12810529Smorr@cs.wisc.edu } 1298975Sandreas.hansson@arm.com lsq->recvTimingSnoopReq(pkt); 1308948Sandreas.hansson@arm.com} 1318948Sandreas.hansson@arm.com 1328948Sandreas.hansson@arm.comtemplate <class Impl> 1338707Sandreas.hansson@arm.comvoid 13410713Sandreas.hansson@arm.comFullO3CPU<Impl>::DcachePort::recvReqRetry() 1358707Sandreas.hansson@arm.com{ 13610713Sandreas.hansson@arm.com lsq->recvReqRetry(); 1378707Sandreas.hansson@arm.com} 1388707Sandreas.hansson@arm.com 1391060SN/Atemplate <class Impl> 1405595Sgblack@eecs.umich.eduFullO3CPU<Impl>::FullO3CPU(DerivO3CPUParams *params) 1412733Sktlim@umich.edu : BaseO3CPU(params), 1423781Sgblack@eecs.umich.edu itb(params->itb), 1433781Sgblack@eecs.umich.edu dtb(params->dtb), 14412127Sspwilson2@wisc.edu tickEvent([this]{ tick(); }, "FullO3CPU tick", 14512127Sspwilson2@wisc.edu false, Event::CPU_Tick_Pri), 1465737Scws3k@cs.virginia.edu#ifndef NDEBUG 1475737Scws3k@cs.virginia.edu instcount(0), 1485737Scws3k@cs.virginia.edu#endif 1492292SN/A removeInstsThisCycle(false), 1505595Sgblack@eecs.umich.edu fetch(this, params), 1515595Sgblack@eecs.umich.edu decode(this, params), 1525595Sgblack@eecs.umich.edu rename(this, params), 1535595Sgblack@eecs.umich.edu iew(this, params), 1545595Sgblack@eecs.umich.edu commit(this, params), 1551060SN/A 15612109SRekai.GonzalezAlberquilla@arm.com /* It is mandatory that all SMT threads use the same renaming mode as 15712109SRekai.GonzalezAlberquilla@arm.com * they are sharing registers and rename */ 15812109SRekai.GonzalezAlberquilla@arm.com vecMode(initRenameMode<TheISA::ISA>::mode(params->isa[0])), 1599915Ssteve.reinhardt@amd.com regFile(params->numPhysIntRegs, 1609920Syasuko.eckert@amd.com params->numPhysFloatRegs, 16112109SRekai.GonzalezAlberquilla@arm.com params->numPhysVecRegs, 16212109SRekai.GonzalezAlberquilla@arm.com params->numPhysCCRegs, 16312109SRekai.GonzalezAlberquilla@arm.com vecMode), 1641060SN/A 1659919Ssteve.reinhardt@amd.com freeList(name() + ".freelist", ®File), 1661060SN/A 1679954SFaissal.Sleiman@arm.com rob(this, params), 1681060SN/A 1699916Ssteve.reinhardt@amd.com scoreboard(name() + ".scoreboard", 17012105Snathanael.premillieu@arm.com regFile.totalNumPhysRegs()), 1711060SN/A 1729384SAndreas.Sandberg@arm.com isa(numThreads, NULL), 1739384SAndreas.Sandberg@arm.com 1748707Sandreas.hansson@arm.com icachePort(&fetch, this), 1758707Sandreas.hansson@arm.com dcachePort(&iew.ldstQueue, this), 1768707Sandreas.hansson@arm.com 1772873Sktlim@umich.edu timeBuffer(params->backComSize, params->forwardComSize), 1782873Sktlim@umich.edu fetchQueue(params->backComSize, params->forwardComSize), 1792873Sktlim@umich.edu decodeQueue(params->backComSize, params->forwardComSize), 1802873Sktlim@umich.edu renameQueue(params->backComSize, params->forwardComSize), 1812873Sktlim@umich.edu iewQueue(params->backComSize, params->forwardComSize), 1825804Snate@binkert.org activityRec(name(), NumStages, 1832873Sktlim@umich.edu params->backComSize + params->forwardComSize, 1842873Sktlim@umich.edu params->activity), 1851060SN/A 1861060SN/A globalSeqNum(1), 1872292SN/A system(params->system), 1889180Sandreas.hansson@arm.com lastRunningCycle(curCycle()) 1891060SN/A{ 1909433SAndreas.Sandberg@ARM.com if (!params->switched_out) { 1913221Sktlim@umich.edu _status = Running; 1923221Sktlim@umich.edu } else { 1939152Satgutier@umich.edu _status = SwitchedOut; 1943221Sktlim@umich.edu } 1951681SN/A 1962794Sktlim@umich.edu if (params->checker) { 1972316SN/A BaseCPU *temp_checker = params->checker; 1988733Sgeoffrey.blake@arm.com checker = dynamic_cast<Checker<Impl> *>(temp_checker); 1998707Sandreas.hansson@arm.com checker->setIcachePort(&icachePort); 2002316SN/A checker->setSystem(params->system); 2014598Sbinkertn@umich.edu } else { 2024598Sbinkertn@umich.edu checker = NULL; 2034598Sbinkertn@umich.edu } 2042316SN/A 2058793Sgblack@eecs.umich.edu if (!FullSystem) { 2068793Sgblack@eecs.umich.edu thread.resize(numThreads); 2078793Sgblack@eecs.umich.edu tids.resize(numThreads); 2088793Sgblack@eecs.umich.edu } 2091681SN/A 2102325SN/A // The stages also need their CPU pointer setup. However this 2112325SN/A // must be done at the upper level CPU because they have pointers 2122325SN/A // to the upper level CPU, and not this FullO3CPU. 2131060SN/A 2142292SN/A // Set up Pointers to the activeThreads list for each stage 2152292SN/A fetch.setActiveThreads(&activeThreads); 2162292SN/A decode.setActiveThreads(&activeThreads); 2172292SN/A rename.setActiveThreads(&activeThreads); 2182292SN/A iew.setActiveThreads(&activeThreads); 2192292SN/A commit.setActiveThreads(&activeThreads); 2201060SN/A 2211060SN/A // Give each of the stages the time buffer they will use. 2221060SN/A fetch.setTimeBuffer(&timeBuffer); 2231060SN/A decode.setTimeBuffer(&timeBuffer); 2241060SN/A rename.setTimeBuffer(&timeBuffer); 2251060SN/A iew.setTimeBuffer(&timeBuffer); 2261060SN/A commit.setTimeBuffer(&timeBuffer); 2271060SN/A 2281060SN/A // Also setup each of the stages' queues. 2291060SN/A fetch.setFetchQueue(&fetchQueue); 2301060SN/A decode.setFetchQueue(&fetchQueue); 2312292SN/A commit.setFetchQueue(&fetchQueue); 2321060SN/A decode.setDecodeQueue(&decodeQueue); 2331060SN/A rename.setDecodeQueue(&decodeQueue); 2341060SN/A rename.setRenameQueue(&renameQueue); 2351060SN/A iew.setRenameQueue(&renameQueue); 2361060SN/A iew.setIEWQueue(&iewQueue); 2371060SN/A commit.setIEWQueue(&iewQueue); 2381060SN/A commit.setRenameQueue(&renameQueue); 2391060SN/A 2402292SN/A commit.setIEWStage(&iew); 2412292SN/A rename.setIEWStage(&iew); 2422292SN/A rename.setCommitStage(&commit); 2432292SN/A 2448793Sgblack@eecs.umich.edu ThreadID active_threads; 2458793Sgblack@eecs.umich.edu if (FullSystem) { 2468793Sgblack@eecs.umich.edu active_threads = 1; 2478793Sgblack@eecs.umich.edu } else { 2488793Sgblack@eecs.umich.edu active_threads = params->workload.size(); 2492831Sksewell@umich.edu 2508793Sgblack@eecs.umich.edu if (active_threads > Impl::MaxThreads) { 2518793Sgblack@eecs.umich.edu panic("Workload Size too large. Increase the 'MaxThreads' " 2528793Sgblack@eecs.umich.edu "constant in your O3CPU impl. file (e.g. o3/alpha/impl.hh) " 2538793Sgblack@eecs.umich.edu "or edit your workload size."); 2548793Sgblack@eecs.umich.edu } 2552831Sksewell@umich.edu } 2562292SN/A 2572316SN/A //Make Sure That this a Valid Architeture 2582292SN/A assert(params->numPhysIntRegs >= numThreads * TheISA::NumIntRegs); 2592292SN/A assert(params->numPhysFloatRegs >= numThreads * TheISA::NumFloatRegs); 26012109SRekai.GonzalezAlberquilla@arm.com assert(params->numPhysVecRegs >= numThreads * TheISA::NumVecRegs); 2619920Syasuko.eckert@amd.com assert(params->numPhysCCRegs >= numThreads * TheISA::NumCCRegs); 2622292SN/A 2632292SN/A rename.setScoreboard(&scoreboard); 2642292SN/A iew.setScoreboard(&scoreboard); 2652292SN/A 2661060SN/A // Setup the rename map for whichever stages need it. 2676221Snate@binkert.org for (ThreadID tid = 0; tid < numThreads; tid++) { 2689384SAndreas.Sandberg@arm.com isa[tid] = params->isa[tid]; 26912109SRekai.GonzalezAlberquilla@arm.com assert(initRenameMode<TheISA::ISA>::equals(isa[tid], isa[0])); 2709384SAndreas.Sandberg@arm.com 2719919Ssteve.reinhardt@amd.com // Only Alpha has an FP zero register, so for other ISAs we 2729919Ssteve.reinhardt@amd.com // use an invalid FP register index to avoid special treatment 2739919Ssteve.reinhardt@amd.com // of any valid FP reg. 2749919Ssteve.reinhardt@amd.com RegIndex invalidFPReg = TheISA::NumFloatRegs + 1; 2759919Ssteve.reinhardt@amd.com RegIndex fpZeroReg = 2769919Ssteve.reinhardt@amd.com (THE_ISA == ALPHA_ISA) ? TheISA::ZeroReg : invalidFPReg; 2772292SN/A 2789919Ssteve.reinhardt@amd.com commitRenameMap[tid].init(®File, TheISA::ZeroReg, fpZeroReg, 27912109SRekai.GonzalezAlberquilla@arm.com &freeList, 28012109SRekai.GonzalezAlberquilla@arm.com vecMode); 2812292SN/A 2829919Ssteve.reinhardt@amd.com renameMap[tid].init(®File, TheISA::ZeroReg, fpZeroReg, 28312109SRekai.GonzalezAlberquilla@arm.com &freeList, vecMode); 2842292SN/A } 2852292SN/A 2869919Ssteve.reinhardt@amd.com // Initialize rename map to assign physical registers to the 2879919Ssteve.reinhardt@amd.com // architectural registers for active threads only. 2889919Ssteve.reinhardt@amd.com for (ThreadID tid = 0; tid < active_threads; tid++) { 2899919Ssteve.reinhardt@amd.com for (RegIndex ridx = 0; ridx < TheISA::NumIntRegs; ++ridx) { 2909919Ssteve.reinhardt@amd.com // Note that we can't use the rename() method because we don't 2919919Ssteve.reinhardt@amd.com // want special treatment for the zero register at this point 29212105Snathanael.premillieu@arm.com PhysRegIdPtr phys_reg = freeList.getIntReg(); 29312106SRekai.GonzalezAlberquilla@arm.com renameMap[tid].setEntry(RegId(IntRegClass, ridx), phys_reg); 29412106SRekai.GonzalezAlberquilla@arm.com commitRenameMap[tid].setEntry(RegId(IntRegClass, ridx), phys_reg); 2959919Ssteve.reinhardt@amd.com } 2969919Ssteve.reinhardt@amd.com 2979919Ssteve.reinhardt@amd.com for (RegIndex ridx = 0; ridx < TheISA::NumFloatRegs; ++ridx) { 29812105Snathanael.premillieu@arm.com PhysRegIdPtr phys_reg = freeList.getFloatReg(); 29912106SRekai.GonzalezAlberquilla@arm.com renameMap[tid].setEntry(RegId(FloatRegClass, ridx), phys_reg); 30012106SRekai.GonzalezAlberquilla@arm.com commitRenameMap[tid].setEntry( 30112106SRekai.GonzalezAlberquilla@arm.com RegId(FloatRegClass, ridx), phys_reg); 3029919Ssteve.reinhardt@amd.com } 3039920Syasuko.eckert@amd.com 30412109SRekai.GonzalezAlberquilla@arm.com /* Here we need two 'interfaces' the 'whole register' and the 30512109SRekai.GonzalezAlberquilla@arm.com * 'register element'. At any point only one of them will be 30612109SRekai.GonzalezAlberquilla@arm.com * active. */ 30712109SRekai.GonzalezAlberquilla@arm.com if (vecMode == Enums::Full) { 30812109SRekai.GonzalezAlberquilla@arm.com /* Initialize the full-vector interface */ 30912109SRekai.GonzalezAlberquilla@arm.com for (RegIndex ridx = 0; ridx < TheISA::NumVecRegs; ++ridx) { 31012109SRekai.GonzalezAlberquilla@arm.com RegId rid = RegId(VecRegClass, ridx); 31112109SRekai.GonzalezAlberquilla@arm.com PhysRegIdPtr phys_reg = freeList.getVecReg(); 31212109SRekai.GonzalezAlberquilla@arm.com renameMap[tid].setEntry(rid, phys_reg); 31312109SRekai.GonzalezAlberquilla@arm.com commitRenameMap[tid].setEntry(rid, phys_reg); 31412109SRekai.GonzalezAlberquilla@arm.com } 31512109SRekai.GonzalezAlberquilla@arm.com } else { 31612109SRekai.GonzalezAlberquilla@arm.com /* Initialize the vector-element interface */ 31712109SRekai.GonzalezAlberquilla@arm.com for (RegIndex ridx = 0; ridx < TheISA::NumVecRegs; ++ridx) { 31812109SRekai.GonzalezAlberquilla@arm.com for (ElemIndex ldx = 0; ldx < TheISA::NumVecElemPerVecReg; 31912109SRekai.GonzalezAlberquilla@arm.com ++ldx) { 32012109SRekai.GonzalezAlberquilla@arm.com RegId lrid = RegId(VecElemClass, ridx, ldx); 32112109SRekai.GonzalezAlberquilla@arm.com PhysRegIdPtr phys_elem = freeList.getVecElem(); 32212109SRekai.GonzalezAlberquilla@arm.com renameMap[tid].setEntry(lrid, phys_elem); 32312109SRekai.GonzalezAlberquilla@arm.com commitRenameMap[tid].setEntry(lrid, phys_elem); 32412109SRekai.GonzalezAlberquilla@arm.com } 32512109SRekai.GonzalezAlberquilla@arm.com } 32612109SRekai.GonzalezAlberquilla@arm.com } 32712109SRekai.GonzalezAlberquilla@arm.com 3289920Syasuko.eckert@amd.com for (RegIndex ridx = 0; ridx < TheISA::NumCCRegs; ++ridx) { 32912105Snathanael.premillieu@arm.com PhysRegIdPtr phys_reg = freeList.getCCReg(); 33012106SRekai.GonzalezAlberquilla@arm.com renameMap[tid].setEntry(RegId(CCRegClass, ridx), phys_reg); 33112106SRekai.GonzalezAlberquilla@arm.com commitRenameMap[tid].setEntry(RegId(CCRegClass, ridx), phys_reg); 3329920Syasuko.eckert@amd.com } 3339919Ssteve.reinhardt@amd.com } 3349919Ssteve.reinhardt@amd.com 3352292SN/A rename.setRenameMap(renameMap); 3362292SN/A commit.setRenameMap(commitRenameMap); 3371060SN/A rename.setFreeList(&freeList); 3382292SN/A 3391060SN/A // Setup the ROB for whichever stages need it. 3401060SN/A commit.setROB(&rob); 3412292SN/A 3429158Sandreas.hansson@arm.com lastActivatedCycle = 0; 3436221Snate@binkert.org#if 0 3443093Sksewell@umich.edu // Give renameMap & rename stage access to the freeList; 3456221Snate@binkert.org for (ThreadID tid = 0; tid < numThreads; tid++) 3466221Snate@binkert.org globalSeqNum[tid] = 1; 3476221Snate@binkert.org#endif 3483093Sksewell@umich.edu 3495595Sgblack@eecs.umich.edu DPRINTF(O3CPU, "Creating O3CPU object.\n"); 3505595Sgblack@eecs.umich.edu 3515595Sgblack@eecs.umich.edu // Setup any thread state. 3525595Sgblack@eecs.umich.edu this->thread.resize(this->numThreads); 3535595Sgblack@eecs.umich.edu 3546221Snate@binkert.org for (ThreadID tid = 0; tid < this->numThreads; ++tid) { 3558793Sgblack@eecs.umich.edu if (FullSystem) { 3568793Sgblack@eecs.umich.edu // SMT is not supported in FS mode yet. 3578793Sgblack@eecs.umich.edu assert(this->numThreads == 1); 3588793Sgblack@eecs.umich.edu this->thread[tid] = new Thread(this, 0, NULL); 3598793Sgblack@eecs.umich.edu } else { 3608793Sgblack@eecs.umich.edu if (tid < params->workload.size()) { 3618793Sgblack@eecs.umich.edu DPRINTF(O3CPU, "Workload[%i] process is %#x", 3628793Sgblack@eecs.umich.edu tid, this->thread[tid]); 3638793Sgblack@eecs.umich.edu this->thread[tid] = new typename FullO3CPU<Impl>::Thread( 3648793Sgblack@eecs.umich.edu (typename Impl::O3CPU *)(this), 3658793Sgblack@eecs.umich.edu tid, params->workload[tid]); 3665595Sgblack@eecs.umich.edu 3678793Sgblack@eecs.umich.edu //usedTids[tid] = true; 3688793Sgblack@eecs.umich.edu //threadMap[tid] = tid; 3698793Sgblack@eecs.umich.edu } else { 3708793Sgblack@eecs.umich.edu //Allocate Empty thread so M5 can use later 3718793Sgblack@eecs.umich.edu //when scheduling threads to CPU 3728793Sgblack@eecs.umich.edu Process* dummy_proc = NULL; 3735595Sgblack@eecs.umich.edu 3748793Sgblack@eecs.umich.edu this->thread[tid] = new typename FullO3CPU<Impl>::Thread( 3758793Sgblack@eecs.umich.edu (typename Impl::O3CPU *)(this), 3768793Sgblack@eecs.umich.edu tid, dummy_proc); 3778793Sgblack@eecs.umich.edu //usedTids[tid] = false; 3788793Sgblack@eecs.umich.edu } 3795595Sgblack@eecs.umich.edu } 3805595Sgblack@eecs.umich.edu 3815595Sgblack@eecs.umich.edu ThreadContext *tc; 3825595Sgblack@eecs.umich.edu 3835595Sgblack@eecs.umich.edu // Setup the TC that will serve as the interface to the threads/CPU. 3845595Sgblack@eecs.umich.edu O3ThreadContext<Impl> *o3_tc = new O3ThreadContext<Impl>; 3855595Sgblack@eecs.umich.edu 3865595Sgblack@eecs.umich.edu tc = o3_tc; 3875595Sgblack@eecs.umich.edu 3885595Sgblack@eecs.umich.edu // If we're using a checker, then the TC should be the 3895595Sgblack@eecs.umich.edu // CheckerThreadContext. 3905595Sgblack@eecs.umich.edu if (params->checker) { 3915595Sgblack@eecs.umich.edu tc = new CheckerThreadContext<O3ThreadContext<Impl> >( 3925595Sgblack@eecs.umich.edu o3_tc, this->checker); 3935595Sgblack@eecs.umich.edu } 3945595Sgblack@eecs.umich.edu 3955595Sgblack@eecs.umich.edu o3_tc->cpu = (typename Impl::O3CPU *)(this); 3965595Sgblack@eecs.umich.edu assert(o3_tc->cpu); 3976221Snate@binkert.org o3_tc->thread = this->thread[tid]; 3985595Sgblack@eecs.umich.edu 39911627Smichael.lebeane@amd.com // Setup quiesce event. 40011627Smichael.lebeane@amd.com this->thread[tid]->quiesceEvent = new EndQuiesceEvent(tc); 40111627Smichael.lebeane@amd.com 4025595Sgblack@eecs.umich.edu // Give the thread the TC. 4036221Snate@binkert.org this->thread[tid]->tc = tc; 4045595Sgblack@eecs.umich.edu 4055595Sgblack@eecs.umich.edu // Add the TC to the CPU's list of TC's. 4065595Sgblack@eecs.umich.edu this->threadContexts.push_back(tc); 4075595Sgblack@eecs.umich.edu } 4085595Sgblack@eecs.umich.edu 4098876Sandreas.hansson@arm.com // FullO3CPU always requires an interrupt controller. 41011150Smitch.hayenga@arm.com if (!params->switched_out && interrupts.empty()) { 4118876Sandreas.hansson@arm.com fatal("FullO3CPU %s has no interrupt controller.\n" 4128876Sandreas.hansson@arm.com "Ensure createInterruptController() is called.\n", name()); 4138876Sandreas.hansson@arm.com } 4148876Sandreas.hansson@arm.com 4156221Snate@binkert.org for (ThreadID tid = 0; tid < this->numThreads; tid++) 4166221Snate@binkert.org this->thread[tid]->setFuncExeInst(0); 4171060SN/A} 4181060SN/A 4191060SN/Atemplate <class Impl> 4201755SN/AFullO3CPU<Impl>::~FullO3CPU() 4211060SN/A{ 4221060SN/A} 4231060SN/A 4241060SN/Atemplate <class Impl> 4251060SN/Avoid 42610023Smatt.horsnell@ARM.comFullO3CPU<Impl>::regProbePoints() 42710023Smatt.horsnell@ARM.com{ 42810464SAndreas.Sandberg@ARM.com BaseCPU::regProbePoints(); 42910464SAndreas.Sandberg@ARM.com 43010023Smatt.horsnell@ARM.com ppInstAccessComplete = new ProbePointArg<PacketPtr>(getProbeManager(), "InstAccessComplete"); 43110023Smatt.horsnell@ARM.com ppDataAccessComplete = new ProbePointArg<std::pair<DynInstPtr, PacketPtr> >(getProbeManager(), "DataAccessComplete"); 43210464SAndreas.Sandberg@ARM.com 43310023Smatt.horsnell@ARM.com fetch.regProbePoints(); 43411246Sradhika.jagtap@ARM.com rename.regProbePoints(); 43510023Smatt.horsnell@ARM.com iew.regProbePoints(); 43610023Smatt.horsnell@ARM.com commit.regProbePoints(); 43710023Smatt.horsnell@ARM.com} 43810023Smatt.horsnell@ARM.com 43910023Smatt.horsnell@ARM.comtemplate <class Impl> 44010023Smatt.horsnell@ARM.comvoid 4415595Sgblack@eecs.umich.eduFullO3CPU<Impl>::regStats() 4421062SN/A{ 4432733Sktlim@umich.edu BaseO3CPU::regStats(); 4442292SN/A 4452733Sktlim@umich.edu // Register any of the O3CPU's stats here. 4462292SN/A timesIdled 4472292SN/A .name(name() + ".timesIdled") 4482292SN/A .desc("Number of times that the entire CPU went into an idle state and" 4492292SN/A " unscheduled itself") 4502292SN/A .prereq(timesIdled); 4512292SN/A 4522292SN/A idleCycles 4532292SN/A .name(name() + ".idleCycles") 4542292SN/A .desc("Total number of cycles that the CPU has spent unscheduled due " 4552292SN/A "to idling") 4562292SN/A .prereq(idleCycles); 4572292SN/A 4588627SAli.Saidi@ARM.com quiesceCycles 4598627SAli.Saidi@ARM.com .name(name() + ".quiesceCycles") 4608627SAli.Saidi@ARM.com .desc("Total number of cycles that CPU has spent quiesced or waiting " 4618627SAli.Saidi@ARM.com "for an interrupt") 4628627SAli.Saidi@ARM.com .prereq(quiesceCycles); 4638627SAli.Saidi@ARM.com 4642292SN/A // Number of Instructions simulated 4652292SN/A // -------------------------------- 4662292SN/A // Should probably be in Base CPU but need templated 4672292SN/A // MaxThreads so put in here instead 4682292SN/A committedInsts 4692292SN/A .init(numThreads) 4702292SN/A .name(name() + ".committedInsts") 47110225Snilay@cs.wisc.edu .desc("Number of Instructions Simulated") 47210225Snilay@cs.wisc.edu .flags(Stats::total); 4732292SN/A 4748834Satgutier@umich.edu committedOps 4758834Satgutier@umich.edu .init(numThreads) 4768834Satgutier@umich.edu .name(name() + ".committedOps") 47710225Snilay@cs.wisc.edu .desc("Number of Ops (including micro ops) Simulated") 47810225Snilay@cs.wisc.edu .flags(Stats::total); 4792292SN/A 4802292SN/A cpi 4812292SN/A .name(name() + ".cpi") 4822292SN/A .desc("CPI: Cycles Per Instruction") 4832292SN/A .precision(6); 4844392Sktlim@umich.edu cpi = numCycles / committedInsts; 4852292SN/A 4862292SN/A totalCpi 4872292SN/A .name(name() + ".cpi_total") 4882292SN/A .desc("CPI: Total CPI of All Threads") 4892292SN/A .precision(6); 49010225Snilay@cs.wisc.edu totalCpi = numCycles / sum(committedInsts); 4912292SN/A 4922292SN/A ipc 4932292SN/A .name(name() + ".ipc") 4942292SN/A .desc("IPC: Instructions Per Cycle") 4952292SN/A .precision(6); 4964392Sktlim@umich.edu ipc = committedInsts / numCycles; 4972292SN/A 4982292SN/A totalIpc 4992292SN/A .name(name() + ".ipc_total") 5002292SN/A .desc("IPC: Total IPC of All Threads") 5012292SN/A .precision(6); 50210225Snilay@cs.wisc.edu totalIpc = sum(committedInsts) / numCycles; 5032292SN/A 5045595Sgblack@eecs.umich.edu this->fetch.regStats(); 5055595Sgblack@eecs.umich.edu this->decode.regStats(); 5065595Sgblack@eecs.umich.edu this->rename.regStats(); 5075595Sgblack@eecs.umich.edu this->iew.regStats(); 5085595Sgblack@eecs.umich.edu this->commit.regStats(); 5097897Shestness@cs.utexas.edu this->rob.regStats(); 5107897Shestness@cs.utexas.edu 5117897Shestness@cs.utexas.edu intRegfileReads 5127897Shestness@cs.utexas.edu .name(name() + ".int_regfile_reads") 5137897Shestness@cs.utexas.edu .desc("number of integer regfile reads") 5147897Shestness@cs.utexas.edu .prereq(intRegfileReads); 5157897Shestness@cs.utexas.edu 5167897Shestness@cs.utexas.edu intRegfileWrites 5177897Shestness@cs.utexas.edu .name(name() + ".int_regfile_writes") 5187897Shestness@cs.utexas.edu .desc("number of integer regfile writes") 5197897Shestness@cs.utexas.edu .prereq(intRegfileWrites); 5207897Shestness@cs.utexas.edu 5217897Shestness@cs.utexas.edu fpRegfileReads 5227897Shestness@cs.utexas.edu .name(name() + ".fp_regfile_reads") 5237897Shestness@cs.utexas.edu .desc("number of floating regfile reads") 5247897Shestness@cs.utexas.edu .prereq(fpRegfileReads); 5257897Shestness@cs.utexas.edu 5267897Shestness@cs.utexas.edu fpRegfileWrites 5277897Shestness@cs.utexas.edu .name(name() + ".fp_regfile_writes") 5287897Shestness@cs.utexas.edu .desc("number of floating regfile writes") 5297897Shestness@cs.utexas.edu .prereq(fpRegfileWrites); 5307897Shestness@cs.utexas.edu 53112109SRekai.GonzalezAlberquilla@arm.com vecRegfileReads 53212109SRekai.GonzalezAlberquilla@arm.com .name(name() + ".vec_regfile_reads") 53312109SRekai.GonzalezAlberquilla@arm.com .desc("number of vector regfile reads") 53412109SRekai.GonzalezAlberquilla@arm.com .prereq(vecRegfileReads); 53512109SRekai.GonzalezAlberquilla@arm.com 53612109SRekai.GonzalezAlberquilla@arm.com vecRegfileWrites 53712109SRekai.GonzalezAlberquilla@arm.com .name(name() + ".vec_regfile_writes") 53812109SRekai.GonzalezAlberquilla@arm.com .desc("number of vector regfile writes") 53912109SRekai.GonzalezAlberquilla@arm.com .prereq(vecRegfileWrites); 54012109SRekai.GonzalezAlberquilla@arm.com 5419920Syasuko.eckert@amd.com ccRegfileReads 5429920Syasuko.eckert@amd.com .name(name() + ".cc_regfile_reads") 5439920Syasuko.eckert@amd.com .desc("number of cc regfile reads") 5449920Syasuko.eckert@amd.com .prereq(ccRegfileReads); 5459920Syasuko.eckert@amd.com 5469920Syasuko.eckert@amd.com ccRegfileWrites 5479920Syasuko.eckert@amd.com .name(name() + ".cc_regfile_writes") 5489920Syasuko.eckert@amd.com .desc("number of cc regfile writes") 5499920Syasuko.eckert@amd.com .prereq(ccRegfileWrites); 5509920Syasuko.eckert@amd.com 5517897Shestness@cs.utexas.edu miscRegfileReads 5527897Shestness@cs.utexas.edu .name(name() + ".misc_regfile_reads") 5537897Shestness@cs.utexas.edu .desc("number of misc regfile reads") 5547897Shestness@cs.utexas.edu .prereq(miscRegfileReads); 5557897Shestness@cs.utexas.edu 5567897Shestness@cs.utexas.edu miscRegfileWrites 5577897Shestness@cs.utexas.edu .name(name() + ".misc_regfile_writes") 5587897Shestness@cs.utexas.edu .desc("number of misc regfile writes") 5597897Shestness@cs.utexas.edu .prereq(miscRegfileWrites); 5601062SN/A} 5611062SN/A 5621062SN/Atemplate <class Impl> 5631062SN/Avoid 5641755SN/AFullO3CPU<Impl>::tick() 5651060SN/A{ 5662733Sktlim@umich.edu DPRINTF(O3CPU, "\n\nFullO3CPU: Ticking main, FullO3CPU.\n"); 5679444SAndreas.Sandberg@ARM.com assert(!switchedOut()); 56810913Sandreas.sandberg@arm.com assert(drainState() != DrainState::Drained); 5691060SN/A 5702292SN/A ++numCycles; 57110464SAndreas.Sandberg@ARM.com ppCycles->notify(1); 5722292SN/A 5732325SN/A// activity = false; 5742292SN/A 5752292SN/A //Tick each of the stages 5761060SN/A fetch.tick(); 5771060SN/A 5781060SN/A decode.tick(); 5791060SN/A 5801060SN/A rename.tick(); 5811060SN/A 5821060SN/A iew.tick(); 5831060SN/A 5841060SN/A commit.tick(); 5851060SN/A 5862292SN/A // Now advance the time buffers 5871060SN/A timeBuffer.advance(); 5881060SN/A 5891060SN/A fetchQueue.advance(); 5901060SN/A decodeQueue.advance(); 5911060SN/A renameQueue.advance(); 5921060SN/A iewQueue.advance(); 5931060SN/A 5942325SN/A activityRec.advance(); 5952292SN/A 5962292SN/A if (removeInstsThisCycle) { 5972292SN/A cleanUpRemovedInsts(); 5982292SN/A } 5992292SN/A 6002325SN/A if (!tickEvent.scheduled()) { 6019444SAndreas.Sandberg@ARM.com if (_status == SwitchedOut) { 6023226Sktlim@umich.edu DPRINTF(O3CPU, "Switched out!\n"); 6032325SN/A // increment stat 6049179Sandreas.hansson@arm.com lastRunningCycle = curCycle(); 6053221Sktlim@umich.edu } else if (!activityRec.active() || _status == Idle) { 6063226Sktlim@umich.edu DPRINTF(O3CPU, "Idle!\n"); 6079179Sandreas.hansson@arm.com lastRunningCycle = curCycle(); 6082325SN/A timesIdled++; 6092325SN/A } else { 6109180Sandreas.hansson@arm.com schedule(tickEvent, clockEdge(Cycles(1))); 6113226Sktlim@umich.edu DPRINTF(O3CPU, "Scheduling next tick!\n"); 6122325SN/A } 6132292SN/A } 6142292SN/A 6158793Sgblack@eecs.umich.edu if (!FullSystem) 6168793Sgblack@eecs.umich.edu updateThreadPriority(); 6179444SAndreas.Sandberg@ARM.com 6189444SAndreas.Sandberg@ARM.com tryDrain(); 6191060SN/A} 6201060SN/A 6211060SN/Atemplate <class Impl> 6221060SN/Avoid 6231755SN/AFullO3CPU<Impl>::init() 6241060SN/A{ 6255714Shsul@eecs.umich.edu BaseCPU::init(); 6261060SN/A 6278921Sandreas.hansson@arm.com for (ThreadID tid = 0; tid < numThreads; ++tid) { 6289382SAli.Saidi@ARM.com // Set noSquashFromTC so that the CPU doesn't squash when initially 6298921Sandreas.hansson@arm.com // setting up registers. 6309382SAli.Saidi@ARM.com thread[tid]->noSquashFromTC = true; 6318921Sandreas.hansson@arm.com // Initialise the ThreadContext's memory proxies 6328921Sandreas.hansson@arm.com thread[tid]->initMemProxies(thread[tid]->getTC()); 6338921Sandreas.hansson@arm.com } 6342292SN/A 6359433SAndreas.Sandberg@ARM.com if (FullSystem && !params()->switched_out) { 6368793Sgblack@eecs.umich.edu for (ThreadID tid = 0; tid < numThreads; tid++) { 6378793Sgblack@eecs.umich.edu ThreadContext *src_tc = threadContexts[tid]; 6388793Sgblack@eecs.umich.edu TheISA::initCPU(src_tc, src_tc->contextId()); 6398793Sgblack@eecs.umich.edu } 6406034Ssteve.reinhardt@amd.com } 6412292SN/A 6429382SAli.Saidi@ARM.com // Clear noSquashFromTC. 6436221Snate@binkert.org for (int tid = 0; tid < numThreads; ++tid) 6449382SAli.Saidi@ARM.com thread[tid]->noSquashFromTC = false; 6452292SN/A 6469427SAndreas.Sandberg@ARM.com commit.setThreads(thread); 6479427SAndreas.Sandberg@ARM.com} 6482292SN/A 6499427SAndreas.Sandberg@ARM.comtemplate <class Impl> 6509427SAndreas.Sandberg@ARM.comvoid 6519427SAndreas.Sandberg@ARM.comFullO3CPU<Impl>::startup() 6529427SAndreas.Sandberg@ARM.com{ 6539992Snilay@cs.wisc.edu BaseCPU::startup(); 6549461Snilay@cs.wisc.edu for (int tid = 0; tid < numThreads; ++tid) 6559461Snilay@cs.wisc.edu isa[tid]->startup(threadContexts[tid]); 6569461Snilay@cs.wisc.edu 6579427SAndreas.Sandberg@ARM.com fetch.startupStage(); 6589444SAndreas.Sandberg@ARM.com decode.startupStage(); 6599427SAndreas.Sandberg@ARM.com iew.startupStage(); 6609427SAndreas.Sandberg@ARM.com rename.startupStage(); 6619427SAndreas.Sandberg@ARM.com commit.startupStage(); 6622292SN/A} 6632292SN/A 6642292SN/Atemplate <class Impl> 6652292SN/Avoid 6666221Snate@binkert.orgFullO3CPU<Impl>::activateThread(ThreadID tid) 6672875Sksewell@umich.edu{ 6686221Snate@binkert.org list<ThreadID>::iterator isActive = 6695314Sstever@gmail.com std::find(activeThreads.begin(), activeThreads.end(), tid); 6702875Sksewell@umich.edu 6713226Sktlim@umich.edu DPRINTF(O3CPU, "[tid:%i]: Calling activate thread.\n", tid); 6729444SAndreas.Sandberg@ARM.com assert(!switchedOut()); 6733226Sktlim@umich.edu 6742875Sksewell@umich.edu if (isActive == activeThreads.end()) { 6752875Sksewell@umich.edu DPRINTF(O3CPU, "[tid:%i]: Adding to active threads list\n", 6762875Sksewell@umich.edu tid); 6772875Sksewell@umich.edu 6782875Sksewell@umich.edu activeThreads.push_back(tid); 6792875Sksewell@umich.edu } 6802875Sksewell@umich.edu} 6812875Sksewell@umich.edu 6822875Sksewell@umich.edutemplate <class Impl> 6832875Sksewell@umich.eduvoid 6846221Snate@binkert.orgFullO3CPU<Impl>::deactivateThread(ThreadID tid) 6852875Sksewell@umich.edu{ 6862875Sksewell@umich.edu //Remove From Active List, if Active 6876221Snate@binkert.org list<ThreadID>::iterator thread_it = 6885314Sstever@gmail.com std::find(activeThreads.begin(), activeThreads.end(), tid); 6892875Sksewell@umich.edu 6903226Sktlim@umich.edu DPRINTF(O3CPU, "[tid:%i]: Calling deactivate thread.\n", tid); 6919444SAndreas.Sandberg@ARM.com assert(!switchedOut()); 6923226Sktlim@umich.edu 6932875Sksewell@umich.edu if (thread_it != activeThreads.end()) { 6942875Sksewell@umich.edu DPRINTF(O3CPU,"[tid:%i]: Removing from active threads list\n", 6952875Sksewell@umich.edu tid); 6962875Sksewell@umich.edu activeThreads.erase(thread_it); 6972875Sksewell@umich.edu } 69810331Smitch.hayenga@arm.com 69910331Smitch.hayenga@arm.com fetch.deactivateThread(tid); 70010331Smitch.hayenga@arm.com commit.deactivateThread(tid); 7012875Sksewell@umich.edu} 7022875Sksewell@umich.edu 7032875Sksewell@umich.edutemplate <class Impl> 7046221Snate@binkert.orgCounter 7058834Satgutier@umich.eduFullO3CPU<Impl>::totalInsts() const 7066221Snate@binkert.org{ 7076221Snate@binkert.org Counter total(0); 7086221Snate@binkert.org 7096221Snate@binkert.org ThreadID size = thread.size(); 7106221Snate@binkert.org for (ThreadID i = 0; i < size; i++) 7116221Snate@binkert.org total += thread[i]->numInst; 7126221Snate@binkert.org 7136221Snate@binkert.org return total; 7146221Snate@binkert.org} 7156221Snate@binkert.org 7166221Snate@binkert.orgtemplate <class Impl> 7178834Satgutier@umich.eduCounter 7188834Satgutier@umich.eduFullO3CPU<Impl>::totalOps() const 7198834Satgutier@umich.edu{ 7208834Satgutier@umich.edu Counter total(0); 7218834Satgutier@umich.edu 7228834Satgutier@umich.edu ThreadID size = thread.size(); 7238834Satgutier@umich.edu for (ThreadID i = 0; i < size; i++) 7248834Satgutier@umich.edu total += thread[i]->numOp; 7258834Satgutier@umich.edu 7268834Satgutier@umich.edu return total; 7278834Satgutier@umich.edu} 7288834Satgutier@umich.edu 7298834Satgutier@umich.edutemplate <class Impl> 7302875Sksewell@umich.eduvoid 73110407Smitch.hayenga@arm.comFullO3CPU<Impl>::activateContext(ThreadID tid) 7322875Sksewell@umich.edu{ 7339444SAndreas.Sandberg@ARM.com assert(!switchedOut()); 7349444SAndreas.Sandberg@ARM.com 7352875Sksewell@umich.edu // Needs to set each stage to running as well. 73610407Smitch.hayenga@arm.com activateThread(tid); 7372875Sksewell@umich.edu 7389444SAndreas.Sandberg@ARM.com // We don't want to wake the CPU if it is drained. In that case, 7399444SAndreas.Sandberg@ARM.com // we just want to flag the thread as active and schedule the tick 7409444SAndreas.Sandberg@ARM.com // event from drainResume() instead. 74110913Sandreas.sandberg@arm.com if (drainState() == DrainState::Drained) 7429444SAndreas.Sandberg@ARM.com return; 7439444SAndreas.Sandberg@ARM.com 7449158Sandreas.hansson@arm.com // If we are time 0 or if the last activation time is in the past, 7459158Sandreas.hansson@arm.com // schedule the next tick and wake up the fetch unit 7469158Sandreas.hansson@arm.com if (lastActivatedCycle == 0 || lastActivatedCycle < curTick()) { 74710407Smitch.hayenga@arm.com scheduleTickEvent(Cycles(0)); 7482875Sksewell@umich.edu 7492875Sksewell@umich.edu // Be sure to signal that there's some activity so the CPU doesn't 7502875Sksewell@umich.edu // deschedule itself. 7512875Sksewell@umich.edu activityRec.activity(); 7522875Sksewell@umich.edu fetch.wakeFromQuiesce(); 7532875Sksewell@umich.edu 7549180Sandreas.hansson@arm.com Cycles cycles(curCycle() - lastRunningCycle); 7559180Sandreas.hansson@arm.com // @todo: This is an oddity that is only here to match the stats 7569179Sandreas.hansson@arm.com if (cycles != 0) 7579179Sandreas.hansson@arm.com --cycles; 7589179Sandreas.hansson@arm.com quiesceCycles += cycles; 7598627SAli.Saidi@ARM.com 7607823Ssteve.reinhardt@amd.com lastActivatedCycle = curTick(); 7612875Sksewell@umich.edu 7622875Sksewell@umich.edu _status = Running; 76311526Sdavid.guillen@arm.com 76411526Sdavid.guillen@arm.com BaseCPU::activateContext(tid); 7652875Sksewell@umich.edu } 7662875Sksewell@umich.edu} 7672875Sksewell@umich.edu 7682875Sksewell@umich.edutemplate <class Impl> 76910407Smitch.hayenga@arm.comvoid 7706221Snate@binkert.orgFullO3CPU<Impl>::suspendContext(ThreadID tid) 7712875Sksewell@umich.edu{ 7722875Sksewell@umich.edu DPRINTF(O3CPU,"[tid: %i]: Suspending Thread Context.\n", tid); 7739444SAndreas.Sandberg@ARM.com assert(!switchedOut()); 77410408Smitch.hayenga@arm.com 77510408Smitch.hayenga@arm.com deactivateThread(tid); 77610407Smitch.hayenga@arm.com 7773221Sktlim@umich.edu // If this was the last thread then unschedule the tick event. 77810683Salexandru.dutu@amd.com if (activeThreads.size() == 0) { 7792910Sksewell@umich.edu unscheduleTickEvent(); 78010683Salexandru.dutu@amd.com lastRunningCycle = curCycle(); 78110683Salexandru.dutu@amd.com _status = Idle; 78210683Salexandru.dutu@amd.com } 7838627SAli.Saidi@ARM.com 7848627SAli.Saidi@ARM.com DPRINTF(Quiesce, "Suspending Context\n"); 78511526Sdavid.guillen@arm.com 78611526Sdavid.guillen@arm.com BaseCPU::suspendContext(tid); 7872875Sksewell@umich.edu} 7882875Sksewell@umich.edu 7892875Sksewell@umich.edutemplate <class Impl> 7902875Sksewell@umich.eduvoid 7916221Snate@binkert.orgFullO3CPU<Impl>::haltContext(ThreadID tid) 7922875Sksewell@umich.edu{ 7932910Sksewell@umich.edu //For now, this is the same as deallocate 7942910Sksewell@umich.edu DPRINTF(O3CPU,"[tid:%i]: Halt Context called. Deallocating", tid); 7959444SAndreas.Sandberg@ARM.com assert(!switchedOut()); 79610408Smitch.hayenga@arm.com 79710408Smitch.hayenga@arm.com deactivateThread(tid); 79810408Smitch.hayenga@arm.com removeThread(tid); 7992875Sksewell@umich.edu} 8002875Sksewell@umich.edu 8012875Sksewell@umich.edutemplate <class Impl> 8022875Sksewell@umich.eduvoid 8036221Snate@binkert.orgFullO3CPU<Impl>::insertThread(ThreadID tid) 8042292SN/A{ 8052847Sksewell@umich.edu DPRINTF(O3CPU,"[tid:%i] Initializing thread into CPU"); 8062292SN/A // Will change now that the PC and thread state is internal to the CPU 8072683Sktlim@umich.edu // and not in the ThreadContext. 8088793Sgblack@eecs.umich.edu ThreadContext *src_tc; 8098793Sgblack@eecs.umich.edu if (FullSystem) 8108793Sgblack@eecs.umich.edu src_tc = system->threadContexts[tid]; 8118793Sgblack@eecs.umich.edu else 8128793Sgblack@eecs.umich.edu src_tc = tcBase(tid); 8132292SN/A 8142292SN/A //Bind Int Regs to Rename Map 81512104Snathanael.premillieu@arm.com 81612106SRekai.GonzalezAlberquilla@arm.com for (RegId reg_id(IntRegClass, 0); reg_id.index() < TheISA::NumIntRegs; 81712106SRekai.GonzalezAlberquilla@arm.com reg_id.index()++) { 81812105Snathanael.premillieu@arm.com PhysRegIdPtr phys_reg = freeList.getIntReg(); 81912104Snathanael.premillieu@arm.com renameMap[tid].setEntry(reg_id, phys_reg); 8202292SN/A scoreboard.setReg(phys_reg); 8212292SN/A } 8222292SN/A 8232292SN/A //Bind Float Regs to Rename Map 82412106SRekai.GonzalezAlberquilla@arm.com for (RegId reg_id(FloatRegClass, 0); reg_id.index() < TheISA::NumFloatRegs; 82512106SRekai.GonzalezAlberquilla@arm.com reg_id.index()++) { 82612105Snathanael.premillieu@arm.com PhysRegIdPtr phys_reg = freeList.getFloatReg(); 82712104Snathanael.premillieu@arm.com renameMap[tid].setEntry(reg_id, phys_reg); 8282292SN/A scoreboard.setReg(phys_reg); 8292292SN/A } 8302292SN/A 8319920Syasuko.eckert@amd.com //Bind condition-code Regs to Rename Map 83212106SRekai.GonzalezAlberquilla@arm.com for (RegId reg_id(CCRegClass, 0); reg_id.index() < TheISA::NumCCRegs; 83312106SRekai.GonzalezAlberquilla@arm.com reg_id.index()++) { 83412105Snathanael.premillieu@arm.com PhysRegIdPtr phys_reg = freeList.getCCReg(); 83512104Snathanael.premillieu@arm.com renameMap[tid].setEntry(reg_id, phys_reg); 8369920Syasuko.eckert@amd.com scoreboard.setReg(phys_reg); 8379920Syasuko.eckert@amd.com } 8389920Syasuko.eckert@amd.com 8392292SN/A //Copy Thread Data Into RegFile 8402847Sksewell@umich.edu //this->copyFromTC(tid); 8412292SN/A 8422847Sksewell@umich.edu //Set PC/NPC/NNPC 8437720Sgblack@eecs.umich.edu pcState(src_tc->pcState(), tid); 8442292SN/A 8452680Sktlim@umich.edu src_tc->setStatus(ThreadContext::Active); 8462292SN/A 84710407Smitch.hayenga@arm.com activateContext(tid); 8482292SN/A 8492292SN/A //Reset ROB/IQ/LSQ Entries 8502292SN/A commit.rob->resetEntries(); 8512292SN/A iew.resetEntries(); 8522292SN/A} 8532292SN/A 8542292SN/Atemplate <class Impl> 8552292SN/Avoid 8566221Snate@binkert.orgFullO3CPU<Impl>::removeThread(ThreadID tid) 8572292SN/A{ 8582877Sksewell@umich.edu DPRINTF(O3CPU,"[tid:%i] Removing thread context from CPU.\n", tid); 8592847Sksewell@umich.edu 8602847Sksewell@umich.edu // Copy Thread Data From RegFile 8612847Sksewell@umich.edu // If thread is suspended, it might be re-allocated 8625364Sksewell@umich.edu // this->copyToTC(tid); 8635364Sksewell@umich.edu 8645364Sksewell@umich.edu 8655364Sksewell@umich.edu // @todo: 2-27-2008: Fix how we free up rename mappings 8665364Sksewell@umich.edu // here to alleviate the case for double-freeing registers 8675364Sksewell@umich.edu // in SMT workloads. 8682847Sksewell@umich.edu 8692847Sksewell@umich.edu // Unbind Int Regs from Rename Map 87012106SRekai.GonzalezAlberquilla@arm.com for (RegId reg_id(IntRegClass, 0); reg_id.index() < TheISA::NumIntRegs; 87112106SRekai.GonzalezAlberquilla@arm.com reg_id.index()++) { 87212105Snathanael.premillieu@arm.com PhysRegIdPtr phys_reg = renameMap[tid].lookup(reg_id); 8732292SN/A scoreboard.unsetReg(phys_reg); 8742292SN/A freeList.addReg(phys_reg); 8752292SN/A } 8762292SN/A 8772847Sksewell@umich.edu // Unbind Float Regs from Rename Map 87812106SRekai.GonzalezAlberquilla@arm.com for (RegId reg_id(FloatRegClass, 0); reg_id.index() < TheISA::NumFloatRegs; 87912106SRekai.GonzalezAlberquilla@arm.com reg_id.index()++) { 88012105Snathanael.premillieu@arm.com PhysRegIdPtr phys_reg = renameMap[tid].lookup(reg_id); 8812292SN/A scoreboard.unsetReg(phys_reg); 8822292SN/A freeList.addReg(phys_reg); 8832292SN/A } 8842292SN/A 8859920Syasuko.eckert@amd.com // Unbind condition-code Regs from Rename Map 88612106SRekai.GonzalezAlberquilla@arm.com for (RegId reg_id(CCRegClass, 0); reg_id.index() < TheISA::NumCCRegs; 88712106SRekai.GonzalezAlberquilla@arm.com reg_id.index()++) { 88812105Snathanael.premillieu@arm.com PhysRegIdPtr phys_reg = renameMap[tid].lookup(reg_id); 8899920Syasuko.eckert@amd.com scoreboard.unsetReg(phys_reg); 8909920Syasuko.eckert@amd.com freeList.addReg(phys_reg); 8919920Syasuko.eckert@amd.com } 8929920Syasuko.eckert@amd.com 8932847Sksewell@umich.edu // Squash Throughout Pipeline 8948138SAli.Saidi@ARM.com DynInstPtr inst = commit.rob->readHeadInst(tid); 8958138SAli.Saidi@ARM.com InstSeqNum squash_seq_num = inst->seqNum; 8968138SAli.Saidi@ARM.com fetch.squash(0, squash_seq_num, inst, tid); 8972292SN/A decode.squash(tid); 8982935Sksewell@umich.edu rename.squash(squash_seq_num, tid); 8992875Sksewell@umich.edu iew.squash(tid); 9005363Sksewell@umich.edu iew.ldstQueue.squash(squash_seq_num, tid); 9012935Sksewell@umich.edu commit.rob->squash(squash_seq_num, tid); 9022292SN/A 9035362Sksewell@umich.edu 9045362Sksewell@umich.edu assert(iew.instQueue.getCount(tid) == 0); 9052292SN/A assert(iew.ldstQueue.getCount(tid) == 0); 9062292SN/A 9072847Sksewell@umich.edu // Reset ROB/IQ/LSQ Entries 9083229Sktlim@umich.edu 9093229Sktlim@umich.edu // Commented out for now. This should be possible to do by 9103229Sktlim@umich.edu // telling all the pipeline stages to drain first, and then 9113229Sktlim@umich.edu // checking until the drain completes. Once the pipeline is 9123229Sktlim@umich.edu // drained, call resetEntries(). - 10-09-06 ktlim 9133229Sktlim@umich.edu/* 9142292SN/A if (activeThreads.size() >= 1) { 9152292SN/A commit.rob->resetEntries(); 9162292SN/A iew.resetEntries(); 9172292SN/A } 9183229Sktlim@umich.edu*/ 9192292SN/A} 9202292SN/A 9214192Sktlim@umich.edutemplate <class Impl> 9225595Sgblack@eecs.umich.eduFault 9236221Snate@binkert.orgFullO3CPU<Impl>::hwrei(ThreadID tid) 9245702Ssaidi@eecs.umich.edu{ 9255702Ssaidi@eecs.umich.edu#if THE_ISA == ALPHA_ISA 9265702Ssaidi@eecs.umich.edu // Need to clear the lock flag upon returning from an interrupt. 9275702Ssaidi@eecs.umich.edu this->setMiscRegNoEffect(AlphaISA::MISCREG_LOCKFLAG, false, tid); 9285702Ssaidi@eecs.umich.edu 9295702Ssaidi@eecs.umich.edu this->thread[tid]->kernelStats->hwrei(); 9305702Ssaidi@eecs.umich.edu 9315702Ssaidi@eecs.umich.edu // FIXME: XXX check for interrupts? XXX 9325702Ssaidi@eecs.umich.edu#endif 9335702Ssaidi@eecs.umich.edu return NoFault; 9345702Ssaidi@eecs.umich.edu} 9355702Ssaidi@eecs.umich.edu 9365702Ssaidi@eecs.umich.edutemplate <class Impl> 9375702Ssaidi@eecs.umich.edubool 9386221Snate@binkert.orgFullO3CPU<Impl>::simPalCheck(int palFunc, ThreadID tid) 9395702Ssaidi@eecs.umich.edu{ 9405702Ssaidi@eecs.umich.edu#if THE_ISA == ALPHA_ISA 9415702Ssaidi@eecs.umich.edu if (this->thread[tid]->kernelStats) 9425702Ssaidi@eecs.umich.edu this->thread[tid]->kernelStats->callpal(palFunc, 9435702Ssaidi@eecs.umich.edu this->threadContexts[tid]); 9445702Ssaidi@eecs.umich.edu 9455702Ssaidi@eecs.umich.edu switch (palFunc) { 9465702Ssaidi@eecs.umich.edu case PAL::halt: 9475702Ssaidi@eecs.umich.edu halt(); 9485702Ssaidi@eecs.umich.edu if (--System::numSystemsRunning == 0) 9495702Ssaidi@eecs.umich.edu exitSimLoop("all cpus halted"); 9505702Ssaidi@eecs.umich.edu break; 9515702Ssaidi@eecs.umich.edu 9525702Ssaidi@eecs.umich.edu case PAL::bpt: 9535702Ssaidi@eecs.umich.edu case PAL::bugchk: 9545702Ssaidi@eecs.umich.edu if (this->system->breakpoint()) 9555702Ssaidi@eecs.umich.edu return false; 9565702Ssaidi@eecs.umich.edu break; 9575702Ssaidi@eecs.umich.edu } 9585702Ssaidi@eecs.umich.edu#endif 9595702Ssaidi@eecs.umich.edu return true; 9605702Ssaidi@eecs.umich.edu} 9615702Ssaidi@eecs.umich.edu 9625702Ssaidi@eecs.umich.edutemplate <class Impl> 9635702Ssaidi@eecs.umich.eduFault 9645595Sgblack@eecs.umich.eduFullO3CPU<Impl>::getInterrupts() 9655595Sgblack@eecs.umich.edu{ 9665595Sgblack@eecs.umich.edu // Check if there are any outstanding interrupts 96711150Smitch.hayenga@arm.com return this->interrupts[0]->getInterrupt(this->threadContexts[0]); 9685595Sgblack@eecs.umich.edu} 9695595Sgblack@eecs.umich.edu 9705595Sgblack@eecs.umich.edutemplate <class Impl> 9715595Sgblack@eecs.umich.eduvoid 97210379Sandreas.hansson@arm.comFullO3CPU<Impl>::processInterrupts(const Fault &interrupt) 9735595Sgblack@eecs.umich.edu{ 9745595Sgblack@eecs.umich.edu // Check for interrupts here. For now can copy the code that 9755595Sgblack@eecs.umich.edu // exists within isa_fullsys_traits.hh. Also assume that thread 0 9765595Sgblack@eecs.umich.edu // is the one that handles the interrupts. 9775595Sgblack@eecs.umich.edu // @todo: Possibly consolidate the interrupt checking code. 9785595Sgblack@eecs.umich.edu // @todo: Allow other threads to handle interrupts. 9795595Sgblack@eecs.umich.edu 9805595Sgblack@eecs.umich.edu assert(interrupt != NoFault); 98111150Smitch.hayenga@arm.com this->interrupts[0]->updateIntrInfo(this->threadContexts[0]); 9825595Sgblack@eecs.umich.edu 9835595Sgblack@eecs.umich.edu DPRINTF(O3CPU, "Interrupt %s being handled\n", interrupt->name()); 98410417Sandreas.hansson@arm.com this->trap(interrupt, 0, nullptr); 9855595Sgblack@eecs.umich.edu} 9865595Sgblack@eecs.umich.edu 9871060SN/Atemplate <class Impl> 9882852Sktlim@umich.eduvoid 98910417Sandreas.hansson@arm.comFullO3CPU<Impl>::trap(const Fault &fault, ThreadID tid, 99010417Sandreas.hansson@arm.com const StaticInstPtr &inst) 9915595Sgblack@eecs.umich.edu{ 9925595Sgblack@eecs.umich.edu // Pass the thread's TC into the invoke method. 9937684Sgblack@eecs.umich.edu fault->invoke(this->threadContexts[tid], inst); 9945595Sgblack@eecs.umich.edu} 9955595Sgblack@eecs.umich.edu 9965595Sgblack@eecs.umich.edutemplate <class Impl> 9975595Sgblack@eecs.umich.eduvoid 99811877Sbrandon.potter@amd.comFullO3CPU<Impl>::syscall(int64_t callnum, ThreadID tid, Fault *fault) 9995595Sgblack@eecs.umich.edu{ 10005595Sgblack@eecs.umich.edu DPRINTF(O3CPU, "[tid:%i] Executing syscall().\n\n", tid); 10015595Sgblack@eecs.umich.edu 10025595Sgblack@eecs.umich.edu DPRINTF(Activity,"Activity: syscall() called.\n"); 10035595Sgblack@eecs.umich.edu 10045595Sgblack@eecs.umich.edu // Temporarily increase this by one to account for the syscall 10055595Sgblack@eecs.umich.edu // instruction. 10065595Sgblack@eecs.umich.edu ++(this->thread[tid]->funcExeInst); 10075595Sgblack@eecs.umich.edu 10085595Sgblack@eecs.umich.edu // Execute the actual syscall. 100911877Sbrandon.potter@amd.com this->thread[tid]->syscall(callnum, fault); 10105595Sgblack@eecs.umich.edu 10115595Sgblack@eecs.umich.edu // Decrease funcExeInst by one as the normal commit will handle 10125595Sgblack@eecs.umich.edu // incrementing it. 10135595Sgblack@eecs.umich.edu --(this->thread[tid]->funcExeInst); 10145595Sgblack@eecs.umich.edu} 10155595Sgblack@eecs.umich.edu 10165595Sgblack@eecs.umich.edutemplate <class Impl> 10175595Sgblack@eecs.umich.eduvoid 101810905Sandreas.sandberg@arm.comFullO3CPU<Impl>::serializeThread(CheckpointOut &cp, ThreadID tid) const 10192864Sktlim@umich.edu{ 102010905Sandreas.sandberg@arm.com thread[tid]->serialize(cp); 10212864Sktlim@umich.edu} 10222864Sktlim@umich.edu 10232864Sktlim@umich.edutemplate <class Impl> 10242864Sktlim@umich.eduvoid 102510905Sandreas.sandberg@arm.comFullO3CPU<Impl>::unserializeThread(CheckpointIn &cp, ThreadID tid) 10262864Sktlim@umich.edu{ 102710905Sandreas.sandberg@arm.com thread[tid]->unserialize(cp); 10282864Sktlim@umich.edu} 10292864Sktlim@umich.edu 10302864Sktlim@umich.edutemplate <class Impl> 103110913Sandreas.sandberg@arm.comDrainState 103210913Sandreas.sandberg@arm.comFullO3CPU<Impl>::drain() 10331060SN/A{ 10349444SAndreas.Sandberg@ARM.com // If the CPU isn't doing anything, then return immediately. 103510913Sandreas.sandberg@arm.com if (switchedOut()) 103610913Sandreas.sandberg@arm.com return DrainState::Drained; 10373512Sktlim@umich.edu 10389444SAndreas.Sandberg@ARM.com DPRINTF(Drain, "Draining...\n"); 10393512Sktlim@umich.edu 10409444SAndreas.Sandberg@ARM.com // We only need to signal a drain to the commit stage as this 10419444SAndreas.Sandberg@ARM.com // initiates squashing controls the draining. Once the commit 10429444SAndreas.Sandberg@ARM.com // stage commits an instruction where it is safe to stop, it'll 10439444SAndreas.Sandberg@ARM.com // squash the rest of the instructions in the pipeline and force 10449444SAndreas.Sandberg@ARM.com // the fetch stage to stall. The pipeline will be drained once all 10459444SAndreas.Sandberg@ARM.com // in-flight instructions have retired. 10462843Sktlim@umich.edu commit.drain(); 10472325SN/A 10482325SN/A // Wake the CPU and record activity so everything can drain out if 10492863Sktlim@umich.edu // the CPU was not able to immediately drain. 10509444SAndreas.Sandberg@ARM.com if (!isDrained()) { 10512863Sktlim@umich.edu wakeCPU(); 10522863Sktlim@umich.edu activityRec.activity(); 10532852Sktlim@umich.edu 10549152Satgutier@umich.edu DPRINTF(Drain, "CPU not drained\n"); 10559152Satgutier@umich.edu 105610913Sandreas.sandberg@arm.com return DrainState::Draining; 10572863Sktlim@umich.edu } else { 10589444SAndreas.Sandberg@ARM.com DPRINTF(Drain, "CPU is already drained\n"); 10599444SAndreas.Sandberg@ARM.com if (tickEvent.scheduled()) 10609444SAndreas.Sandberg@ARM.com deschedule(tickEvent); 10619444SAndreas.Sandberg@ARM.com 10629444SAndreas.Sandberg@ARM.com // Flush out any old data from the time buffers. In 10639444SAndreas.Sandberg@ARM.com // particular, there might be some data in flight from the 10649444SAndreas.Sandberg@ARM.com // fetch stage that isn't visible in any of the CPU buffers we 10659444SAndreas.Sandberg@ARM.com // test in isDrained(). 10669444SAndreas.Sandberg@ARM.com for (int i = 0; i < timeBuffer.getSize(); ++i) { 10679444SAndreas.Sandberg@ARM.com timeBuffer.advance(); 10689444SAndreas.Sandberg@ARM.com fetchQueue.advance(); 10699444SAndreas.Sandberg@ARM.com decodeQueue.advance(); 10709444SAndreas.Sandberg@ARM.com renameQueue.advance(); 10719444SAndreas.Sandberg@ARM.com iewQueue.advance(); 10729444SAndreas.Sandberg@ARM.com } 10739444SAndreas.Sandberg@ARM.com 10749444SAndreas.Sandberg@ARM.com drainSanityCheck(); 107510913Sandreas.sandberg@arm.com return DrainState::Drained; 10762863Sktlim@umich.edu } 10772316SN/A} 10782310SN/A 10792316SN/Atemplate <class Impl> 10809444SAndreas.Sandberg@ARM.combool 10819444SAndreas.Sandberg@ARM.comFullO3CPU<Impl>::tryDrain() 10829444SAndreas.Sandberg@ARM.com{ 108310913Sandreas.sandberg@arm.com if (drainState() != DrainState::Draining || !isDrained()) 10849444SAndreas.Sandberg@ARM.com return false; 10859444SAndreas.Sandberg@ARM.com 10869444SAndreas.Sandberg@ARM.com if (tickEvent.scheduled()) 10879444SAndreas.Sandberg@ARM.com deschedule(tickEvent); 10889444SAndreas.Sandberg@ARM.com 10899444SAndreas.Sandberg@ARM.com DPRINTF(Drain, "CPU done draining, processing drain event\n"); 109010913Sandreas.sandberg@arm.com signalDrainDone(); 10919444SAndreas.Sandberg@ARM.com 10929444SAndreas.Sandberg@ARM.com return true; 10939444SAndreas.Sandberg@ARM.com} 10949444SAndreas.Sandberg@ARM.com 10959444SAndreas.Sandberg@ARM.comtemplate <class Impl> 10969444SAndreas.Sandberg@ARM.comvoid 10979444SAndreas.Sandberg@ARM.comFullO3CPU<Impl>::drainSanityCheck() const 10989444SAndreas.Sandberg@ARM.com{ 10999444SAndreas.Sandberg@ARM.com assert(isDrained()); 11009444SAndreas.Sandberg@ARM.com fetch.drainSanityCheck(); 11019444SAndreas.Sandberg@ARM.com decode.drainSanityCheck(); 11029444SAndreas.Sandberg@ARM.com rename.drainSanityCheck(); 11039444SAndreas.Sandberg@ARM.com iew.drainSanityCheck(); 11049444SAndreas.Sandberg@ARM.com commit.drainSanityCheck(); 11059444SAndreas.Sandberg@ARM.com} 11069444SAndreas.Sandberg@ARM.com 11079444SAndreas.Sandberg@ARM.comtemplate <class Impl> 11089444SAndreas.Sandberg@ARM.combool 11099444SAndreas.Sandberg@ARM.comFullO3CPU<Impl>::isDrained() const 11109444SAndreas.Sandberg@ARM.com{ 11119444SAndreas.Sandberg@ARM.com bool drained(true); 11129444SAndreas.Sandberg@ARM.com 11139444SAndreas.Sandberg@ARM.com if (!instList.empty() || !removeList.empty()) { 11149444SAndreas.Sandberg@ARM.com DPRINTF(Drain, "Main CPU structures not drained.\n"); 11159444SAndreas.Sandberg@ARM.com drained = false; 11169444SAndreas.Sandberg@ARM.com } 11179444SAndreas.Sandberg@ARM.com 11189444SAndreas.Sandberg@ARM.com if (!fetch.isDrained()) { 11199444SAndreas.Sandberg@ARM.com DPRINTF(Drain, "Fetch not drained.\n"); 11209444SAndreas.Sandberg@ARM.com drained = false; 11219444SAndreas.Sandberg@ARM.com } 11229444SAndreas.Sandberg@ARM.com 11239444SAndreas.Sandberg@ARM.com if (!decode.isDrained()) { 11249444SAndreas.Sandberg@ARM.com DPRINTF(Drain, "Decode not drained.\n"); 11259444SAndreas.Sandberg@ARM.com drained = false; 11269444SAndreas.Sandberg@ARM.com } 11279444SAndreas.Sandberg@ARM.com 11289444SAndreas.Sandberg@ARM.com if (!rename.isDrained()) { 11299444SAndreas.Sandberg@ARM.com DPRINTF(Drain, "Rename not drained.\n"); 11309444SAndreas.Sandberg@ARM.com drained = false; 11319444SAndreas.Sandberg@ARM.com } 11329444SAndreas.Sandberg@ARM.com 11339444SAndreas.Sandberg@ARM.com if (!iew.isDrained()) { 11349444SAndreas.Sandberg@ARM.com DPRINTF(Drain, "IEW not drained.\n"); 11359444SAndreas.Sandberg@ARM.com drained = false; 11369444SAndreas.Sandberg@ARM.com } 11379444SAndreas.Sandberg@ARM.com 11389444SAndreas.Sandberg@ARM.com if (!commit.isDrained()) { 11399444SAndreas.Sandberg@ARM.com DPRINTF(Drain, "Commit not drained.\n"); 11409444SAndreas.Sandberg@ARM.com drained = false; 11419444SAndreas.Sandberg@ARM.com } 11429444SAndreas.Sandberg@ARM.com 11439444SAndreas.Sandberg@ARM.com return drained; 11449444SAndreas.Sandberg@ARM.com} 11459444SAndreas.Sandberg@ARM.com 11469444SAndreas.Sandberg@ARM.comtemplate <class Impl> 11479444SAndreas.Sandberg@ARM.comvoid 11489444SAndreas.Sandberg@ARM.comFullO3CPU<Impl>::commitDrained(ThreadID tid) 11499444SAndreas.Sandberg@ARM.com{ 11509444SAndreas.Sandberg@ARM.com fetch.drainStall(tid); 11519444SAndreas.Sandberg@ARM.com} 11529444SAndreas.Sandberg@ARM.com 11539444SAndreas.Sandberg@ARM.comtemplate <class Impl> 11542316SN/Avoid 11559342SAndreas.Sandberg@arm.comFullO3CPU<Impl>::drainResume() 11562316SN/A{ 11579444SAndreas.Sandberg@ARM.com if (switchedOut()) 11589444SAndreas.Sandberg@ARM.com return; 11592316SN/A 11609444SAndreas.Sandberg@ARM.com DPRINTF(Drain, "Resuming...\n"); 11619523SAndreas.Sandberg@ARM.com verifyMemoryMode(); 11623319Shsul@eecs.umich.edu 11639444SAndreas.Sandberg@ARM.com fetch.drainResume(); 11649444SAndreas.Sandberg@ARM.com commit.drainResume(); 11652316SN/A 11669444SAndreas.Sandberg@ARM.com _status = Idle; 11679444SAndreas.Sandberg@ARM.com for (ThreadID i = 0; i < thread.size(); i++) { 11689444SAndreas.Sandberg@ARM.com if (thread[i]->status() == ThreadContext::Active) { 11699444SAndreas.Sandberg@ARM.com DPRINTF(Drain, "Activating thread: %i\n", i); 11709444SAndreas.Sandberg@ARM.com activateThread(i); 11719444SAndreas.Sandberg@ARM.com _status = Running; 11722863Sktlim@umich.edu } 11732310SN/A } 11749444SAndreas.Sandberg@ARM.com 11759444SAndreas.Sandberg@ARM.com assert(!tickEvent.scheduled()); 11769444SAndreas.Sandberg@ARM.com if (_status == Running) 11779444SAndreas.Sandberg@ARM.com schedule(tickEvent, nextCycle()); 11782843Sktlim@umich.edu} 11792843Sktlim@umich.edu 11802843Sktlim@umich.edutemplate <class Impl> 11812843Sktlim@umich.eduvoid 11822843Sktlim@umich.eduFullO3CPU<Impl>::switchOut() 11832843Sktlim@umich.edu{ 11849444SAndreas.Sandberg@ARM.com DPRINTF(O3CPU, "Switching out\n"); 11859429SAndreas.Sandberg@ARM.com BaseCPU::switchOut(); 11869429SAndreas.Sandberg@ARM.com 11879444SAndreas.Sandberg@ARM.com activityRec.reset(); 11882843Sktlim@umich.edu 11892843Sktlim@umich.edu _status = SwitchedOut; 11908887Sgeoffrey.blake@arm.com 11912843Sktlim@umich.edu if (checker) 11922843Sktlim@umich.edu checker->switchOut(); 11931060SN/A} 11941060SN/A 11951060SN/Atemplate <class Impl> 11961060SN/Avoid 11971755SN/AFullO3CPU<Impl>::takeOverFrom(BaseCPU *oldCPU) 11981060SN/A{ 11998737Skoansin.tan@gmail.com BaseCPU::takeOverFrom(oldCPU); 12001060SN/A 12012307SN/A fetch.takeOverFrom(); 12022307SN/A decode.takeOverFrom(); 12032307SN/A rename.takeOverFrom(); 12042307SN/A iew.takeOverFrom(); 12052307SN/A commit.takeOverFrom(); 12062307SN/A 12079444SAndreas.Sandberg@ARM.com assert(!tickEvent.scheduled()); 12081060SN/A 12099152Satgutier@umich.edu FullO3CPU<Impl> *oldO3CPU = dynamic_cast<FullO3CPU<Impl>*>(oldCPU); 12109152Satgutier@umich.edu if (oldO3CPU) 12119152Satgutier@umich.edu globalSeqNum = oldO3CPU->globalSeqNum; 12129152Satgutier@umich.edu 12139179Sandreas.hansson@arm.com lastRunningCycle = curCycle(); 12149444SAndreas.Sandberg@ARM.com _status = Idle; 12151060SN/A} 12161060SN/A 12171060SN/Atemplate <class Impl> 12189523SAndreas.Sandberg@ARM.comvoid 12199523SAndreas.Sandberg@ARM.comFullO3CPU<Impl>::verifyMemoryMode() const 12209523SAndreas.Sandberg@ARM.com{ 12219524SAndreas.Sandberg@ARM.com if (!system->isTimingMode()) { 12229523SAndreas.Sandberg@ARM.com fatal("The O3 CPU requires the memory system to be in " 12239523SAndreas.Sandberg@ARM.com "'timing' mode.\n"); 12249523SAndreas.Sandberg@ARM.com } 12259523SAndreas.Sandberg@ARM.com} 12269523SAndreas.Sandberg@ARM.com 12279523SAndreas.Sandberg@ARM.comtemplate <class Impl> 12285595Sgblack@eecs.umich.eduTheISA::MiscReg 122910698Sandreas.hansson@arm.comFullO3CPU<Impl>::readMiscRegNoEffect(int misc_reg, ThreadID tid) const 12305595Sgblack@eecs.umich.edu{ 12319384SAndreas.Sandberg@arm.com return this->isa[tid]->readMiscRegNoEffect(misc_reg); 12325595Sgblack@eecs.umich.edu} 12335595Sgblack@eecs.umich.edu 12345595Sgblack@eecs.umich.edutemplate <class Impl> 12355595Sgblack@eecs.umich.eduTheISA::MiscReg 12366221Snate@binkert.orgFullO3CPU<Impl>::readMiscReg(int misc_reg, ThreadID tid) 12375595Sgblack@eecs.umich.edu{ 12387897Shestness@cs.utexas.edu miscRegfileReads++; 12399384SAndreas.Sandberg@arm.com return this->isa[tid]->readMiscReg(misc_reg, tcBase(tid)); 12405595Sgblack@eecs.umich.edu} 12415595Sgblack@eecs.umich.edu 12425595Sgblack@eecs.umich.edutemplate <class Impl> 12435595Sgblack@eecs.umich.eduvoid 12445595Sgblack@eecs.umich.eduFullO3CPU<Impl>::setMiscRegNoEffect(int misc_reg, 12456221Snate@binkert.org const TheISA::MiscReg &val, ThreadID tid) 12465595Sgblack@eecs.umich.edu{ 12479384SAndreas.Sandberg@arm.com this->isa[tid]->setMiscRegNoEffect(misc_reg, val); 12485595Sgblack@eecs.umich.edu} 12495595Sgblack@eecs.umich.edu 12505595Sgblack@eecs.umich.edutemplate <class Impl> 12515595Sgblack@eecs.umich.eduvoid 12525595Sgblack@eecs.umich.eduFullO3CPU<Impl>::setMiscReg(int misc_reg, 12536221Snate@binkert.org const TheISA::MiscReg &val, ThreadID tid) 12545595Sgblack@eecs.umich.edu{ 12557897Shestness@cs.utexas.edu miscRegfileWrites++; 12569384SAndreas.Sandberg@arm.com this->isa[tid]->setMiscReg(misc_reg, val, tcBase(tid)); 12575595Sgblack@eecs.umich.edu} 12585595Sgblack@eecs.umich.edu 12595595Sgblack@eecs.umich.edutemplate <class Impl> 12601060SN/Auint64_t 126112105Snathanael.premillieu@arm.comFullO3CPU<Impl>::readIntReg(PhysRegIdPtr phys_reg) 12621060SN/A{ 12637897Shestness@cs.utexas.edu intRegfileReads++; 126412105Snathanael.premillieu@arm.com return regFile.readIntReg(phys_reg); 12651060SN/A} 12661060SN/A 12671060SN/Atemplate <class Impl> 12682455SN/AFloatReg 126912105Snathanael.premillieu@arm.comFullO3CPU<Impl>::readFloatReg(PhysRegIdPtr phys_reg) 12701060SN/A{ 12717897Shestness@cs.utexas.edu fpRegfileReads++; 127212105Snathanael.premillieu@arm.com return regFile.readFloatReg(phys_reg); 12731060SN/A} 12741060SN/A 12751060SN/Atemplate <class Impl> 12762455SN/AFloatRegBits 127712105Snathanael.premillieu@arm.comFullO3CPU<Impl>::readFloatRegBits(PhysRegIdPtr phys_reg) 12782455SN/A{ 12797897Shestness@cs.utexas.edu fpRegfileReads++; 128012105Snathanael.premillieu@arm.com return regFile.readFloatRegBits(phys_reg); 12811060SN/A} 12821060SN/A 12831060SN/Atemplate <class Impl> 128412109SRekai.GonzalezAlberquilla@arm.comauto 128512109SRekai.GonzalezAlberquilla@arm.comFullO3CPU<Impl>::readVecReg(PhysRegIdPtr phys_reg) const 128612109SRekai.GonzalezAlberquilla@arm.com -> const VecRegContainer& 128712109SRekai.GonzalezAlberquilla@arm.com{ 128812109SRekai.GonzalezAlberquilla@arm.com vecRegfileReads++; 128912109SRekai.GonzalezAlberquilla@arm.com return regFile.readVecReg(phys_reg); 129012109SRekai.GonzalezAlberquilla@arm.com} 129112109SRekai.GonzalezAlberquilla@arm.com 129212109SRekai.GonzalezAlberquilla@arm.comtemplate <class Impl> 129312109SRekai.GonzalezAlberquilla@arm.comauto 129412109SRekai.GonzalezAlberquilla@arm.comFullO3CPU<Impl>::getWritableVecReg(PhysRegIdPtr phys_reg) 129512109SRekai.GonzalezAlberquilla@arm.com -> VecRegContainer& 129612109SRekai.GonzalezAlberquilla@arm.com{ 129712109SRekai.GonzalezAlberquilla@arm.com vecRegfileWrites++; 129812109SRekai.GonzalezAlberquilla@arm.com return regFile.getWritableVecReg(phys_reg); 129912109SRekai.GonzalezAlberquilla@arm.com} 130012109SRekai.GonzalezAlberquilla@arm.com 130112109SRekai.GonzalezAlberquilla@arm.comtemplate <class Impl> 130212109SRekai.GonzalezAlberquilla@arm.comauto 130312109SRekai.GonzalezAlberquilla@arm.comFullO3CPU<Impl>::readVecElem(PhysRegIdPtr phys_reg) const -> const VecElem& 130412109SRekai.GonzalezAlberquilla@arm.com{ 130512109SRekai.GonzalezAlberquilla@arm.com vecRegfileReads++; 130612109SRekai.GonzalezAlberquilla@arm.com return regFile.readVecElem(phys_reg); 130712109SRekai.GonzalezAlberquilla@arm.com} 130812109SRekai.GonzalezAlberquilla@arm.com 130912109SRekai.GonzalezAlberquilla@arm.comtemplate <class Impl> 13109920Syasuko.eckert@amd.comCCReg 131112105Snathanael.premillieu@arm.comFullO3CPU<Impl>::readCCReg(PhysRegIdPtr phys_reg) 13129920Syasuko.eckert@amd.com{ 13139920Syasuko.eckert@amd.com ccRegfileReads++; 131412105Snathanael.premillieu@arm.com return regFile.readCCReg(phys_reg); 13159920Syasuko.eckert@amd.com} 13169920Syasuko.eckert@amd.com 13179920Syasuko.eckert@amd.comtemplate <class Impl> 13181060SN/Avoid 131912105Snathanael.premillieu@arm.comFullO3CPU<Impl>::setIntReg(PhysRegIdPtr phys_reg, uint64_t val) 13201060SN/A{ 13217897Shestness@cs.utexas.edu intRegfileWrites++; 132212105Snathanael.premillieu@arm.com regFile.setIntReg(phys_reg, val); 13231060SN/A} 13241060SN/A 13251060SN/Atemplate <class Impl> 13261060SN/Avoid 132712105Snathanael.premillieu@arm.comFullO3CPU<Impl>::setFloatReg(PhysRegIdPtr phys_reg, FloatReg val) 13281060SN/A{ 13297897Shestness@cs.utexas.edu fpRegfileWrites++; 133012105Snathanael.premillieu@arm.com regFile.setFloatReg(phys_reg, val); 13311060SN/A} 13321060SN/A 13331060SN/Atemplate <class Impl> 13341060SN/Avoid 133512105Snathanael.premillieu@arm.comFullO3CPU<Impl>::setFloatRegBits(PhysRegIdPtr phys_reg, FloatRegBits val) 13362455SN/A{ 13377897Shestness@cs.utexas.edu fpRegfileWrites++; 133812105Snathanael.premillieu@arm.com regFile.setFloatRegBits(phys_reg, val); 13391060SN/A} 13401060SN/A 13411060SN/Atemplate <class Impl> 13429920Syasuko.eckert@amd.comvoid 134312109SRekai.GonzalezAlberquilla@arm.comFullO3CPU<Impl>::setVecReg(PhysRegIdPtr phys_reg, const VecRegContainer& val) 134412109SRekai.GonzalezAlberquilla@arm.com{ 134512109SRekai.GonzalezAlberquilla@arm.com vecRegfileWrites++; 134612109SRekai.GonzalezAlberquilla@arm.com regFile.setVecReg(phys_reg, val); 134712109SRekai.GonzalezAlberquilla@arm.com} 134812109SRekai.GonzalezAlberquilla@arm.com 134912109SRekai.GonzalezAlberquilla@arm.comtemplate <class Impl> 135012109SRekai.GonzalezAlberquilla@arm.comvoid 135112109SRekai.GonzalezAlberquilla@arm.comFullO3CPU<Impl>::setVecElem(PhysRegIdPtr phys_reg, const VecElem& val) 135212109SRekai.GonzalezAlberquilla@arm.com{ 135312109SRekai.GonzalezAlberquilla@arm.com vecRegfileWrites++; 135412109SRekai.GonzalezAlberquilla@arm.com regFile.setVecElem(phys_reg, val); 135512109SRekai.GonzalezAlberquilla@arm.com} 135612109SRekai.GonzalezAlberquilla@arm.com 135712109SRekai.GonzalezAlberquilla@arm.comtemplate <class Impl> 135812109SRekai.GonzalezAlberquilla@arm.comvoid 135912105Snathanael.premillieu@arm.comFullO3CPU<Impl>::setCCReg(PhysRegIdPtr phys_reg, CCReg val) 13609920Syasuko.eckert@amd.com{ 13619920Syasuko.eckert@amd.com ccRegfileWrites++; 136212105Snathanael.premillieu@arm.com regFile.setCCReg(phys_reg, val); 13639920Syasuko.eckert@amd.com} 13649920Syasuko.eckert@amd.com 13659920Syasuko.eckert@amd.comtemplate <class Impl> 13661060SN/Auint64_t 13676221Snate@binkert.orgFullO3CPU<Impl>::readArchIntReg(int reg_idx, ThreadID tid) 13681060SN/A{ 13697897Shestness@cs.utexas.edu intRegfileReads++; 137012106SRekai.GonzalezAlberquilla@arm.com PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup( 137112106SRekai.GonzalezAlberquilla@arm.com RegId(IntRegClass, reg_idx)); 13722292SN/A 13732292SN/A return regFile.readIntReg(phys_reg); 13742292SN/A} 13752292SN/A 13762292SN/Atemplate <class Impl> 13772292SN/Afloat 13786314Sgblack@eecs.umich.eduFullO3CPU<Impl>::readArchFloatReg(int reg_idx, ThreadID tid) 13792292SN/A{ 13807897Shestness@cs.utexas.edu fpRegfileReads++; 138112106SRekai.GonzalezAlberquilla@arm.com PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup( 138212106SRekai.GonzalezAlberquilla@arm.com RegId(FloatRegClass, reg_idx)); 13832292SN/A 13842669Sktlim@umich.edu return regFile.readFloatReg(phys_reg); 13852292SN/A} 13862292SN/A 13872292SN/Atemplate <class Impl> 13882292SN/Auint64_t 13896221Snate@binkert.orgFullO3CPU<Impl>::readArchFloatRegInt(int reg_idx, ThreadID tid) 13902292SN/A{ 13917897Shestness@cs.utexas.edu fpRegfileReads++; 139212106SRekai.GonzalezAlberquilla@arm.com PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup( 139312106SRekai.GonzalezAlberquilla@arm.com RegId(FloatRegClass, reg_idx)); 13942292SN/A 13952669Sktlim@umich.edu return regFile.readFloatRegBits(phys_reg); 13961060SN/A} 13971060SN/A 13981060SN/Atemplate <class Impl> 139912109SRekai.GonzalezAlberquilla@arm.comauto 140012109SRekai.GonzalezAlberquilla@arm.comFullO3CPU<Impl>::readArchVecReg(int reg_idx, ThreadID tid) const 140112109SRekai.GonzalezAlberquilla@arm.com -> const VecRegContainer& 140212109SRekai.GonzalezAlberquilla@arm.com{ 140312109SRekai.GonzalezAlberquilla@arm.com PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup( 140412109SRekai.GonzalezAlberquilla@arm.com RegId(VecRegClass, reg_idx)); 140512109SRekai.GonzalezAlberquilla@arm.com return readVecReg(phys_reg); 140612109SRekai.GonzalezAlberquilla@arm.com} 140712109SRekai.GonzalezAlberquilla@arm.com 140812109SRekai.GonzalezAlberquilla@arm.comtemplate <class Impl> 140912109SRekai.GonzalezAlberquilla@arm.comauto 141012109SRekai.GonzalezAlberquilla@arm.comFullO3CPU<Impl>::getWritableArchVecReg(int reg_idx, ThreadID tid) 141112109SRekai.GonzalezAlberquilla@arm.com -> VecRegContainer& 141212109SRekai.GonzalezAlberquilla@arm.com{ 141312109SRekai.GonzalezAlberquilla@arm.com PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup( 141412109SRekai.GonzalezAlberquilla@arm.com RegId(VecRegClass, reg_idx)); 141512109SRekai.GonzalezAlberquilla@arm.com return getWritableVecReg(phys_reg); 141612109SRekai.GonzalezAlberquilla@arm.com} 141712109SRekai.GonzalezAlberquilla@arm.com 141812109SRekai.GonzalezAlberquilla@arm.comtemplate <class Impl> 141912109SRekai.GonzalezAlberquilla@arm.comauto 142012109SRekai.GonzalezAlberquilla@arm.comFullO3CPU<Impl>::readArchVecElem(const RegIndex& reg_idx, const ElemIndex& ldx, 142112109SRekai.GonzalezAlberquilla@arm.com ThreadID tid) const -> const VecElem& 142212109SRekai.GonzalezAlberquilla@arm.com{ 142312109SRekai.GonzalezAlberquilla@arm.com PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup( 142412109SRekai.GonzalezAlberquilla@arm.com RegId(VecRegClass, reg_idx, ldx)); 142512109SRekai.GonzalezAlberquilla@arm.com return readVecElem(phys_reg); 142612109SRekai.GonzalezAlberquilla@arm.com} 142712109SRekai.GonzalezAlberquilla@arm.com 142812109SRekai.GonzalezAlberquilla@arm.comtemplate <class Impl> 14299920Syasuko.eckert@amd.comCCReg 14309920Syasuko.eckert@amd.comFullO3CPU<Impl>::readArchCCReg(int reg_idx, ThreadID tid) 14319920Syasuko.eckert@amd.com{ 14329920Syasuko.eckert@amd.com ccRegfileReads++; 143312106SRekai.GonzalezAlberquilla@arm.com PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup( 143412106SRekai.GonzalezAlberquilla@arm.com RegId(CCRegClass, reg_idx)); 14359920Syasuko.eckert@amd.com 14369920Syasuko.eckert@amd.com return regFile.readCCReg(phys_reg); 14379920Syasuko.eckert@amd.com} 14389920Syasuko.eckert@amd.com 14399920Syasuko.eckert@amd.comtemplate <class Impl> 14401060SN/Avoid 14416221Snate@binkert.orgFullO3CPU<Impl>::setArchIntReg(int reg_idx, uint64_t val, ThreadID tid) 14421060SN/A{ 14437897Shestness@cs.utexas.edu intRegfileWrites++; 144412106SRekai.GonzalezAlberquilla@arm.com PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup( 144512106SRekai.GonzalezAlberquilla@arm.com RegId(IntRegClass, reg_idx)); 14462292SN/A 14472292SN/A regFile.setIntReg(phys_reg, val); 14481060SN/A} 14491060SN/A 14501060SN/Atemplate <class Impl> 14511060SN/Avoid 14526314Sgblack@eecs.umich.eduFullO3CPU<Impl>::setArchFloatReg(int reg_idx, float val, ThreadID tid) 14531060SN/A{ 14547897Shestness@cs.utexas.edu fpRegfileWrites++; 145512106SRekai.GonzalezAlberquilla@arm.com PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup( 145612106SRekai.GonzalezAlberquilla@arm.com RegId(FloatRegClass, reg_idx)); 14572292SN/A 14582669Sktlim@umich.edu regFile.setFloatReg(phys_reg, val); 14591060SN/A} 14601060SN/A 14611060SN/Atemplate <class Impl> 14621060SN/Avoid 14636221Snate@binkert.orgFullO3CPU<Impl>::setArchFloatRegInt(int reg_idx, uint64_t val, ThreadID tid) 14641060SN/A{ 14657897Shestness@cs.utexas.edu fpRegfileWrites++; 146612106SRekai.GonzalezAlberquilla@arm.com PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup( 146712106SRekai.GonzalezAlberquilla@arm.com RegId(FloatRegClass, reg_idx)); 14681060SN/A 14692669Sktlim@umich.edu regFile.setFloatRegBits(phys_reg, val); 14702292SN/A} 14712292SN/A 14722292SN/Atemplate <class Impl> 14739920Syasuko.eckert@amd.comvoid 147412109SRekai.GonzalezAlberquilla@arm.comFullO3CPU<Impl>::setArchVecReg(int reg_idx, const VecRegContainer& val, 147512109SRekai.GonzalezAlberquilla@arm.com ThreadID tid) 147612109SRekai.GonzalezAlberquilla@arm.com{ 147712109SRekai.GonzalezAlberquilla@arm.com PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup( 147812109SRekai.GonzalezAlberquilla@arm.com RegId(VecRegClass, reg_idx)); 147912109SRekai.GonzalezAlberquilla@arm.com setVecReg(phys_reg, val); 148012109SRekai.GonzalezAlberquilla@arm.com} 148112109SRekai.GonzalezAlberquilla@arm.com 148212109SRekai.GonzalezAlberquilla@arm.comtemplate <class Impl> 148312109SRekai.GonzalezAlberquilla@arm.comvoid 148412109SRekai.GonzalezAlberquilla@arm.comFullO3CPU<Impl>::setArchVecElem(const RegIndex& reg_idx, const ElemIndex& ldx, 148512109SRekai.GonzalezAlberquilla@arm.com const VecElem& val, ThreadID tid) 148612109SRekai.GonzalezAlberquilla@arm.com{ 148712109SRekai.GonzalezAlberquilla@arm.com PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup( 148812109SRekai.GonzalezAlberquilla@arm.com RegId(VecRegClass, reg_idx, ldx)); 148912109SRekai.GonzalezAlberquilla@arm.com setVecElem(phys_reg, val); 149012109SRekai.GonzalezAlberquilla@arm.com} 149112109SRekai.GonzalezAlberquilla@arm.com 149212109SRekai.GonzalezAlberquilla@arm.comtemplate <class Impl> 149312109SRekai.GonzalezAlberquilla@arm.comvoid 14949920Syasuko.eckert@amd.comFullO3CPU<Impl>::setArchCCReg(int reg_idx, CCReg val, ThreadID tid) 14959920Syasuko.eckert@amd.com{ 14969920Syasuko.eckert@amd.com ccRegfileWrites++; 149712106SRekai.GonzalezAlberquilla@arm.com PhysRegIdPtr phys_reg = commitRenameMap[tid].lookup( 149812106SRekai.GonzalezAlberquilla@arm.com RegId(CCRegClass, reg_idx)); 14999920Syasuko.eckert@amd.com 15009920Syasuko.eckert@amd.com regFile.setCCReg(phys_reg, val); 15019920Syasuko.eckert@amd.com} 15029920Syasuko.eckert@amd.com 15039920Syasuko.eckert@amd.comtemplate <class Impl> 15047720Sgblack@eecs.umich.eduTheISA::PCState 15057720Sgblack@eecs.umich.eduFullO3CPU<Impl>::pcState(ThreadID tid) 15062292SN/A{ 15077720Sgblack@eecs.umich.edu return commit.pcState(tid); 15081060SN/A} 15091060SN/A 15101060SN/Atemplate <class Impl> 15111060SN/Avoid 15127720Sgblack@eecs.umich.eduFullO3CPU<Impl>::pcState(const TheISA::PCState &val, ThreadID tid) 15131060SN/A{ 15147720Sgblack@eecs.umich.edu commit.pcState(val, tid); 15152292SN/A} 15161060SN/A 15172292SN/Atemplate <class Impl> 15187720Sgblack@eecs.umich.eduAddr 15197720Sgblack@eecs.umich.eduFullO3CPU<Impl>::instAddr(ThreadID tid) 15204636Sgblack@eecs.umich.edu{ 15217720Sgblack@eecs.umich.edu return commit.instAddr(tid); 15224636Sgblack@eecs.umich.edu} 15234636Sgblack@eecs.umich.edu 15244636Sgblack@eecs.umich.edutemplate <class Impl> 15257720Sgblack@eecs.umich.eduAddr 15267720Sgblack@eecs.umich.eduFullO3CPU<Impl>::nextInstAddr(ThreadID tid) 15274636Sgblack@eecs.umich.edu{ 15287720Sgblack@eecs.umich.edu return commit.nextInstAddr(tid); 15294636Sgblack@eecs.umich.edu} 15304636Sgblack@eecs.umich.edu 15314636Sgblack@eecs.umich.edutemplate <class Impl> 15327720Sgblack@eecs.umich.eduMicroPC 15337720Sgblack@eecs.umich.eduFullO3CPU<Impl>::microPC(ThreadID tid) 15342292SN/A{ 15357720Sgblack@eecs.umich.edu return commit.microPC(tid); 15364636Sgblack@eecs.umich.edu} 15374636Sgblack@eecs.umich.edu 15384636Sgblack@eecs.umich.edutemplate <class Impl> 15395595Sgblack@eecs.umich.eduvoid 15406221Snate@binkert.orgFullO3CPU<Impl>::squashFromTC(ThreadID tid) 15415595Sgblack@eecs.umich.edu{ 15429382SAli.Saidi@ARM.com this->thread[tid]->noSquashFromTC = true; 15435595Sgblack@eecs.umich.edu this->commit.generateTCEvent(tid); 15445595Sgblack@eecs.umich.edu} 15455595Sgblack@eecs.umich.edu 15465595Sgblack@eecs.umich.edutemplate <class Impl> 15472292SN/Atypename FullO3CPU<Impl>::ListIt 15482292SN/AFullO3CPU<Impl>::addInst(DynInstPtr &inst) 15492292SN/A{ 15502292SN/A instList.push_back(inst); 15511060SN/A 15522292SN/A return --(instList.end()); 15532292SN/A} 15541060SN/A 15552292SN/Atemplate <class Impl> 15562292SN/Avoid 15578834Satgutier@umich.eduFullO3CPU<Impl>::instDone(ThreadID tid, DynInstPtr &inst) 15582292SN/A{ 15592292SN/A // Keep an instruction count. 15608834Satgutier@umich.edu if (!inst->isMicroop() || inst->isLastMicroop()) { 15618834Satgutier@umich.edu thread[tid]->numInst++; 15628834Satgutier@umich.edu thread[tid]->numInsts++; 15638834Satgutier@umich.edu committedInsts[tid]++; 156410774Snikos.nikoleris@gmail.com system->totalNumInsts++; 156510774Snikos.nikoleris@gmail.com 156610774Snikos.nikoleris@gmail.com // Check for instruction-count-based events. 156710774Snikos.nikoleris@gmail.com comInstEventQueue[tid]->serviceEvents(thread[tid]->numInst); 156810774Snikos.nikoleris@gmail.com system->instEventQueue.serviceEvents(system->totalNumInsts); 15698834Satgutier@umich.edu } 15708834Satgutier@umich.edu thread[tid]->numOp++; 15718834Satgutier@umich.edu thread[tid]->numOps++; 15728834Satgutier@umich.edu committedOps[tid]++; 15738834Satgutier@umich.edu 157410464SAndreas.Sandberg@ARM.com probeInstCommit(inst->staticInst); 15752292SN/A} 15762292SN/A 15772292SN/Atemplate <class Impl> 15782292SN/Avoid 15791755SN/AFullO3CPU<Impl>::removeFrontInst(DynInstPtr &inst) 15801060SN/A{ 15817720Sgblack@eecs.umich.edu DPRINTF(O3CPU, "Removing committed instruction [tid:%i] PC %s " 15822292SN/A "[sn:%lli]\n", 15837720Sgblack@eecs.umich.edu inst->threadNumber, inst->pcState(), inst->seqNum); 15841060SN/A 15852292SN/A removeInstsThisCycle = true; 15861060SN/A 15871060SN/A // Remove the front instruction. 15882292SN/A removeList.push(inst->getInstListIt()); 15891060SN/A} 15901060SN/A 15911060SN/Atemplate <class Impl> 15921060SN/Avoid 15936221Snate@binkert.orgFullO3CPU<Impl>::removeInstsNotInROB(ThreadID tid) 15941060SN/A{ 15952733Sktlim@umich.edu DPRINTF(O3CPU, "Thread %i: Deleting instructions from instruction" 15962292SN/A " list.\n", tid); 15971060SN/A 15982292SN/A ListIt end_it; 15991060SN/A 16002292SN/A bool rob_empty = false; 16012292SN/A 16022292SN/A if (instList.empty()) { 16032292SN/A return; 160410164Ssleimanf@umich.edu } else if (rob.isEmpty(tid)) { 16052733Sktlim@umich.edu DPRINTF(O3CPU, "ROB is empty, squashing all insts.\n"); 16062292SN/A end_it = instList.begin(); 16072292SN/A rob_empty = true; 16082292SN/A } else { 16092292SN/A end_it = (rob.readTailInst(tid))->getInstListIt(); 16102733Sktlim@umich.edu DPRINTF(O3CPU, "ROB is not empty, squashing insts not in ROB.\n"); 16112292SN/A } 16122292SN/A 16132292SN/A removeInstsThisCycle = true; 16142292SN/A 16152292SN/A ListIt inst_it = instList.end(); 16162292SN/A 16172292SN/A inst_it--; 16182292SN/A 16192292SN/A // Walk through the instruction list, removing any instructions 16202292SN/A // that were inserted after the given instruction iterator, end_it. 16212292SN/A while (inst_it != end_it) { 16222292SN/A assert(!instList.empty()); 16232292SN/A 16242292SN/A squashInstIt(inst_it, tid); 16252292SN/A 16262292SN/A inst_it--; 16272292SN/A } 16282292SN/A 16292292SN/A // If the ROB was empty, then we actually need to remove the first 16302292SN/A // instruction as well. 16312292SN/A if (rob_empty) { 16322292SN/A squashInstIt(inst_it, tid); 16332292SN/A } 16341060SN/A} 16351060SN/A 16361060SN/Atemplate <class Impl> 16371060SN/Avoid 16386221Snate@binkert.orgFullO3CPU<Impl>::removeInstsUntil(const InstSeqNum &seq_num, ThreadID tid) 16391062SN/A{ 16402292SN/A assert(!instList.empty()); 16412292SN/A 16422292SN/A removeInstsThisCycle = true; 16432292SN/A 16442292SN/A ListIt inst_iter = instList.end(); 16452292SN/A 16462292SN/A inst_iter--; 16472292SN/A 16482733Sktlim@umich.edu DPRINTF(O3CPU, "Deleting instructions from instruction " 16492292SN/A "list that are from [tid:%i] and above [sn:%lli] (end=%lli).\n", 16502292SN/A tid, seq_num, (*inst_iter)->seqNum); 16511062SN/A 16522292SN/A while ((*inst_iter)->seqNum > seq_num) { 16531062SN/A 16542292SN/A bool break_loop = (inst_iter == instList.begin()); 16551062SN/A 16562292SN/A squashInstIt(inst_iter, tid); 16571062SN/A 16582292SN/A inst_iter--; 16591062SN/A 16602292SN/A if (break_loop) 16612292SN/A break; 16622292SN/A } 16632292SN/A} 16642292SN/A 16652292SN/Atemplate <class Impl> 16662292SN/Ainline void 16676221Snate@binkert.orgFullO3CPU<Impl>::squashInstIt(const ListIt &instIt, ThreadID tid) 16682292SN/A{ 16692292SN/A if ((*instIt)->threadNumber == tid) { 16702733Sktlim@umich.edu DPRINTF(O3CPU, "Squashing instruction, " 16717720Sgblack@eecs.umich.edu "[tid:%i] [sn:%lli] PC %s\n", 16722292SN/A (*instIt)->threadNumber, 16732292SN/A (*instIt)->seqNum, 16747720Sgblack@eecs.umich.edu (*instIt)->pcState()); 16751062SN/A 16761062SN/A // Mark it as squashed. 16772292SN/A (*instIt)->setSquashed(); 16782292SN/A 16792325SN/A // @todo: Formulate a consistent method for deleting 16802325SN/A // instructions from the instruction list 16812292SN/A // Remove the instruction from the list. 16822292SN/A removeList.push(instIt); 16832292SN/A } 16842292SN/A} 16852292SN/A 16862292SN/Atemplate <class Impl> 16872292SN/Avoid 16882292SN/AFullO3CPU<Impl>::cleanUpRemovedInsts() 16892292SN/A{ 16902292SN/A while (!removeList.empty()) { 16912733Sktlim@umich.edu DPRINTF(O3CPU, "Removing instruction, " 16927720Sgblack@eecs.umich.edu "[tid:%i] [sn:%lli] PC %s\n", 16932292SN/A (*removeList.front())->threadNumber, 16942292SN/A (*removeList.front())->seqNum, 16957720Sgblack@eecs.umich.edu (*removeList.front())->pcState()); 16962292SN/A 16972292SN/A instList.erase(removeList.front()); 16982292SN/A 16992292SN/A removeList.pop(); 17001062SN/A } 17011062SN/A 17022292SN/A removeInstsThisCycle = false; 17031062SN/A} 17042325SN/A/* 17051062SN/Atemplate <class Impl> 17061062SN/Avoid 17071755SN/AFullO3CPU<Impl>::removeAllInsts() 17081060SN/A{ 17091060SN/A instList.clear(); 17101060SN/A} 17112325SN/A*/ 17121060SN/Atemplate <class Impl> 17131060SN/Avoid 17141755SN/AFullO3CPU<Impl>::dumpInsts() 17151060SN/A{ 17161060SN/A int num = 0; 17171060SN/A 17182292SN/A ListIt inst_list_it = instList.begin(); 17192292SN/A 17202292SN/A cprintf("Dumping Instruction List\n"); 17212292SN/A 17222292SN/A while (inst_list_it != instList.end()) { 17232292SN/A cprintf("Instruction:%i\nPC:%#x\n[tid:%i]\n[sn:%lli]\nIssued:%i\n" 17242292SN/A "Squashed:%i\n\n", 17257720Sgblack@eecs.umich.edu num, (*inst_list_it)->instAddr(), (*inst_list_it)->threadNumber, 17262292SN/A (*inst_list_it)->seqNum, (*inst_list_it)->isIssued(), 17272292SN/A (*inst_list_it)->isSquashed()); 17281060SN/A inst_list_it++; 17291060SN/A ++num; 17301060SN/A } 17311060SN/A} 17322325SN/A/* 17331060SN/Atemplate <class Impl> 17341060SN/Avoid 17351755SN/AFullO3CPU<Impl>::wakeDependents(DynInstPtr &inst) 17361060SN/A{ 17371060SN/A iew.wakeDependents(inst); 17381060SN/A} 17392325SN/A*/ 17402292SN/Atemplate <class Impl> 17412292SN/Avoid 17422292SN/AFullO3CPU<Impl>::wakeCPU() 17432292SN/A{ 17442325SN/A if (activityRec.active() || tickEvent.scheduled()) { 17452325SN/A DPRINTF(Activity, "CPU already running.\n"); 17462292SN/A return; 17472292SN/A } 17482292SN/A 17492325SN/A DPRINTF(Activity, "Waking up CPU\n"); 17502325SN/A 17519180Sandreas.hansson@arm.com Cycles cycles(curCycle() - lastRunningCycle); 17529180Sandreas.hansson@arm.com // @todo: This is an oddity that is only here to match the stats 175310464SAndreas.Sandberg@ARM.com if (cycles > 1) { 17549179Sandreas.hansson@arm.com --cycles; 175510464SAndreas.Sandberg@ARM.com idleCycles += cycles; 175610464SAndreas.Sandberg@ARM.com numCycles += cycles; 175710464SAndreas.Sandberg@ARM.com ppCycles->notify(cycles); 175810464SAndreas.Sandberg@ARM.com } 17592292SN/A 17609648Sdam.sunwoo@arm.com schedule(tickEvent, clockEdge()); 17612292SN/A} 17622292SN/A 17635807Snate@binkert.orgtemplate <class Impl> 17645807Snate@binkert.orgvoid 176511151Smitch.hayenga@arm.comFullO3CPU<Impl>::wakeup(ThreadID tid) 17665807Snate@binkert.org{ 176711151Smitch.hayenga@arm.com if (this->thread[tid]->status() != ThreadContext::Suspended) 17685807Snate@binkert.org return; 17695807Snate@binkert.org 17705807Snate@binkert.org this->wakeCPU(); 17715807Snate@binkert.org 17725807Snate@binkert.org DPRINTF(Quiesce, "Suspended Processor woken\n"); 177311151Smitch.hayenga@arm.com this->threadContexts[tid]->activate(); 17745807Snate@binkert.org} 17755807Snate@binkert.org 17762292SN/Atemplate <class Impl> 17776221Snate@binkert.orgThreadID 17782292SN/AFullO3CPU<Impl>::getFreeTid() 17792292SN/A{ 17806221Snate@binkert.org for (ThreadID tid = 0; tid < numThreads; tid++) { 17816221Snate@binkert.org if (!tids[tid]) { 17826221Snate@binkert.org tids[tid] = true; 17836221Snate@binkert.org return tid; 17842292SN/A } 17852292SN/A } 17862292SN/A 17876221Snate@binkert.org return InvalidThreadID; 17882292SN/A} 17892292SN/A 17902292SN/Atemplate <class Impl> 17912292SN/Avoid 17922292SN/AFullO3CPU<Impl>::updateThreadPriority() 17932292SN/A{ 17946221Snate@binkert.org if (activeThreads.size() > 1) { 17952292SN/A //DEFAULT TO ROUND ROBIN SCHEME 17962292SN/A //e.g. Move highest priority to end of thread list 17976221Snate@binkert.org list<ThreadID>::iterator list_begin = activeThreads.begin(); 17982292SN/A 17992292SN/A unsigned high_thread = *list_begin; 18002292SN/A 18012292SN/A activeThreads.erase(list_begin); 18022292SN/A 18032292SN/A activeThreads.push_back(high_thread); 18042292SN/A } 18052292SN/A} 18061060SN/A 18071755SN/A// Forward declaration of FullO3CPU. 18082818Sksewell@umich.edutemplate class FullO3CPU<O3CPUImpl>; 1809