params.py (13891:b92919e5fb16) params.py (14049:b9aea12fc52c)
1# Copyright (c) 2012-2014, 2017, 2018 ARM Limited
1# Copyright (c) 2012-2014, 2017-2019 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
9# terms below provided that you ensure that this notice is replicated

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

756 cxx_type = 'AddrRange'
757
758 def __init__(self, *args, **kwargs):
759 # Disable interleaving and hashing by default
760 self.intlvHighBit = 0
761 self.xorHighBit = 0
762 self.intlvBits = 0
763 self.intlvMatch = 0
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
9# terms below provided that you ensure that this notice is replicated

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

756 cxx_type = 'AddrRange'
757
758 def __init__(self, *args, **kwargs):
759 # Disable interleaving and hashing by default
760 self.intlvHighBit = 0
761 self.xorHighBit = 0
762 self.intlvBits = 0
763 self.intlvMatch = 0
764 self.masks = []
764
765 def handle_kwargs(self, kwargs):
766 # An address range needs to have an upper limit, specified
767 # either explicitly with an end, or as an offset using the
768 # size keyword.
769 if 'end' in kwargs:
770 self.end = Addr(kwargs.pop('end'))
771 elif 'size' in kwargs:
772 self.end = self.start + Addr(kwargs.pop('size')) - 1
773 else:
774 raise TypeError("Either end or size must be specified")
775
776 # Now on to the optional bit
765
766 def handle_kwargs(self, kwargs):
767 # An address range needs to have an upper limit, specified
768 # either explicitly with an end, or as an offset using the
769 # size keyword.
770 if 'end' in kwargs:
771 self.end = Addr(kwargs.pop('end'))
772 elif 'size' in kwargs:
773 self.end = self.start + Addr(kwargs.pop('size')) - 1
774 else:
775 raise TypeError("Either end or size must be specified")
776
777 # Now on to the optional bit
777 if 'intlvHighBit' in kwargs:
778 self.intlvHighBit = int(kwargs.pop('intlvHighBit'))
779 if 'xorHighBit' in kwargs:
780 self.xorHighBit = int(kwargs.pop('xorHighBit'))
781 if 'intlvBits' in kwargs:
782 self.intlvBits = int(kwargs.pop('intlvBits'))
783 if 'intlvMatch' in kwargs:
784 self.intlvMatch = int(kwargs.pop('intlvMatch'))
785
778 if 'intlvMatch' in kwargs:
779 self.intlvMatch = int(kwargs.pop('intlvMatch'))
780
781 if 'masks' in kwargs:
782 self.masks = [ long(x) for x in list(kwargs.pop('masks')) ]
783 self.intlvBits = len(self.masks)
784 else:
785 if 'intlvHighBit' in kwargs:
786 intlv_high_bit = int(kwargs.pop('intlvHighBit'))
787 if 'xorHighBit' in kwargs:
788 xor_high_bit = int(kwargs.pop('xorHighBit'))
789 if 'intlvBits' in kwargs:
790 self.intlvBits = int(kwargs.pop('intlvBits'))
791 self.masks = [0] * self.intlvBits
792 for i in range(0, self.intlvBits):
793 bit1 = intlv_high_bit - i
794 mask = 1 << bit1
795 if xor_high_bit != 0:
796 bit2 = xor_high_bit - i
797 mask |= 1 << bit2
798 self.masks[self.intlvBits - i - 1] = mask
799
786 if len(args) == 0:
787 self.start = Addr(kwargs.pop('start'))
788 handle_kwargs(self, kwargs)
789
790 elif len(args) == 1:
791 if kwargs:
792 self.start = Addr(args[0])
793 handle_kwargs(self, kwargs)

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

803 self.end = Addr(args[1])
804 else:
805 raise TypeError("Too many arguments specified")
806
807 if kwargs:
808 raise TypeError("Too many keywords: %s" % list(kwargs.keys()))
809
810 def __str__(self):
800 if len(args) == 0:
801 self.start = Addr(kwargs.pop('start'))
802 handle_kwargs(self, kwargs)
803
804 elif len(args) == 1:
805 if kwargs:
806 self.start = Addr(args[0])
807 handle_kwargs(self, kwargs)

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

817 self.end = Addr(args[1])
818 else:
819 raise TypeError("Too many arguments specified")
820
821 if kwargs:
822 raise TypeError("Too many keywords: %s" % list(kwargs.keys()))
823
824 def __str__(self):
811 return '%s:%s:%s:%s:%s:%s' \
812 % (self.start, self.end, self.intlvHighBit, self.xorHighBit,\
813 self.intlvBits, self.intlvMatch)
825 if len(self.masks) == 0:
826 return '%s:%s' % (self.start, self.end)
827 else:
828 return '%s:%s:%s:%s' % (self.start, self.end, self.intlvMatch,
829 ':'.join(str(m) for m in self.masks))
814
815 def size(self):
816 # Divide the size by the size of the interleaving slice
817 return (long(self.end) - long(self.start) + 1) >> self.intlvBits
818
819 @classmethod
820 def cxx_predecls(cls, code):
821 Addr.cxx_predecls(code)
822 code('#include "base/addr_range.hh"')
823
824 @classmethod
825 def pybind_predecls(cls, code):
826 Addr.pybind_predecls(code)
827 code('#include "base/addr_range.hh"')
828
829 @classmethod
830 def cxx_ini_predecls(cls, code):
831 code('#include <sstream>')
830
831 def size(self):
832 # Divide the size by the size of the interleaving slice
833 return (long(self.end) - long(self.start) + 1) >> self.intlvBits
834
835 @classmethod
836 def cxx_predecls(cls, code):
837 Addr.cxx_predecls(code)
838 code('#include "base/addr_range.hh"')
839
840 @classmethod
841 def pybind_predecls(cls, code):
842 Addr.pybind_predecls(code)
843 code('#include "base/addr_range.hh"')
844
845 @classmethod
846 def cxx_ini_predecls(cls, code):
847 code('#include <sstream>')
848 code('#include <vector>')
849 code('#include "base/types.hh"')
832
833 @classmethod
834 def cxx_ini_parse(cls, code, src, dest, ret):
850
851 @classmethod
852 def cxx_ini_parse(cls, code, src, dest, ret):
835 code('uint64_t _start, _end, _intlvHighBit = 0, _xorHighBit = 0;')
836 code('uint64_t _intlvBits = 0, _intlvMatch = 0;')
853 code('bool _ret = true;')
854 code('uint64_t _start, _end, _intlvMatch = 0;')
855 code('std::vector<Addr> _masks;')
837 code('char _sep;')
838 code('std::istringstream _stream(${src});')
839 code('_stream >> _start;')
840 code('_stream.get(_sep);')
856 code('char _sep;')
857 code('std::istringstream _stream(${src});')
858 code('_stream >> _start;')
859 code('_stream.get(_sep);')
860 code('_ret = _sep == \':\';')
841 code('_stream >> _end;')
842 code('if (!_stream.fail() && !_stream.eof()) {')
843 code(' _stream.get(_sep);')
861 code('_stream >> _end;')
862 code('if (!_stream.fail() && !_stream.eof()) {')
863 code(' _stream.get(_sep);')
844 code(' _stream >> _intlvHighBit;')
845 code(' _stream.get(_sep);')
846 code(' _stream >> _xorHighBit;')
847 code(' _stream.get(_sep);')
848 code(' _stream >> _intlvBits;')
849 code(' _stream.get(_sep);')
864 code(' _ret = ret && _sep == \':\';')
850 code(' _stream >> _intlvMatch;')
865 code(' _stream >> _intlvMatch;')
866 code(' while (!_stream.fail() && !_stream.eof()) {')
867 code(' _stream.get(_sep);')
868 code(' _ret = ret && _sep == \':\';')
869 code(' Addr mask;')
870 code(' _stream >> mask;')
871 code(' _masks.push_back(mask);')
872 code(' }')
851 code('}')
873 code('}')
852 code('bool _ret = !_stream.fail() &&'
853 '_stream.eof() && _sep == \':\';')
874 code('_ret = _ret && !_stream.fail() && _stream.eof();')
854 code('if (_ret)')
875 code('if (_ret)')
855 code(' ${dest} = AddrRange(_start, _end, _intlvHighBit, \
856 _xorHighBit, _intlvBits, _intlvMatch);')
876 code(' ${dest} = AddrRange(_start, _end, _masks, _intlvMatch);')
857 code('${ret} _ret;')
858
859 def getValue(self):
860 # Go from the Python class to the wrapped C++ class
861 from _m5.range import AddrRange
862
863 return AddrRange(long(self.start), long(self.end),
877 code('${ret} _ret;')
878
879 def getValue(self):
880 # Go from the Python class to the wrapped C++ class
881 from _m5.range import AddrRange
882
883 return AddrRange(long(self.start), long(self.end),
864 int(self.intlvHighBit), int(self.xorHighBit),
865 int(self.intlvBits), int(self.intlvMatch))
884 self.masks, int(self.intlvMatch))
866
867# Boolean parameter type. Python doesn't let you subclass bool, since
868# it doesn't want to let you create multiple instances of True and
869# False. Thus this is a little more complicated than String.
870class Bool(ParamValue):
871 cxx_type = 'bool'
872 cmd_line_settable = True
873

--- 1299 unchanged lines hidden ---
885
886# Boolean parameter type. Python doesn't let you subclass bool, since
887# it doesn't want to let you create multiple instances of True and
888# False. Thus this is a little more complicated than String.
889class Bool(ParamValue):
890 cxx_type = 'bool'
891 cmd_line_settable = True
892

--- 1299 unchanged lines hidden ---