135a136,139
>
> # dict to look up SimObjects based on path
> instanceDict = {}
>
203c207,208
< 'children' : types.ListType }
---
> 'children' : types.ListType,
> 'ccObject' : types.ObjectType }
235a241
> cls._ports = multidict()
250a257
> cls._ports.parent = base._ports
261a269,272
> # port objects
> elif isinstance(val, Port):
> cls._ports[key] = val
>
315a327,330
> if cls._ports.has_key(attr):
> self._ports[attr].connect(self, attr, value)
> return
>
430a446,448
> self._ccObject = None # pointer to C++ object
> self._port_map = {} # map of port connections
>
445a464,468
> if self._ports.has_key(attr):
> # return reference that can be assigned to another port
> # via __setattr__
> return self._ports[attr].makeRef(self, attr)
>
459a483,487
> if self._ports.has_key(attr):
> # set up port connection
> self._ports[attr].connect(self, attr, value)
> return
>
556a585,586
> instanceDict[self.path()] = self
>
587a618,635
> # Call C++ to create C++ object corresponding to this object and
> # (recursively) all its children
> def createCCObject(self):
> if self._ccObject:
> return
> self._ccObject = -1
> self._ccObject = m5.main.createSimObject(self.path())
> for child in self._children.itervalues():
> child.createCCObject()
>
> # Create C++ port connections corresponding to the connections in
> # _port_map (& recursively for all children)
> def connectPorts(self):
> for portRef in self._port_map.itervalues():
> applyOrMap(portRef, 'ccConnect')
> for child in self._children.itervalues():
> child.connectPorts()
>
1421a1470
>
1422a1472,1477
> #
> # Port objects
> #
> # Ports are used to interconnect objects in the memory system.
> #
> #####################################################################
1423a1479,1543
> # Port reference: encapsulates a reference to a particular port on a
> # particular SimObject.
> class PortRef(object):
> def __init__(self, simobj, name, isVec):
> self.simobj = simobj
> self.name = name
> self.index = -1
> self.isVec = isVec # is this a vector port?
> self.peer = None # not associated with another port yet
> self.ccConnected = False # C++ port connection done?
>
> # Set peer port reference. Called via __setattr__ as a result of
> # a port assignment, e.g., "obj1.port1 = obj2.port2".
> def setPeer(self, other):
> if self.isVec:
> curMap = self.simobj._port_map.get(self.name, [])
> self.index = len(curMap)
> curMap.append(other)
> else:
> curMap = self.simobj._port_map.get(self.name)
> if curMap and not self.isVec:
> print "warning: overwriting port", self.simobj, self.name
> curMap = other
> self.simobj._port_map[self.name] = curMap
> self.peer = other
>
> # Call C++ to create corresponding port connection between C++ objects
> def ccConnect(self):
> if self.ccConnected: # already done this
> return
> peer = self.peer
> m5.main.connectPorts(self.simobj._ccObject, self.name, self.index,
> peer.simobj._ccObject, peer.name, peer.index)
> self.ccConnected = True
> peer.ccConnected = True
>
> # Port description object. Like a ParamDesc object, this represents a
> # logical port in the SimObject class, not a particular port on a
> # SimObject instance. The latter are represented by PortRef objects.
> class Port(object):
> def __init__(self, desc):
> self.desc = desc
> self.isVec = False
>
> # Generate a PortRef for this port on the given SimObject with the
> # given name
> def makeRef(self, simobj, name):
> return PortRef(simobj, name, self.isVec)
>
> # Connect an instance of this port (on the given SimObject with
> # the given name) with the port described by the supplied PortRef
> def connect(self, simobj, name, ref):
> myRef = self.makeRef(simobj, name)
> myRef.setPeer(ref)
> ref.setPeer(myRef)
>
> # VectorPort description object. Like Port, but represents a vector
> # of connections (e.g., as on a Bus).
> class VectorPort(Port):
> def __init__(self, desc):
> Port.__init__(self, desc)
> self.isVec = True
>
> #####################################################################
>
1439c1559,1560
< 'NextEthernetAddr']
---
> 'NextEthernetAddr',
> 'Port', 'VectorPort']