From 688796f3c142f5174330e9f09369e7478cb1314c Mon Sep 17 00:00:00 2001 From: angloth <angus.lothian@hotmail.com> Date: Tue, 25 Feb 2020 14:49:14 +0100 Subject: [PATCH] Move OperationID from operation to signal_flow_graph and change sfg operations datastructure to a dict --- b_asic/operation.py | 11 ----------- b_asic/signal_flow_graph.py | 13 +++++++++---- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/b_asic/operation.py b/b_asic/operation.py index 731822f1..afe1df79 100644 --- a/b_asic/operation.py +++ b/b_asic/operation.py @@ -11,23 +11,12 @@ if TYPE_CHECKING: from b_asic.port import InputPort, OutputPort from b_asic.simulation import SimulationState -OperationId = NewType("OperationId", int) - - class Operation(ABC): """ Operation interface. TODO: More info. """ - @abstractmethod - def identifier(self) -> OperationId: - """ - Get the unique identifier. - TODO: Move id info to SFG, remove id class members. - """ - pass - @abstractmethod def inputs(self) -> "List[InputPort]": """ diff --git a/b_asic/signal_flow_graph.py b/b_asic/signal_flow_graph.py index f9671636..3c709ab3 100644 --- a/b_asic/signal_flow_graph.py +++ b/b_asic/signal_flow_graph.py @@ -3,11 +3,14 @@ B-ASIC Signal Flow Graph Module. TODO: More info. """ -from b_asic.operation import OperationId, Operation +from b_asic.operation import Operation from b_asic.basic_operation import BasicOperation from b_asic.signal import SignalSource, SignalDestination from b_asic.simulation import SimulationState, OperationState -from typing import List +from typing import List, Dict + +# Types +OperationId = NewType("OperationId", int) class SFG(BasicOperation): @@ -16,7 +19,7 @@ class SFG(BasicOperation): TODO: More info. """ - _operations: List[Operation] + _operations: Dict[OperationID, Operation] def __init__(self, identifier: OperationId, input_destinations: List[SignalDestination], output_sources: List[SignalSource]): """ @@ -24,7 +27,9 @@ class SFG(BasicOperation): """ super().__init__(identifier) # TODO: Allocate input/output ports with appropriate IDs. - self._operations = [] + + self._operations = dict # Map Operation ID to Operation objects + # TODO: Traverse the graph between the inputs/outputs and add to self._operations. # TODO: Connect ports with signals with appropriate IDs. -- GitLab