diff options
author | Daniel R. Carvalho <odanrc@yahoo.com.br> | 2019-05-29 21:15:06 +0200 |
---|---|---|
committer | Daniel Carvalho <odanrc@yahoo.com.br> | 2019-08-29 20:19:05 +0000 |
commit | fc528bb0c0d2c6fe1ae55e9aa5be8652cc3fd456 (patch) | |
tree | 559dca56c6f3fde1035f16298a165e72e97b75ac /src/base/sat_counter.hh | |
parent | 51d38a4b79d54a97d438ecdba5ce94d6e9172eef (diff) | |
download | gem5-fc528bb0c0d2c6fe1ae55e9aa5be8652cc3fd456.tar.xz |
base: Add function to saturate SatCounter
Create a saturation function for the SatCounter that makes its
internal counter reach its maximum value.
Change-Id: Ibd30fa27c4ae2714dd48e3eba85addd035fb737c
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/20451
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'src/base/sat_counter.hh')
-rw-r--r-- | src/base/sat_counter.hh | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/base/sat_counter.hh b/src/base/sat_counter.hh index 3de9486db..6aeca681d 100644 --- a/src/base/sat_counter.hh +++ b/src/base/sat_counter.hh @@ -235,6 +235,18 @@ class SatCounter */ bool isSaturated() const { return counter == maxVal; } + /** + * Saturate the counter. + * + * @return The value added to the counter to reach saturation. + */ + uint8_t saturate() + { + const uint8_t diff = maxVal - counter; + counter = maxVal; + return diff; + } + private: uint8_t initialVal; uint8_t maxVal; |