iew_impl.hh revision 6221
11689SN/A/* 22326SN/A * Copyright (c) 2004-2006 The Regents of The University of Michigan 31689SN/A * All rights reserved. 41689SN/A * 51689SN/A * Redistribution and use in source and binary forms, with or without 61689SN/A * modification, are permitted provided that the following conditions are 71689SN/A * met: redistributions of source code must retain the above copyright 81689SN/A * notice, this list of conditions and the following disclaimer; 91689SN/A * redistributions in binary form must reproduce the above copyright 101689SN/A * notice, this list of conditions and the following disclaimer in the 111689SN/A * documentation and/or other materials provided with the distribution; 121689SN/A * neither the name of the copyright holders nor the names of its 131689SN/A * contributors may be used to endorse or promote products derived from 141689SN/A * this software without specific prior written permission. 151689SN/A * 161689SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 171689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 181689SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 191689SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 201689SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 211689SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 221689SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 231689SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 241689SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 251689SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 261689SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Kevin Lim 291689SN/A */ 301689SN/A 311060SN/A// @todo: Fix the instantaneous communication among all the stages within 321060SN/A// iew. There's a clear delay between issue and execute, yet backwards 331689SN/A// communication happens simultaneously. 341060SN/A 351060SN/A#include <queue> 361060SN/A 371060SN/A#include "base/timebuf.hh" 382292SN/A#include "cpu/o3/fu_pool.hh" 391717SN/A#include "cpu/o3/iew.hh" 405529Snate@binkert.org#include "params/DerivO3CPU.hh" 411060SN/A 426221Snate@binkert.orgusing namespace std; 436221Snate@binkert.org 441681SN/Atemplate<class Impl> 455529Snate@binkert.orgDefaultIEW<Impl>::DefaultIEW(O3CPU *_cpu, DerivO3CPUParams *params) 462873Sktlim@umich.edu : issueToExecQueue(params->backComSize, params->forwardComSize), 474329Sktlim@umich.edu cpu(_cpu), 484329Sktlim@umich.edu instQueue(_cpu, this, params), 494329Sktlim@umich.edu ldstQueue(_cpu, this, params), 502292SN/A fuPool(params->fuPool), 512292SN/A commitToIEWDelay(params->commitToIEWDelay), 522292SN/A renameToIEWDelay(params->renameToIEWDelay), 532292SN/A issueToExecuteDelay(params->issueToExecuteDelay), 542820Sktlim@umich.edu dispatchWidth(params->dispatchWidth), 552292SN/A issueWidth(params->issueWidth), 562820Sktlim@umich.edu wbOutstanding(0), 572820Sktlim@umich.edu wbWidth(params->wbWidth), 585529Snate@binkert.org numThreads(params->numThreads), 592307SN/A switchedOut(false) 601060SN/A{ 612292SN/A _status = Active; 622292SN/A exeStatus = Running; 632292SN/A wbStatus = Idle; 641060SN/A 651060SN/A // Setup wire to read instructions coming from issue. 661060SN/A fromIssue = issueToExecQueue.getWire(-issueToExecuteDelay); 671060SN/A 681060SN/A // Instruction queue needs the queue between issue and execute. 691060SN/A instQueue.setIssueToExecuteQueue(&issueToExecQueue); 701681SN/A 716221Snate@binkert.org for (ThreadID tid = 0; tid < numThreads; tid++) { 726221Snate@binkert.org dispatchStatus[tid] = Running; 736221Snate@binkert.org stalls[tid].commit = false; 746221Snate@binkert.org fetchRedirect[tid] = false; 752292SN/A } 762292SN/A 772820Sktlim@umich.edu wbMax = wbWidth * params->wbDepth; 782820Sktlim@umich.edu 792292SN/A updateLSQNextCycle = false; 802292SN/A 812820Sktlim@umich.edu ableToIssue = true; 822820Sktlim@umich.edu 832292SN/A skidBufferMax = (3 * (renameToIEWDelay * params->renameWidth)) + issueWidth; 842292SN/A} 852292SN/A 862292SN/Atemplate <class Impl> 872292SN/Astd::string 882292SN/ADefaultIEW<Impl>::name() const 892292SN/A{ 902292SN/A return cpu->name() + ".iew"; 911060SN/A} 921060SN/A 931681SN/Atemplate <class Impl> 941062SN/Avoid 952292SN/ADefaultIEW<Impl>::regStats() 961062SN/A{ 972301SN/A using namespace Stats; 982301SN/A 991062SN/A instQueue.regStats(); 1002727Sktlim@umich.edu ldstQueue.regStats(); 1011062SN/A 1021062SN/A iewIdleCycles 1031062SN/A .name(name() + ".iewIdleCycles") 1041062SN/A .desc("Number of cycles IEW is idle"); 1051062SN/A 1061062SN/A iewSquashCycles 1071062SN/A .name(name() + ".iewSquashCycles") 1081062SN/A .desc("Number of cycles IEW is squashing"); 1091062SN/A 1101062SN/A iewBlockCycles 1111062SN/A .name(name() + ".iewBlockCycles") 1121062SN/A .desc("Number of cycles IEW is blocking"); 1131062SN/A 1141062SN/A iewUnblockCycles 1151062SN/A .name(name() + ".iewUnblockCycles") 1161062SN/A .desc("Number of cycles IEW is unblocking"); 1171062SN/A 1181062SN/A iewDispatchedInsts 1191062SN/A .name(name() + ".iewDispatchedInsts") 1201062SN/A .desc("Number of instructions dispatched to IQ"); 1211062SN/A 1221062SN/A iewDispSquashedInsts 1231062SN/A .name(name() + ".iewDispSquashedInsts") 1241062SN/A .desc("Number of squashed instructions skipped by dispatch"); 1251062SN/A 1261062SN/A iewDispLoadInsts 1271062SN/A .name(name() + ".iewDispLoadInsts") 1281062SN/A .desc("Number of dispatched load instructions"); 1291062SN/A 1301062SN/A iewDispStoreInsts 1311062SN/A .name(name() + ".iewDispStoreInsts") 1321062SN/A .desc("Number of dispatched store instructions"); 1331062SN/A 1341062SN/A iewDispNonSpecInsts 1351062SN/A .name(name() + ".iewDispNonSpecInsts") 1361062SN/A .desc("Number of dispatched non-speculative instructions"); 1371062SN/A 1381062SN/A iewIQFullEvents 1391062SN/A .name(name() + ".iewIQFullEvents") 1401062SN/A .desc("Number of times the IQ has become full, causing a stall"); 1411062SN/A 1422292SN/A iewLSQFullEvents 1432292SN/A .name(name() + ".iewLSQFullEvents") 1442292SN/A .desc("Number of times the LSQ has become full, causing a stall"); 1452292SN/A 1461062SN/A memOrderViolationEvents 1471062SN/A .name(name() + ".memOrderViolationEvents") 1481062SN/A .desc("Number of memory order violations"); 1491062SN/A 1501062SN/A predictedTakenIncorrect 1511062SN/A .name(name() + ".predictedTakenIncorrect") 1521062SN/A .desc("Number of branches that were predicted taken incorrectly"); 1532292SN/A 1542292SN/A predictedNotTakenIncorrect 1552292SN/A .name(name() + ".predictedNotTakenIncorrect") 1562292SN/A .desc("Number of branches that were predicted not taken incorrectly"); 1572292SN/A 1582292SN/A branchMispredicts 1592292SN/A .name(name() + ".branchMispredicts") 1602292SN/A .desc("Number of branch mispredicts detected at execute"); 1612292SN/A 1622292SN/A branchMispredicts = predictedTakenIncorrect + predictedNotTakenIncorrect; 1632301SN/A 1642727Sktlim@umich.edu iewExecutedInsts 1652353SN/A .name(name() + ".iewExecutedInsts") 1662727Sktlim@umich.edu .desc("Number of executed instructions"); 1672727Sktlim@umich.edu 1682727Sktlim@umich.edu iewExecLoadInsts 1696221Snate@binkert.org .init(cpu->numThreads) 1702353SN/A .name(name() + ".iewExecLoadInsts") 1712727Sktlim@umich.edu .desc("Number of load instructions executed") 1722727Sktlim@umich.edu .flags(total); 1732727Sktlim@umich.edu 1742727Sktlim@umich.edu iewExecSquashedInsts 1752353SN/A .name(name() + ".iewExecSquashedInsts") 1762727Sktlim@umich.edu .desc("Number of squashed instructions skipped in execute"); 1772727Sktlim@umich.edu 1782727Sktlim@umich.edu iewExecutedSwp 1796221Snate@binkert.org .init(cpu->numThreads) 1802301SN/A .name(name() + ".EXEC:swp") 1812301SN/A .desc("number of swp insts executed") 1822727Sktlim@umich.edu .flags(total); 1832301SN/A 1842727Sktlim@umich.edu iewExecutedNop 1856221Snate@binkert.org .init(cpu->numThreads) 1862301SN/A .name(name() + ".EXEC:nop") 1872301SN/A .desc("number of nop insts executed") 1882727Sktlim@umich.edu .flags(total); 1892301SN/A 1902727Sktlim@umich.edu iewExecutedRefs 1916221Snate@binkert.org .init(cpu->numThreads) 1922301SN/A .name(name() + ".EXEC:refs") 1932301SN/A .desc("number of memory reference insts executed") 1942727Sktlim@umich.edu .flags(total); 1952301SN/A 1962727Sktlim@umich.edu iewExecutedBranches 1976221Snate@binkert.org .init(cpu->numThreads) 1982301SN/A .name(name() + ".EXEC:branches") 1992301SN/A .desc("Number of branches executed") 2002727Sktlim@umich.edu .flags(total); 2012301SN/A 2022301SN/A iewExecStoreInsts 2032301SN/A .name(name() + ".EXEC:stores") 2042301SN/A .desc("Number of stores executed") 2052727Sktlim@umich.edu .flags(total); 2062727Sktlim@umich.edu iewExecStoreInsts = iewExecutedRefs - iewExecLoadInsts; 2072727Sktlim@umich.edu 2082727Sktlim@umich.edu iewExecRate 2092727Sktlim@umich.edu .name(name() + ".EXEC:rate") 2102727Sktlim@umich.edu .desc("Inst execution rate") 2112727Sktlim@umich.edu .flags(total); 2122727Sktlim@umich.edu 2132727Sktlim@umich.edu iewExecRate = iewExecutedInsts / cpu->numCycles; 2142301SN/A 2152301SN/A iewInstsToCommit 2166221Snate@binkert.org .init(cpu->numThreads) 2172301SN/A .name(name() + ".WB:sent") 2182301SN/A .desc("cumulative count of insts sent to commit") 2192727Sktlim@umich.edu .flags(total); 2202301SN/A 2212326SN/A writebackCount 2226221Snate@binkert.org .init(cpu->numThreads) 2232301SN/A .name(name() + ".WB:count") 2242301SN/A .desc("cumulative count of insts written-back") 2252727Sktlim@umich.edu .flags(total); 2262301SN/A 2272326SN/A producerInst 2286221Snate@binkert.org .init(cpu->numThreads) 2292301SN/A .name(name() + ".WB:producers") 2302301SN/A .desc("num instructions producing a value") 2312727Sktlim@umich.edu .flags(total); 2322301SN/A 2332326SN/A consumerInst 2346221Snate@binkert.org .init(cpu->numThreads) 2352301SN/A .name(name() + ".WB:consumers") 2362301SN/A .desc("num instructions consuming a value") 2372727Sktlim@umich.edu .flags(total); 2382301SN/A 2392326SN/A wbPenalized 2406221Snate@binkert.org .init(cpu->numThreads) 2412301SN/A .name(name() + ".WB:penalized") 2422301SN/A .desc("number of instrctions required to write to 'other' IQ") 2432727Sktlim@umich.edu .flags(total); 2442301SN/A 2452326SN/A wbPenalizedRate 2462301SN/A .name(name() + ".WB:penalized_rate") 2472301SN/A .desc ("fraction of instructions written-back that wrote to 'other' IQ") 2482727Sktlim@umich.edu .flags(total); 2492301SN/A 2502326SN/A wbPenalizedRate = wbPenalized / writebackCount; 2512301SN/A 2522326SN/A wbFanout 2532301SN/A .name(name() + ".WB:fanout") 2542301SN/A .desc("average fanout of values written-back") 2552727Sktlim@umich.edu .flags(total); 2562301SN/A 2572326SN/A wbFanout = producerInst / consumerInst; 2582301SN/A 2592326SN/A wbRate 2602301SN/A .name(name() + ".WB:rate") 2612301SN/A .desc("insts written-back per cycle") 2622727Sktlim@umich.edu .flags(total); 2632326SN/A wbRate = writebackCount / cpu->numCycles; 2641062SN/A} 2651062SN/A 2661681SN/Atemplate<class Impl> 2671060SN/Avoid 2682292SN/ADefaultIEW<Impl>::initStage() 2691060SN/A{ 2706221Snate@binkert.org for (ThreadID tid = 0; tid < numThreads; tid++) { 2712292SN/A toRename->iewInfo[tid].usedIQ = true; 2722292SN/A toRename->iewInfo[tid].freeIQEntries = 2732292SN/A instQueue.numFreeEntries(tid); 2742292SN/A 2752292SN/A toRename->iewInfo[tid].usedLSQ = true; 2762292SN/A toRename->iewInfo[tid].freeLSQEntries = 2772292SN/A ldstQueue.numFreeEntries(tid); 2782292SN/A } 2792292SN/A 2802733Sktlim@umich.edu cpu->activateStage(O3CPU::IEWIdx); 2811060SN/A} 2821060SN/A 2831681SN/Atemplate<class Impl> 2841060SN/Avoid 2852292SN/ADefaultIEW<Impl>::setTimeBuffer(TimeBuffer<TimeStruct> *tb_ptr) 2861060SN/A{ 2871060SN/A timeBuffer = tb_ptr; 2881060SN/A 2891060SN/A // Setup wire to read information from time buffer, from commit. 2901060SN/A fromCommit = timeBuffer->getWire(-commitToIEWDelay); 2911060SN/A 2921060SN/A // Setup wire to write information back to previous stages. 2931060SN/A toRename = timeBuffer->getWire(0); 2941060SN/A 2952292SN/A toFetch = timeBuffer->getWire(0); 2962292SN/A 2971060SN/A // Instruction queue also needs main time buffer. 2981060SN/A instQueue.setTimeBuffer(tb_ptr); 2991060SN/A} 3001060SN/A 3011681SN/Atemplate<class Impl> 3021060SN/Avoid 3032292SN/ADefaultIEW<Impl>::setRenameQueue(TimeBuffer<RenameStruct> *rq_ptr) 3041060SN/A{ 3051060SN/A renameQueue = rq_ptr; 3061060SN/A 3071060SN/A // Setup wire to read information from rename queue. 3081060SN/A fromRename = renameQueue->getWire(-renameToIEWDelay); 3091060SN/A} 3101060SN/A 3111681SN/Atemplate<class Impl> 3121060SN/Avoid 3132292SN/ADefaultIEW<Impl>::setIEWQueue(TimeBuffer<IEWStruct> *iq_ptr) 3141060SN/A{ 3151060SN/A iewQueue = iq_ptr; 3161060SN/A 3171060SN/A // Setup wire to write instructions to commit. 3181060SN/A toCommit = iewQueue->getWire(0); 3191060SN/A} 3201060SN/A 3211681SN/Atemplate<class Impl> 3221060SN/Avoid 3236221Snate@binkert.orgDefaultIEW<Impl>::setActiveThreads(list<ThreadID> *at_ptr) 3241060SN/A{ 3252292SN/A activeThreads = at_ptr; 3262292SN/A 3272292SN/A ldstQueue.setActiveThreads(at_ptr); 3282292SN/A instQueue.setActiveThreads(at_ptr); 3291060SN/A} 3301060SN/A 3311681SN/Atemplate<class Impl> 3321060SN/Avoid 3332292SN/ADefaultIEW<Impl>::setScoreboard(Scoreboard *sb_ptr) 3341060SN/A{ 3352292SN/A scoreboard = sb_ptr; 3361060SN/A} 3371060SN/A 3382307SN/Atemplate <class Impl> 3392863Sktlim@umich.edubool 3402843Sktlim@umich.eduDefaultIEW<Impl>::drain() 3412307SN/A{ 3422843Sktlim@umich.edu // IEW is ready to drain at any time. 3432843Sktlim@umich.edu cpu->signalDrained(); 3442863Sktlim@umich.edu return true; 3451681SN/A} 3461681SN/A 3472316SN/Atemplate <class Impl> 3481681SN/Avoid 3492843Sktlim@umich.eduDefaultIEW<Impl>::resume() 3502843Sktlim@umich.edu{ 3512843Sktlim@umich.edu} 3522843Sktlim@umich.edu 3532843Sktlim@umich.edutemplate <class Impl> 3542843Sktlim@umich.eduvoid 3552843Sktlim@umich.eduDefaultIEW<Impl>::switchOut() 3561681SN/A{ 3572348SN/A // Clear any state. 3582307SN/A switchedOut = true; 3592367SN/A assert(insts[0].empty()); 3602367SN/A assert(skidBuffer[0].empty()); 3611681SN/A 3622307SN/A instQueue.switchOut(); 3632307SN/A ldstQueue.switchOut(); 3642307SN/A fuPool->switchOut(); 3652307SN/A 3666221Snate@binkert.org for (ThreadID tid = 0; tid < numThreads; tid++) { 3676221Snate@binkert.org while (!insts[tid].empty()) 3686221Snate@binkert.org insts[tid].pop(); 3696221Snate@binkert.org while (!skidBuffer[tid].empty()) 3706221Snate@binkert.org skidBuffer[tid].pop(); 3712307SN/A } 3721681SN/A} 3731681SN/A 3742307SN/Atemplate <class Impl> 3751681SN/Avoid 3762307SN/ADefaultIEW<Impl>::takeOverFrom() 3771060SN/A{ 3782348SN/A // Reset all state. 3792307SN/A _status = Active; 3802307SN/A exeStatus = Running; 3812307SN/A wbStatus = Idle; 3822307SN/A switchedOut = false; 3831060SN/A 3842307SN/A instQueue.takeOverFrom(); 3852307SN/A ldstQueue.takeOverFrom(); 3862307SN/A fuPool->takeOverFrom(); 3871060SN/A 3882307SN/A initStage(); 3892307SN/A cpu->activityThisCycle(); 3901060SN/A 3916221Snate@binkert.org for (ThreadID tid = 0; tid < numThreads; tid++) { 3926221Snate@binkert.org dispatchStatus[tid] = Running; 3936221Snate@binkert.org stalls[tid].commit = false; 3946221Snate@binkert.org fetchRedirect[tid] = false; 3952307SN/A } 3961060SN/A 3972307SN/A updateLSQNextCycle = false; 3982307SN/A 3992873Sktlim@umich.edu for (int i = 0; i < issueToExecQueue.getSize(); ++i) { 4002307SN/A issueToExecQueue.advance(); 4011060SN/A } 4021060SN/A} 4031060SN/A 4041681SN/Atemplate<class Impl> 4051060SN/Avoid 4066221Snate@binkert.orgDefaultIEW<Impl>::squash(ThreadID tid) 4072107SN/A{ 4086221Snate@binkert.org DPRINTF(IEW, "[tid:%i]: Squashing all instructions.\n", tid); 4092107SN/A 4102292SN/A // Tell the IQ to start squashing. 4112292SN/A instQueue.squash(tid); 4122107SN/A 4132292SN/A // Tell the LDSTQ to start squashing. 4142326SN/A ldstQueue.squash(fromCommit->commitInfo[tid].doneSeqNum, tid); 4152292SN/A updatedQueues = true; 4162107SN/A 4172292SN/A // Clear the skid buffer in case it has any data in it. 4182935Sksewell@umich.edu DPRINTF(IEW, "[tid:%i]: Removing skidbuffer instructions until [sn:%i].\n", 4194632Sgblack@eecs.umich.edu tid, fromCommit->commitInfo[tid].doneSeqNum); 4202935Sksewell@umich.edu 4212292SN/A while (!skidBuffer[tid].empty()) { 4222292SN/A if (skidBuffer[tid].front()->isLoad() || 4232292SN/A skidBuffer[tid].front()->isStore() ) { 4242292SN/A toRename->iewInfo[tid].dispatchedToLSQ++; 4252292SN/A } 4262107SN/A 4272292SN/A toRename->iewInfo[tid].dispatched++; 4282107SN/A 4292292SN/A skidBuffer[tid].pop(); 4302292SN/A } 4312107SN/A 4322702Sktlim@umich.edu emptyRenameInsts(tid); 4332107SN/A} 4342107SN/A 4352107SN/Atemplate<class Impl> 4362107SN/Avoid 4376221Snate@binkert.orgDefaultIEW<Impl>::squashDueToBranch(DynInstPtr &inst, ThreadID tid) 4382292SN/A{ 4392292SN/A DPRINTF(IEW, "[tid:%i]: Squashing from a specific instruction, PC: %#x " 4402292SN/A "[sn:%i].\n", tid, inst->readPC(), inst->seqNum); 4412292SN/A 4422292SN/A toCommit->squash[tid] = true; 4432292SN/A toCommit->squashedSeqNum[tid] = inst->seqNum; 4442292SN/A toCommit->mispredPC[tid] = inst->readPC(); 4452292SN/A toCommit->branchMispredict[tid] = true; 4462935Sksewell@umich.edu 4474632Sgblack@eecs.umich.edu#if ISA_HAS_DELAY_SLOT 4483969Sgblack@eecs.umich.edu int instSize = sizeof(TheISA::MachInst); 4494632Sgblack@eecs.umich.edu toCommit->branchTaken[tid] = 4503795Sgblack@eecs.umich.edu !(inst->readNextPC() + instSize == inst->readNextNPC() && 4513795Sgblack@eecs.umich.edu (inst->readNextPC() == inst->readPC() + instSize || 4523795Sgblack@eecs.umich.edu inst->readNextPC() == inst->readPC() + 2 * instSize)); 4533093Sksewell@umich.edu#else 4543093Sksewell@umich.edu toCommit->branchTaken[tid] = inst->readNextPC() != 4553093Sksewell@umich.edu (inst->readPC() + sizeof(TheISA::MachInst)); 4564632Sgblack@eecs.umich.edu#endif 4573093Sksewell@umich.edu toCommit->nextPC[tid] = inst->readNextPC(); 4584632Sgblack@eecs.umich.edu toCommit->nextNPC[tid] = inst->readNextNPC(); 4594636Sgblack@eecs.umich.edu toCommit->nextMicroPC[tid] = inst->readNextMicroPC(); 4602292SN/A 4612292SN/A toCommit->includeSquashInst[tid] = false; 4622292SN/A 4632292SN/A wroteToTimeBuffer = true; 4642292SN/A} 4652292SN/A 4662292SN/Atemplate<class Impl> 4672292SN/Avoid 4686221Snate@binkert.orgDefaultIEW<Impl>::squashDueToMemOrder(DynInstPtr &inst, ThreadID tid) 4692292SN/A{ 4702292SN/A DPRINTF(IEW, "[tid:%i]: Squashing from a specific instruction, " 4712292SN/A "PC: %#x [sn:%i].\n", tid, inst->readPC(), inst->seqNum); 4722292SN/A 4732292SN/A toCommit->squash[tid] = true; 4742292SN/A toCommit->squashedSeqNum[tid] = inst->seqNum; 4752292SN/A toCommit->nextPC[tid] = inst->readNextPC(); 4763795Sgblack@eecs.umich.edu toCommit->nextNPC[tid] = inst->readNextNPC(); 4773732Sktlim@umich.edu toCommit->branchMispredict[tid] = false; 4782292SN/A 4792292SN/A toCommit->includeSquashInst[tid] = false; 4802292SN/A 4812292SN/A wroteToTimeBuffer = true; 4822292SN/A} 4832292SN/A 4842292SN/Atemplate<class Impl> 4852292SN/Avoid 4866221Snate@binkert.orgDefaultIEW<Impl>::squashDueToMemBlocked(DynInstPtr &inst, ThreadID tid) 4872292SN/A{ 4882292SN/A DPRINTF(IEW, "[tid:%i]: Memory blocked, squashing load and younger insts, " 4892292SN/A "PC: %#x [sn:%i].\n", tid, inst->readPC(), inst->seqNum); 4902292SN/A 4912292SN/A toCommit->squash[tid] = true; 4922292SN/A toCommit->squashedSeqNum[tid] = inst->seqNum; 4932292SN/A toCommit->nextPC[tid] = inst->readPC(); 4943958Sgblack@eecs.umich.edu toCommit->nextNPC[tid] = inst->readNextPC(); 4953732Sktlim@umich.edu toCommit->branchMispredict[tid] = false; 4962292SN/A 4972348SN/A // Must include the broadcasted SN in the squash. 4982292SN/A toCommit->includeSquashInst[tid] = true; 4992292SN/A 5002292SN/A ldstQueue.setLoadBlockedHandled(tid); 5012292SN/A 5022292SN/A wroteToTimeBuffer = true; 5032292SN/A} 5042292SN/A 5052292SN/Atemplate<class Impl> 5062292SN/Avoid 5076221Snate@binkert.orgDefaultIEW<Impl>::block(ThreadID tid) 5082292SN/A{ 5092292SN/A DPRINTF(IEW, "[tid:%u]: Blocking.\n", tid); 5102292SN/A 5112292SN/A if (dispatchStatus[tid] != Blocked && 5122292SN/A dispatchStatus[tid] != Unblocking) { 5132292SN/A toRename->iewBlock[tid] = true; 5142292SN/A wroteToTimeBuffer = true; 5152292SN/A } 5162292SN/A 5172292SN/A // Add the current inputs to the skid buffer so they can be 5182292SN/A // reprocessed when this stage unblocks. 5192292SN/A skidInsert(tid); 5202292SN/A 5212292SN/A dispatchStatus[tid] = Blocked; 5222292SN/A} 5232292SN/A 5242292SN/Atemplate<class Impl> 5252292SN/Avoid 5266221Snate@binkert.orgDefaultIEW<Impl>::unblock(ThreadID tid) 5272292SN/A{ 5282292SN/A DPRINTF(IEW, "[tid:%i]: Reading instructions out of the skid " 5292292SN/A "buffer %u.\n",tid, tid); 5302292SN/A 5312292SN/A // If the skid bufffer is empty, signal back to previous stages to unblock. 5322292SN/A // Also switch status to running. 5332292SN/A if (skidBuffer[tid].empty()) { 5342292SN/A toRename->iewUnblock[tid] = true; 5352292SN/A wroteToTimeBuffer = true; 5362292SN/A DPRINTF(IEW, "[tid:%i]: Done unblocking.\n",tid); 5372292SN/A dispatchStatus[tid] = Running; 5382292SN/A } 5392292SN/A} 5402292SN/A 5412292SN/Atemplate<class Impl> 5422292SN/Avoid 5432292SN/ADefaultIEW<Impl>::wakeDependents(DynInstPtr &inst) 5441060SN/A{ 5451681SN/A instQueue.wakeDependents(inst); 5461060SN/A} 5471060SN/A 5482292SN/Atemplate<class Impl> 5492292SN/Avoid 5502292SN/ADefaultIEW<Impl>::rescheduleMemInst(DynInstPtr &inst) 5512292SN/A{ 5522292SN/A instQueue.rescheduleMemInst(inst); 5532292SN/A} 5541681SN/A 5551681SN/Atemplate<class Impl> 5561060SN/Avoid 5572292SN/ADefaultIEW<Impl>::replayMemInst(DynInstPtr &inst) 5581060SN/A{ 5592292SN/A instQueue.replayMemInst(inst); 5602292SN/A} 5611060SN/A 5622292SN/Atemplate<class Impl> 5632292SN/Avoid 5642292SN/ADefaultIEW<Impl>::instToCommit(DynInstPtr &inst) 5652292SN/A{ 5663221Sktlim@umich.edu // This function should not be called after writebackInsts in a 5673221Sktlim@umich.edu // single cycle. That will cause problems with an instruction 5683221Sktlim@umich.edu // being added to the queue to commit without being processed by 5693221Sktlim@umich.edu // writebackInsts prior to being sent to commit. 5703221Sktlim@umich.edu 5712292SN/A // First check the time slot that this instruction will write 5722292SN/A // to. If there are free write ports at the time, then go ahead 5732292SN/A // and write the instruction to that time. If there are not, 5742292SN/A // keep looking back to see where's the first time there's a 5752326SN/A // free slot. 5762292SN/A while ((*iewQueue)[wbCycle].insts[wbNumInst]) { 5772292SN/A ++wbNumInst; 5782820Sktlim@umich.edu if (wbNumInst == wbWidth) { 5792292SN/A ++wbCycle; 5802292SN/A wbNumInst = 0; 5812292SN/A } 5822292SN/A 5832353SN/A assert((wbCycle * wbWidth + wbNumInst) <= wbMax); 5842292SN/A } 5852292SN/A 5862353SN/A DPRINTF(IEW, "Current wb cycle: %i, width: %i, numInst: %i\nwbActual:%i\n", 5872353SN/A wbCycle, wbWidth, wbNumInst, wbCycle * wbWidth + wbNumInst); 5882292SN/A // Add finished instruction to queue to commit. 5892292SN/A (*iewQueue)[wbCycle].insts[wbNumInst] = inst; 5902292SN/A (*iewQueue)[wbCycle].size++; 5912292SN/A} 5922292SN/A 5932292SN/Atemplate <class Impl> 5942292SN/Aunsigned 5952292SN/ADefaultIEW<Impl>::validInstsFromRename() 5962292SN/A{ 5972292SN/A unsigned inst_count = 0; 5982292SN/A 5992292SN/A for (int i=0; i<fromRename->size; i++) { 6002731Sktlim@umich.edu if (!fromRename->insts[i]->isSquashed()) 6012292SN/A inst_count++; 6022292SN/A } 6032292SN/A 6042292SN/A return inst_count; 6052292SN/A} 6062292SN/A 6072292SN/Atemplate<class Impl> 6082292SN/Avoid 6096221Snate@binkert.orgDefaultIEW<Impl>::skidInsert(ThreadID tid) 6102292SN/A{ 6112292SN/A DynInstPtr inst = NULL; 6122292SN/A 6132292SN/A while (!insts[tid].empty()) { 6142292SN/A inst = insts[tid].front(); 6152292SN/A 6162292SN/A insts[tid].pop(); 6172292SN/A 6182292SN/A DPRINTF(Decode,"[tid:%i]: Inserting [sn:%lli] PC:%#x into " 6192292SN/A "dispatch skidBuffer %i\n",tid, inst->seqNum, 6202292SN/A inst->readPC(),tid); 6212292SN/A 6222292SN/A skidBuffer[tid].push(inst); 6232292SN/A } 6242292SN/A 6252292SN/A assert(skidBuffer[tid].size() <= skidBufferMax && 6262292SN/A "Skidbuffer Exceeded Max Size"); 6272292SN/A} 6282292SN/A 6292292SN/Atemplate<class Impl> 6302292SN/Aint 6312292SN/ADefaultIEW<Impl>::skidCount() 6322292SN/A{ 6332292SN/A int max=0; 6342292SN/A 6356221Snate@binkert.org list<ThreadID>::iterator threads = activeThreads->begin(); 6366221Snate@binkert.org list<ThreadID>::iterator end = activeThreads->end(); 6372292SN/A 6383867Sbinkertn@umich.edu while (threads != end) { 6396221Snate@binkert.org ThreadID tid = *threads++; 6403867Sbinkertn@umich.edu unsigned thread_count = skidBuffer[tid].size(); 6412292SN/A if (max < thread_count) 6422292SN/A max = thread_count; 6432292SN/A } 6442292SN/A 6452292SN/A return max; 6462292SN/A} 6472292SN/A 6482292SN/Atemplate<class Impl> 6492292SN/Abool 6502292SN/ADefaultIEW<Impl>::skidsEmpty() 6512292SN/A{ 6526221Snate@binkert.org list<ThreadID>::iterator threads = activeThreads->begin(); 6536221Snate@binkert.org list<ThreadID>::iterator end = activeThreads->end(); 6542292SN/A 6553867Sbinkertn@umich.edu while (threads != end) { 6566221Snate@binkert.org ThreadID tid = *threads++; 6573867Sbinkertn@umich.edu 6583867Sbinkertn@umich.edu if (!skidBuffer[tid].empty()) 6592292SN/A return false; 6602292SN/A } 6612292SN/A 6622292SN/A return true; 6631062SN/A} 6641062SN/A 6651681SN/Atemplate <class Impl> 6661062SN/Avoid 6672292SN/ADefaultIEW<Impl>::updateStatus() 6681062SN/A{ 6692292SN/A bool any_unblocking = false; 6701062SN/A 6716221Snate@binkert.org list<ThreadID>::iterator threads = activeThreads->begin(); 6726221Snate@binkert.org list<ThreadID>::iterator end = activeThreads->end(); 6731062SN/A 6743867Sbinkertn@umich.edu while (threads != end) { 6756221Snate@binkert.org ThreadID tid = *threads++; 6761062SN/A 6772292SN/A if (dispatchStatus[tid] == Unblocking) { 6782292SN/A any_unblocking = true; 6792292SN/A break; 6802292SN/A } 6812292SN/A } 6821062SN/A 6832292SN/A // If there are no ready instructions waiting to be scheduled by the IQ, 6842292SN/A // and there's no stores waiting to write back, and dispatch is not 6852292SN/A // unblocking, then there is no internal activity for the IEW stage. 6862292SN/A if (_status == Active && !instQueue.hasReadyInsts() && 6872292SN/A !ldstQueue.willWB() && !any_unblocking) { 6882292SN/A DPRINTF(IEW, "IEW switching to idle\n"); 6891062SN/A 6902292SN/A deactivateStage(); 6911062SN/A 6922292SN/A _status = Inactive; 6932292SN/A } else if (_status == Inactive && (instQueue.hasReadyInsts() || 6942292SN/A ldstQueue.willWB() || 6952292SN/A any_unblocking)) { 6962292SN/A // Otherwise there is internal activity. Set to active. 6972292SN/A DPRINTF(IEW, "IEW switching to active\n"); 6981062SN/A 6992292SN/A activateStage(); 7001062SN/A 7012292SN/A _status = Active; 7021062SN/A } 7031062SN/A} 7041062SN/A 7051681SN/Atemplate <class Impl> 7061062SN/Avoid 7072292SN/ADefaultIEW<Impl>::resetEntries() 7081062SN/A{ 7092292SN/A instQueue.resetEntries(); 7102292SN/A ldstQueue.resetEntries(); 7112292SN/A} 7121062SN/A 7132292SN/Atemplate <class Impl> 7142292SN/Avoid 7156221Snate@binkert.orgDefaultIEW<Impl>::readStallSignals(ThreadID tid) 7162292SN/A{ 7172292SN/A if (fromCommit->commitBlock[tid]) { 7182292SN/A stalls[tid].commit = true; 7192292SN/A } 7201062SN/A 7212292SN/A if (fromCommit->commitUnblock[tid]) { 7222292SN/A assert(stalls[tid].commit); 7232292SN/A stalls[tid].commit = false; 7242292SN/A } 7252292SN/A} 7262292SN/A 7272292SN/Atemplate <class Impl> 7282292SN/Abool 7296221Snate@binkert.orgDefaultIEW<Impl>::checkStall(ThreadID tid) 7302292SN/A{ 7312292SN/A bool ret_val(false); 7322292SN/A 7332292SN/A if (stalls[tid].commit) { 7342292SN/A DPRINTF(IEW,"[tid:%i]: Stall from Commit stage detected.\n",tid); 7352292SN/A ret_val = true; 7362292SN/A } else if (instQueue.isFull(tid)) { 7372292SN/A DPRINTF(IEW,"[tid:%i]: Stall: IQ is full.\n",tid); 7382292SN/A ret_val = true; 7392292SN/A } else if (ldstQueue.isFull(tid)) { 7402292SN/A DPRINTF(IEW,"[tid:%i]: Stall: LSQ is full\n",tid); 7412292SN/A 7422292SN/A if (ldstQueue.numLoads(tid) > 0 ) { 7432292SN/A 7442292SN/A DPRINTF(IEW,"[tid:%i]: LSQ oldest load: [sn:%i] \n", 7452292SN/A tid,ldstQueue.getLoadHeadSeqNum(tid)); 7462292SN/A } 7472292SN/A 7482292SN/A if (ldstQueue.numStores(tid) > 0) { 7492292SN/A 7502292SN/A DPRINTF(IEW,"[tid:%i]: LSQ oldest store: [sn:%i] \n", 7512292SN/A tid,ldstQueue.getStoreHeadSeqNum(tid)); 7522292SN/A } 7532292SN/A 7542292SN/A ret_val = true; 7552292SN/A } else if (ldstQueue.isStalled(tid)) { 7562292SN/A DPRINTF(IEW,"[tid:%i]: Stall: LSQ stall detected.\n",tid); 7572292SN/A ret_val = true; 7582292SN/A } 7592292SN/A 7602292SN/A return ret_val; 7612292SN/A} 7622292SN/A 7632292SN/Atemplate <class Impl> 7642292SN/Avoid 7656221Snate@binkert.orgDefaultIEW<Impl>::checkSignalsAndUpdate(ThreadID tid) 7662292SN/A{ 7672292SN/A // Check if there's a squash signal, squash if there is 7682292SN/A // Check stall signals, block if there is. 7692292SN/A // If status was Blocked 7702292SN/A // if so then go to unblocking 7712292SN/A // If status was Squashing 7722292SN/A // check if squashing is not high. Switch to running this cycle. 7732292SN/A 7742292SN/A readStallSignals(tid); 7752292SN/A 7762292SN/A if (fromCommit->commitInfo[tid].squash) { 7772292SN/A squash(tid); 7782292SN/A 7792292SN/A if (dispatchStatus[tid] == Blocked || 7802292SN/A dispatchStatus[tid] == Unblocking) { 7812292SN/A toRename->iewUnblock[tid] = true; 7822292SN/A wroteToTimeBuffer = true; 7832292SN/A } 7842292SN/A 7852292SN/A dispatchStatus[tid] = Squashing; 7862292SN/A 7872292SN/A fetchRedirect[tid] = false; 7882292SN/A return; 7892292SN/A } 7902292SN/A 7912292SN/A if (fromCommit->commitInfo[tid].robSquashing) { 7922702Sktlim@umich.edu DPRINTF(IEW, "[tid:%i]: ROB is still squashing.\n", tid); 7932292SN/A 7942292SN/A dispatchStatus[tid] = Squashing; 7952292SN/A 7962702Sktlim@umich.edu emptyRenameInsts(tid); 7972702Sktlim@umich.edu wroteToTimeBuffer = true; 7982292SN/A return; 7992292SN/A } 8002292SN/A 8012292SN/A if (checkStall(tid)) { 8022292SN/A block(tid); 8032292SN/A dispatchStatus[tid] = Blocked; 8042292SN/A return; 8052292SN/A } 8062292SN/A 8072292SN/A if (dispatchStatus[tid] == Blocked) { 8082292SN/A // Status from previous cycle was blocked, but there are no more stall 8092292SN/A // conditions. Switch over to unblocking. 8102292SN/A DPRINTF(IEW, "[tid:%i]: Done blocking, switching to unblocking.\n", 8112292SN/A tid); 8122292SN/A 8132292SN/A dispatchStatus[tid] = Unblocking; 8142292SN/A 8152292SN/A unblock(tid); 8162292SN/A 8172292SN/A return; 8182292SN/A } 8192292SN/A 8202292SN/A if (dispatchStatus[tid] == Squashing) { 8212292SN/A // Switch status to running if rename isn't being told to block or 8222292SN/A // squash this cycle. 8232292SN/A DPRINTF(IEW, "[tid:%i]: Done squashing, switching to running.\n", 8242292SN/A tid); 8252292SN/A 8262292SN/A dispatchStatus[tid] = Running; 8272292SN/A 8282292SN/A return; 8292292SN/A } 8302292SN/A} 8312292SN/A 8322292SN/Atemplate <class Impl> 8332292SN/Avoid 8342292SN/ADefaultIEW<Impl>::sortInsts() 8352292SN/A{ 8362292SN/A int insts_from_rename = fromRename->size; 8372326SN/A#ifdef DEBUG 8386221Snate@binkert.org for (ThreadID tid = 0; tid < numThreads; tid++) 8396221Snate@binkert.org assert(insts[tid].empty()); 8402326SN/A#endif 8412292SN/A for (int i = 0; i < insts_from_rename; ++i) { 8422292SN/A insts[fromRename->insts[i]->threadNumber].push(fromRename->insts[i]); 8432292SN/A } 8442292SN/A} 8452292SN/A 8462292SN/Atemplate <class Impl> 8472292SN/Avoid 8486221Snate@binkert.orgDefaultIEW<Impl>::emptyRenameInsts(ThreadID tid) 8492702Sktlim@umich.edu{ 8504632Sgblack@eecs.umich.edu DPRINTF(IEW, "[tid:%i]: Removing incoming rename instructions\n", tid); 8512935Sksewell@umich.edu 8522702Sktlim@umich.edu while (!insts[tid].empty()) { 8532935Sksewell@umich.edu 8542702Sktlim@umich.edu if (insts[tid].front()->isLoad() || 8552702Sktlim@umich.edu insts[tid].front()->isStore() ) { 8562702Sktlim@umich.edu toRename->iewInfo[tid].dispatchedToLSQ++; 8572702Sktlim@umich.edu } 8582702Sktlim@umich.edu 8592702Sktlim@umich.edu toRename->iewInfo[tid].dispatched++; 8602702Sktlim@umich.edu 8612702Sktlim@umich.edu insts[tid].pop(); 8622702Sktlim@umich.edu } 8632702Sktlim@umich.edu} 8642702Sktlim@umich.edu 8652702Sktlim@umich.edutemplate <class Impl> 8662702Sktlim@umich.eduvoid 8672292SN/ADefaultIEW<Impl>::wakeCPU() 8682292SN/A{ 8692292SN/A cpu->wakeCPU(); 8702292SN/A} 8712292SN/A 8722292SN/Atemplate <class Impl> 8732292SN/Avoid 8742292SN/ADefaultIEW<Impl>::activityThisCycle() 8752292SN/A{ 8762292SN/A DPRINTF(Activity, "Activity this cycle.\n"); 8772292SN/A cpu->activityThisCycle(); 8782292SN/A} 8792292SN/A 8802292SN/Atemplate <class Impl> 8812292SN/Ainline void 8822292SN/ADefaultIEW<Impl>::activateStage() 8832292SN/A{ 8842292SN/A DPRINTF(Activity, "Activating stage.\n"); 8852733Sktlim@umich.edu cpu->activateStage(O3CPU::IEWIdx); 8862292SN/A} 8872292SN/A 8882292SN/Atemplate <class Impl> 8892292SN/Ainline void 8902292SN/ADefaultIEW<Impl>::deactivateStage() 8912292SN/A{ 8922292SN/A DPRINTF(Activity, "Deactivating stage.\n"); 8932733Sktlim@umich.edu cpu->deactivateStage(O3CPU::IEWIdx); 8942292SN/A} 8952292SN/A 8962292SN/Atemplate<class Impl> 8972292SN/Avoid 8986221Snate@binkert.orgDefaultIEW<Impl>::dispatch(ThreadID tid) 8992292SN/A{ 9002292SN/A // If status is Running or idle, 9012292SN/A // call dispatchInsts() 9022292SN/A // If status is Unblocking, 9032292SN/A // buffer any instructions coming from rename 9042292SN/A // continue trying to empty skid buffer 9052292SN/A // check if stall conditions have passed 9062292SN/A 9072292SN/A if (dispatchStatus[tid] == Blocked) { 9082292SN/A ++iewBlockCycles; 9092292SN/A 9102292SN/A } else if (dispatchStatus[tid] == Squashing) { 9112292SN/A ++iewSquashCycles; 9122292SN/A } 9132292SN/A 9142292SN/A // Dispatch should try to dispatch as many instructions as its bandwidth 9152292SN/A // will allow, as long as it is not currently blocked. 9162292SN/A if (dispatchStatus[tid] == Running || 9172292SN/A dispatchStatus[tid] == Idle) { 9182292SN/A DPRINTF(IEW, "[tid:%i] Not blocked, so attempting to run " 9192292SN/A "dispatch.\n", tid); 9202292SN/A 9212292SN/A dispatchInsts(tid); 9222292SN/A } else if (dispatchStatus[tid] == Unblocking) { 9232292SN/A // Make sure that the skid buffer has something in it if the 9242292SN/A // status is unblocking. 9252292SN/A assert(!skidsEmpty()); 9262292SN/A 9272292SN/A // If the status was unblocking, then instructions from the skid 9282292SN/A // buffer were used. Remove those instructions and handle 9292292SN/A // the rest of unblocking. 9302292SN/A dispatchInsts(tid); 9312292SN/A 9322292SN/A ++iewUnblockCycles; 9332292SN/A 9345215Sgblack@eecs.umich.edu if (validInstsFromRename()) { 9352292SN/A // Add the current inputs to the skid buffer so they can be 9362292SN/A // reprocessed when this stage unblocks. 9372292SN/A skidInsert(tid); 9382292SN/A } 9392292SN/A 9402292SN/A unblock(tid); 9412292SN/A } 9422292SN/A} 9432292SN/A 9442292SN/Atemplate <class Impl> 9452292SN/Avoid 9466221Snate@binkert.orgDefaultIEW<Impl>::dispatchInsts(ThreadID tid) 9472292SN/A{ 9482292SN/A // Obtain instructions from skid buffer if unblocking, or queue from rename 9492292SN/A // otherwise. 9502292SN/A std::queue<DynInstPtr> &insts_to_dispatch = 9512292SN/A dispatchStatus[tid] == Unblocking ? 9522292SN/A skidBuffer[tid] : insts[tid]; 9532292SN/A 9542292SN/A int insts_to_add = insts_to_dispatch.size(); 9552292SN/A 9562292SN/A DynInstPtr inst; 9572292SN/A bool add_to_iq = false; 9582292SN/A int dis_num_inst = 0; 9592292SN/A 9602292SN/A // Loop through the instructions, putting them in the instruction 9612292SN/A // queue. 9622292SN/A for ( ; dis_num_inst < insts_to_add && 9632820Sktlim@umich.edu dis_num_inst < dispatchWidth; 9642292SN/A ++dis_num_inst) 9652292SN/A { 9662292SN/A inst = insts_to_dispatch.front(); 9672292SN/A 9682292SN/A if (dispatchStatus[tid] == Unblocking) { 9692292SN/A DPRINTF(IEW, "[tid:%i]: Issue: Examining instruction from skid " 9702292SN/A "buffer\n", tid); 9712292SN/A } 9722292SN/A 9732292SN/A // Make sure there's a valid instruction there. 9742292SN/A assert(inst); 9752292SN/A 9762292SN/A DPRINTF(IEW, "[tid:%i]: Issue: Adding PC %#x [sn:%lli] [tid:%i] to " 9772292SN/A "IQ.\n", 9782292SN/A tid, inst->readPC(), inst->seqNum, inst->threadNumber); 9792292SN/A 9802292SN/A // Be sure to mark these instructions as ready so that the 9812292SN/A // commit stage can go ahead and execute them, and mark 9822292SN/A // them as issued so the IQ doesn't reprocess them. 9832292SN/A 9842292SN/A // Check for squashed instructions. 9852292SN/A if (inst->isSquashed()) { 9862292SN/A DPRINTF(IEW, "[tid:%i]: Issue: Squashed instruction encountered, " 9872292SN/A "not adding to IQ.\n", tid); 9882292SN/A 9892292SN/A ++iewDispSquashedInsts; 9902292SN/A 9912292SN/A insts_to_dispatch.pop(); 9922292SN/A 9932292SN/A //Tell Rename That An Instruction has been processed 9942292SN/A if (inst->isLoad() || inst->isStore()) { 9952292SN/A toRename->iewInfo[tid].dispatchedToLSQ++; 9962292SN/A } 9972292SN/A toRename->iewInfo[tid].dispatched++; 9982292SN/A 9992292SN/A continue; 10002292SN/A } 10012292SN/A 10022292SN/A // Check for full conditions. 10032292SN/A if (instQueue.isFull(tid)) { 10042292SN/A DPRINTF(IEW, "[tid:%i]: Issue: IQ has become full.\n", tid); 10052292SN/A 10062292SN/A // Call function to start blocking. 10072292SN/A block(tid); 10082292SN/A 10092292SN/A // Set unblock to false. Special case where we are using 10102292SN/A // skidbuffer (unblocking) instructions but then we still 10112292SN/A // get full in the IQ. 10122292SN/A toRename->iewUnblock[tid] = false; 10132292SN/A 10142292SN/A ++iewIQFullEvents; 10152292SN/A break; 10162292SN/A } else if (ldstQueue.isFull(tid)) { 10172292SN/A DPRINTF(IEW, "[tid:%i]: Issue: LSQ has become full.\n",tid); 10182292SN/A 10192292SN/A // Call function to start blocking. 10202292SN/A block(tid); 10212292SN/A 10222292SN/A // Set unblock to false. Special case where we are using 10232292SN/A // skidbuffer (unblocking) instructions but then we still 10242292SN/A // get full in the IQ. 10252292SN/A toRename->iewUnblock[tid] = false; 10262292SN/A 10272292SN/A ++iewLSQFullEvents; 10282292SN/A break; 10292292SN/A } 10302292SN/A 10312292SN/A // Otherwise issue the instruction just fine. 10322292SN/A if (inst->isLoad()) { 10332292SN/A DPRINTF(IEW, "[tid:%i]: Issue: Memory instruction " 10342292SN/A "encountered, adding to LSQ.\n", tid); 10352292SN/A 10362292SN/A // Reserve a spot in the load store queue for this 10372292SN/A // memory access. 10382292SN/A ldstQueue.insertLoad(inst); 10392292SN/A 10402292SN/A ++iewDispLoadInsts; 10412292SN/A 10422292SN/A add_to_iq = true; 10432292SN/A 10442292SN/A toRename->iewInfo[tid].dispatchedToLSQ++; 10452292SN/A } else if (inst->isStore()) { 10462292SN/A DPRINTF(IEW, "[tid:%i]: Issue: Memory instruction " 10472292SN/A "encountered, adding to LSQ.\n", tid); 10482292SN/A 10492292SN/A ldstQueue.insertStore(inst); 10502292SN/A 10512292SN/A ++iewDispStoreInsts; 10522292SN/A 10532336SN/A if (inst->isStoreConditional()) { 10542336SN/A // Store conditionals need to be set as "canCommit()" 10552336SN/A // so that commit can process them when they reach the 10562336SN/A // head of commit. 10572348SN/A // @todo: This is somewhat specific to Alpha. 10582292SN/A inst->setCanCommit(); 10592292SN/A instQueue.insertNonSpec(inst); 10602292SN/A add_to_iq = false; 10612292SN/A 10622292SN/A ++iewDispNonSpecInsts; 10632292SN/A } else { 10642292SN/A add_to_iq = true; 10652292SN/A } 10662292SN/A 10672292SN/A toRename->iewInfo[tid].dispatchedToLSQ++; 10682292SN/A } else if (inst->isMemBarrier() || inst->isWriteBarrier()) { 10692326SN/A // Same as non-speculative stores. 10702292SN/A inst->setCanCommit(); 10712292SN/A instQueue.insertBarrier(inst); 10722292SN/A add_to_iq = false; 10732292SN/A } else if (inst->isNop()) { 10742292SN/A DPRINTF(IEW, "[tid:%i]: Issue: Nop instruction encountered, " 10752292SN/A "skipping.\n", tid); 10762292SN/A 10772292SN/A inst->setIssued(); 10782292SN/A inst->setExecuted(); 10792292SN/A inst->setCanCommit(); 10802292SN/A 10812326SN/A instQueue.recordProducer(inst); 10822292SN/A 10832727Sktlim@umich.edu iewExecutedNop[tid]++; 10842301SN/A 10852292SN/A add_to_iq = false; 10862292SN/A } else if (inst->isExecuted()) { 10872292SN/A assert(0 && "Instruction shouldn't be executed.\n"); 10882292SN/A DPRINTF(IEW, "Issue: Executed branch encountered, " 10892292SN/A "skipping.\n"); 10902292SN/A 10912292SN/A inst->setIssued(); 10922292SN/A inst->setCanCommit(); 10932292SN/A 10942326SN/A instQueue.recordProducer(inst); 10952292SN/A 10962292SN/A add_to_iq = false; 10972292SN/A } else { 10982292SN/A add_to_iq = true; 10992292SN/A } 11004033Sktlim@umich.edu if (inst->isNonSpeculative()) { 11014033Sktlim@umich.edu DPRINTF(IEW, "[tid:%i]: Issue: Nonspeculative instruction " 11024033Sktlim@umich.edu "encountered, skipping.\n", tid); 11034033Sktlim@umich.edu 11044033Sktlim@umich.edu // Same as non-speculative stores. 11054033Sktlim@umich.edu inst->setCanCommit(); 11064033Sktlim@umich.edu 11074033Sktlim@umich.edu // Specifically insert it as nonspeculative. 11084033Sktlim@umich.edu instQueue.insertNonSpec(inst); 11094033Sktlim@umich.edu 11104033Sktlim@umich.edu ++iewDispNonSpecInsts; 11114033Sktlim@umich.edu 11124033Sktlim@umich.edu add_to_iq = false; 11134033Sktlim@umich.edu } 11142292SN/A 11152292SN/A // If the instruction queue is not full, then add the 11162292SN/A // instruction. 11172292SN/A if (add_to_iq) { 11182292SN/A instQueue.insert(inst); 11192292SN/A } 11202292SN/A 11212292SN/A insts_to_dispatch.pop(); 11222292SN/A 11232292SN/A toRename->iewInfo[tid].dispatched++; 11242292SN/A 11252292SN/A ++iewDispatchedInsts; 11262292SN/A } 11272292SN/A 11282292SN/A if (!insts_to_dispatch.empty()) { 11292935Sksewell@umich.edu DPRINTF(IEW,"[tid:%i]: Issue: Bandwidth Full. Blocking.\n", tid); 11302292SN/A block(tid); 11312292SN/A toRename->iewUnblock[tid] = false; 11322292SN/A } 11332292SN/A 11342292SN/A if (dispatchStatus[tid] == Idle && dis_num_inst) { 11352292SN/A dispatchStatus[tid] = Running; 11362292SN/A 11372292SN/A updatedQueues = true; 11382292SN/A } 11392292SN/A 11402292SN/A dis_num_inst = 0; 11412292SN/A} 11422292SN/A 11432292SN/Atemplate <class Impl> 11442292SN/Avoid 11452292SN/ADefaultIEW<Impl>::printAvailableInsts() 11462292SN/A{ 11472292SN/A int inst = 0; 11482292SN/A 11492980Sgblack@eecs.umich.edu std::cout << "Available Instructions: "; 11502292SN/A 11512292SN/A while (fromIssue->insts[inst]) { 11522292SN/A 11532980Sgblack@eecs.umich.edu if (inst%3==0) std::cout << "\n\t"; 11542292SN/A 11552980Sgblack@eecs.umich.edu std::cout << "PC: " << fromIssue->insts[inst]->readPC() 11562292SN/A << " TN: " << fromIssue->insts[inst]->threadNumber 11572292SN/A << " SN: " << fromIssue->insts[inst]->seqNum << " | "; 11582292SN/A 11592292SN/A inst++; 11602292SN/A 11612292SN/A } 11622292SN/A 11632980Sgblack@eecs.umich.edu std::cout << "\n"; 11642292SN/A} 11652292SN/A 11662292SN/Atemplate <class Impl> 11672292SN/Avoid 11682292SN/ADefaultIEW<Impl>::executeInsts() 11692292SN/A{ 11702292SN/A wbNumInst = 0; 11712292SN/A wbCycle = 0; 11722292SN/A 11736221Snate@binkert.org list<ThreadID>::iterator threads = activeThreads->begin(); 11746221Snate@binkert.org list<ThreadID>::iterator end = activeThreads->end(); 11752292SN/A 11763867Sbinkertn@umich.edu while (threads != end) { 11776221Snate@binkert.org ThreadID tid = *threads++; 11782292SN/A fetchRedirect[tid] = false; 11792292SN/A } 11802292SN/A 11812698Sktlim@umich.edu // Uncomment this if you want to see all available instructions. 11822698Sktlim@umich.edu// printAvailableInsts(); 11831062SN/A 11841062SN/A // Execute/writeback any instructions that are available. 11852333SN/A int insts_to_execute = fromIssue->size; 11862292SN/A int inst_num = 0; 11872333SN/A for (; inst_num < insts_to_execute; 11882326SN/A ++inst_num) { 11891062SN/A 11902292SN/A DPRINTF(IEW, "Execute: Executing instructions from IQ.\n"); 11911062SN/A 11922333SN/A DynInstPtr inst = instQueue.getInstToExecute(); 11931062SN/A 11942292SN/A DPRINTF(IEW, "Execute: Processing PC %#x, [tid:%i] [sn:%i].\n", 11952292SN/A inst->readPC(), inst->threadNumber,inst->seqNum); 11961062SN/A 11971062SN/A // Check if the instruction is squashed; if so then skip it 11981062SN/A if (inst->isSquashed()) { 11992292SN/A DPRINTF(IEW, "Execute: Instruction was squashed.\n"); 12001062SN/A 12011062SN/A // Consider this instruction executed so that commit can go 12021062SN/A // ahead and retire the instruction. 12031062SN/A inst->setExecuted(); 12041062SN/A 12052292SN/A // Not sure if I should set this here or just let commit try to 12062292SN/A // commit any squashed instructions. I like the latter a bit more. 12072292SN/A inst->setCanCommit(); 12081062SN/A 12091062SN/A ++iewExecSquashedInsts; 12101062SN/A 12112820Sktlim@umich.edu decrWb(inst->seqNum); 12121062SN/A continue; 12131062SN/A } 12141062SN/A 12152292SN/A Fault fault = NoFault; 12161062SN/A 12171062SN/A // Execute instruction. 12181062SN/A // Note that if the instruction faults, it will be handled 12191062SN/A // at the commit stage. 12202292SN/A if (inst->isMemRef() && 12212292SN/A (!inst->isDataPrefetch() && !inst->isInstPrefetch())) { 12222292SN/A DPRINTF(IEW, "Execute: Calculating address for memory " 12231062SN/A "reference.\n"); 12241062SN/A 12251062SN/A // Tell the LDSTQ to execute this instruction (if it is a load). 12261062SN/A if (inst->isLoad()) { 12272292SN/A // Loads will mark themselves as executed, and their writeback 12282292SN/A // event adds the instruction to the queue to commit 12292292SN/A fault = ldstQueue.executeLoad(inst); 12301062SN/A } else if (inst->isStore()) { 12312367SN/A fault = ldstQueue.executeStore(inst); 12321062SN/A 12332292SN/A // If the store had a fault then it may not have a mem req 12342367SN/A if (!inst->isStoreConditional() && fault == NoFault) { 12352292SN/A inst->setExecuted(); 12362292SN/A 12372292SN/A instToCommit(inst); 12382367SN/A } else if (fault != NoFault) { 12392367SN/A // If the instruction faulted, then we need to send it along to commit 12402367SN/A // without the instruction completing. 12413732Sktlim@umich.edu DPRINTF(IEW, "Store has fault %s! [sn:%lli]\n", 12423732Sktlim@umich.edu fault->name(), inst->seqNum); 12432367SN/A 12442367SN/A // Send this instruction to commit, also make sure iew stage 12452367SN/A // realizes there is activity. 12462367SN/A inst->setExecuted(); 12472367SN/A 12482367SN/A instToCommit(inst); 12492367SN/A activityThisCycle(); 12502292SN/A } 12512326SN/A 12522326SN/A // Store conditionals will mark themselves as 12532326SN/A // executed, and their writeback event will add the 12542326SN/A // instruction to the queue to commit. 12551062SN/A } else { 12562292SN/A panic("Unexpected memory type!\n"); 12571062SN/A } 12581062SN/A 12591062SN/A } else { 12601062SN/A inst->execute(); 12611062SN/A 12622292SN/A inst->setExecuted(); 12632292SN/A 12642292SN/A instToCommit(inst); 12651062SN/A } 12661062SN/A 12672301SN/A updateExeInstStats(inst); 12681681SN/A 12692326SN/A // Check if branch prediction was correct, if not then we need 12702326SN/A // to tell commit to squash in flight instructions. Only 12712326SN/A // handle this if there hasn't already been something that 12722107SN/A // redirects fetch in this group of instructions. 12731681SN/A 12742292SN/A // This probably needs to prioritize the redirects if a different 12752292SN/A // scheduler is used. Currently the scheduler schedules the oldest 12762292SN/A // instruction first, so the branch resolution order will be correct. 12776221Snate@binkert.org ThreadID tid = inst->threadNumber; 12781062SN/A 12793732Sktlim@umich.edu if (!fetchRedirect[tid] || 12803732Sktlim@umich.edu toCommit->squashedSeqNum[tid] > inst->seqNum) { 12811062SN/A 12821062SN/A if (inst->mispredicted()) { 12832292SN/A fetchRedirect[tid] = true; 12841062SN/A 12852292SN/A DPRINTF(IEW, "Execute: Branch mispredict detected.\n"); 12866036Sksewell@umich.edu DPRINTF(IEW, "Predicted target was PC:%#x, NPC:%#x.\n", 12873969Sgblack@eecs.umich.edu inst->readPredPC(), inst->readPredNPC()); 12883969Sgblack@eecs.umich.edu DPRINTF(IEW, "Execute: Redirecting fetch to PC: %#x," 12893969Sgblack@eecs.umich.edu " NPC: %#x.\n", inst->readNextPC(), 12903969Sgblack@eecs.umich.edu inst->readNextNPC()); 12911062SN/A // If incorrect, then signal the ROB that it must be squashed. 12922292SN/A squashDueToBranch(inst, tid); 12931062SN/A 12943795Sgblack@eecs.umich.edu if (inst->readPredTaken()) { 12951062SN/A predictedTakenIncorrect++; 12962292SN/A } else { 12972292SN/A predictedNotTakenIncorrect++; 12981062SN/A } 12992292SN/A } else if (ldstQueue.violation(tid)) { 13004033Sktlim@umich.edu assert(inst->isMemRef()); 13012326SN/A // If there was an ordering violation, then get the 13022326SN/A // DynInst that caused the violation. Note that this 13032292SN/A // clears the violation signal. 13042292SN/A DynInstPtr violator; 13052292SN/A violator = ldstQueue.getMemDepViolator(tid); 13061062SN/A 13072292SN/A DPRINTF(IEW, "LDSTQ detected a violation. Violator PC: " 13081062SN/A "%#x, inst PC: %#x. Addr is: %#x.\n", 13091062SN/A violator->readPC(), inst->readPC(), inst->physEffAddr); 13101062SN/A 13113732Sktlim@umich.edu // Ensure the violating instruction is older than 13123732Sktlim@umich.edu // current squash 13134033Sktlim@umich.edu/* if (fetchRedirect[tid] && 13144033Sktlim@umich.edu violator->seqNum >= toCommit->squashedSeqNum[tid] + 1) 13153732Sktlim@umich.edu continue; 13164033Sktlim@umich.edu*/ 13173732Sktlim@umich.edu fetchRedirect[tid] = true; 13183732Sktlim@umich.edu 13191062SN/A // Tell the instruction queue that a violation has occured. 13201062SN/A instQueue.violation(inst, violator); 13211062SN/A 13221062SN/A // Squash. 13232292SN/A squashDueToMemOrder(inst,tid); 13241062SN/A 13251062SN/A ++memOrderViolationEvents; 13262292SN/A } else if (ldstQueue.loadBlocked(tid) && 13272292SN/A !ldstQueue.isLoadBlockedHandled(tid)) { 13282292SN/A fetchRedirect[tid] = true; 13292292SN/A 13302292SN/A DPRINTF(IEW, "Load operation couldn't execute because the " 13312292SN/A "memory system is blocked. PC: %#x [sn:%lli]\n", 13322292SN/A inst->readPC(), inst->seqNum); 13332292SN/A 13342292SN/A squashDueToMemBlocked(inst, tid); 13351062SN/A } 13364033Sktlim@umich.edu } else { 13374033Sktlim@umich.edu // Reset any state associated with redirects that will not 13384033Sktlim@umich.edu // be used. 13394033Sktlim@umich.edu if (ldstQueue.violation(tid)) { 13404033Sktlim@umich.edu assert(inst->isMemRef()); 13414033Sktlim@umich.edu 13424033Sktlim@umich.edu DynInstPtr violator = ldstQueue.getMemDepViolator(tid); 13434033Sktlim@umich.edu 13444033Sktlim@umich.edu DPRINTF(IEW, "LDSTQ detected a violation. Violator PC: " 13454033Sktlim@umich.edu "%#x, inst PC: %#x. Addr is: %#x.\n", 13464033Sktlim@umich.edu violator->readPC(), inst->readPC(), inst->physEffAddr); 13474033Sktlim@umich.edu DPRINTF(IEW, "Violation will not be handled because " 13484033Sktlim@umich.edu "already squashing\n"); 13494033Sktlim@umich.edu 13504033Sktlim@umich.edu ++memOrderViolationEvents; 13514033Sktlim@umich.edu } 13524033Sktlim@umich.edu if (ldstQueue.loadBlocked(tid) && 13534033Sktlim@umich.edu !ldstQueue.isLoadBlockedHandled(tid)) { 13544033Sktlim@umich.edu DPRINTF(IEW, "Load operation couldn't execute because the " 13554033Sktlim@umich.edu "memory system is blocked. PC: %#x [sn:%lli]\n", 13564033Sktlim@umich.edu inst->readPC(), inst->seqNum); 13574033Sktlim@umich.edu DPRINTF(IEW, "Blocked load will not be handled because " 13584033Sktlim@umich.edu "already squashing\n"); 13594033Sktlim@umich.edu 13604033Sktlim@umich.edu ldstQueue.setLoadBlockedHandled(tid); 13614033Sktlim@umich.edu } 13624033Sktlim@umich.edu 13631062SN/A } 13641062SN/A } 13652292SN/A 13662348SN/A // Update and record activity if we processed any instructions. 13672292SN/A if (inst_num) { 13682292SN/A if (exeStatus == Idle) { 13692292SN/A exeStatus = Running; 13702292SN/A } 13712292SN/A 13722292SN/A updatedQueues = true; 13732292SN/A 13742292SN/A cpu->activityThisCycle(); 13752292SN/A } 13762292SN/A 13772292SN/A // Need to reset this in case a writeback event needs to write into the 13782292SN/A // iew queue. That way the writeback event will write into the correct 13792292SN/A // spot in the queue. 13802292SN/A wbNumInst = 0; 13812107SN/A} 13822107SN/A 13832292SN/Atemplate <class Impl> 13842107SN/Avoid 13852292SN/ADefaultIEW<Impl>::writebackInsts() 13862107SN/A{ 13872326SN/A // Loop through the head of the time buffer and wake any 13882326SN/A // dependents. These instructions are about to write back. Also 13892326SN/A // mark scoreboard that this instruction is finally complete. 13902326SN/A // Either have IEW have direct access to scoreboard, or have this 13912326SN/A // as part of backwards communication. 13923958Sgblack@eecs.umich.edu for (int inst_num = 0; inst_num < wbWidth && 13932292SN/A toCommit->insts[inst_num]; inst_num++) { 13942107SN/A DynInstPtr inst = toCommit->insts[inst_num]; 13956221Snate@binkert.org ThreadID tid = inst->threadNumber; 13962107SN/A 13972698Sktlim@umich.edu DPRINTF(IEW, "Sending instructions to commit, [sn:%lli] PC %#x.\n", 13982698Sktlim@umich.edu inst->seqNum, inst->readPC()); 13992107SN/A 14002301SN/A iewInstsToCommit[tid]++; 14012301SN/A 14022292SN/A // Some instructions will be sent to commit without having 14032292SN/A // executed because they need commit to handle them. 14042292SN/A // E.g. Uncached loads have not actually executed when they 14052292SN/A // are first sent to commit. Instead commit must tell the LSQ 14062292SN/A // when it's ready to execute the uncached load. 14072367SN/A if (!inst->isSquashed() && inst->isExecuted() && inst->getFault() == NoFault) { 14082301SN/A int dependents = instQueue.wakeDependents(inst); 14092107SN/A 14102292SN/A for (int i = 0; i < inst->numDestRegs(); i++) { 14112292SN/A //mark as Ready 14122292SN/A DPRINTF(IEW,"Setting Destination Register %i\n", 14132292SN/A inst->renamedDestRegIdx(i)); 14142292SN/A scoreboard->setReg(inst->renamedDestRegIdx(i)); 14152107SN/A } 14162301SN/A 14172348SN/A if (dependents) { 14182348SN/A producerInst[tid]++; 14192348SN/A consumerInst[tid]+= dependents; 14202348SN/A } 14212326SN/A writebackCount[tid]++; 14222107SN/A } 14232820Sktlim@umich.edu 14242820Sktlim@umich.edu decrWb(inst->seqNum); 14252107SN/A } 14261060SN/A} 14271060SN/A 14281681SN/Atemplate<class Impl> 14291060SN/Avoid 14302292SN/ADefaultIEW<Impl>::tick() 14311060SN/A{ 14322292SN/A wbNumInst = 0; 14332292SN/A wbCycle = 0; 14341060SN/A 14352292SN/A wroteToTimeBuffer = false; 14362292SN/A updatedQueues = false; 14371060SN/A 14382292SN/A sortInsts(); 14391060SN/A 14402326SN/A // Free function units marked as being freed this cycle. 14412326SN/A fuPool->processFreeUnits(); 14421062SN/A 14436221Snate@binkert.org list<ThreadID>::iterator threads = activeThreads->begin(); 14446221Snate@binkert.org list<ThreadID>::iterator end = activeThreads->end(); 14451060SN/A 14462326SN/A // Check stall and squash signals, dispatch any instructions. 14473867Sbinkertn@umich.edu while (threads != end) { 14486221Snate@binkert.org ThreadID tid = *threads++; 14491060SN/A 14502292SN/A DPRINTF(IEW,"Issue: Processing [tid:%i]\n",tid); 14511060SN/A 14522292SN/A checkSignalsAndUpdate(tid); 14532292SN/A dispatch(tid); 14541060SN/A } 14551060SN/A 14562292SN/A if (exeStatus != Squashing) { 14572292SN/A executeInsts(); 14581060SN/A 14592292SN/A writebackInsts(); 14602292SN/A 14612292SN/A // Have the instruction queue try to schedule any ready instructions. 14622292SN/A // (In actuality, this scheduling is for instructions that will 14632292SN/A // be executed next cycle.) 14642292SN/A instQueue.scheduleReadyInsts(); 14652292SN/A 14662292SN/A // Also should advance its own time buffers if the stage ran. 14672292SN/A // Not the best place for it, but this works (hopefully). 14682292SN/A issueToExecQueue.advance(); 14692292SN/A } 14702292SN/A 14712292SN/A bool broadcast_free_entries = false; 14722292SN/A 14732292SN/A if (updatedQueues || exeStatus == Running || updateLSQNextCycle) { 14742292SN/A exeStatus = Idle; 14752292SN/A updateLSQNextCycle = false; 14762292SN/A 14772292SN/A broadcast_free_entries = true; 14782292SN/A } 14792292SN/A 14802292SN/A // Writeback any stores using any leftover bandwidth. 14811681SN/A ldstQueue.writebackStores(); 14821681SN/A 14831061SN/A // Check the committed load/store signals to see if there's a load 14841061SN/A // or store to commit. Also check if it's being told to execute a 14851061SN/A // nonspeculative instruction. 14861681SN/A // This is pretty inefficient... 14872292SN/A 14883867Sbinkertn@umich.edu threads = activeThreads->begin(); 14893867Sbinkertn@umich.edu while (threads != end) { 14906221Snate@binkert.org ThreadID tid = (*threads++); 14912292SN/A 14922292SN/A DPRINTF(IEW,"Processing [tid:%i]\n",tid); 14932292SN/A 14942348SN/A // Update structures based on instructions committed. 14952292SN/A if (fromCommit->commitInfo[tid].doneSeqNum != 0 && 14962292SN/A !fromCommit->commitInfo[tid].squash && 14972292SN/A !fromCommit->commitInfo[tid].robSquashing) { 14982292SN/A 14992292SN/A ldstQueue.commitStores(fromCommit->commitInfo[tid].doneSeqNum,tid); 15002292SN/A 15012292SN/A ldstQueue.commitLoads(fromCommit->commitInfo[tid].doneSeqNum,tid); 15022292SN/A 15032292SN/A updateLSQNextCycle = true; 15042292SN/A instQueue.commit(fromCommit->commitInfo[tid].doneSeqNum,tid); 15052292SN/A } 15062292SN/A 15072292SN/A if (fromCommit->commitInfo[tid].nonSpecSeqNum != 0) { 15082292SN/A 15092292SN/A //DPRINTF(IEW,"NonspecInst from thread %i",tid); 15102292SN/A if (fromCommit->commitInfo[tid].uncached) { 15112292SN/A instQueue.replayMemInst(fromCommit->commitInfo[tid].uncachedLoad); 15124033Sktlim@umich.edu fromCommit->commitInfo[tid].uncachedLoad->setAtCommit(); 15132292SN/A } else { 15142292SN/A instQueue.scheduleNonSpec( 15152292SN/A fromCommit->commitInfo[tid].nonSpecSeqNum); 15162292SN/A } 15172292SN/A } 15182292SN/A 15192292SN/A if (broadcast_free_entries) { 15202292SN/A toFetch->iewInfo[tid].iqCount = 15212292SN/A instQueue.getCount(tid); 15222292SN/A toFetch->iewInfo[tid].ldstqCount = 15232292SN/A ldstQueue.getCount(tid); 15242292SN/A 15252292SN/A toRename->iewInfo[tid].usedIQ = true; 15262292SN/A toRename->iewInfo[tid].freeIQEntries = 15272292SN/A instQueue.numFreeEntries(); 15282292SN/A toRename->iewInfo[tid].usedLSQ = true; 15292292SN/A toRename->iewInfo[tid].freeLSQEntries = 15302292SN/A ldstQueue.numFreeEntries(tid); 15312292SN/A 15322292SN/A wroteToTimeBuffer = true; 15332292SN/A } 15342292SN/A 15352292SN/A DPRINTF(IEW, "[tid:%i], Dispatch dispatched %i instructions.\n", 15362292SN/A tid, toRename->iewInfo[tid].dispatched); 15371061SN/A } 15381061SN/A 15392292SN/A DPRINTF(IEW, "IQ has %i free entries (Can schedule: %i). " 15402292SN/A "LSQ has %i free entries.\n", 15412292SN/A instQueue.numFreeEntries(), instQueue.hasReadyInsts(), 15422292SN/A ldstQueue.numFreeEntries()); 15432292SN/A 15442292SN/A updateStatus(); 15452292SN/A 15462292SN/A if (wroteToTimeBuffer) { 15472292SN/A DPRINTF(Activity, "Activity this cycle.\n"); 15482292SN/A cpu->activityThisCycle(); 15491061SN/A } 15501060SN/A} 15511060SN/A 15522301SN/Atemplate <class Impl> 15531060SN/Avoid 15542301SN/ADefaultIEW<Impl>::updateExeInstStats(DynInstPtr &inst) 15551060SN/A{ 15566221Snate@binkert.org ThreadID tid = inst->threadNumber; 15571060SN/A 15582301SN/A // 15592301SN/A // Pick off the software prefetches 15602301SN/A // 15612301SN/A#ifdef TARGET_ALPHA 15622301SN/A if (inst->isDataPrefetch()) 15636221Snate@binkert.org iewExecutedSwp[tid]++; 15642301SN/A else 15652727Sktlim@umich.edu iewIewExecutedcutedInsts++; 15662301SN/A#else 15672669Sktlim@umich.edu iewExecutedInsts++; 15682301SN/A#endif 15691060SN/A 15702301SN/A // 15712301SN/A // Control operations 15722301SN/A // 15732301SN/A if (inst->isControl()) 15746221Snate@binkert.org iewExecutedBranches[tid]++; 15751060SN/A 15762301SN/A // 15772301SN/A // Memory operations 15782301SN/A // 15792301SN/A if (inst->isMemRef()) { 15806221Snate@binkert.org iewExecutedRefs[tid]++; 15811060SN/A 15822301SN/A if (inst->isLoad()) { 15836221Snate@binkert.org iewExecLoadInsts[tid]++; 15841060SN/A } 15851060SN/A } 15861060SN/A} 1587