summaryrefslogtreecommitdiff
path: root/src/python/m5/params.py
diff options
context:
space:
mode:
authorMitch Hayenga <mitch.hayenga@arm.com>2014-09-03 07:42:20 -0400
committerMitch Hayenga <mitch.hayenga@arm.com>2014-09-03 07:42:20 -0400
commit23c85407562c3e2e2f3e1ca8b8dcbdc38fac82df (patch)
tree3fa6f9e37df77a4ae3fbe0f8358c7a38b57aa205 /src/python/m5/params.py
parent1046b8d6e5303fa4fede2d7c0712ef0719c82eb7 (diff)
downloadgem5-23c85407562c3e2e2f3e1ca8b8dcbdc38fac82df.tar.xz
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 (limited to 'src/python/m5/params.py')
-rw-r--r--src/python/m5/params.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/python/m5/params.py b/src/python/m5/params.py
index 88d38f87a..dfc3ede3b 100644
--- a/src/python/m5/params.py
+++ b/src/python/m5/params.py
@@ -626,9 +626,17 @@ class Addr(CheckedInt):
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):