diff --git a/b_asic/operation.py b/b_asic/operation.py index eeabb2bf8efcec503d2b18102d97e9cdc64a58d7..ed327127991db7a8d3c641c519ebf44257224fc7 100644 --- a/b_asic/operation.py +++ b/b_asic/operation.py @@ -306,5 +306,6 @@ class AbstractOperation(Operation, AbstractGraphComponent): def copy_unconnected(self) -> GraphComponent: new_comp: AbstractOperation = super().copy_unconnected() for name, value in self.params.items(): + new_comp.set_param(name, deepcopy( value)) # pylint: disable=no-member return new_comp diff --git a/b_asic/port.py b/b_asic/port.py index 4f249e3cf81d19943996e2056499a323d6c10a73..103d076af2702e7e565067f7568bb6035d24a2c8 100644 --- a/b_asic/port.py +++ b/b_asic/port.py @@ -8,6 +8,7 @@ from copy import copy from typing import NewType, Optional, List, Iterable, TYPE_CHECKING from b_asic.signal import Signal +from b_asic.graph_component import Name if TYPE_CHECKING: from b_asic.operation import Operation @@ -144,22 +145,24 @@ class InputPort(AbstractPort): """ return None if self._source_signal is None else self._source_signal.source - def connect(self, src: SignalSourceProvider) -> Signal: + def connect(self, src: SignalSourceProvider, name: Name = "") -> Signal: """Connect the provided signal source to this input port by creating a new signal. Returns the new signal. """ assert self._source_signal is None, "Attempted to connect already connected input port." - return Signal(src.source, self) # self._source_signal is set by the signal constructor. - + # self._source_signal is set by the signal constructor. + return Signal(source=src.source, destination=self, name=name) + @property def value_length(self) -> Optional[int]: """Get the number of bits that this port should truncate received values to.""" return self._value_length - + @value_length.setter def value_length(self, bits: Optional[int]) -> None: """Set the number of bits that this port should truncate received values to.""" - assert bits is None or (isinstance(bits, int) and bits >= 0), "Value length must be non-negative." + assert bits is None or (isinstance( + bits, int) and bits >= 0), "Value length must be non-negative." self._value_length = bits @@ -185,7 +188,7 @@ class OutputPort(AbstractPort, SignalSourceProvider): def add_signal(self, signal: Signal) -> None: assert signal not in self._destination_signals, "Attempted to add already connected signal." self._destination_signals.append(signal) - signal.set_source(self) + signal.set_source(self) def remove_signal(self, signal: Signal) -> None: assert signal in self._destination_signals, "Attempted to remove already removed signal." @@ -195,7 +198,7 @@ class OutputPort(AbstractPort, SignalSourceProvider): def clear(self) -> None: for signal in copy(self._destination_signals): self.remove_signal(signal) - + @property def source(self) -> "OutputPort": - return self \ No newline at end of file + return self