SimObject.py (8999:6f306dd5cee0) SimObject.py (9017:a20f46ccb9ce)
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

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

926 # instantiated system for use by scripts that want to do power, thermal
927 # visualization, and other similar tasks
928 def get_config_as_dict(self):
929 d = attrdict()
930 if hasattr(self, 'type'):
931 d.type = self.type
932 if hasattr(self, 'cxx_class'):
933 d.cxx_class = self.cxx_class
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

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

926 # instantiated system for use by scripts that want to do power, thermal
927 # visualization, and other similar tasks
928 def get_config_as_dict(self):
929 d = attrdict()
930 if hasattr(self, 'type'):
931 d.type = self.type
932 if hasattr(self, 'cxx_class'):
933 d.cxx_class = self.cxx_class
934 # Add the name and path of this object to be able to link to
935 # the stats
936 d.name = self.get_name()
937 d.path = self.path()
934
935 for param in sorted(self._params.keys()):
936 value = self._values.get(param)
937 if value != None:
938 try:
939 # Use native type for those supported by JSON and
940 # strings for everything else. skipkeys=True seems
941 # to not work as well as one would hope
942 if type(self._values[param].value) in \
943 [str, unicode, int, long, float, bool, None]:
944 d[param] = self._values[param].value
945 else:
946 d[param] = str(self._values[param])
947
948 except AttributeError:
949 pass
950
951 for n in sorted(self._children.keys()):
938
939 for param in sorted(self._params.keys()):
940 value = self._values.get(param)
941 if value != None:
942 try:
943 # Use native type for those supported by JSON and
944 # strings for everything else. skipkeys=True seems
945 # to not work as well as one would hope
946 if type(self._values[param].value) in \
947 [str, unicode, int, long, float, bool, None]:
948 d[param] = self._values[param].value
949 else:
950 d[param] = str(self._values[param])
951
952 except AttributeError:
953 pass
954
955 for n in sorted(self._children.keys()):
952 d[self._children[n].get_name()] = self._children[n].get_config_as_dict()
956 child = self._children[n]
957 # Use the name of the attribute (and not get_name()) as
958 # the key in the JSON dictionary to capture the hierarchy
959 # in the Python code that assembled this system
960 d[n] = child.get_config_as_dict()
953
954 for port_name in sorted(self._ports.keys()):
955 port = self._port_refs.get(port_name, None)
956 if port != None:
961
962 for port_name in sorted(self._ports.keys()):
963 port = self._port_refs.get(port_name, None)
964 if port != None:
957 # Might want to actually make this reference the object
958 # in the future, although execing the string problem would
959 # get some of the way there
960 d[port_name] = port.ini_str()
965 # Represent each port with a dictionary containing the
966 # prominent attributes
967 d[port_name] = port.get_config_as_dict()
961
962 return d
963
964 def getCCParams(self):
965 if self._ccParams:
966 return self._ccParams
967
968 cc_params_struct = getattr(m5.internal.params, '%sParams' % self.type)

--- 149 unchanged lines hidden ---
968
969 return d
970
971 def getCCParams(self):
972 if self._ccParams:
973 return self._ccParams
974
975 cc_params_struct = getattr(m5.internal.params, '%sParams' % self.type)

--- 149 unchanged lines hidden ---