python: Fix param -> int conversion issues
authorAndreas Sandberg <andreas.sandberg@arm.com>
Sun, 27 Jan 2019 09:31:31 +0000 (09:31 +0000)
committerAndreas Sandberg <andreas.sandberg@arm.com>
Fri, 22 Feb 2019 15:26:41 +0000 (15:26 +0000)
Python 3 doesn't convert params to integers automatically in
range(). Add __index__ to CheckedInt to enable implicit conversions
again. Add explicit conversions where necessary.

Change-Id: I2de6c9906d3bb7616f12ada6728b9e4b1928511c
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/16000
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>

src/cpu/BaseCPU.py
src/python/m5/params.py

index 60c86a44f524f945ea081f4f626df76e47dfcf6c..93cb6e07195691a4594b07f8547ef0e073bf2289 100644 (file)
@@ -365,7 +365,7 @@ class BaseCPU(MemObject):
                 warn("Platform not found for device tree generation; " \
                      "system or multiple CPUs may not start")
 
-            freq = round(self.clk_domain.unproxy(self).clock[0].frequency)
+            freq = int(self.clk_domain.unproxy(self).clock[0].frequency)
             node.append(FdtPropertyWords("clock-frequency", freq))
 
             # Unique key for this CPU
index 729fc1242af5a3a78d6c6c9091a8f75e75f504e1..1470765bbc1fef085a52e659267310cee2b95e07 100644 (file)
@@ -606,6 +606,9 @@ class CheckedInt(NumericParamValue):
         self.__init__(value)
         return value
 
+    def __index__(self):
+        return int(self.value)
+
     @classmethod
     def cxx_predecls(cls, code):
         # most derived types require this, so we just do it here once