Deleted Added
sdiff udiff text old ( 10364:c12ec2a0de52 ) new ( 10380:ec1af95a2958 )
full compact
1# Copyright (c) 2012-2014 ARM Limited
2# All rights reserved.
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder. You may use the software subject to the license

--- 100 unchanged lines hidden (view full) ---

109 def swig_predecls(cls, code):
110 pass
111
112 # default for printing to .ini file is regular string conversion.
113 # will be overridden in some cases
114 def ini_str(self):
115 return str(self)
116
117 # default for printing to .json file is regular string conversion.
118 # will be overridden in some cases, mostly to use native Python
119 # types where there are similar JSON types
120 def config_value(self):
121 return str(self)
122
123 # allows us to blithely call unproxy() on things without checking
124 # if they're really proxies or not
125 def unproxy(self, base):
126 return self
127
128 # Produce a human readable version of the stored value
129 def pretty_print(self, value):
130 return str(value)

--- 90 unchanged lines hidden (view full) ---

221# single value.
222
223class VectorParamValue(list):
224 __metaclass__ = MetaParamValue
225 def __setattr__(self, attr, value):
226 raise AttributeError, \
227 "Not allowed to set %s on '%s'" % (attr, type(self).__name__)
228
229 def config_value(self):
230 return [v.config_value() for v in self]
231
232 def ini_str(self):
233 return ' '.join([v.ini_str() for v in self])
234
235 def getValue(self):
236 return [ v.getValue() for v in self ]
237
238 def unproxy(self, base):
239 if len(self) == 1 and isinstance(self[0], proxy.AllProxy):

--- 252 unchanged lines hidden (view full) ---

492 return newobj
493
494 def __sub__(self, other):
495 newobj = self.__class__(self)
496 newobj.value -= other
497 newobj._check()
498 return newobj
499
500 def config_value(self):
501 return self.value
502
503# Metaclass for bounds-checked integer parameters. See CheckedInt.
504class CheckedIntType(MetaParamValue):
505 def __init__(cls, name, bases, dict):
506 super(CheckedIntType, cls).__init__(name, bases, dict)
507
508 # CheckedInt is an abstract base class, so we actually don't
509 # want to do any processing on it... the rest of this code is
510 # just for classes that derive from CheckedInt.

--- 94 unchanged lines hidden (view full) ---

605
606 def __call__(self, value):
607 self.__init__(value)
608 return value
609
610 def getValue(self):
611 return float(self.value)
612
613 def config_value(self):
614 return self
615
616class MemorySize(CheckedInt):
617 cxx_type = 'uint64_t'
618 ex_str = '512MB'
619 size = 64
620 unsigned = True
621 def __init__(self, value):
622 if isinstance(value, MemorySize):
623 self.value = value.value

--- 151 unchanged lines hidden (view full) ---

775 def __nonzero__(self):
776 return bool(self.value)
777
778 def ini_str(self):
779 if self.value:
780 return 'true'
781 return 'false'
782
783 def config_value(self):
784 return self.value
785
786def IncEthernetAddr(addr, val = 1):
787 bytes = map(lambda x: int(x, 16), addr.split(':'))
788 bytes[5] += val
789 for i in (5, 4, 3, 2, 1):
790 val,rem = divmod(bytes[i], 256)
791 bytes[i] = rem
792 if val == 0:
793 break

--- 264 unchanged lines hidden (view full) ---

1058 if self.port < 0 or self.port > 0xffff:
1059 raise TypeError, "invalid port %d" % self.port
1060
1061 def getValue(self):
1062 from m5.internal.params import IpWithPort
1063 return IpWithPort(self.ip, self.port)
1064
1065time_formats = [ "%a %b %d %H:%M:%S %Z %Y",
1066 "%a %b %d %H:%M:%S %Y",
1067 "%Y/%m/%d %H:%M:%S",
1068 "%Y/%m/%d %H:%M",
1069 "%Y/%m/%d",
1070 "%m/%d/%Y %H:%M:%S",
1071 "%m/%d/%Y %H:%M",
1072 "%m/%d/%Y",
1073 "%m/%d/%y %H:%M:%S",
1074 "%m/%d/%y %H:%M",

--- 71 unchanged lines hidden (view full) ---

1146
1147 def __str__(self):
1148 return time.asctime(self.value)
1149
1150 def ini_str(self):
1151 return str(self)
1152
1153 def get_config_as_dict(self):
1154 assert false
1155 return str(self)
1156
1157# Enumerated types are a little more complex. The user specifies the
1158# type as Enum(foo) where foo is either a list or dictionary of
1159# alternatives (typically strings, but not necessarily so). (In the
1160# long run, the integer value of the parameter will be the list index
1161# or the corresponding dictionary value. For now, since we only check
1162# that the alternative is valid and then spit it into a .ini file,

--- 203 unchanged lines hidden (view full) ---

1366
1367 def getValue(self):
1368 if self.ticks or self.value == 0:
1369 value = self.value
1370 else:
1371 value = ticks.fromSeconds(self.value)
1372 return long(value)
1373
1374 def config_value(self):
1375 return self.getValue()
1376
1377 # convert latency to ticks
1378 def ini_str(self):
1379 return '%d' % self.getValue()
1380
1381class Frequency(TickParamValue):
1382 ex_str = "1GHz"
1383
1384 def __init__(self, value):

--- 24 unchanged lines hidden (view full) ---

1409 # convert latency to ticks
1410 def getValue(self):
1411 if self.ticks or self.value == 0:
1412 value = self.value
1413 else:
1414 value = ticks.fromSeconds(1.0 / self.value)
1415 return long(value)
1416
1417 def config_value(self):
1418 return self.getValue()
1419
1420 def ini_str(self):
1421 return '%d' % self.getValue()
1422
1423# A generic Frequency and/or Latency value. Value is stored as a
1424# latency, just like Latency and Frequency.
1425class Clock(TickParamValue):
1426 def __init__(self, value):
1427 if isinstance(value, (Latency, Clock)):

--- 21 unchanged lines hidden (view full) ---

1449 return Frequency(self)
1450 if attr in ('latency', 'period'):
1451 return Latency(self)
1452 raise AttributeError, "Frequency object has no attribute '%s'" % attr
1453
1454 def getValue(self):
1455 return self.period.getValue()
1456
1457 def config_value(self):
1458 return self.period.config_value()
1459
1460 def ini_str(self):
1461 return self.period.ini_str()
1462
1463class Voltage(float,ParamValue):
1464 cxx_type = 'double'
1465 ex_str = "1V"
1466 cmd_line_settable = False
1467

--- 40 unchanged lines hidden (view full) ---

1508 value = 8.0 / float(self)
1509 # convert to ticks per byte
1510 value = ticks.fromSeconds(value)
1511 return float(value)
1512
1513 def ini_str(self):
1514 return '%f' % self.getValue()
1515
1516 def config_value(self):
1517 return '%f' % self.getValue()
1518
1519class MemoryBandwidth(float,ParamValue):
1520 cxx_type = 'float'
1521 ex_str = "1GB/s"
1522 cmd_line_settable = True
1523
1524 def __new__(cls, value):
1525 # convert to bytes per second
1526 val = convert.toMemoryBandwidth(value)

--- 11 unchanged lines hidden (view full) ---

1538 value = 1.0 / float(self)
1539 # convert to ticks per byte
1540 value = ticks.fromSeconds(value)
1541 return float(value)
1542
1543 def ini_str(self):
1544 return '%f' % self.getValue()
1545
1546 def config_value(self):
1547 return '%f' % self.getValue()
1548
1549#
1550# "Constants"... handy aliases for various values.
1551#
1552
1553# Special class for NULL pointers. Note the special check in
1554# make_param_value() above that lets these be assigned where a
1555# SimObject is required.
1556# only one copy of a particular node

--- 13 unchanged lines hidden (view full) ---

1570 return self
1571
1572 def set_path(self, parent, name):
1573 pass
1574
1575 def __str__(self):
1576 return 'Null'
1577
1578 def config_value(self):
1579 return None
1580
1581 def getValue(self):
1582 return None
1583
1584# The only instance you'll ever need...
1585NULL = NullSimObject()
1586
1587def isNullPointer(value):
1588 return isinstance(value, NullSimObject)

--- 348 unchanged lines hidden ---