示例#1
0
 def check_export(self, export):
     """Check that the export implements needed methods"""
     if not isinstance(export, uvm_export_base):
         raise UVMTLMConnectionError(
             f"{export} must be a subclass of uvm_export_base")
     for needed in self.needed_methods:
         if not hasattr(export, needed):
             raise UVMTLMConnectionError(
                 f"{export} must implement '{needed}()'"
                 f" to connect to a {self.__class__}")
示例#2
0
 async def transport(self, put_data):
     try:
         get_data = await self.export.transport(put_data)
     except AttributeError:
         raise UVMTLMConnectionError(
             "Missing or wrong export in"
             f" {self.get_full_name()}. Did you connect it?")
     return get_data
示例#3
0
 def nb_transport(self, put_data):
     try:
         success, get_data = self.export.nb_transport(put_data)
     except AttributeError:
         raise UVMTLMConnectionError(
             "Missing or wrong export in"
             f" {self.get_full_name()}. Did you connect it?")
     return success, get_data
示例#4
0
 def write(self, datum):
     """
     :param datum: data to send
     :return: None
     """
     for export in self.subscribers:
         if not hasattr(export, "write"):
             raise UVMTLMConnectionError(f"No write() method in {export}. Did you connect it?")
         export.write(datum)
示例#5
0
    def get(self, timeout=None):
        """

        A blocking get that returns the data got
        :return: data
        """
        try:
            data = self.export.get(timeout=timeout)
            return data
        except AttributeError:
            raise UVMTLMConnectionError(f"Missing or wrong export in {self.get_full_name()}. Did you connect it?")
示例#6
0
    def try_peek(self):
        """

        Tries to peek for data and returns
        a tuple with success and the data
        :return: (success, data)
        """
        try:
            success, data = self.export.try_peek()
        except AttributeError:
            raise UVMTLMConnectionError(f"Missing or wrong export in {self.get_full_name()}. Did you connect it?")
        return success, data
示例#7
0
    def peek(self):
        """
        A blocking peek that returns data without
        consuming it.

        :return: datum
        """
        try:
            datum = self.export.peek()
            return datum
        except AttributeError:
            raise UVMTLMConnectionError(f"Missing or wrong export in {self.get_full_name()}. Did you connect it?")
示例#8
0
    def can_get(self):
        """
        Returns true if there is data to get

        :return: bool
        """
        try:
            can = self.export.can_get()
        except AttributeError:
            raise UVMTLMConnectionError(f"Missing or wrong export in {self.get_full_name()}. Did you connect it?")

        return can
示例#9
0
    def can_put(self):
        """
        Returns true if there is room for data to
        be put on the port

        :return: bool
        """
        try:
            can_do_it = self.export.can_put()
            return can_do_it
        except AttributeError:
            raise UVMTLMConnectionError(f"Missing or wrong export in {self.get_full_name()}. Did you connect it?")
示例#10
0
    def put(self, datum, timeout=None):
        """
         A blocking put that calls the export.put

        :param timeout: Timeout before throwing queue.Full
        :param datum: Datum to put
        :return: None
        """
        try:
            self.export.put(datum)
        except AttributeError:
            raise UVMTLMConnectionError(f"Missing or wrong export in {self.get_full_name()}. Did you connect it?")
示例#11
0
 async def put(self, datum):
     """
      A blocking put that calls the export.put
     :param datum: Datum to put
     :return: None
     """
     try:
         await self.export.put(datum)
     except AttributeError:
         raise UVMTLMConnectionError(
             "Missing or wrong export in"
             f" {self.get_full_name()}. Did you connect it?")
示例#12
0
    async def get(self):
        """

        A blocking get that returns the data got
        :return: data
        """
        try:
            data = await self.export.get()
            return data
        except AttributeError:
            raise UVMTLMConnectionError(
                "Missing or wrong export in "
                f"{self.get_full_name()}. Did you connect it?")
示例#13
0
    def try_put(self, data):
        """
        Tries to put data on a port, but if the
        port is full it returns False

        :param data: data to deliver
        :return: True = success
        """
        try:
            success = self.export.try_put(data)
            return success
        except AttributeError:
            raise UVMTLMConnectionError(f"Missing or wrong export in {self.get_full_name()}. Did you connect it?")
示例#14
0
    def connect(self, export):
        """
        Attach this port to the associated export.

        :param export:
        :return:
        """
        try:
            self.export = export
            self.connected_to[export.get_full_name()] = export
            export.provided_to[self.get_full_name()] = self
        except KeyError:
            raise UVMTLMConnectionError(f"Error connecting {self.get_name()} using {export}")
示例#15
0
    def try_get(self):
        """
        12.2.4.2.6
        Returns a tuple containing success and the data
        This is different than SV UVM that returns the
        data through the argument list.
        :return: (success, data)
        """

        try:
            (success, data) = self.export.try_get()
        except AttributeError:
            raise UVMTLMConnectionError(f"Missing or wrong export in {self.get_full_name()}. Did you connect it?")

        return success, data
示例#16
0
 def connect(self, export):
     if not (isinstance(export, uvm_nonblocking_get_port) or isinstance(export, uvm_nonblocking_peek_port)
             or isinstance(export, uvm_blocking_get_port) or isinstance(export, uvm_blocking_peek_port)):
         raise UVMTLMConnectionError(
             f"Tried to connect an illegal export to uvm_blocking_get_peek {self.get_full_name()}")
     super().connect(export)
示例#17
0
 def check_export(export, check_class):
     if not isinstance(export, check_class):
         raise UVMTLMConnectionError(f"{export} must be an instance of\n{check_class} not\n{type(export)}")