1# Copyright (c) 2012 ARM Limited
2# All rights reserved.
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder. You may use the software subject to the license

--- 1335 unchanged lines hidden (view full) ---

1344 self.role = role
1345 self.peer = None # not associated with another port yet
1346 self.ccConnected = False # C++ port connection done?
1347 self.index = -1 # always -1 for non-vector ports
1348
1349 def __str__(self):
1350 return '%s.%s' % (self.simobj, self.name)
1351
1352 def __len__(self):
1353 # Return the number of connected ports, i.e. 0 is we have no
1354 # peer and 1 if we do.
1355 return int(self.peer != None)
1356
1357 # for config.ini, print peer's name (not ours)
1358 def ini_str(self):
1359 return str(self.peer)
1360
1361 def __getattr__(self, attr):
1362 if attr == 'peerObj':
1363 # shorthand for proxies
1364 return self.peer.simobj

--- 97 unchanged lines hidden (view full) ---

1462 self.simobj = simobj
1463 self.name = name
1464 self.role = role
1465 self.elements = []
1466
1467 def __str__(self):
1468 return '%s.%s[:]' % (self.simobj, self.name)
1469
1470 def __len__(self):
1471 # Return the number of connected peers, corresponding the the
1472 # length of the elements.
1473 return len(self.elements)
1474
1475 # for config.ini, print peer's name (not ours)
1476 def ini_str(self):
1477 return ' '.join([el.ini_str() for el in self.elements])
1478
1479 def __getitem__(self, key):
1480 if not isinstance(key, int):
1481 raise TypeError, "VectorPort index must be integer"
1482 if key >= len(self.elements):

--- 47 unchanged lines hidden (view full) ---

1530 def makeRef(self, simobj):
1531 return PortRef(simobj, self.name, self.role)
1532
1533 # Connect an instance of this port (on the given SimObject with
1534 # the given name) with the port described by the supplied PortRef
1535 def connect(self, simobj, ref):
1536 self.makeRef(simobj).connect(ref)
1537
1538 # No need for any pre-declarations at the moment as we merely rely
1539 # on an unsigned int.
1540 def cxx_predecls(self, code):
1541 pass
1542
1543 # Declare an unsigned int with the same name as the port, that
1544 # will eventually hold the number of connected ports (and thus the
1545 # number of elements for a VectorPort).
1546 def cxx_decl(self, code):
1547 code('unsigned int port_${{self.name}}_connection_count;')
1548
1549class MasterPort(Port):
1550 # MasterPort("description")
1551 def __init__(self, *args):
1552 if len(args) == 1:
1553 self.desc = args[0]
1554 self.role = 'MASTER'
1555 else:
1556 raise TypeError, 'wrong number of arguments'

--- 75 unchanged lines hidden ---