scoreboard.cc revision 8232
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" 348232Snate@binkert.org#include "debug/Scoreboard.hh" 352292SN/A 362292SN/AScoreboard::Scoreboard(unsigned activeThreads, 372292SN/A unsigned _numLogicalIntRegs, 382292SN/A unsigned _numPhysicalIntRegs, 392292SN/A unsigned _numLogicalFloatRegs, 402292SN/A unsigned _numPhysicalFloatRegs, 412292SN/A unsigned _numMiscRegs, 422292SN/A unsigned _zeroRegIdx) 432292SN/A : numLogicalIntRegs(_numLogicalIntRegs), 442292SN/A numPhysicalIntRegs(_numPhysicalIntRegs), 452292SN/A numLogicalFloatRegs(_numLogicalFloatRegs), 462292SN/A numPhysicalFloatRegs(_numPhysicalFloatRegs), 472292SN/A numMiscRegs(_numMiscRegs), 482292SN/A zeroRegIdx(_zeroRegIdx) 492292SN/A{ 502292SN/A //Get Register Sizes 512292SN/A numLogicalRegs = numLogicalIntRegs + numLogicalFloatRegs; 522292SN/A numPhysicalRegs = numPhysicalIntRegs + numPhysicalFloatRegs; 532292SN/A 542292SN/A //Resize scoreboard appropriately 557699Sgblack@eecs.umich.edu resize(numPhysicalRegs + (numMiscRegs * activeThreads)); 562292SN/A 572292SN/A //Initialize values 582292SN/A for (int i=0; i < numLogicalIntRegs * activeThreads; i++) { 597699Sgblack@eecs.umich.edu assert(indexInBounds(i)); 602292SN/A regScoreBoard[i] = 1; 612292SN/A } 622292SN/A 632292SN/A for (int i= numPhysicalIntRegs; 642292SN/A i < numPhysicalIntRegs + (numLogicalFloatRegs * activeThreads); 652292SN/A i++) { 667699Sgblack@eecs.umich.edu assert(indexInBounds(i)); 672292SN/A regScoreBoard[i] = 1; 682292SN/A } 692292SN/A 702292SN/A for (int i = numPhysicalRegs; 712292SN/A i < numPhysicalRegs + (numMiscRegs * activeThreads); 722292SN/A i++) { 737699Sgblack@eecs.umich.edu assert(indexInBounds(i)); 742292SN/A regScoreBoard[i] = 1; 752292SN/A } 762292SN/A} 772292SN/A 782292SN/Astd::string 792292SN/AScoreboard::name() const 802292SN/A{ 812292SN/A return "cpu.scoreboard"; 822292SN/A} 832292SN/A 842292SN/Abool 852292SN/AScoreboard::getReg(PhysRegIndex phys_reg) 862292SN/A{ 874642Sgblack@eecs.umich.edu#if THE_ISA == ALPHA_ISA 882292SN/A // Always ready if int or fp zero reg. 892292SN/A if (phys_reg == zeroRegIdx || 902292SN/A phys_reg == (zeroRegIdx + numPhysicalIntRegs)) { 912292SN/A return 1; 922292SN/A } 934642Sgblack@eecs.umich.edu#else 944642Sgblack@eecs.umich.edu // Always ready if int zero reg. 954642Sgblack@eecs.umich.edu if (phys_reg == zeroRegIdx) { 964642Sgblack@eecs.umich.edu return 1; 974642Sgblack@eecs.umich.edu } 984642Sgblack@eecs.umich.edu#endif 992292SN/A 1007699Sgblack@eecs.umich.edu assert(indexInBounds(phys_reg)); 1012292SN/A return regScoreBoard[phys_reg]; 1022292SN/A} 1032292SN/A 1042292SN/Avoid 1052292SN/AScoreboard::setReg(PhysRegIndex phys_reg) 1062292SN/A{ 1072292SN/A DPRINTF(Scoreboard, "Setting reg %i as ready\n", phys_reg); 1082292SN/A 1097699Sgblack@eecs.umich.edu assert(indexInBounds(phys_reg)); 1102292SN/A regScoreBoard[phys_reg] = 1; 1112292SN/A} 1122292SN/A 1132292SN/Avoid 1142292SN/AScoreboard::unsetReg(PhysRegIndex ready_reg) 1152292SN/A{ 1164642Sgblack@eecs.umich.edu#if THE_ISA == ALPHA_ISA 1172292SN/A if (ready_reg == zeroRegIdx || 1182292SN/A ready_reg == (zeroRegIdx + numPhysicalIntRegs)) { 1192292SN/A // Don't do anything if int or fp zero reg. 1202329SN/A return; 1212292SN/A } 1224642Sgblack@eecs.umich.edu#else 1234642Sgblack@eecs.umich.edu if (ready_reg == zeroRegIdx) { 1244642Sgblack@eecs.umich.edu // Don't do anything if int zero reg. 1254642Sgblack@eecs.umich.edu return; 1264642Sgblack@eecs.umich.edu } 1274642Sgblack@eecs.umich.edu#endif 1282292SN/A 1297699Sgblack@eecs.umich.edu assert(indexInBounds(ready_reg)); 1302292SN/A regScoreBoard[ready_reg] = 0; 1312292SN/A} 132