SimObject.py (8597:45c9f664a365) SimObject.py (8664:42052d5bb793)
1# Copyright (c) 2004-2006 The Regents of The University of Michigan
2# Copyright (c) 2010 Advanced Micro Devices, Inc.
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

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

869 def print_ini(self, ini_file):
870 print >>ini_file, '[' + self.path() + ']' # .ini section header
871
872 instanceDict[self.path()] = self
873
874 if hasattr(self, 'type'):
875 print >>ini_file, 'type=%s' % self.type
876
1# Copyright (c) 2004-2006 The Regents of The University of Michigan
2# Copyright (c) 2010 Advanced Micro Devices, Inc.
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

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

869 def print_ini(self, ini_file):
870 print >>ini_file, '[' + self.path() + ']' # .ini section header
871
872 instanceDict[self.path()] = self
873
874 if hasattr(self, 'type'):
875 print >>ini_file, 'type=%s' % self.type
876
877 child_names = self._children.keys()
878 child_names.sort()
879 if len(child_names):
877 if len(self._children.keys()):
880 print >>ini_file, 'children=%s' % \
878 print >>ini_file, 'children=%s' % \
881 ' '.join(self._children[n].get_name() for n in child_names)
879 ' '.join(self._children[n].get_name() \
880 for n in sorted(self._children.keys()))
882
881
883 param_names = self._params.keys()
884 param_names.sort()
885 for param in param_names:
882 for param in sorted(self._params.keys()):
886 value = self._values.get(param)
887 if value != None:
888 print >>ini_file, '%s=%s' % (param,
889 self._values[param].ini_str())
890
883 value = self._values.get(param)
884 if value != None:
885 print >>ini_file, '%s=%s' % (param,
886 self._values[param].ini_str())
887
891 port_names = self._ports.keys()
892 port_names.sort()
893 for port_name in port_names:
888 for port_name in sorted(self._ports.keys()):
894 port = self._port_refs.get(port_name, None)
895 if port != None:
896 print >>ini_file, '%s=%s' % (port_name, port.ini_str())
897
898 print >>ini_file # blank line between objects
899
889 port = self._port_refs.get(port_name, None)
890 if port != None:
891 print >>ini_file, '%s=%s' % (port_name, port.ini_str())
892
893 print >>ini_file # blank line between objects
894
895 # generate a tree of dictionaries expressing all the parameters in the
896 # instantiated system for use by scripts that want to do power, thermal
897 # visualization, and other similar tasks
898 def get_config_as_dict(self):
899 d = attrdict()
900 if hasattr(self, 'type'):
901 d.type = self.type
902 if hasattr(self, 'cxx_class'):
903 d.cxx_class = self.cxx_class
904
905 for param in sorted(self._params.keys()):
906 value = self._values.get(param)
907 try:
908 d[param] = self._values[param].value
909 except AttributeError:
910 pass
911
912 for n in sorted(self._children.keys()):
913 d[self._children[n].get_name()] = self._children[n].get_config_as_dict()
914
915 for port_name in sorted(self._ports.keys()):
916 port = self._port_refs.get(port_name, None)
917 if port != None:
918 # Might want to actually make this reference the object
919 # in the future, although execing the string problem would
920 # get some of the way there
921 d[port_name] = port.ini_str()
922
923 return d
924
900 def getCCParams(self):
901 if self._ccParams:
902 return self._ccParams
903
904 cc_params_struct = getattr(m5.internal.params, '%sParams' % self.type)
905 cc_params = cc_params_struct()
906 cc_params.pyobj = self
907 cc_params.name = str(self)

--- 185 unchanged lines hidden ---
925 def getCCParams(self):
926 if self._ccParams:
927 return self._ccParams
928
929 cc_params_struct = getattr(m5.internal.params, '%sParams' % self.type)
930 cc_params = cc_params_struct()
931 cc_params.pyobj = self
932 cc_params.name = str(self)

--- 185 unchanged lines hidden ---