示例#1
0
 def loads(self):
     """
     An iterator for gathering all loads on a signal
     """
     iterator = simulator.iterate(self._handle, simulator.LOADS)
     while True:
         yield SimHandle(simulator.next(iterator))
示例#2
0
文件: handle.py 项目: pwiecha/cocotb
    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
示例#3
0
文件: handle.py 项目: icicle99/cocotb
 def loads(self):
     """
     An iterator for gathering all loads on a signal
     """
     iterator = simulator.iterate(self._handle, simulator.LOADS)
     while True:
         yield SimHandle(simulator.next(iterator))
示例#4
0
 def drivers(self):
     """
     An iterator for gathering all drivers for a signal
     """
     iterator = simulator.iterate(self._handle, simulator.DRIVERS)
     while True:
         yield SimHandle(simulator.next(iterator))
示例#5
0
文件: handle.py 项目: icicle99/cocotb
 def drivers(self):
     """
     An iterator for gathering all drivers for a signal
     """
     iterator = simulator.iterate(self._handle, simulator.DRIVERS)
     while True:
         yield SimHandle(simulator.next(iterator))
示例#6
0
文件: handle.py 项目: udog14/cocotb
 def loads(self):
     """
     An iterator for gathering all loads on a signal
     """
     iterator = simulator.iterate(self._handle, simulator.LOADS)
     while True:
         # Path is left as the default None since handles are not derived from the hierarchy
         yield SimHandle(simulator.next(iterator))
示例#7
0
 def loads(self):
     """
     An iterator for gathering all loads on a signal
     """
     iterator = simulator.iterate(self._handle, simulator.LOADS)
     while True:
         # Path is left as the default None since handles are not derived from the hierarchy
         yield SimHandle(simulator.next(iterator))
示例#8
0
文件: handle.py 项目: pwiecha/cocotb
 def drivers(self):
     """An iterator for gathering all drivers for a signal."""
     try:
         iterator = simulator.iterate(self._handle, simulator.DRIVERS)
         while True:
             # Path is left as the default None since handles are not derived from the hierarchy
             yield SimHandle(simulator.next(iterator))
     except GeneratorExit:
         pass
示例#9
0
    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
示例#10
0
文件: handle.py 项目: icicle99/cocotb
    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
示例#11
0
 def __iter__(self):
     """Iterates over all known types defined by simulator module"""
     for handle_type in [
             simulator.MODULE, simulator.PARAMETER, simulator.REG,
             simulator.NET, simulator.NETARRAY
     ]:
         iterator = simulator.iterate(handle_type, self._handle)
         while True:
             try:
                 thing = simulator.next(iterator)
             except StopIteration:
                 break
             hdl = SimHandle(thing)
             self._sub_handles[hdl.name] = hdl
             yield hdl
示例#12
0
 def __iter__(self):
     """Iterates over all known types defined by simulator module"""
     for handle_type in [simulator.MODULE,
                         simulator.PARAMETER,
                         simulator.REG,
                         simulator.NET,
                         simulator.NETARRAY]:
         iterator = simulator.iterate(handle_type, self._handle)
         while True:
             try:
                 thing = simulator.next(iterator)
             except StopIteration:
                 break
             hdl = SimHandle(thing)
             self._sub_handles[hdl.name] = hdl
             yield hdl
示例#13
0
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)
示例#14
0
 def __next__(self):
     return simulator.next(self._iter)