base: Fix negative op-assign of SatCounter
authorDaniel R. Carvalho <odanrc@yahoo.com.br>
Sun, 15 Dec 2019 15:24:15 +0000 (16:24 +0100)
committerDaniel Carvalho <odanrc@yahoo.com.br>
Sat, 21 Dec 2019 10:58:08 +0000 (10:58 +0000)
commit8ba0ba4871907aaa08c862534033f2922a3d2ba7
tree84653473bf4039d0cba9065fbdefdca43ac45ac5
parentc3fecd4520555dfaf6a3836f791e638de1412e28
base: Fix negative op-assign of SatCounter

The value of the add and subtract assignment operations can be negative,
and this was not being handled properly previously. Regarding shift
assignment, the standard says it is undefined behaviour if a negative
number is given, so add assertions for these cases.

Change-Id: I2f1e4143c6385caa80fb25f84ca8edb0ca7e62b7
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23664
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/base/sat_counter.hh
src/base/sat_counter.test.cc