scoreboard.cc revision 7699
12292SN/A/* 22689Sktlim@umich.edu * Copyright (c) 2005-2006 The Regents of The University of Michigan 32292SN/A * All rights reserved. 42292SN/A * 52292SN/A * Redistribution and use in source and binary forms, with or without 62292SN/A * modification, are permitted provided that the following conditions are 72292SN/A * met: redistributions of source code must retain the above copyright 82292SN/A * notice, this list of conditions and the following disclaimer; 92292SN/A * redistributions in binary form must reproduce the above copyright 102292SN/A * notice, this list of conditions and the following disclaimer in the 112292SN/A * documentation and/or other materials provided with the distribution; 122292SN/A * neither the name of the copyright holders nor the names of its 132292SN/A * contributors may be used to endorse or promote products derived from 142292SN/A * this software without specific prior written permission. 152292SN/A * 162292SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172292SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182292SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192292SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202292SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212292SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222292SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232292SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242292SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252292SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262292SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272689Sktlim@umich.edu * 282689Sktlim@umich.edu * Authors: Korey Sewell 292689Sktlim@umich.edu * Kevin Lim 302292SN/A */ 312292SN/A 326658Snate@binkert.org#include "config/the_isa.hh" 332292SN/A#include "cpu/o3/scoreboard.hh" 342292SN/A 352292SN/AScoreboard::Scoreboard(unsigned activeThreads, 362292SN/A unsigned _numLogicalIntRegs, 372292SN/A unsigned _numPhysicalIntRegs, 382292SN/A unsigned _numLogicalFloatRegs, 392292SN/A unsigned _numPhysicalFloatRegs, 402292SN/A unsigned _numMiscRegs, 412292SN/A unsigned _zeroRegIdx) 422292SN/A : numLogicalIntRegs(_numLogicalIntRegs), 432292SN/A numPhysicalIntRegs(_numPhysicalIntRegs), 442292SN/A numLogicalFloatRegs(_numLogicalFloatRegs), 452292SN/A numPhysicalFloatRegs(_numPhysicalFloatRegs), 462292SN/A numMiscRegs(_numMiscRegs), 472292SN/A zeroRegIdx(_zeroRegIdx) 482292SN/A{ 492292SN/A //Get Register Sizes 502292SN/A numLogicalRegs = numLogicalIntRegs + numLogicalFloatRegs; 512292SN/A numPhysicalRegs = numPhysicalIntRegs + numPhysicalFloatRegs; 522292SN/A 532292SN/A //Resize scoreboard appropriately 547699Sgblack@eecs.umich.edu resize(numPhysicalRegs + (numMiscRegs * activeThreads)); 552292SN/A 562292SN/A //Initialize values 572292SN/A for (int i=0; i < numLogicalIntRegs * activeThreads; i++) { 587699Sgblack@eecs.umich.edu assert(indexInBounds(i)); 592292SN/A regScoreBoard[i] = 1; 602292SN/A } 612292SN/A 622292SN/A for (int i= numPhysicalIntRegs; 632292SN/A i < numPhysicalIntRegs + (numLogicalFloatRegs * activeThreads); 642292SN/A i++) { 657699Sgblack@eecs.umich.edu assert(indexInBounds(i)); 662292SN/A regScoreBoard[i] = 1; 672292SN/A } 682292SN/A 692292SN/A for (int i = numPhysicalRegs; 702292SN/A i < numPhysicalRegs + (numMiscRegs * activeThreads); 712292SN/A i++) { 727699Sgblack@eecs.umich.edu assert(indexInBounds(i)); 732292SN/A regScoreBoard[i] = 1; 742292SN/A } 752292SN/A} 762292SN/A 772292SN/Astd::string 782292SN/AScoreboard::name() const 792292SN/A{ 802292SN/A return "cpu.scoreboard"; 812292SN/A} 822292SN/A 832292SN/Abool 842292SN/AScoreboard::getReg(PhysRegIndex phys_reg) 852292SN/A{ 864642Sgblack@eecs.umich.edu#if THE_ISA == ALPHA_ISA 872292SN/A // Always ready if int or fp zero reg. 882292SN/A if (phys_reg == zeroRegIdx || 892292SN/A phys_reg == (zeroRegIdx + numPhysicalIntRegs)) { 902292SN/A return 1; 912292SN/A } 924642Sgblack@eecs.umich.edu#else 934642Sgblack@eecs.umich.edu // Always ready if int zero reg. 944642Sgblack@eecs.umich.edu if (phys_reg == zeroRegIdx) { 954642Sgblack@eecs.umich.edu return 1; 964642Sgblack@eecs.umich.edu } 974642Sgblack@eecs.umich.edu#endif 982292SN/A 997699Sgblack@eecs.umich.edu assert(indexInBounds(phys_reg)); 1002292SN/A return regScoreBoard[phys_reg]; 1012292SN/A} 1022292SN/A 1032292SN/Avoid 1042292SN/AScoreboard::setReg(PhysRegIndex phys_reg) 1052292SN/A{ 1062292SN/A DPRINTF(Scoreboard, "Setting reg %i as ready\n", phys_reg); 1072292SN/A 1087699Sgblack@eecs.umich.edu assert(indexInBounds(phys_reg)); 1092292SN/A regScoreBoard[phys_reg] = 1; 1102292SN/A} 1112292SN/A 1122292SN/Avoid 1132292SN/AScoreboard::unsetReg(PhysRegIndex ready_reg) 1142292SN/A{ 1154642Sgblack@eecs.umich.edu#if THE_ISA == ALPHA_ISA 1162292SN/A if (ready_reg == zeroRegIdx || 1172292SN/A ready_reg == (zeroRegIdx + numPhysicalIntRegs)) { 1182292SN/A // Don't do anything if int or fp zero reg. 1192329SN/A return; 1202292SN/A } 1214642Sgblack@eecs.umich.edu#else 1224642Sgblack@eecs.umich.edu if (ready_reg == zeroRegIdx) { 1234642Sgblack@eecs.umich.edu // Don't do anything if int zero reg. 1244642Sgblack@eecs.umich.edu return; 1254642Sgblack@eecs.umich.edu } 1264642Sgblack@eecs.umich.edu#endif 1272292SN/A 1287699Sgblack@eecs.umich.edu assert(indexInBounds(ready_reg)); 1292292SN/A regScoreBoard[ready_reg] = 0; 1302292SN/A} 131