Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/5622
Change subject: config: Simplify the definitions of the Voltage and Current
params.
......................................................................
config: Simplify the definitions of the Voltage and Current params.
These had a lot of code which duplicated what was already in the
Float param value class. Also, printing into the ini file with "%f"
forces python to truncate values which require more precision than the
fixed float format supports.
Change-Id: Iad9623b71a31d17b69c184082585dcbb881eaa20
---
M src/python/m5/params.py
1 file changed, 12 insertions(+), 56 deletions(-)
diff --git a/src/python/m5/params.py b/src/python/m5/params.py
index 9ca4f2d..8bac9f0 100644
--- a/src/python/m5/params.py
+++ b/src/python/m5/params.py
@@ -1541,71 +1541,27 @@
def ini_str(self):
return self.period.ini_str()
-class Voltage(float,ParamValue):
- cxx_type = 'double'
+class Voltage(Float):
ex_str = "1V"
- cmd_line_settable = True
def __new__(cls, value):
- # convert to voltage
- val = convert.toVoltage(value)
- return super(cls, Voltage).__new__(cls, val)
+ value = convert.toVoltage(value)
+ return super(cls, Voltage).__new__(cls, value)
- def __call__(self, value):
- val = convert.toVoltage(value)
- self.__init__(val)
- return value
+ def __init__(self, value):
+ value = convert.toVoltage(value)
+ super(Voltage, self).__init__(value)
- def __str__(self):
- return str(self.getValue())
-
- def getValue(self):
- value = float(self)
- return value
-
- def ini_str(self):
- return '%f' % self.getValue()
-
- @classmethod
- def cxx_ini_predecls(cls, code):
- code('#include <sstream>')
-
- @classmethod
- 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'
+class Current(Float):
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)
+ value = convert.toCurrent(value)
+ return super(cls, Current).__new__(cls, value)
- 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()
-
- @classmethod
- def cxx_ini_predecls(cls, code):
- code('#include <sstream>')
-
- @classmethod
- def cxx_ini_parse(self, code, src, dest, ret):
- code('%s (std::istringstream(%s) >> %s).eof();' % (ret, src, dest))
+ def __init__(self, value):
+ value = convert.toCurrent(value)
+ super(Current, self).__init__(value)
class NetworkBandwidth(float,ParamValue):
cxx_type = 'float'
--
To view, visit https://gem5-review.googlesource.com/5622
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iad9623b71a31d17b69c184082585dcbb881eaa20
Gerrit-Change-Number: 5622
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev