changeset 19f5df7ac6a1 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=19f5df7ac6a1
description:
        config: Change parsing of Addr so hex values work from scripts

        When passed from a configuration script with a hexadecimal value (like
        "0x80000000"), gem5 would error out. This is because it would call
        "toMemorySize" which requires the argument to end with a size specifier 
(like
        1MB, etc).

        This modification makes it so raw hex values can be passed through Addr
        parameters from the configuration scripts.

diffstat:

 src/arch/arm/ArmSystem.py |   2 +-
 src/python/m5/params.py   |  12 ++++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diffs (35 lines):

diff -r d2850235e31c -r 19f5df7ac6a1 src/arch/arm/ArmSystem.py
--- a/src/arch/arm/ArmSystem.py Wed Sep 03 07:42:19 2014 -0400
+++ b/src/arch/arm/ArmSystem.py Wed Sep 03 07:42:20 2014 -0400
@@ -65,7 +65,7 @@
     highest_el_is_64 = Param.Bool(False,
         "True if the register width of the highest implemented exception level 
"
         "is 64 bits (ARMv8)")
-    reset_addr_64 = Param.UInt64(0x0,
+    reset_addr_64 = Param.Addr(0x0,
         "Reset address if the highest implemented exception level is 64 bits "
         "(ARMv8)")
     phys_addr_range_64 = Param.UInt8(40,
diff -r d2850235e31c -r 19f5df7ac6a1 src/python/m5/params.py
--- a/src/python/m5/params.py   Wed Sep 03 07:42:19 2014 -0400
+++ b/src/python/m5/params.py   Wed Sep 03 07:42:20 2014 -0400
@@ -626,9 +626,17 @@
             self.value = value.value
         else:
             try:
+                # Often addresses are referred to with sizes. Ex: A device
+                # base address is at "512MB".  Use toMemorySize() to convert
+                # these into addresses. If the address is not specified with a
+                # "size", an exception will occur and numeric translation will
+                # proceed below.
                 self.value = convert.toMemorySize(value)
-            except TypeError:
-                self.value = long(value)
+            except (TypeError, ValueError):
+                # Convert number to string and use long() to do automatic
+                # base conversion (requires base=0 for auto-conversion)
+                self.value = long(str(value), base=0)
+
         self._check()
     def __add__(self, other):
         if isinstance(other, Addr):
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to