gem5  v21.1.0.2
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"
40 
41 namespace gem5
42 {
43 
44 namespace o3
45 {
46 
54 {
55  private:
58  const std::string _name;
59 
62 
66 
69 
70  public:
75  Scoreboard(const std::string &_my_name, unsigned _numPhysicalRegs,
76  RegIndex _zero_reg);
77 
80 
82  std::string name() const { return _name; };
83 
85  bool
86  getReg(PhysRegIdPtr phys_reg) const
87  {
88  assert(phys_reg->flatIndex() < numPhysRegs);
89 
90  if (phys_reg->isFixedMapping()) {
91  // Fixed mapping regs are always ready
92  return true;
93  }
94 
95  bool ready = regScoreBoard[phys_reg->flatIndex()];
96 
97  if (phys_reg->is(IntRegClass) && phys_reg->index() == zeroReg)
98  assert(ready);
99 
100  return ready;
101  }
102 
104  void
106  {
107  assert(phys_reg->flatIndex() < numPhysRegs);
108 
109  if (phys_reg->isFixedMapping()) {
110  // Fixed mapping regs are always ready, ignore attempts to change
111  // that
112  return;
113  }
114 
115  DPRINTF(Scoreboard, "Setting reg %i (%s) as ready\n",
116  phys_reg->index(), phys_reg->className());
117 
118  regScoreBoard[phys_reg->flatIndex()] = true;
119  }
120 
122  void
124  {
125  assert(phys_reg->flatIndex() < numPhysRegs);
126 
127  if (phys_reg->isFixedMapping()) {
128  // Fixed mapping regs are always ready, ignore attempts to
129  // change that
130  return;
131  }
132 
133  // zero reg should never be marked unready
134  if (phys_reg->is(IntRegClass) && phys_reg->index() == zeroReg)
135  return;
136 
137  regScoreBoard[phys_reg->flatIndex()] = false;
138  }
139 
140 };
141 
142 } // namespace o3
143 } // namespace gem5
144 
145 #endif
gem5::o3::Scoreboard::getReg
bool getReg(PhysRegIdPtr phys_reg) const
Checks if the register is ready.
Definition: scoreboard.hh:86
gem5::o3::Scoreboard
Implements a simple scoreboard to track which registers are ready.
Definition: scoreboard.hh:53
std::vector< bool >
gem5::o3::Scoreboard::zeroReg
const RegIndex zeroReg
Index of the zero integer register.
Definition: scoreboard.hh:61
gem5::o3::Scoreboard::regScoreBoard
std::vector< bool > regScoreBoard
Scoreboard of physical integer registers, saying whether or not they are ready.
Definition: scoreboard.hh:65
gem5::o3::Scoreboard::name
std::string name() const
Returns the name of the scoreboard.
Definition: scoreboard.hh:82
GEM5_CLASS_VAR_USED
#define GEM5_CLASS_VAR_USED
Definition: compiler.hh:189
gem5::PhysRegId::flatIndex
const RegIndex & flatIndex() const
Flat index accessor.
Definition: reg_class.hh:263
gem5::o3::Scoreboard::numPhysRegs
GEM5_CLASS_VAR_USED unsigned numPhysRegs
The number of actual physical registers.
Definition: scoreboard.hh:68
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:186
gem5::o3::Scoreboard::setReg
void setReg(PhysRegIdPtr phys_reg)
Sets the register as ready.
Definition: scoreboard.hh:105
compiler.hh
gem5::o3::Scoreboard::~Scoreboard
~Scoreboard()
Destructor.
Definition: scoreboard.hh:79
gem5::o3::Scoreboard::unsetReg
void unsetReg(PhysRegIdPtr phys_reg)
Sets the register as not ready.
Definition: scoreboard.hh:123
gem5::PhysRegId::className
const char * className() const
Return a const char* with the register class name.
Definition: reg_class.hh:182
reg_class.hh
gem5::PhysRegId
Physical register ID.
Definition: reg_class.hh:198
gem5::o3::Scoreboard::_name
const std::string _name
The object name, for DPRINTF.
Definition: scoreboard.hh:58
trace.hh
gem5::PhysRegId::isFixedMapping
bool isFixedMapping() const
Returns true if this register is always associated to the same architectural register.
Definition: reg_class.hh:260
gem5::PhysRegId::is
bool is(RegClass reg_class) const
Definition: reg_class.hh:150
gem5::RegIndex
uint16_t RegIndex
Definition: types.hh:176
gem5::IntRegClass
@ IntRegClass
Integer register.
Definition: reg_class.hh:57
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::PhysRegId::index
RegIndex index() const
Visible RegId methods.
Definition: reg_class.hh:154
gem5::o3::Scoreboard::Scoreboard
Scoreboard(const std::string &_my_name, unsigned _numPhysicalRegs, RegIndex _zero_reg)
Constructs a scoreboard.
Definition: scoreboard.cc:38

Generated on Tue Sep 21 2021 12:25:01 for gem5 by doxygen 1.8.17