cpu: Delete authors lists from the cpu directory.
[gem5.git] / src / cpu / o3 / scoreboard.hh
1 /*
2 * Copyright (c) 2005-2006 The Regents of The University of Michigan
3 * Copyright (c) 2013 Advanced Micro Devices, Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 #ifndef __CPU_O3_SCOREBOARD_HH__
31 #define __CPU_O3_SCOREBOARD_HH__
32
33 #include <iostream>
34 #include <utility>
35 #include <vector>
36
37 #include "base/trace.hh"
38 #include "config/the_isa.hh"
39 #include "cpu/o3/comm.hh"
40 #include "debug/Scoreboard.hh"
41
42 /**
43 * Implements a simple scoreboard to track which registers are
44 * ready. This class operates on the unified physical register space,
45 * because the different classes of registers do not need to be distinguished.
46 * Registers being part of a fixed mapping are always considered ready.
47 */
48 class Scoreboard
49 {
50 private:
51 /** The object name, for DPRINTF. We have to declare this
52 * explicitly because Scoreboard is not a SimObject. */
53 const std::string _name;
54
55 /** Scoreboard of physical integer registers, saying whether or not they
56 * are ready. */
57 std::vector<bool> regScoreBoard;
58
59 /** The number of actual physical registers */
60 unsigned M5_CLASS_VAR_USED numPhysRegs;
61
62 public:
63 /** Constructs a scoreboard.
64 * @param _numPhysicalRegs Number of physical registers.
65 * @param _numMiscRegs Number of miscellaneous registers.
66 */
67 Scoreboard(const std::string &_my_name,
68 unsigned _numPhysicalRegs);
69
70 /** Destructor. */
71 ~Scoreboard() {}
72
73 /** Returns the name of the scoreboard. */
74 std::string name() const { return _name; };
75
76 /** Checks if the register is ready. */
77 bool getReg(PhysRegIdPtr phys_reg) const
78 {
79 assert(phys_reg->flatIndex() < numPhysRegs);
80
81 if (phys_reg->isFixedMapping()) {
82 // Fixed mapping regs are always ready
83 return true;
84 }
85
86 bool ready = regScoreBoard[phys_reg->flatIndex()];
87
88 if (phys_reg->isZeroReg())
89 assert(ready);
90
91 return ready;
92 }
93
94 /** Sets the register as ready. */
95 void setReg(PhysRegIdPtr phys_reg)
96 {
97 assert(phys_reg->flatIndex() < numPhysRegs);
98
99 if (phys_reg->isFixedMapping()) {
100 // Fixed mapping regs are always ready, ignore attempts to change
101 // that
102 return;
103 }
104
105 DPRINTF(Scoreboard, "Setting reg %i (%s) as ready\n",
106 phys_reg->index(), phys_reg->className());
107
108 regScoreBoard[phys_reg->flatIndex()] = true;
109 }
110
111 /** Sets the register as not ready. */
112 void unsetReg(PhysRegIdPtr phys_reg)
113 {
114 assert(phys_reg->flatIndex() < numPhysRegs);
115
116 if (phys_reg->isFixedMapping()) {
117 // Fixed mapping regs are always ready, ignore attempts to
118 // change that
119 return;
120 }
121
122 // zero reg should never be marked unready
123 if (phys_reg->isZeroReg())
124 return;
125
126 regScoreBoard[phys_reg->flatIndex()] = false;
127 }
128
129 };
130
131 #endif