2a3
> * Copyright (c) 2013 Advanced Micro Devices, Inc.
29a31
> * Steve Reinhardt
39a42
> #include "config/the_isa.hh"
40a44
> #include "debug/Scoreboard.hh"
43,48c47,54
< * 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.
51a58,88
> 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));
> }
>
54,58c91
< * @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.
60a94,95
> * @param _fpZeroRegIdx Index of the FP zero register (if any, currently
> * used only for Alpha).
62,66c97,98
< Scoreboard(unsigned activeThreads,
< unsigned _numLogicalIntRegs,
< unsigned _numPhysicalIntRegs,
< unsigned _numLogicalFloatRegs,
< unsigned _numPhysicalFloatRegs,
---
> Scoreboard(const std::string &_my_name,
> unsigned _numPhysicalRegs,
68c100,101
< unsigned _zeroRegIdx);
---
> PhysRegIndex _zeroRegIdx,
> PhysRegIndex _fpZeroRegIdx);
74c107
< std::string name() const;
---
> std::string name() const { return _name; };
77c110,112
< bool getReg(PhysRegIndex ready_reg);
---
> bool getReg(PhysRegIndex reg_idx) const
> {
> assert(reg_idx < numTotalRegs);
79,80c114,117
< /** Sets the register as ready. */
< void setReg(PhysRegIndex phys_reg);
---
> if (reg_idx >= numPhysRegs) {
> // misc regs are always ready
> return true;
> }
82,83c119
< /** Sets the register as not ready. */
< void unsetReg(PhysRegIndex ready_reg);
---
> bool ready = regScoreBoard[reg_idx];
85,89c121,122
< private:
< /** Scoreboard of physical integer registers, saying whether or not they
< * are ready.
< */
< std::vector<bool> regScoreBoard;
---
> if (isZeroReg(reg_idx))
> assert(ready);
91,92c124,125
< /** Number of logical integer registers. */
< int numLogicalIntRegs;
---
> return ready;
> }
94,95c127,130
< /** Number of physical integer registers. */
< int numPhysicalIntRegs;
---
> /** Sets the register as ready. */
> void setReg(PhysRegIndex reg_idx)
> {
> assert(reg_idx < numTotalRegs);
97,98c132,135
< /** Number of logical floating point registers. */
< int numLogicalFloatRegs;
---
> if (reg_idx >= numPhysRegs) {
> // misc regs are always ready, ignore attempts to change that
> return;
> }
100,101c137
< /** Number of physical floating point registers. */
< int numPhysicalFloatRegs;
---
> DPRINTF(Scoreboard, "Setting reg %i as ready\n", reg_idx);
103,104c139,141
< /** Number of miscellaneous registers. */
< int numMiscRegs;
---
> assert(reg_idx < numTotalRegs);
> regScoreBoard[reg_idx] = true;
> }
106,107c143,146
< /** Number of logical integer + float registers. */
< int numLogicalRegs;
---
> /** Sets the register as not ready. */
> void unsetReg(PhysRegIndex reg_idx)
> {
> assert(reg_idx < numTotalRegs);
109,110c148,151
< /** Number of physical integer + float registers. */
< int numPhysicalRegs;
---
> if (reg_idx >= numPhysRegs) {
> // misc regs are always ready, ignore attempts to change that
> return;
> }
112,113c153,155
< /** The logical index of the zero register. */
< int zeroRegIdx;
---
> // zero reg should never be marked unready
> if (isZeroReg(reg_idx))
> return;
115,121c157
< int currentSize;
<
< void
< resize(int newSize)
< {
< currentSize = newSize;
< regScoreBoard.resize(newSize);
---
> regScoreBoard[reg_idx] = false;
124,128d159
< bool
< indexInBounds(int idx)
< {
< return idx < currentSize;
< }