diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2012-05-23 09:16:39 -0400 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2012-05-23 09:16:39 -0400 |
commit | 01906f957a82fd070a619ccb1f58d5ca8c82d85c (patch) | |
tree | 9c00849a07c15103fdc3e6bc7170ed45a47be929 /src/python/m5/params.py | |
parent | d4847fe6ea63a1122ed14e6ac6d10ef0a8469194 (diff) | |
download | gem5-01906f957a82fd070a619ccb1f58d5ca8c82d85c.tar.xz |
Config: Use the attribute naming and include ports in JSON
This patch changes the organisation of the JSON output slightly to
make it easier to traverse and use the files. Most importantly, the
hierarchical dictionaries now use keys that correspond to the
attribute names also in the case of VectorParams (used to be
e.f. "cpu0 cpu1"). It also adds the name and the path to each
SimObject directory entry. Before this patch, to get cpu0, you would
have to query dict['system']['cpu0 cpu1'][0] and this could be a dict
with 'cpu0' : { cpu parameters }. Now you use dict['system']['cpu'][0]
and get { cpu parameters } (where one is "name" : "cpu0").
Additionally this patch includes more verbose information about the
ports, specifying their role, and using a JSON array rather than a
concatenated string for the peer.
Diffstat (limited to 'src/python/m5/params.py')
-rw-r--r-- | src/python/m5/params.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/python/m5/params.py b/src/python/m5/params.py index b7fa60782..3dcbecd2f 100644 --- a/src/python/m5/params.py +++ b/src/python/m5/params.py @@ -1363,6 +1363,10 @@ class PortRef(object): def ini_str(self): return str(self.peer) + # for config.json + def get_config_as_dict(self): + return {'role' : self.role, 'peer' : str(self.peer)} + def __getattr__(self, attr): if attr == 'peerObj': # shorthand for proxies @@ -1480,6 +1484,11 @@ class VectorPortRef(object): def ini_str(self): return ' '.join([el.ini_str() for el in self.elements]) + # for config.json + def get_config_as_dict(self): + return {'role' : self.role, + 'peer' : [el.ini_str() for el in self.elements]} + def __getitem__(self, key): if not isinstance(key, int): raise TypeError, "VectorPort index must be integer" |