def _discover_all(self): """When iterating or performing tab completion, we run through ahead of time and discover all possible children, populating the ``_sub_handles`` mapping. Hierarchy can't change after elaboration so we only have to do this once. """ if self._discovered: return self._log.debug("Discovering all on %s", self._name) iterator = simulator.iterate(self._handle, simulator.OBJECTS) while True: try: thing = simulator.next(iterator) except StopIteration: # Iterator is cleaned up internally in GPI break name = simulator.get_name_string(thing) try: hdl = SimHandle(thing, self._child_path(name)) except TestError as e: self._log.debug("%s" % e) continue key = self._sub_handle_key(name) if not key is None: self._sub_handles[key] = hdl else: self._log.debug("Unable to translate handle >%s< to a valid _sub_handle key" % hdl._name) continue self._discovered = True
def _discover_all(self): """When iterating or performing tab completion, we run through ahead of time and discover all possible children, populating the ``_sub_handles`` mapping. Hierarchy can't change after elaboration so we only have to do this once. """ if self._discovered: return self._log.debug("Discovering all on %s", self._name) for thing in _SimIterator(self._handle, simulator.OBJECTS): name = simulator.get_name_string(thing) try: hdl = SimHandle(thing, self._child_path(name)) except TestError as e: self._log.debug("%s", e) continue key = self._sub_handle_key(name) if key is not None: self._sub_handles[key] = hdl else: self._log.debug( "Unable to translate handle >%s< to a valid _sub_handle key", hdl._name) continue self._discovered = True
def _discover_all(self): """ When iterating or performing tab completion, we run through ahead of time and discover all possible children, populating the _sub_handle mapping. Hierarchy can't change after elaboration so we only have to do this once. """ if self._discovered: return self._log.debug("Discovering all on %s", self._name) iterator = simulator.iterate(self._handle, simulator.OBJECTS) while True: try: thing = simulator.next(iterator) except StopIteration: # Iterator is cleaned up internally in GPI break name = simulator.get_name_string(thing) try: hdl = SimHandle(thing) except TestError as e: self._log.debug("%s" % e) continue # This is slightly hacky, but we want generate loops to result in a list # These are renamed in VHPI to __X where X is the index import re result = re.match("(?P<name>.*)__(?P<index>\d+)$", name) if not result: result = re.match("(?P<name>.*)\((?P<index>\d+)\)$", name) # Modelsim VPI returns names in standard form name[index] if not result: result = re.match("(?P<name>.*)\[(?P<index>\d+)\]$", name) if result: index = int(result.group("index")) name = result.group("name") if name not in self._sub_handles: self._sub_handles[name] = [] self._log.debug("creating new group for %s", name) if len(self._sub_handles[name]) < index + 1: delta = index - len(self._sub_handles[name]) + 1 self._sub_handles[name].extend([None] * delta) self._sub_handles[name][index] = hdl self._log.debug("%s.%s[%d] is now %s", self._name, name, index, hdl._name) #for something in self._sub_handles[name]: # self._log.debug("%s: %s" % (type(something), something)) else: self._log.debug("%s didn't match an index pattern", name) self._sub_handles[hdl._name.split(".")[-1]] = hdl self._discovered = True
def _discover_all(self): """ When iterating or performing tab completion, we run through ahead of time and discover all possible children, populating the _sub_handle mapping. Hierarchy can't change after elaboration so we only have to do this once. """ if self._discovered: return self._log.debug("Discovering all on %s", self._name) iterator = simulator.iterate(self._handle, simulator.OBJECTS) while True: try: thing = simulator.next(iterator) except StopIteration: # Iterator is cleaned up internally in GPI break name = simulator.get_name_string(thing) try: hdl = SimHandle(thing) except TestError as e: self._log.debug("%s" % e) continue # This is slightly hacky, but we want generate loops to result in a list # These are renamed in VHPI to __X where X is the index import re result = re.match("(?P<name>.*)__(?P<index>\d+)$", name) if not result: result = re.match("(?P<name>.*)\((?P<index>\d+)\)$", name) # Modelsim VPI returns names in standard form name[index] if not result: result = re.match("(?P<name>.*)\[(?P<index>\d+)\]$", name) if result: index = int(result.group("index")) name = result.group("name") if name not in self._sub_handles: self._sub_handles[name] = [] self._log.debug("creating new group for %s", name) if len(self._sub_handles[name]) < index + 1: delta = index - len(self._sub_handles[name]) + 1 self._sub_handles[name].extend([None]*delta) self._sub_handles[name][index] = hdl self._log.debug("%s.%s[%d] is now %s", self._name, name, index, hdl._name) #for something in self._sub_handles[name]: # self._log.debug("%s: %s" % (type(something), something)) else: self._log.debug("%s didn't match an index pattern", name) self._sub_handles[hdl._name.split(".")[-1]] = hdl self._discovered = True
def __init__(self, handle): """ Args: _handle [integer] : vpi/vhpi handle to the simulator object """ self._handle = handle # handle used for future simulator transactions self._sub_handles = {} # Dictionary of SimHandle objects created by getattr self._len = None self.name = simulator.get_name_string(self._handle) self.fullname = self.name + '(%s)' % simulator.get_type_string(self._handle) self.log = SimLog('cocotb.' + self.name) self.log.debug("Created!")
def __init__(self, handle): """ Args: _handle [integer] : vpi/vhpi handle to the simulator object """ self._handle = handle # handle used for future simulator transactions self._sub_handles = {} # Dict. of SimHandle objects created by getattr self._len = None self.name = simulator.get_name_string(self._handle) self.fullname = '%s(%s)' % (self.name, simulator.get_type_string(self._handle)) self.log = SimLog('cocotb.' + self.name) self.log.debug("Created!") self._r_edge = _RisingEdge(self) self._f_edge = _FallingEdge(self)
def __init__(self, handle): """ Args: handle (integer) : the GPI handle to the simulator object """ self._handle = handle self._len = None self._sub_handles = {} # Dictionary of children self._invalid_sub_handles = {} # Dictionary of invalid queries self._discovered = False self._name = simulator.get_name_string(self._handle) self._type = simulator.get_type_string(self._handle) self._fullname = self._name + "(%s)" % self._type self._log = SimLog("cocotb.%s" % self._name) self._log.debug("Created")
def get_checkpoint_hier(entity): iterator = simulator.iterate(entity._handle, simulator.OBJECTS) while True: try: ii = simulator.next(iterator) except StopIteration: break hdl = SimHandle(ii, entity._path + "." + simulator.get_name_string(ii)) if ((simulator.get_type(ii) is simulator.MODULE) or (simulator.get_type(ii) is simulator.NETARRAY) or (simulator.get_type(ii) is simulator.GENARRAY)): get_checkpoint_hier(hdl) elif simulator.get_type(ii) is simulator.REG: checkpoint_hier.append(hdl)
def __init__(self, handle, path): """ Args: handle (integer) : the GPI handle to the simulator object path (string) : path to this handle, None if root """ self._handle = handle self._len = None self._sub_handles = {} # Dictionary of children self._invalid_sub_handles = {} # Dictionary of invalid queries self._name = simulator.get_name_string(self._handle) self._type = simulator.get_type_string(self._handle) self._fullname = self._name + "(%s)" % self._type self._path = self._name if path is None else path self._log = SimLog("cocotb.%s" % self._name) self._log.debug("Created")
def __init__(self, handle, path): """ .. Constructor. This RST comment works around sphinx-doc/sphinx#6885 Args: handle (int): The GPI handle to the simulator object. path (str): Path to this handle, ``None`` if root. """ self._handle = handle self._len = None self._sub_handles = {} # Dictionary of children self._invalid_sub_handles = {} # Dictionary of invalid queries self._name = simulator.get_name_string(self._handle) self._type = simulator.get_type_string(self._handle) self._fullname = self._name + "(%s)" % self._type self._path = self._name if path is None else path self._log = SimLog("cocotb.%s" % self._name) self._log.debug("Created") self._def_name = simulator.get_definition_name(self._handle) self._def_file = simulator.get_definition_file(self._handle)