Skip to content
Snippets Groups Projects
signal.py 1.42 KiB
Newer Older
  • Learn to ignore specific revisions
  • """@package docstring
    
    B-ASIC Signal Module.
    """
    
    Kevin Scott's avatar
    Kevin Scott committed
    from typing import TYPE_CHECKING, Optional
    
    
    from b_asic.graph_component import TypeName
    from b_asic.abstract_graph_component import AbstractGraphComponent
    
    
    Kevin Scott's avatar
    Kevin Scott committed
    if TYPE_CHECKING:
    	from b_asic import OutputPort, InputPort
    
    Kevin Scott's avatar
    Kevin Scott committed
    	"""A connection between two ports."""
    	_source: "OutputPort"
    	_destination: "InputPort"
    
    	def __init__(self, src: Optional["OutputPort"] = None, dest: Optional["InputPort"] = None, **kwds):
    		super().__init__(**kwds)
    
    Kevin Scott's avatar
    Kevin Scott committed
    		self._source = src
    		self._destination = dest
    
    	@property
    	def source(self) -> "OutputPort":
    		"""Returns the source OutputPort of the signal."""
    
    Kevin Scott's avatar
    Kevin Scott committed
    		return self._source
    
    Kevin Scott's avatar
    Kevin Scott committed
    	@property
    
    	def destination(self) -> "InputPort":
    		"""Returns the destination InputPort of the signal."""
    
    Kevin Scott's avatar
    Kevin Scott committed
    		return self._destination
    
    Kevin Scott's avatar
    Kevin Scott committed
    	@source.setter
    
    	def source(self, src: "OutputPort") -> None:
    		"""Sets the value of the source OutputPort of the signal."""
    
    Kevin Scott's avatar
    Kevin Scott committed
    		self._source = src
    
    Kevin Scott's avatar
    Kevin Scott committed
    	@destination.setter
    	def destination(self, dest: "InputPort") -> None:
    
    		"""Sets the value of the destination InputPort of the signal."""
    
    Kevin Scott's avatar
    Kevin Scott committed
    		self._destination = dest
    
    	@property
    	def type_name(self) -> TypeName:
    		return "s"
    
    
    Kevin Scott's avatar
    Kevin Scott committed
    	def disconnect_source(self) -> None:
    
    		"""Disconnects the source OutputPort of the signal."""
    
    Kevin Scott's avatar
    Kevin Scott committed
    		self._source = None
    
    Kevin Scott's avatar
    Kevin Scott committed
    	def disconnect_destination(self) -> None:
    
    		"""Disconnects the destination InputPort of the signal."""
    
    Kevin Scott's avatar
    Kevin Scott committed
    		self._destination = None