diff options
author | Gabe Black <gabeblack@google.com> | 2019-04-15 21:05:55 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2019-04-24 11:00:20 +0000 |
commit | 3c3f360bbe8a3394657a0fa78bae90826100a235 (patch) | |
tree | 814904202b8a469796654036cf350e6f8343bf43 /src | |
parent | 9c23850bba9778a05bcb30efb10523a6194e2025 (diff) | |
download | gem5-3c3f360bbe8a3394657a0fa78bae90826100a235.tar.xz |
python: Generalize the Port.splice function.
Now that the MASTER and SLAVE roles aren't special, the splice function
needs to be able to handle arbitrarily role-d peers.
Change-Id: I22a28b7cdcb93f7f370730b7e38b0e6d3500a6a0
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18170
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/python/m5/params.py | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/python/m5/params.py b/src/python/m5/params.py index 9b2ee3972..60d4a14b9 100644 --- a/src/python/m5/params.py +++ b/src/python/m5/params.py @@ -1895,35 +1895,36 @@ class PortRef(object): if other.peer is not self: other.connect(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): + # Allow a compatible 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_1, new_2): if not self.peer or proxy.isproxy(self.peer): fatal("Port %s not connected, cannot splice in new peers\n", self) - if not isinstance(new_master_peer, PortRef) or \ - not isinstance(new_slave_peer, PortRef): + if not isinstance(new_1, PortRef) or not isinstance(new_2, PortRef): raise TypeError( "Splicing non-port references '%s','%s' to port '%s'" % \ - (new_master_peer, new_slave_peer, self)) + (new_1, new_2, self)) 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) + + if Port.is_compat(old_peer, new_1) and Port.is_compat(self, new_2): + old_peer.peer = new_1 + new_1.peer = old_peer + self.peer = new_2 + new_2.peer = self + elif Port.is_compat(old_peer, new_2) and Port.is_compat(self, new_1): + old_peer.peer = new_2 + new_2.peer = old_peer + self.peer = new_1 + new_1.peer = self else: - panic("Port %s has unknown role, "+\ - "cannot splice in new peers\n", self) + fatal("Ports %s(%s) and %s(%s) can't be compatibly spliced with " + "%s(%s) and %s(%s)", self, self.role, + old_peer, old_peer.role, new_1, new_1.role, + new_2, new_2.role) def clone(self, simobj, memo): if self in memo: |