diff options
author | Kevin Lim <ktlim@umich.edu> | 2005-03-10 15:53:27 -0500 |
---|---|---|
committer | Kevin Lim <ktlim@umich.edu> | 2005-03-10 15:53:27 -0500 |
commit | c12a665c3120b61ed4e09da5d8a52c57406763d5 (patch) | |
tree | b5176be0d526ea24cafcd6f615058651f2b34dfb /cpu/beta_cpu/sat_counter.cc | |
parent | aa8c9db159422a313f6dfc9a76fd827515b32126 (diff) | |
parent | 51108a8c0a3a42702f49a945f8a4dac776a8d189 (diff) | |
download | gem5-c12a665c3120b61ed4e09da5d8a52c57406763d5.tar.xz |
Merge ktlim@zizzer.eecs.umich.edu:/bk/m5
into zamp.eecs.umich.edu:/z/ktlim2/m5
--HG--
extra : convert_revision : a58535776cf5a3d17f8d9f65144cdf8db54289aa
Diffstat (limited to 'cpu/beta_cpu/sat_counter.cc')
-rw-r--r-- | cpu/beta_cpu/sat_counter.cc | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/cpu/beta_cpu/sat_counter.cc b/cpu/beta_cpu/sat_counter.cc new file mode 100644 index 000000000..da095c3e1 --- /dev/null +++ b/cpu/beta_cpu/sat_counter.cc @@ -0,0 +1,43 @@ +#include "base/misc.hh" +#include "cpu/beta_cpu/sat_counter.hh" + +SatCounter::SatCounter() + : maxVal(0), counter(0) +{ +} + +SatCounter::SatCounter(unsigned bits) + : maxVal((1 << bits) - 1), counter(0) +{ +} + +SatCounter::SatCounter(unsigned bits, unsigned initial_val) + : maxVal((1 << bits) - 1), counter(initial_val) +{ + // Check to make sure initial value doesn't exceed the max counter value. + if (initial_val > maxVal) { + panic("BP: Initial counter value exceeds max size."); + } +} + +void +SatCounter::setBits(unsigned bits) +{ + maxVal = (1 << bits) - 1; +} + +void +SatCounter::increment() +{ + if(counter < maxVal) { + ++counter; + } +} + +void +SatCounter::decrement() +{ + if(counter > 0) { + --counter; + } +} |