summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorSteve Reinhardt <stever@eecs.umich.edu>2005-04-17 00:41:50 -0400
committerSteve Reinhardt <stever@eecs.umich.edu>2005-04-17 00:41:50 -0400
commit535cfaa01e0234e224e588e753419d8777e22d0b (patch)
treef065aaf5c08aa2db78ace7dda7ad83e3d48e5f8f /python
parent26df1a96c966d00cdcfbbcae239b0c77c24473e2 (diff)
downloadgem5-535cfaa01e0234e224e588e753419d8777e22d0b.tar.xz
Mostly hacks for multiplying Frequency-type proxies by constants
(plus some small fixes). python/m5/config.py: Hacks to allow multiplication on Frequency/Latency-valued proxies. Provide __rmul__ as well as __mul__ on Proxy objects. test/genini.py: Default value for -EFOO should be True not 1 (since 1 is no longer convertable to Bool). --HG-- extra : convert_revision : f8a221fcd9e095fdd7b7db4be0ed0cdcd20074be
Diffstat (limited to 'python')
-rw-r--r--python/m5/config.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/python/m5/config.py b/python/m5/config.py
index 74988109b..2db2164fc 100644
--- a/python/m5/config.py
+++ b/python/m5/config.py
@@ -177,7 +177,7 @@ class Proxy(object):
# support multiplying proxies by constants
def __mul__(self, other):
- if not isinstance(other, int):
+ if not isinstance(other, (int, float)):
raise TypeError, "Proxy multiplier must be integer"
if self._multiplier == None:
self._multiplier = other
@@ -186,13 +186,19 @@ class Proxy(object):
self._multiplier *= other
return self
+ __rmul__ = __mul__
+
def _mulcheck(self, result):
if self._multiplier == None:
return result
if not isinstance(result, int):
- raise TypeError, "Proxy with multiplier resolves to " \
- "non-integer value"
- return result * self._multiplier
+ # this was an error, but for now we'll assume if it's not
+ # an int it must be a Frequency (yuk)
+ result = Frequency._convert(result)
+ # assuming we're dealing with a frequency here, turn it into
+ # a string and give it a 't' suffix so the Frequency._convert
+ # doesn't choke on it later.
+ return ("%d" % int(round((result * self._multiplier)))) + 't'
def unproxy(self, base, ptype):
obj = base