+ if len(self._children.keys()):
+ print >>ini_file, 'children=%s' % \
+ ' '.join(self._children[n].get_name() \
+ for n in sorted(self._children.keys()))
+
+ for param in sorted(self._params.keys()):
+ value = self._values.get(param)
+ if value != None:
+ print >>ini_file, '%s=%s' % (param,
+ self._values[param].ini_str())
+
+ for port_name in sorted(self._ports.keys()):
+ port = self._port_refs.get(port_name, None)
+ if port != None:
+ print >>ini_file, '%s=%s' % (port_name, port.ini_str())
+
+ print >>ini_file # blank line between objects
+
+ # generate a tree of dictionaries expressing all the parameters in the
+ # instantiated system for use by scripts that want to do power, thermal
+ # visualization, and other similar tasks
+ def get_config_as_dict(self):
+ d = attrdict()
+ if hasattr(self, 'type'):
+ d.type = self.type
+ if hasattr(self, 'cxx_class'):
+ d.cxx_class = self.cxx_class
+ # Add the name and path of this object to be able to link to
+ # the stats
+ d.name = self.get_name()
+ d.path = self.path()
+
+ for param in sorted(self._params.keys()):
+ value = self._values.get(param)
+ if value != None:
+ try:
+ # Use native type for those supported by JSON and
+ # strings for everything else. skipkeys=True seems
+ # to not work as well as one would hope
+ if type(self._values[param].value) in \
+ [str, unicode, int, long, float, bool, None]:
+ d[param] = self._values[param].value
+ else:
+ d[param] = str(self._values[param])
+
+ except AttributeError:
+ pass
+
+ for n in sorted(self._children.keys()):
+ child = self._children[n]
+ # Use the name of the attribute (and not get_name()) as
+ # the key in the JSON dictionary to capture the hierarchy
+ # in the Python code that assembled this system
+ d[n] = child.get_config_as_dict()
+
+ for port_name in sorted(self._ports.keys()):
+ port = self._port_refs.get(port_name, None)
+ if port != None:
+ # Represent each port with a dictionary containing the
+ # prominent attributes
+ d[port_name] = port.get_config_as_dict()
+
+ return d
+
+ def getCCParams(self):
+ if self._ccParams:
+ return self._ccParams
+
+ cc_params_struct = getattr(m5.internal.params, '%sParams' % self.type)
+ cc_params = cc_params_struct()
+ cc_params.pyobj = self
+ cc_params.name = str(self)