scoreboard.cc (2669:f2b336e89d2a) scoreboard.cc (2689:dbf969c18a65)
1/*
1/*
2 * Copyright (c) 2004-2005 The Regents of The University of Michigan
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.
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
27 */
28
29#include "cpu/o3/scoreboard.hh"
30
31Scoreboard::Scoreboard(unsigned activeThreads,
32 unsigned _numLogicalIntRegs,
33 unsigned _numPhysicalIntRegs,
34 unsigned _numLogicalFloatRegs,
35 unsigned _numPhysicalFloatRegs,
36 unsigned _numMiscRegs,
37 unsigned _zeroRegIdx)
38 : numLogicalIntRegs(_numLogicalIntRegs),
39 numPhysicalIntRegs(_numPhysicalIntRegs),
40 numLogicalFloatRegs(_numLogicalFloatRegs),
41 numPhysicalFloatRegs(_numPhysicalFloatRegs),
42 numMiscRegs(_numMiscRegs),
43 zeroRegIdx(_zeroRegIdx)
44{
45 //Get Register Sizes
46 numLogicalRegs = numLogicalIntRegs + numLogicalFloatRegs;
47 numPhysicalRegs = numPhysicalIntRegs + numPhysicalFloatRegs;
48
49 //Resize scoreboard appropriately
50 regScoreBoard.resize(numPhysicalRegs + (numMiscRegs * activeThreads));
51
52 //Initialize values
53 for (int i=0; i < numLogicalIntRegs * activeThreads; i++) {
54 regScoreBoard[i] = 1;
55 }
56
57 for (int i= numPhysicalIntRegs;
58 i < numPhysicalIntRegs + (numLogicalFloatRegs * activeThreads);
59 i++) {
60 regScoreBoard[i] = 1;
61 }
62
63 for (int i = numPhysicalRegs;
64 i < numPhysicalRegs + (numMiscRegs * activeThreads);
65 i++) {
66 regScoreBoard[i] = 1;
67 }
68}
69
70std::string
71Scoreboard::name() const
72{
73 return "cpu.scoreboard";
74}
75
76bool
77Scoreboard::getReg(PhysRegIndex phys_reg)
78{
79 // Always ready if int or fp zero reg.
80 if (phys_reg == zeroRegIdx ||
81 phys_reg == (zeroRegIdx + numPhysicalIntRegs)) {
82 return 1;
83 }
84
85 return regScoreBoard[phys_reg];
86}
87
88void
89Scoreboard::setReg(PhysRegIndex phys_reg)
90{
91 DPRINTF(Scoreboard, "Setting reg %i as ready\n", phys_reg);
92
93 regScoreBoard[phys_reg] = 1;
94}
95
96void
97Scoreboard::unsetReg(PhysRegIndex ready_reg)
98{
99 if (ready_reg == zeroRegIdx ||
100 ready_reg == (zeroRegIdx + numPhysicalIntRegs)) {
101 // Don't do anything if int or fp zero reg.
102 return;
103 }
104
105 regScoreBoard[ready_reg] = 0;
106}
30 */
31
32#include "cpu/o3/scoreboard.hh"
33
34Scoreboard::Scoreboard(unsigned activeThreads,
35 unsigned _numLogicalIntRegs,
36 unsigned _numPhysicalIntRegs,
37 unsigned _numLogicalFloatRegs,
38 unsigned _numPhysicalFloatRegs,
39 unsigned _numMiscRegs,
40 unsigned _zeroRegIdx)
41 : numLogicalIntRegs(_numLogicalIntRegs),
42 numPhysicalIntRegs(_numPhysicalIntRegs),
43 numLogicalFloatRegs(_numLogicalFloatRegs),
44 numPhysicalFloatRegs(_numPhysicalFloatRegs),
45 numMiscRegs(_numMiscRegs),
46 zeroRegIdx(_zeroRegIdx)
47{
48 //Get Register Sizes
49 numLogicalRegs = numLogicalIntRegs + numLogicalFloatRegs;
50 numPhysicalRegs = numPhysicalIntRegs + numPhysicalFloatRegs;
51
52 //Resize scoreboard appropriately
53 regScoreBoard.resize(numPhysicalRegs + (numMiscRegs * activeThreads));
54
55 //Initialize values
56 for (int i=0; i < numLogicalIntRegs * activeThreads; i++) {
57 regScoreBoard[i] = 1;
58 }
59
60 for (int i= numPhysicalIntRegs;
61 i < numPhysicalIntRegs + (numLogicalFloatRegs * activeThreads);
62 i++) {
63 regScoreBoard[i] = 1;
64 }
65
66 for (int i = numPhysicalRegs;
67 i < numPhysicalRegs + (numMiscRegs * activeThreads);
68 i++) {
69 regScoreBoard[i] = 1;
70 }
71}
72
73std::string
74Scoreboard::name() const
75{
76 return "cpu.scoreboard";
77}
78
79bool
80Scoreboard::getReg(PhysRegIndex phys_reg)
81{
82 // Always ready if int or fp zero reg.
83 if (phys_reg == zeroRegIdx ||
84 phys_reg == (zeroRegIdx + numPhysicalIntRegs)) {
85 return 1;
86 }
87
88 return regScoreBoard[phys_reg];
89}
90
91void
92Scoreboard::setReg(PhysRegIndex phys_reg)
93{
94 DPRINTF(Scoreboard, "Setting reg %i as ready\n", phys_reg);
95
96 regScoreBoard[phys_reg] = 1;
97}
98
99void
100Scoreboard::unsetReg(PhysRegIndex ready_reg)
101{
102 if (ready_reg == zeroRegIdx ||
103 ready_reg == (zeroRegIdx + numPhysicalIntRegs)) {
104 // Don't do anything if int or fp zero reg.
105 return;
106 }
107
108 regScoreBoard[ready_reg] = 0;
109}