Deleted Added
sdiff udiff text old ( 9184:a1a8f137b796 ) new ( 9232:3bb99fab80d4 )
full compact
1# Copyright (c) 2012 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

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

544 self.value = long(value)
545 self._check()
546 def __add__(self, other):
547 if isinstance(other, Addr):
548 return self.value + other.value
549 else:
550 return self.value + other
551
552
553class MetaRange(MetaParamValue):
554 def __init__(cls, name, bases, dict):
555 super(MetaRange, cls).__init__(name, bases, dict)
556 if name == 'Range':
557 return
558 cls.cxx_type = 'Range< %s >' % cls.type.cxx_type
559
560class Range(ParamValue):
561 __metaclass__ = MetaRange
562 type = Int # default; can be overridden in subclasses
563 def __init__(self, *args, **kwargs):
564 def handle_kwargs(self, kwargs):
565 if 'end' in kwargs:
566 self.second = self.type(kwargs.pop('end'))
567 elif 'size' in kwargs:
568 self.second = self.first + self.type(kwargs.pop('size')) - 1
569 else:
570 raise TypeError, "Either end or size must be specified"
571
572 if len(args) == 0:
573 self.first = self.type(kwargs.pop('start'))
574 handle_kwargs(self, kwargs)
575
576 elif len(args) == 1:
577 if kwargs:
578 self.first = self.type(args[0])
579 handle_kwargs(self, kwargs)
580 elif isinstance(args[0], Range):
581 self.first = self.type(args[0].first)
582 self.second = self.type(args[0].second)
583 elif isinstance(args[0], (list, tuple)):
584 self.first = self.type(args[0][0])
585 self.second = self.type(args[0][1])
586 else:
587 self.first = self.type(0)
588 self.second = self.type(args[0]) - 1
589
590 elif len(args) == 2:
591 self.first = self.type(args[0])
592 self.second = self.type(args[1])
593 else:
594 raise TypeError, "Too many arguments specified"
595
596 if kwargs:
597 raise TypeError, "too many keywords: %s" % kwargs.keys()
598
599 def __str__(self):
600 return '%s:%s' % (self.first, self.second)
601
602 @classmethod
603 def cxx_predecls(cls, code):
604 cls.type.cxx_predecls(code)
605 code('#include "base/range.hh"')
606
607 @classmethod
608 def swig_predecls(cls, code):
609 cls.type.swig_predecls(code)
610 code('%import "python/swig/range.i"')
611
612class AddrRange(Range):
613 type = Addr
614
615 def getValue(self):
616 from m5.internal.range import AddrRange
617
618 value = AddrRange()
619 value.start = long(self.first)
620 value.end = long(self.second)
621 return value
622
623class TickRange(Range):
624 type = Tick
625
626 def getValue(self):
627 from m5.internal.range import TickRange
628
629 value = TickRange()
630 value.start = long(self.first)
631 value.end = long(self.second)
632 return value
633
634# Boolean parameter type. Python doesn't let you subclass bool, since
635# it doesn't want to let you create multiple instances of True and
636# False. Thus this is a little more complicated than String.
637class Bool(ParamValue):
638 cxx_type = 'bool'
639 def __init__(self, value):
640 try:
641 self.value = convert.toBool(value)

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

1638 'Int', 'Unsigned', 'Int8', 'UInt8', 'Int16', 'UInt16',
1639 'Int32', 'UInt32', 'Int64', 'UInt64',
1640 'Counter', 'Addr', 'Tick', 'Percent',
1641 'TcpPort', 'UdpPort', 'EthernetAddr',
1642 'IpAddress', 'IpNetmask', 'IpWithPort',
1643 'MemorySize', 'MemorySize32',
1644 'Latency', 'Frequency', 'Clock',
1645 'NetworkBandwidth', 'MemoryBandwidth',
1646 'Range', 'AddrRange', 'TickRange',
1647 'MaxAddr', 'MaxTick', 'AllMemory',
1648 'Time',
1649 'NextEthernetAddr', 'NULL',
1650 'MasterPort', 'SlavePort',
1651 'VectorMasterPort', 'VectorSlavePort']
1652
1653import SimObject