summaryrefslogtreecommitdiff
path: root/src/cpu/o3/scoreboard.hh
diff options
context:
space:
mode:
authorSteve Reinhardt <steve.reinhardt@amd.com>2013-10-15 14:22:43 -0400
committerSteve Reinhardt <steve.reinhardt@amd.com>2013-10-15 14:22:43 -0400
commit9bd017b8aee1432b78361da89ce4980dabb70084 (patch)
treedd72d8882f825474a0a24297137e819212c8ec33 /src/cpu/o3/scoreboard.hh
parentc009d0eb2a02dddce6cca1033d73efde21445487 (diff)
downloadgem5-9bd017b8aee1432b78361da89ce4980dabb70084.tar.xz
cpu/o3: clean up scoreboard object
It had a bunch of fields (and associated constructor parameters) thet it didn't really use, and the array initialization was needlessly verbose. Also just hardwired the getReg() method to aleays return true for misc regs, rather than having an array of bits that we always kept marked as ready.
Diffstat (limited to 'src/cpu/o3/scoreboard.hh')
-rw-r--r--src/cpu/o3/scoreboard.hh143
1 files changed, 87 insertions, 56 deletions
diff --git a/src/cpu/o3/scoreboard.hh b/src/cpu/o3/scoreboard.hh
index 8a49d7a3a..79271082d 100644
--- a/src/cpu/o3/scoreboard.hh
+++ b/src/cpu/o3/scoreboard.hh
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2005-2006 The Regents of The University of Michigan
+ * Copyright (c) 2013 Advanced Micro Devices, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,6 +28,7 @@
*
* Authors: Korey Sewell
* Kevin Lim
+ * Steve Reinhardt
*/
#ifndef __CPU_O3_SCOREBOARD_HH__
@@ -37,95 +39,124 @@
#include <vector>
#include "base/trace.hh"
+#include "config/the_isa.hh"
#include "cpu/o3/comm.hh"
+#include "debug/Scoreboard.hh"
/**
- * Implements a simple scoreboard to track which registers are ready.
- * This class assumes that the fp registers start, index wise, right after
- * the integer registers. The misc. registers start, index wise, right after
- * the fp registers.
- * @todo: Fix up handling of the zero register in case the decoder does not
- * automatically make insts that write the zero register into nops.
+ * Implements a simple scoreboard to track which registers are
+ * ready. This class operates on the unified physical register space,
+ * so integer and floating-point registers are not distinguished. For
+ * convenience, it also accepts operations on the physical-space
+ * mapping of misc registers, which are numbered starting after the
+ * end of the actual physical register file. However, there is no
+ * actual scoreboard for misc registers, and they are always
+ * considered ready.
*/
class Scoreboard
{
+ private:
+ /** The object name, for DPRINTF. We have to declare this
+ * explicitly because Scoreboard is not a SimObject. */
+ const std::string _name;
+
+ /** Scoreboard of physical integer registers, saying whether or not they
+ * are ready. */
+ std::vector<bool> regScoreBoard;
+
+ /** The number of actual physical registers */
+ unsigned numPhysRegs;
+
+ /**
+ * The total number of registers which can be indexed, including
+ * the misc registers that come after the physical registers and
+ * which are hardwired to be always considered ready.
+ */
+ unsigned numTotalRegs;
+
+ /** The index of the zero register. */
+ PhysRegIndex zeroRegIdx;
+
+ /** The index of the FP zero register. */
+ PhysRegIndex fpZeroRegIdx;
+
+ bool isZeroReg(PhysRegIndex idx) const
+ {
+ return (idx == zeroRegIdx ||
+ (THE_ISA == ALPHA_ISA && idx == fpZeroRegIdx));
+ }
+
public:
/** Constructs a scoreboard.
- * @param activeThreads The number of active threads.
- * @param _numLogicalIntRegs Number of logical integer registers.
- * @param _numPhysicalIntRegs Number of physical integer registers.
- * @param _numLogicalFloatRegs Number of logical fp registers.
- * @param _numPhysicalFloatRegs Number of physical fp registers.
+ * @param _numPhysicalRegs Number of physical registers.
* @param _numMiscRegs Number of miscellaneous registers.
* @param _zeroRegIdx Index of the zero register.
+ * @param _fpZeroRegIdx Index of the FP zero register (if any, currently
+ * used only for Alpha).
*/
- Scoreboard(unsigned activeThreads,
- unsigned _numLogicalIntRegs,
- unsigned _numPhysicalIntRegs,
- unsigned _numLogicalFloatRegs,
- unsigned _numPhysicalFloatRegs,
+ Scoreboard(const std::string &_my_name,
+ unsigned _numPhysicalRegs,
unsigned _numMiscRegs,
- unsigned _zeroRegIdx);
+ PhysRegIndex _zeroRegIdx,
+ PhysRegIndex _fpZeroRegIdx);
/** Destructor. */
~Scoreboard() {}
/** Returns the name of the scoreboard. */
- std::string name() const;
+ std::string name() const { return _name; };
/** Checks if the register is ready. */
- bool getReg(PhysRegIndex ready_reg);
-
- /** Sets the register as ready. */
- void setReg(PhysRegIndex phys_reg);
+ bool getReg(PhysRegIndex reg_idx) const
+ {
+ assert(reg_idx < numTotalRegs);
- /** Sets the register as not ready. */
- void unsetReg(PhysRegIndex ready_reg);
+ if (reg_idx >= numPhysRegs) {
+ // misc regs are always ready
+ return true;
+ }
- private:
- /** Scoreboard of physical integer registers, saying whether or not they
- * are ready.
- */
- std::vector<bool> regScoreBoard;
+ bool ready = regScoreBoard[reg_idx];
- /** Number of logical integer registers. */
- int numLogicalIntRegs;
+ if (isZeroReg(reg_idx))
+ assert(ready);
- /** Number of physical integer registers. */
- int numPhysicalIntRegs;
+ return ready;
+ }
- /** Number of logical floating point registers. */
- int numLogicalFloatRegs;
+ /** Sets the register as ready. */
+ void setReg(PhysRegIndex reg_idx)
+ {
+ assert(reg_idx < numTotalRegs);
- /** Number of physical floating point registers. */
- int numPhysicalFloatRegs;
+ if (reg_idx >= numPhysRegs) {
+ // misc regs are always ready, ignore attempts to change that
+ return;
+ }
- /** Number of miscellaneous registers. */
- int numMiscRegs;
+ DPRINTF(Scoreboard, "Setting reg %i as ready\n", reg_idx);
- /** Number of logical integer + float registers. */
- int numLogicalRegs;
+ assert(reg_idx < numTotalRegs);
+ regScoreBoard[reg_idx] = true;
+ }
- /** Number of physical integer + float registers. */
- int numPhysicalRegs;
+ /** Sets the register as not ready. */
+ void unsetReg(PhysRegIndex reg_idx)
+ {
+ assert(reg_idx < numTotalRegs);
- /** The logical index of the zero register. */
- int zeroRegIdx;
+ if (reg_idx >= numPhysRegs) {
+ // misc regs are always ready, ignore attempts to change that
+ return;
+ }
- int currentSize;
+ // zero reg should never be marked unready
+ if (isZeroReg(reg_idx))
+ return;
- void
- resize(int newSize)
- {
- currentSize = newSize;
- regScoreBoard.resize(newSize);
+ regScoreBoard[reg_idx] = false;
}
- bool
- indexInBounds(int idx)
- {
- return idx < currentSize;
- }
};
#endif