From d4492190e6bbf709724af28d262b0a681c975ec0 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 4 Oct 2010 11:58:06 -0700 Subject: Alpha: Fix Alpha NumMiscArchRegs constant. Also add asserts in O3's Scoreboard class to catch bad indexes. --- src/cpu/o3/scoreboard.cc | 8 +++++++- src/cpu/o3/scoreboard.hh | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'src/cpu/o3') diff --git a/src/cpu/o3/scoreboard.cc b/src/cpu/o3/scoreboard.cc index ae1e13717..7fb47f3c7 100644 --- a/src/cpu/o3/scoreboard.cc +++ b/src/cpu/o3/scoreboard.cc @@ -51,22 +51,25 @@ Scoreboard::Scoreboard(unsigned activeThreads, numPhysicalRegs = numPhysicalIntRegs + numPhysicalFloatRegs; //Resize scoreboard appropriately - regScoreBoard.resize(numPhysicalRegs + (numMiscRegs * activeThreads)); + resize(numPhysicalRegs + (numMiscRegs * activeThreads)); //Initialize values for (int i=0; i < numLogicalIntRegs * activeThreads; i++) { + assert(indexInBounds(i)); regScoreBoard[i] = 1; } for (int i= numPhysicalIntRegs; i < numPhysicalIntRegs + (numLogicalFloatRegs * activeThreads); i++) { + assert(indexInBounds(i)); regScoreBoard[i] = 1; } for (int i = numPhysicalRegs; i < numPhysicalRegs + (numMiscRegs * activeThreads); i++) { + assert(indexInBounds(i)); regScoreBoard[i] = 1; } } @@ -93,6 +96,7 @@ Scoreboard::getReg(PhysRegIndex phys_reg) } #endif + assert(indexInBounds(phys_reg)); return regScoreBoard[phys_reg]; } @@ -101,6 +105,7 @@ Scoreboard::setReg(PhysRegIndex phys_reg) { DPRINTF(Scoreboard, "Setting reg %i as ready\n", phys_reg); + assert(indexInBounds(phys_reg)); regScoreBoard[phys_reg] = 1; } @@ -120,5 +125,6 @@ Scoreboard::unsetReg(PhysRegIndex ready_reg) } #endif + assert(indexInBounds(ready_reg)); regScoreBoard[ready_reg] = 0; } diff --git a/src/cpu/o3/scoreboard.hh b/src/cpu/o3/scoreboard.hh index eefff1d8b..b1c2bd026 100644 --- a/src/cpu/o3/scoreboard.hh +++ b/src/cpu/o3/scoreboard.hh @@ -111,6 +111,21 @@ class Scoreboard /** The logical index of the zero register. */ int zeroRegIdx; + + int currentSize; + + void + resize(int newSize) + { + currentSize = newSize; + regScoreBoard.resize(newSize); + } + + bool + indexInBounds(int idx) + { + return idx < currentSize; + } }; #endif -- cgit v1.2.3