params.py (10364:c12ec2a0de52) | params.py (10380:ec1af95a2958) |
---|---|
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 | 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 |
|
117 # allows us to blithely call unproxy() on things without checking 118 # if they're really proxies or not 119 def unproxy(self, base): 120 return self 121 122 # Produce a human readable version of the stored value 123 def pretty_print(self, value): 124 return str(value) --- 90 unchanged lines hidden (view full) --- 215# single value. 216 217class VectorParamValue(list): 218 __metaclass__ = MetaParamValue 219 def __setattr__(self, attr, value): 220 raise AttributeError, \ 221 "Not allowed to set %s on '%s'" % (attr, type(self).__name__) 222 | 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 |
|
223 def ini_str(self): 224 return ' '.join([v.ini_str() for v in self]) 225 226 def getValue(self): 227 return [ v.getValue() for v in self ] 228 229 def unproxy(self, base): 230 if len(self) == 1 and isinstance(self[0], proxy.AllProxy): --- 252 unchanged lines hidden (view full) --- 483 return newobj 484 485 def __sub__(self, other): 486 newobj = self.__class__(self) 487 newobj.value -= other 488 newobj._check() 489 return newobj 490 | 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 |
|
491# Metaclass for bounds-checked integer parameters. See CheckedInt. 492class CheckedIntType(MetaParamValue): 493 def __init__(cls, name, bases, dict): 494 super(CheckedIntType, cls).__init__(name, bases, dict) 495 496 # CheckedInt is an abstract base class, so we actually don't 497 # want to do any processing on it... the rest of this code is 498 # just for classes that derive from CheckedInt. --- 94 unchanged lines hidden (view full) --- 593 594 def __call__(self, value): 595 self.__init__(value) 596 return value 597 598 def getValue(self): 599 return float(self.value) 600 | 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 |
|
601class MemorySize(CheckedInt): 602 cxx_type = 'uint64_t' 603 ex_str = '512MB' 604 size = 64 605 unsigned = True 606 def __init__(self, value): 607 if isinstance(value, MemorySize): 608 self.value = value.value --- 151 unchanged lines hidden (view full) --- 760 def __nonzero__(self): 761 return bool(self.value) 762 763 def ini_str(self): 764 if self.value: 765 return 'true' 766 return 'false' 767 | 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 |
|
768def IncEthernetAddr(addr, val = 1): 769 bytes = map(lambda x: int(x, 16), addr.split(':')) 770 bytes[5] += val 771 for i in (5, 4, 3, 2, 1): 772 val,rem = divmod(bytes[i], 256) 773 bytes[i] = rem 774 if val == 0: 775 break --- 264 unchanged lines hidden (view full) --- 1040 if self.port < 0 or self.port > 0xffff: 1041 raise TypeError, "invalid port %d" % self.port 1042 1043 def getValue(self): 1044 from m5.internal.params import IpWithPort 1045 return IpWithPort(self.ip, self.port) 1046 1047time_formats = [ "%a %b %d %H:%M:%S %Z %Y", | 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", |
1048 "%a %b %d %H:%M:%S %Z %Y", | 1066 "%a %b %d %H:%M:%S %Y", |
1049 "%Y/%m/%d %H:%M:%S", 1050 "%Y/%m/%d %H:%M", 1051 "%Y/%m/%d", 1052 "%m/%d/%Y %H:%M:%S", 1053 "%m/%d/%Y %H:%M", 1054 "%m/%d/%Y", 1055 "%m/%d/%y %H:%M:%S", 1056 "%m/%d/%y %H:%M", --- 71 unchanged lines hidden (view full) --- 1128 1129 def __str__(self): 1130 return time.asctime(self.value) 1131 1132 def ini_str(self): 1133 return str(self) 1134 1135 def get_config_as_dict(self): | 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 |
|
1136 return str(self) 1137 1138# Enumerated types are a little more complex. The user specifies the 1139# type as Enum(foo) where foo is either a list or dictionary of 1140# alternatives (typically strings, but not necessarily so). (In the 1141# long run, the integer value of the parameter will be the list index 1142# or the corresponding dictionary value. For now, since we only check 1143# that the alternative is valid and then spit it into a .ini file, --- 203 unchanged lines hidden (view full) --- 1347 1348 def getValue(self): 1349 if self.ticks or self.value == 0: 1350 value = self.value 1351 else: 1352 value = ticks.fromSeconds(self.value) 1353 return long(value) 1354 | 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 |
|
1355 # convert latency to ticks 1356 def ini_str(self): 1357 return '%d' % self.getValue() 1358 1359class Frequency(TickParamValue): 1360 ex_str = "1GHz" 1361 1362 def __init__(self, value): --- 24 unchanged lines hidden (view full) --- 1387 # convert latency to ticks 1388 def getValue(self): 1389 if self.ticks or self.value == 0: 1390 value = self.value 1391 else: 1392 value = ticks.fromSeconds(1.0 / self.value) 1393 return long(value) 1394 | 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 |
|
1395 def ini_str(self): 1396 return '%d' % self.getValue() 1397 1398# A generic Frequency and/or Latency value. Value is stored as a 1399# latency, just like Latency and Frequency. 1400class Clock(TickParamValue): 1401 def __init__(self, value): 1402 if isinstance(value, (Latency, Clock)): --- 21 unchanged lines hidden (view full) --- 1424 return Frequency(self) 1425 if attr in ('latency', 'period'): 1426 return Latency(self) 1427 raise AttributeError, "Frequency object has no attribute '%s'" % attr 1428 1429 def getValue(self): 1430 return self.period.getValue() 1431 | 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 |
|
1432 def ini_str(self): 1433 return self.period.ini_str() 1434 1435class Voltage(float,ParamValue): 1436 cxx_type = 'double' 1437 ex_str = "1V" 1438 cmd_line_settable = False 1439 --- 40 unchanged lines hidden (view full) --- 1480 value = 8.0 / float(self) 1481 # convert to ticks per byte 1482 value = ticks.fromSeconds(value) 1483 return float(value) 1484 1485 def ini_str(self): 1486 return '%f' % self.getValue() 1487 | 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 |
|
1488class MemoryBandwidth(float,ParamValue): 1489 cxx_type = 'float' 1490 ex_str = "1GB/s" 1491 cmd_line_settable = True 1492 1493 def __new__(cls, value): 1494 # convert to bytes per second 1495 val = convert.toMemoryBandwidth(value) --- 11 unchanged lines hidden (view full) --- 1507 value = 1.0 / float(self) 1508 # convert to ticks per byte 1509 value = ticks.fromSeconds(value) 1510 return float(value) 1511 1512 def ini_str(self): 1513 return '%f' % self.getValue() 1514 | 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 |
|
1515# 1516# "Constants"... handy aliases for various values. 1517# 1518 1519# Special class for NULL pointers. Note the special check in 1520# make_param_value() above that lets these be assigned where a 1521# SimObject is required. 1522# only one copy of a particular node --- 13 unchanged lines hidden (view full) --- 1536 return self 1537 1538 def set_path(self, parent, name): 1539 pass 1540 1541 def __str__(self): 1542 return 'Null' 1543 | 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 |
|
1544 def getValue(self): 1545 return None 1546 1547# The only instance you'll ever need... 1548NULL = NullSimObject() 1549 1550def isNullPointer(value): 1551 return isinstance(value, NullSimObject) --- 348 unchanged lines hidden --- | 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 --- |