misc: Merge in 'hotfix-m5-tick-rounding-error'

This commit is contained in:
Bobby R. Bruce
2020-06-01 22:46:51 -07:00

View File

@@ -25,7 +25,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from __future__ import print_function
from math import ceil
import decimal
import six
if six.PY3:
long = int
@@ -74,7 +74,8 @@ def fromSeconds(value):
# convert the value from time to ticks
value *= _m5.core.getClockFrequency()
int_value = int(ceil(value))
int_value = int(
decimal.Decimal(value).to_integral_value( decimal.ROUND_HALF_UP))
err = (value - int_value) / value
if err > frequency_tolerance:
warn("rounding error > tolerance\n %f rounded to %d", value,