summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoffrey Blake <Geoffrey.Blake@arm.com>2014-09-03 07:43:03 -0400
committerGeoffrey Blake <Geoffrey.Blake@arm.com>2014-09-03 07:43:03 -0400
commit31e4e475d93fa2cc9ee152e90347129413642c54 (patch)
tree7a69a7a9f6d13c666e360845b6f973d888f1c407
parent291b1f8c1f9c732c2f6ac25806aac96d80d5eca3 (diff)
downloadgem5-31e4e475d93fa2cc9ee152e90347129413642c54.tar.xz
config: Add port splicing capability to PortRef class
The new configuration scripts need the ability to splice a simobject between a pair of ports that are already connected. The primary use case is when a CommMonitor needs to be created after the system is configured and then spliced between the pair of ports it will monitor.
-rw-r--r--src/python/m5/params.py32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/python/m5/params.py b/src/python/m5/params.py
index dfc3ede3b..1f9a41d9e 100644
--- a/src/python/m5/params.py
+++ b/src/python/m5/params.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2012-2013 ARM Limited
+# Copyright (c) 2012-2014 ARM Limited
# All rights reserved.
#
# The license below extends only to copyright in the software and shall
@@ -1616,6 +1616,36 @@ class PortRef(object):
"assigning non-port reference '%s' to port '%s'" \
% (other, self)
+ # Allow a master/slave port pair to be spliced between
+ # a port and its connected peer. Useful operation for connecting
+ # instrumentation structures into a system when it is necessary
+ # to connect the instrumentation after the full system has been
+ # constructed.
+ def splice(self, new_master_peer, new_slave_peer):
+ if self.peer and not proxy.isproxy(self.peer):
+ if isinstance(new_master_peer, PortRef) and \
+ isinstance(new_slave_peer, PortRef):
+ old_peer = self.peer
+ if self.role == 'SLAVE':
+ self.peer = new_master_peer
+ old_peer.peer = new_slave_peer
+ new_master_peer.connect(self)
+ new_slave_peer.connect(old_peer)
+ elif self.role == 'MASTER':
+ self.peer = new_slave_peer
+ old_peer.peer = new_master_peer
+ new_slave_peer.connect(self)
+ new_master_peer.connect(old_peer)
+ else:
+ panic("Port %s has unknown role, "+\
+ "cannot splice in new peers\n", self)
+ else:
+ raise TypeError, \
+ "Splicing non-port references '%s','%s' to port '%s'"\
+ % (new_peer, peers_new_peer, self)
+ else:
+ fatal("Port %s not connected, cannot splice in new peers\n", self)
+
def clone(self, simobj, memo):
if memo.has_key(self):
return memo[self]