Deleted Added
sdiff udiff text old ( 10427:26fee6c20087 ) new ( 10458:64809024b924 )
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

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

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)

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

449 @classmethod
450 def swig_predecls(cls, code):
451 code('%include "std_string.i"')
452
453 def __call__(self, value):
454 self = value
455 return value
456
457 def getValue(self):
458 return self
459
460# superclass for "numeric" parameter values, to emulate math
461# operations in a type-safe way. e.g., a Latency times an int returns
462# a new Latency object.
463class NumericParamValue(ParamValue):
464 def __str__(self):

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

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.

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

587 cxx_type = 'Cycles'
588 size = 64
589 unsigned = True
590
591 def getValue(self):
592 from m5.internal.core import Cycles
593 return Cycles(self.value)
594
595class Float(ParamValue, float):
596 cxx_type = 'double'
597 cmdLineSettable = True
598
599 def __init__(self, value):
600 if isinstance(value, (int, long, float, NumericParamValue, Float, str)):
601 self.value = float(value)
602 else:

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

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

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

733 def cxx_predecls(cls, code):
734 Addr.cxx_predecls(code)
735 code('#include "base/addr_range.hh"')
736
737 @classmethod
738 def swig_predecls(cls, code):
739 Addr.swig_predecls(code)
740
741 def getValue(self):
742 # Go from the Python class to the wrapped C++ class generated
743 # by swig
744 from m5.internal.range import AddrRange
745
746 return AddrRange(long(self.start), long(self.end),
747 int(self.intlvHighBit), int(self.intlvBits),
748 int(self.intlvMatch))

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

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

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

845
846 def getValue(self):
847 from m5.internal.params import EthAddr
848 return EthAddr(self.value)
849
850 def ini_str(self):
851 return self.value
852
853# When initializing an IpAddress, pass in an existing IpAddress, a string of
854# the form "a.b.c.d", or an integer representing an IP.
855class IpAddress(ParamValue):
856 cxx_type = 'Net::IpAddress'
857 ex_str = "127.0.0.1"
858 cmd_line_settable = True
859
860 @classmethod

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

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,
1163# there's not much point in using the dictionary.)
1164

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

1301 @classmethod
1302 def cxx_predecls(cls, code):
1303 code('#include "enums/$0.hh"', cls.__name__)
1304
1305 @classmethod
1306 def swig_predecls(cls, code):
1307 code('%import "python/m5/internal/enum_$0.i"', cls.__name__)
1308
1309 def getValue(self):
1310 return int(self.map[self.value])
1311
1312 def __str__(self):
1313 return self.value
1314
1315# how big does a rounding error need to be before we warn about it?
1316frequency_tolerance = 0.001 # 0.1%

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

1331
1332 def __call__(self, value):
1333 self.__init__(value)
1334 return value
1335
1336 def getValue(self):
1337 return long(self.value)
1338
1339class Latency(TickParamValue):
1340 ex_str = "100ns"
1341
1342 def __init__(self, value):
1343 if isinstance(value, (Latency, Clock)):
1344 self.ticks = value.ticks
1345 self.value = value.value
1346 elif isinstance(value, Frequency):

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

1480
1481 def getValue(self):
1482 value = float(self)
1483 return value
1484
1485 def ini_str(self):
1486 return '%f' % self.getValue()
1487
1488class Current(float, ParamValue):
1489 cxx_type = 'double'
1490 ex_str = "1mA"
1491 cmd_line_settable = False
1492
1493 def __new__(cls, value):
1494 # convert to current
1495 val = convert.toCurrent(value)

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

1505
1506 def getValue(self):
1507 value = float(self)
1508 return value
1509
1510 def ini_str(self):
1511 return '%f' % self.getValue()
1512
1513class NetworkBandwidth(float,ParamValue):
1514 cxx_type = 'float'
1515 ex_str = "1Gbps"
1516 cmd_line_settable = True
1517
1518 def __new__(cls, value):
1519 # convert to bits per second
1520 val = convert.toNetworkBandwidth(value)

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

1536 return float(value)
1537
1538 def ini_str(self):
1539 return '%f' % self.getValue()
1540
1541 def config_value(self):
1542 return '%f' % self.getValue()
1543
1544class MemoryBandwidth(float,ParamValue):
1545 cxx_type = 'float'
1546 ex_str = "1GB/s"
1547 cmd_line_settable = True
1548
1549 def __new__(cls, value):
1550 # convert to bytes per second
1551 val = convert.toMemoryBandwidth(value)

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

1566 return float(value)
1567
1568 def ini_str(self):
1569 return '%f' % self.getValue()
1570
1571 def config_value(self):
1572 return '%f' % self.getValue()
1573
1574#
1575# "Constants"... handy aliases for various values.
1576#
1577
1578# Special class for NULL pointers. Note the special check in
1579# make_param_value() above that lets these be assigned where a
1580# SimObject is required.
1581# only one copy of a particular node

--- 380 unchanged lines hidden ---