gem5  v21.0.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
scoreboard.hh
Go to the documentation of this file.
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 <cassert>
34 #include <vector>
35 
36 #include "base/compiler.hh"
37 #include "base/trace.hh"
38 #include "cpu/reg_class.hh"
39 #include "debug/Scoreboard.hh"
47 {
48  private:
51  const std::string _name;
52 
56 
59 
60  public:
65  Scoreboard(const std::string &_my_name,
66  unsigned _numPhysicalRegs);
67 
70 
72  std::string name() const { return _name; };
73 
75  bool getReg(PhysRegIdPtr phys_reg) const
76  {
77  assert(phys_reg->flatIndex() < numPhysRegs);
78 
79  if (phys_reg->isFixedMapping()) {
80  // Fixed mapping regs are always ready
81  return true;
82  }
83 
84  bool ready = regScoreBoard[phys_reg->flatIndex()];
85 
86  if (phys_reg->isZeroReg())
87  assert(ready);
88 
89  return ready;
90  }
91 
93  void setReg(PhysRegIdPtr phys_reg)
94  {
95  assert(phys_reg->flatIndex() < numPhysRegs);
96 
97  if (phys_reg->isFixedMapping()) {
98  // Fixed mapping regs are always ready, ignore attempts to change
99  // that
100  return;
101  }
102 
103  DPRINTF(Scoreboard, "Setting reg %i (%s) as ready\n",
104  phys_reg->index(), phys_reg->className());
105 
106  regScoreBoard[phys_reg->flatIndex()] = true;
107  }
108 
110  void unsetReg(PhysRegIdPtr phys_reg)
111  {
112  assert(phys_reg->flatIndex() < numPhysRegs);
113 
114  if (phys_reg->isFixedMapping()) {
115  // Fixed mapping regs are always ready, ignore attempts to
116  // change that
117  return;
118  }
119 
120  // zero reg should never be marked unready
121  if (phys_reg->isZeroReg())
122  return;
123 
124  regScoreBoard[phys_reg->flatIndex()] = false;
125  }
126 
127 };
128 
129 #endif
Scoreboard::setReg
void setReg(PhysRegIdPtr phys_reg)
Sets the register as ready.
Definition: scoreboard.hh:93
PhysRegId::isZeroReg
bool isZeroReg() const
Check if this is the zero register.
Definition: reg_class.hh:143
PhysRegId::flatIndex
const PhysRegIndex & flatIndex() const
Flat index accessor.
Definition: reg_class.hh:309
std::vector< bool >
Scoreboard::Scoreboard
Scoreboard(const std::string &_my_name, unsigned _numPhysicalRegs)
Constructs a scoreboard.
Definition: scoreboard.cc:32
PhysRegId::isFixedMapping
bool isFixedMapping() const
Returns true if this register is always associated to the same architectural register.
Definition: reg_class.hh:306
M5_CLASS_VAR_USED
#define M5_CLASS_VAR_USED
Definition: compiler.hh:126
PhysRegId::index
const RegIndex & index() const
Visible RegId methods.
Definition: reg_class.hh:171
Scoreboard::~Scoreboard
~Scoreboard()
Destructor.
Definition: scoreboard.hh:69
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:237
Scoreboard::getReg
bool getReg(PhysRegIdPtr phys_reg) const
Checks if the register is ready.
Definition: scoreboard.hh:75
compiler.hh
Scoreboard::numPhysRegs
M5_CLASS_VAR_USED unsigned numPhysRegs
The number of actual physical registers.
Definition: scoreboard.hh:58
PhysRegId::className
const char * className() const
Return a const char* with the register class name.
Definition: reg_class.hh:201
Scoreboard::regScoreBoard
std::vector< bool > regScoreBoard
Scoreboard of physical integer registers, saying whether or not they are ready.
Definition: scoreboard.hh:55
reg_class.hh
PhysRegId
Physical register ID.
Definition: reg_class.hh:223
trace.hh
Scoreboard::_name
const std::string _name
The object name, for DPRINTF.
Definition: scoreboard.hh:51
Scoreboard::name
std::string name() const
Returns the name of the scoreboard.
Definition: scoreboard.hh:72
Scoreboard
Implements a simple scoreboard to track which registers are ready.
Definition: scoreboard.hh:46
Scoreboard::unsetReg
void unsetReg(PhysRegIdPtr phys_reg)
Sets the register as not ready.
Definition: scoreboard.hh:110

Generated on Tue Jun 22 2021 15:28:26 for gem5 by doxygen 1.8.17