diff -r 8a6c6e7d4ea5 -r dec5e0f271c5 src/python/m5/params.py --- a/src/python/m5/params.py Mon Sep 29 11:42:36 2014 +0100 +++ b/src/python/m5/params.py Mon Sep 29 11:42:52 2014 +0100 @@ -1611,6 +1611,31 @@ def cxx_ini_parse(self, code, src, dest, ret): code('%s (std::istringstream(%s) >> %s).eof();' % (ret, src, dest)) +class Current(float,ParamValue): + cxx_type = 'double' + ex_str = "1mA" + cmd_line_settable = False + + def __new__(cls, value): + # convert to current + val = convert.toCurrent(value) + return super(cls, Current).__new__(cls, val) + + def __call__(self, value): + val = convert.toCurrent(value) + self.__init__(val) + return value + + def __str__(self): + return str(self.getValue()) + + def getValue(self): + value = float(self) + return value + + def ini_str(self): + return '%f' % self.getValue() + class NetworkBandwidth(float,ParamValue): cxx_type = 'float' ex_str = "1Gbps" diff -r 8a6c6e7d4ea5 -r dec5e0f271c5 src/python/m5/util/convert.py --- a/src/python/m5/util/convert.py Mon Sep 29 11:42:36 2014 +0100 +++ b/src/python/m5/util/convert.py Mon Sep 29 11:42:52 2014 +0100 @@ -311,3 +311,11 @@ raise ValueError, "cannot convert '%s' to voltage" % value +def toCurrent(value): + if not isinstance(value, str): + raise TypeError, "wrong type '%s' should be str" % type(value) + + if value.endswith('A'): + return toFloat(value[:-1]) + + raise ValueError, "cannot convert '%s' to current" % value