scoreboard.cc revision 4642
1/*
2 * Copyright (c) 2005-2006 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Korey Sewell
29 *          Kevin Lim
30 */
31
32#include "arch/isa_specific.hh"
33#include "cpu/o3/scoreboard.hh"
34
35Scoreboard::Scoreboard(unsigned activeThreads,
36                       unsigned _numLogicalIntRegs,
37                       unsigned _numPhysicalIntRegs,
38                       unsigned _numLogicalFloatRegs,
39                       unsigned _numPhysicalFloatRegs,
40                       unsigned _numMiscRegs,
41                       unsigned _zeroRegIdx)
42    : numLogicalIntRegs(_numLogicalIntRegs),
43      numPhysicalIntRegs(_numPhysicalIntRegs),
44      numLogicalFloatRegs(_numLogicalFloatRegs),
45      numPhysicalFloatRegs(_numPhysicalFloatRegs),
46      numMiscRegs(_numMiscRegs),
47      zeroRegIdx(_zeroRegIdx)
48{
49    //Get Register Sizes
50    numLogicalRegs = numLogicalIntRegs  + numLogicalFloatRegs;
51    numPhysicalRegs = numPhysicalIntRegs  + numPhysicalFloatRegs;
52
53    //Resize scoreboard appropriately
54    regScoreBoard.resize(numPhysicalRegs + (numMiscRegs * activeThreads));
55
56    //Initialize values
57    for (int i=0; i < numLogicalIntRegs * activeThreads; i++) {
58        regScoreBoard[i] = 1;
59    }
60
61    for (int i= numPhysicalIntRegs;
62         i < numPhysicalIntRegs + (numLogicalFloatRegs * activeThreads);
63         i++) {
64        regScoreBoard[i] = 1;
65    }
66
67    for (int i = numPhysicalRegs;
68         i < numPhysicalRegs + (numMiscRegs * activeThreads);
69         i++) {
70        regScoreBoard[i] = 1;
71    }
72}
73
74std::string
75Scoreboard::name() const
76{
77    return "cpu.scoreboard";
78}
79
80bool
81Scoreboard::getReg(PhysRegIndex phys_reg)
82{
83#if THE_ISA == ALPHA_ISA
84    // Always ready if int or fp zero reg.
85    if (phys_reg == zeroRegIdx ||
86        phys_reg == (zeroRegIdx + numPhysicalIntRegs)) {
87        return 1;
88    }
89#else
90    // Always ready if int zero reg.
91    if (phys_reg == zeroRegIdx) {
92        return 1;
93    }
94#endif
95
96    return regScoreBoard[phys_reg];
97}
98
99void
100Scoreboard::setReg(PhysRegIndex phys_reg)
101{
102    DPRINTF(Scoreboard, "Setting reg %i as ready\n", phys_reg);
103
104    regScoreBoard[phys_reg] = 1;
105}
106
107void
108Scoreboard::unsetReg(PhysRegIndex ready_reg)
109{
110#if THE_ISA == ALPHA_ISA
111    if (ready_reg == zeroRegIdx ||
112        ready_reg == (zeroRegIdx + numPhysicalIntRegs)) {
113        // Don't do anything if int or fp zero reg.
114        return;
115    }
116#else
117    if (ready_reg == zeroRegIdx) {
118        // Don't do anything if int zero reg.
119        return;
120    }
121#endif
122
123    regScoreBoard[ready_reg] = 0;
124}
125