summaryrefslogtreecommitdiff
path: root/cpu/beta_cpu/sat_counter.hh
diff options
context:
space:
mode:
authorKevin Lim <ktlim@umich.edu>2005-03-10 15:53:27 -0500
committerKevin Lim <ktlim@umich.edu>2005-03-10 15:53:27 -0500
commitc12a665c3120b61ed4e09da5d8a52c57406763d5 (patch)
treeb5176be0d526ea24cafcd6f615058651f2b34dfb /cpu/beta_cpu/sat_counter.hh
parentaa8c9db159422a313f6dfc9a76fd827515b32126 (diff)
parent51108a8c0a3a42702f49a945f8a4dac776a8d189 (diff)
downloadgem5-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.hh')
-rw-r--r--cpu/beta_cpu/sat_counter.hh62
1 files changed, 62 insertions, 0 deletions
diff --git a/cpu/beta_cpu/sat_counter.hh b/cpu/beta_cpu/sat_counter.hh
new file mode 100644
index 000000000..e0f23e13e
--- /dev/null
+++ b/cpu/beta_cpu/sat_counter.hh
@@ -0,0 +1,62 @@
+#ifndef __CPU_BETA_CPU_SAT_COUNTER_HH__
+#define __CPU_BETA_CPU_SAT_COUNTER_HH__
+
+#include <stdint.h>
+
+/**
+ * Private counter class for the internal saturating counters.
+ * Implements an n bit saturating counter and provides methods to
+ * increment, decrement, and read it.
+ * @todo Consider making this something that more closely mimics a
+ * built in class so you can use ++ or --.
+ */
+class SatCounter
+{
+ public:
+ /**
+ * Constructor for the counter.
+ */
+ SatCounter();
+
+ /**
+ * Constructor for the counter.
+ * @param bits How many bits the counter will have.
+ */
+ SatCounter(unsigned bits);
+
+ /**
+ * Constructor for the counter.
+ * @param bits How many bits the counter will have.
+ * @param initial_val Starting value for each counter.
+ */
+ SatCounter(unsigned bits, unsigned initial_val);
+
+ /**
+ * Sets the number of bits.
+ */
+ void setBits(unsigned bits);
+
+ /**
+ * Increments the counter's current value.
+ */
+ void increment();
+
+ /**
+ * Decrements the counter's current value.
+ */
+ void decrement();
+
+ /**
+ * Read the counter's value.
+ */
+ const uint8_t read() const
+ {
+ return counter;
+ }
+
+ private:
+ uint8_t maxVal;
+ uint8_t counter;
+};
+
+#endif // __CPU_BETA_CPU_SAT_COUNTER_HH__