scoreboard.cc revision 4642
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
324642Sgblack@eecs.umich.edu#include "arch/isa_specific.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
542292SN/A    regScoreBoard.resize(numPhysicalRegs + (numMiscRegs * activeThreads));
552292SN/A
562292SN/A    //Initialize values
572292SN/A    for (int i=0; i < numLogicalIntRegs * activeThreads; i++) {
582292SN/A        regScoreBoard[i] = 1;
592292SN/A    }
602292SN/A
612292SN/A    for (int i= numPhysicalIntRegs;
622292SN/A         i < numPhysicalIntRegs + (numLogicalFloatRegs * activeThreads);
632292SN/A         i++) {
642292SN/A        regScoreBoard[i] = 1;
652292SN/A    }
662292SN/A
672292SN/A    for (int i = numPhysicalRegs;
682292SN/A         i < numPhysicalRegs + (numMiscRegs * activeThreads);
692292SN/A         i++) {
702292SN/A        regScoreBoard[i] = 1;
712292SN/A    }
722292SN/A}
732292SN/A
742292SN/Astd::string
752292SN/AScoreboard::name() const
762292SN/A{
772292SN/A    return "cpu.scoreboard";
782292SN/A}
792292SN/A
802292SN/Abool
812292SN/AScoreboard::getReg(PhysRegIndex phys_reg)
822292SN/A{
834642Sgblack@eecs.umich.edu#if THE_ISA == ALPHA_ISA
842292SN/A    // Always ready if int or fp zero reg.
852292SN/A    if (phys_reg == zeroRegIdx ||
862292SN/A        phys_reg == (zeroRegIdx + numPhysicalIntRegs)) {
872292SN/A        return 1;
882292SN/A    }
894642Sgblack@eecs.umich.edu#else
904642Sgblack@eecs.umich.edu    // Always ready if int zero reg.
914642Sgblack@eecs.umich.edu    if (phys_reg == zeroRegIdx) {
924642Sgblack@eecs.umich.edu        return 1;
934642Sgblack@eecs.umich.edu    }
944642Sgblack@eecs.umich.edu#endif
952292SN/A
962292SN/A    return regScoreBoard[phys_reg];
972292SN/A}
982292SN/A
992292SN/Avoid
1002292SN/AScoreboard::setReg(PhysRegIndex phys_reg)
1012292SN/A{
1022292SN/A    DPRINTF(Scoreboard, "Setting reg %i as ready\n", phys_reg);
1032292SN/A
1042292SN/A    regScoreBoard[phys_reg] = 1;
1052292SN/A}
1062292SN/A
1072292SN/Avoid
1082292SN/AScoreboard::unsetReg(PhysRegIndex ready_reg)
1092292SN/A{
1104642Sgblack@eecs.umich.edu#if THE_ISA == ALPHA_ISA
1112292SN/A    if (ready_reg == zeroRegIdx ||
1122292SN/A        ready_reg == (zeroRegIdx + numPhysicalIntRegs)) {
1132292SN/A        // Don't do anything if int or fp zero reg.
1142329SN/A        return;
1152292SN/A    }
1164642Sgblack@eecs.umich.edu#else
1174642Sgblack@eecs.umich.edu    if (ready_reg == zeroRegIdx) {
1184642Sgblack@eecs.umich.edu        // Don't do anything if int zero reg.
1194642Sgblack@eecs.umich.edu        return;
1204642Sgblack@eecs.umich.edu    }
1214642Sgblack@eecs.umich.edu#endif
1222292SN/A
1232292SN/A    regScoreBoard[ready_reg] = 0;
1242292SN/A}
125