Skip to content
Snippets Groups Projects
Commit a53fb9ab authored by Jacob Wahlman's avatar Jacob Wahlman :ok_hand:
Browse files

Merge branch 'doxygen-pep' into 'develop'

Doxygen and some PEP formatting

See merge request PUM_TDDD96/B-ASIC!3
parents 5d95d67b 71f1c87b
Branches
No related tags found
4 merge requests!67WIP: B-ASIC version 1.0.0 hotfix,!65B-ASIC version 1.0.0,!15Add changes from sprint 1 and 2 to master,!3Doxygen and some PEP formatting
...@@ -11,4 +11,4 @@ from b_asic.port import * ...@@ -11,4 +11,4 @@ from b_asic.port import *
from b_asic.schema import * from b_asic.schema import *
from b_asic.signal_flow_graph import * from b_asic.signal_flow_graph import *
from b_asic.signal import * from b_asic.signal import *
from b_asic.simulation import * from b_asic.simulation import *
\ No newline at end of file
""" """@package docstring
B-ASIC Basic Operation Module. B-ASIC Basic Operation Module.
TODO: More info. TODO: More info.
""" """
from abc import abstractmethod
from typing import List, Dict, Optional, Any
from numbers import Number
from b_asic.port import InputPort, OutputPort from b_asic.port import InputPort, OutputPort
from b_asic.signal import SignalSource, SignalDestination from b_asic.signal import SignalSource, SignalDestination
from b_asic.operation import Operation from b_asic.operation import Operation
from b_asic.simulation import SimulationState, OperationState from b_asic.simulation import SimulationState, OperationState
from abc import ABC, abstractmethod
from typing import List, Dict, Optional, Any
from numbers import Number
class BasicOperation(Operation): class BasicOperation(Operation):
""" """Generic abstract operation class which most implementations will derive from.
Generic abstract operation class which most implementations will derive from.
TODO: More info. TODO: More info.
""" """
...@@ -23,18 +23,14 @@ class BasicOperation(Operation): ...@@ -23,18 +23,14 @@ class BasicOperation(Operation):
_parameters: Dict[str, Optional[Any]] _parameters: Dict[str, Optional[Any]]
def __init__(self): def __init__(self):
""" """Construct a BasicOperation."""
Construct a BasicOperation.
"""
self._input_ports = [] self._input_ports = []
self._output_ports = [] self._output_ports = []
self._parameters = {} self._parameters = {}
@abstractmethod @abstractmethod
def evaluate(self, inputs: list) -> list: def evaluate(self, inputs: list) -> list:
""" """Evaluate the operation and generate a list of output values given a list of input values."""
Evaluate the operation and generate a list of output values given a list of input values.
"""
pass pass
def inputs(self) -> List[InputPort]: def inputs(self) -> List[InputPort]:
......
""" """@package docstring
B-ASIC Core Operations Module. B-ASIC Core Operations Module.
TODO: More info. TODO: More info.
""" """
from numbers import Number
from b_asic.port import InputPort, OutputPort from b_asic.port import InputPort, OutputPort
from b_asic.operation import Operation from b_asic.operation import Operation
from b_asic.basic_operation import BasicOperation from b_asic.basic_operation import BasicOperation
from b_asic.graph_id import GraphIDType from b_asic.graph_id import GraphIDType
from numbers import Number
class Input(Operation): class Input(Operation):
""" """Input operation.
Input operation.
TODO: More info. TODO: More info.
""" """
...@@ -21,15 +21,12 @@ class Input(Operation): ...@@ -21,15 +21,12 @@ class Input(Operation):
class Constant(BasicOperation): class Constant(BasicOperation):
""" """Constant value operation.
Constant value operation.
TODO: More info. TODO: More info.
""" """
def __init__(self, value: Number): def __init__(self, value: Number):
""" """Construct a Constant."""
Construct a Constant.
"""
super().__init__() super().__init__()
self._output_ports = [OutputPort(1)] # TODO: Generate appropriate ID for ports. self._output_ports = [OutputPort(1)] # TODO: Generate appropriate ID for ports.
self._parameters["value"] = value self._parameters["value"] = value
...@@ -37,19 +34,16 @@ class Constant(BasicOperation): ...@@ -37,19 +34,16 @@ class Constant(BasicOperation):
def evaluate(self, inputs: list) -> list: def evaluate(self, inputs: list) -> list:
return [self.param("value")] return [self.param("value")]
def get_op_name(self) -> GraphIDType: def type_name(self) -> GraphIDType:
return "const" return "const"
class Addition(BasicOperation): class Addition(BasicOperation):
""" """Binary addition operation.
Binary addition operation.
TODO: More info. TODO: More info.
""" """
def __init__(self): def __init__(self):
""" """Construct an Addition."""
Construct an Addition.
"""
super().__init__() super().__init__()
self._input_ports = [InputPort(1), InputPort(1)] # TODO: Generate appropriate ID for ports. self._input_ports = [InputPort(1), InputPort(1)] # TODO: Generate appropriate ID for ports.
self._output_ports = [OutputPort(1)] # TODO: Generate appropriate ID for ports. self._output_ports = [OutputPort(1)] # TODO: Generate appropriate ID for ports.
...@@ -57,20 +51,17 @@ class Addition(BasicOperation): ...@@ -57,20 +51,17 @@ class Addition(BasicOperation):
def evaluate(self, inputs: list) -> list: def evaluate(self, inputs: list) -> list:
return [inputs[0] + inputs[1]] return [inputs[0] + inputs[1]]
def get_op_name(self) -> GraphIDType: def type_name(self) -> GraphIDType:
return "add" return "add"
class ConstantMultiplication(BasicOperation): class ConstantMultiplication(BasicOperation):
""" """Unary constant multiplication operation.
Unary constant multiplication operation.
TODO: More info. TODO: More info.
""" """
def __init__(self, coefficient: Number): def __init__(self, coefficient: Number):
""" """Construct a ConstantMultiplication."""
Construct a ConstantMultiplication.
"""
super().__init__() super().__init__()
self._input_ports = [InputPort(1)] # TODO: Generate appropriate ID for ports. self._input_ports = [InputPort(1)] # TODO: Generate appropriate ID for ports.
self._output_ports = [OutputPort(1)] # TODO: Generate appropriate ID for ports. self._output_ports = [OutputPort(1)] # TODO: Generate appropriate ID for ports.
...@@ -79,7 +70,7 @@ class ConstantMultiplication(BasicOperation): ...@@ -79,7 +70,7 @@ class ConstantMultiplication(BasicOperation):
def evaluate(self, inputs: list) -> list: def evaluate(self, inputs: list) -> list:
return [inputs[0] * self.param("coefficient")] return [inputs[0] * self.param("coefficient")]
def get_op_name(self) -> GraphIDType: def type_name(self) -> GraphIDType:
return "const_mul" return "const_mul"
# TODO: More operations. # TODO: More operations.
""" """@package docstring
B-ASIC Graph ID module for handling IDs of different objects in a graph. B-ASIC Graph ID module for handling IDs of different objects in a graph.
TODO: More info TODO: More info
""" """
from collections import defaultdict from collections import defaultdict
from typing import NewType, Union, DefaultDict from typing import NewType, DefaultDict
GraphID = NewType("GraphID", str) GraphID = NewType("GraphID", str)
GraphIDType = NewType("GraphIDType", str) GraphIDType = NewType("GraphIDType", str)
GraphIDNumber = NewType("GraphIDNumber", int) GraphIDNumber = NewType("GraphIDNumber", int)
class GraphIDGenerator: class GraphIDGenerator:
""" """A class that generates Graph IDs for objects."""
A class that generates Graph IDs for objects.
"""
_next_id_number: DefaultDict[GraphIDType, GraphIDNumber] _next_id_number: DefaultDict[GraphIDType, GraphIDNumber]
...@@ -21,10 +20,7 @@ class GraphIDGenerator: ...@@ -21,10 +20,7 @@ class GraphIDGenerator:
self._next_id_number = defaultdict(lambda: 1) # Initalises every key element to 1 self._next_id_number = defaultdict(lambda: 1) # Initalises every key element to 1
def get_next_id(self, graph_id_type: GraphIDType) -> GraphID: def get_next_id(self, graph_id_type: GraphIDType) -> GraphID:
""" """Returns the next graph id for a certain graph id type."""
Returns the next graph id for a certain graph id type.
"""
graph_id = graph_id_type + str(self._next_id_number[graph_id_type]) graph_id = graph_id_type + str(self._next_id_number[graph_id_type])
self._next_id_number[graph_id_type] += 1 # Increase the current id number self._next_id_number[graph_id_type] += 1 # Increase the current id number
return graph_id return graph_id
""" """@package docstring
B-ASIC Operation Module. B-ASIC Operation Module.
TODO: More info. TODO: More info.
""" """
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from numbers import Number from numbers import Number
from typing import NewType, List, Dict, Optional, Any, TYPE_CHECKING from typing import List, Dict, Optional, Any, TYPE_CHECKING
if TYPE_CHECKING: if TYPE_CHECKING:
from b_asic.port import InputPort, OutputPort from b_asic.port import InputPort, OutputPort
from b_asic.simulation import SimulationState from b_asic.simulation import SimulationState
from b_asic.graph_id import GraphIDType from b_asic.graph_id import GraphIDType
class Operation(ABC): class Operation(ABC):
""" """Operation interface.
Operation interface.
TODO: More info. TODO: More info.
""" """
@abstractmethod @abstractmethod
def inputs(self) -> "List[InputPort]": def inputs(self) -> "List[InputPort]":
""" """Get a list of all input ports."""
Get a list of all input ports.
"""
pass pass
@abstractmethod @abstractmethod
def outputs(self) -> "List[OutputPort]": def outputs(self) -> "List[OutputPort]":
""" """Get a list of all output ports."""
Get a list of all output ports.
"""
pass pass
@abstractmethod @abstractmethod
def input_count(self) -> int: def input_count(self) -> int:
""" """Get the number of input ports."""
Get the number of input ports.
"""
pass pass
@abstractmethod @abstractmethod
def output_count(self) -> int: def output_count(self) -> int:
""" """Get the number of output ports."""
Get the number of output ports.
"""
pass pass
@abstractmethod @abstractmethod
def input(self, i: int) -> "InputPort": def input(self, i: int) -> "InputPort":
""" """Get the input port at index i."""
Get the input port at index i.
"""
pass pass
@abstractmethod @abstractmethod
def output(self, i: int) -> "OutputPort": def output(self, i: int) -> "OutputPort":
""" """Get the output port at index i."""
Get the output port at index i.
"""
pass pass
@abstractmethod @abstractmethod
def params(self) -> Dict[str, Optional[Any]]: def params(self) -> Dict[str, Optional[Any]]:
""" """Get a dictionary of all parameter values."""
Get a dictionary of all parameter values.
"""
pass pass
@abstractmethod @abstractmethod
def param(self, name: str) -> Optional[Any]: def param(self, name: str) -> Optional[Any]:
""" """Get the value of a parameter.
Get the value of a parameter.
Returns None if the parameter is not defined. Returns None if the parameter is not defined.
""" """
pass pass
@abstractmethod @abstractmethod
def set_param(self, name: str, value: Any) -> None: def set_param(self, name: str, value: Any) -> None:
""" """Set the value of a parameter.
Set the value of a parameter.
The parameter must be defined. The parameter must be defined.
""" """
pass pass
@abstractmethod @abstractmethod
def evaluate_outputs(self, state: "SimulationState") -> List[Number]: def evaluate_outputs(self, state: "SimulationState") -> List[Number]:
""" """Simulate the circuit until its iteration count matches that of the simulation state,
Simulate the circuit until its iteration count matches that of the simulation state,
then return the resulting output vector. then return the resulting output vector.
""" """
pass pass
@abstractmethod @abstractmethod
def split(self) -> "List[Operation]": def split(self) -> "List[Operation]":
""" """Split the operation into multiple operations.
Split the operation into multiple operations.
If splitting is not possible, this may return a list containing only the operation itself. If splitting is not possible, this may return a list containing only the operation itself.
""" """
pass pass
@abstractmethod @abstractmethod
def get_op_name(self) -> "GraphIDType": def type_name(self) -> "GraphIDType":
"""Returns a string representing the operation name of the operation.""" """Returns a string representing the operation name of the operation."""
pass pass
@abstractmethod @abstractmethod
def neighbours(self) -> "List[Operation]": def neighbours(self) -> "List[Operation]":
""" """Return all operations that are connected by signals to this operation.
Return all operations that are connected by signals to this operation.
If no neighbours are found this returns an empty list If no neighbours are found this returns an empty list
""" """
# TODO: More stuff. # TODO: More stuff.
""" """@package docstring
B-ASIC Port Module. B-ASIC Port Module.
TODO: More info. TODO: More info.
""" """
from b_asic.signal import Signal
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from typing import NewType, Optional, List, Dict from typing import NewType, Optional, List
from b_asic.signal import Signal
PortId = NewType("PortId", int) PortId = NewType("PortId", int)
class Port(ABC): class Port(ABC):
""" """Abstract port class.
Abstract port class.
TODO: More info. TODO: More info.
""" """
_identifier: PortId _identifier: PortId
def __init__(self, identifier: PortId): def __init__(self, identifier: PortId):
""" """Construct a Port."""
Construct a Port.
"""
self._identifier = identifier self._identifier = identifier
def identifier(self) -> PortId: def identifier(self) -> PortId:
""" """Get the unique identifier."""
Get the unique identifier.
"""
return self._identifier return self._identifier
@abstractmethod @abstractmethod
def signals(self) -> List[Signal]: def signals(self) -> List[Signal]:
""" """Get a list of all connected signals."""
Get a list of all connected signals.
"""
pass pass
@abstractmethod @abstractmethod
def signal_count(self) -> int: def signal_count(self) -> int:
""" """Get the number of connected signals."""
Get the number of connected signals.
"""
pass pass
@abstractmethod @abstractmethod
def signal(self, i: int = 0) -> Signal: def signal(self, i: int = 0) -> Signal:
""" """Get the connected signal at index i."""
Get the connected signal at index i.
"""
pass pass
@abstractmethod @abstractmethod
def connect(self, signal: Signal) -> None: def connect(self, signal: Signal) -> None:
""" """Connect a signal."""
Connect a signal.
"""
pass pass
@abstractmethod @abstractmethod
def disconnect(self, i: int = 0) -> None: def disconnect(self, i: int = 0) -> None:
""" """Disconnect a signal."""
Disconnect a signal.
"""
pass pass
# TODO: More stuff. # TODO: More stuff.
class InputPort(Port): class InputPort(Port):
""" """Input port.
Input port.
TODO: More info. TODO: More info.
""" """
_source_signal: Optional[Signal] _source_signal: Optional[Signal]
def __init__(self, identifier: PortId): def __init__(self, identifier: PortId):
"""
Construct an InputPort.
"""
super().__init__(identifier) super().__init__(identifier)
self._source_signal = None self._source_signal = None
def signals(self) -> List[Signal]: def signals(self) -> List[Signal]:
return [] if self._source_signal == None else [self._source_signal] return [] if self._source_signal is None else [self._source_signal]
def signal_count(self) -> int: def signal_count(self) -> int:
return 0 if self._source_signal == None else 1 return 0 if self._source_signal is None else 1
def signal(self, i: int = 0) -> Signal: def signal(self, i: int = 0) -> Signal:
assert i >= 0 and i < self.signal_count() # TODO: Error message. assert 0 <= i < self.signal_count() # TODO: Error message.
assert self._source_signal != None # TODO: Error message. assert self._source_signal is not None # TODO: Error message.
return self._source_signal return self._source_signal
def connect(self, signal: Signal) -> None: def connect(self, signal: Signal) -> None:
self._source_signal = signal self._source_signal = signal
def disconnect(self, i: int = 0) -> None: def disconnect(self, i: int = 0) -> None:
assert i >= 0 and i < self.signal_count() # TODO: Error message. assert 0 <= i < self.signal_count() # TODO: Error message.
self._source_signal = None self._source_signal = None
# TODO: More stuff. # TODO: More stuff.
class OutputPort(Port): class OutputPort(Port):
""" """Output port.
Output port.
TODO: More info. TODO: More info.
""" """
_destination_signals: List[Signal] _destination_signals: List[Signal]
def __init__(self, identifier: PortId): def __init__(self, identifier: PortId):
"""
Construct an OutputPort.
"""
super().__init__(identifier) super().__init__(identifier)
self._destination_signals = [] self._destination_signals = []
...@@ -125,7 +103,7 @@ class OutputPort(Port): ...@@ -125,7 +103,7 @@ class OutputPort(Port):
return len(self._destination_signals) return len(self._destination_signals)
def signal(self, i: int = 0) -> Signal: def signal(self, i: int = 0) -> Signal:
assert i >= 0 and i < self.signal_count() # TODO: Error message. assert 0 <= i < self.signal_count() # TODO: Error message.
return self._destination_signals[i] return self._destination_signals[i]
def connect(self, signal: Signal) -> None: def connect(self, signal: Signal) -> None:
...@@ -133,7 +111,7 @@ class OutputPort(Port): ...@@ -133,7 +111,7 @@ class OutputPort(Port):
self._destination_signals.append(signal) self._destination_signals.append(signal)
def disconnect(self, i: int = 0) -> None: def disconnect(self, i: int = 0) -> None:
assert i >= 0 and i < self.signal_count() # TODO: Error message. assert 0 <= i < self.signal_count() # TODO: Error message.
del self._destination_signals[i] del self._destination_signals[i]
# TODO: More stuff. # TODO: More stuff.
""" """@package docstring
B-ASIC Precedence Chart Module. B-ASIC Precedence Chart Module.
TODO: More info. TODO: More info.
""" """
...@@ -7,8 +7,7 @@ from b_asic.signal_flow_graph import SFG ...@@ -7,8 +7,7 @@ from b_asic.signal_flow_graph import SFG
class PrecedenceChart: class PrecedenceChart:
""" """Precedence chart constructed from a signal flow graph.
Precedence chart constructed from a signal flow graph.
TODO: More info. TODO: More info.
""" """
...@@ -16,9 +15,6 @@ class PrecedenceChart: ...@@ -16,9 +15,6 @@ class PrecedenceChart:
# TODO: More members. # TODO: More members.
def __init__(self, sfg: SFG): def __init__(self, sfg: SFG):
"""
Construct a PrecedenceChart.
"""
self.sfg = sfg self.sfg = sfg
# TODO: Implement. # TODO: Implement.
......
""" """@package docstring
B-ASIC Schema Module. B-ASIC Schema Module.
TODO: More info. TODO: More info.
""" """
...@@ -7,8 +7,7 @@ from b_asic.precedence_chart import PrecedenceChart ...@@ -7,8 +7,7 @@ from b_asic.precedence_chart import PrecedenceChart
class Schema: class Schema:
""" """Schema constructed from a precedence chart.
Schema constructed from a precedence chart.
TODO: More info. TODO: More info.
""" """
...@@ -16,9 +15,6 @@ class Schema: ...@@ -16,9 +15,6 @@ class Schema:
# TODO: More members. # TODO: More members.
def __init__(self, pc: PrecedenceChart): def __init__(self, pc: PrecedenceChart):
"""
Construct a Schema.
"""
self.pc = pc self.pc = pc
# TODO: Implement. # TODO: Implement.
......
""" """@package docstring
B-ASIC Signal Module. B-ASIC Signal Module.
TODO: More info. TODO: More info.
""" """
from b_asic.operation import Operation from b_asic.operation import Operation
from typing import NewType
class SignalSource: class SignalSource:
""" """Handle to a signal source.
Handle to a signal source.
TODO: More info. TODO: More info.
""" """
operation: Operation operation: Operation
port_index: int port_index: int
def __init__(self, operation: Operation, port_index: int): def __init__(self, operation: Operation, port_index: int):
"""
Construct a SignalSource.
"""
self.operation = operation self.operation = operation
self.port_index = port_index self.port_index = port_index
...@@ -25,17 +21,13 @@ class SignalSource: ...@@ -25,17 +21,13 @@ class SignalSource:
class SignalDestination: class SignalDestination:
""" """Handle to a signal destination.
Handle to a signal destination.
TODO: More info. TODO: More info.
""" """
operation: Operation operation: Operation
port_index: int port_index: int
def __init__(self, operation: Operation, port_index: int): def __init__(self, operation: Operation, port_index: int):
"""
Construct a SignalDestination.
"""
self.operation = operation self.operation = operation
self.port_index = port_index self.port_index = port_index
...@@ -43,17 +35,13 @@ class SignalDestination: ...@@ -43,17 +35,13 @@ class SignalDestination:
class Signal: class Signal:
""" """A connection between two operations consisting of a source and destination handle.
A connection between two operations consisting of a source and destination handle.
TODO: More info. TODO: More info.
""" """
source: SignalSource source: SignalSource
destination: SignalDestination destination: SignalDestination
def __init__(self, source: SignalSource, destination: SignalDestination): def __init__(self, source: SignalSource, destination: SignalDestination):
"""
Construct a Signal.
"""
self.source = source self.source = source
self.destination = destination self.destination = destination
......
""" """@package docstring
B-ASIC Signal Flow Graph Module. B-ASIC Signal Flow Graph Module.
TODO: More info. TODO: More info.
""" """
from typing import List, Dict, Union, Optional
from b_asic.operation import Operation from b_asic.operation import Operation
from b_asic.basic_operation import BasicOperation from b_asic.basic_operation import BasicOperation
from b_asic.signal import Signal, SignalSource, SignalDestination from b_asic.signal import Signal, SignalSource, SignalDestination
from b_asic.simulation import SimulationState, OperationState
from b_asic.graph_id import GraphIDGenerator, GraphID from b_asic.graph_id import GraphIDGenerator, GraphID
from typing import List, Dict, Union, Optional
class SFG(BasicOperation): class SFG(BasicOperation):
""" """Signal flow graph.
Signal flow graph.
TODO: More info. TODO: More info.
""" """
...@@ -21,12 +20,11 @@ class SFG(BasicOperation): ...@@ -21,12 +20,11 @@ class SFG(BasicOperation):
_graph_id_generator: GraphIDGenerator _graph_id_generator: GraphIDGenerator
def __init__(self, input_destinations: List[SignalDestination], output_sources: List[SignalSource]): def __init__(self, input_destinations: List[SignalDestination], output_sources: List[SignalSource]):
"""Constructs an SFG."""
super().__init__() super().__init__()
# TODO: Allocate input/output ports with appropriate IDs. # TODO: Allocate input/output ports with appropriate IDs.
self._graph_objects_by_id = dict # Map Operation ID to Operation objects self._graph_objects_by_id = dict # Map Operation ID to Operation objects
self._graph_id_generator = GraphIDGenerator() self._graph_id_generator = GraphIDGenerator()
# TODO: Traverse the graph between the inputs/outputs and add to self._operations. # TODO: Traverse the graph between the inputs/outputs and add to self._operations.
# TODO: Connect ports with signals with appropriate IDs. # TODO: Connect ports with signals with appropriate IDs.
...@@ -37,23 +35,21 @@ class SFG(BasicOperation): ...@@ -37,23 +35,21 @@ class SFG(BasicOperation):
def add_operation(self, operation: Operation) -> GraphID: def add_operation(self, operation: Operation) -> GraphID:
"""Adds the entered operation to the SFG's dictionary of graph objects and """Adds the entered operation to the SFG's dictionary of graph objects and
returns a generated GraphID for it. returns a generated GraphID for it.
Keyword arguments: Keyword arguments:
operation: Operation to add to the graph. operation: Operation to add to the graph.
""" """
return self._add_graph_obj(operation, operation.get_op_name()) return self._add_graph_obj(operation, operation.type_name())
def add_signal(self, signal: Signal) -> GraphID: def add_signal(self, signal: Signal) -> GraphID:
"""Adds the entered signal to the SFG's dictionary of graph objects and returns """Adds the entered signal to the SFG's dictionary of graph objects and returns
a generated GraphID for it. a generated GraphID for it.
Keyword argumentst: Keyword argumentst:
signal: Signal to add to the graph. signal: Signal to add to the graph.
""" """
return self._add_graph_obj(signal, 'sig') return self._add_graph_obj(signal, 'sig')
def find_by_id(self, graph_id: GraphID) -> Optional[Operation]: def find_by_id(self, graph_id: GraphID) -> Optional[Operation]:
"""Finds a graph object based on the entered Graph ID and returns it. If no graph """Finds a graph object based on the entered Graph ID and returns it. If no graph
object with the entered ID was found then returns None. object with the entered ID was found then returns None.
...@@ -63,14 +59,11 @@ class SFG(BasicOperation): ...@@ -63,14 +59,11 @@ class SFG(BasicOperation):
""" """
if graph_id in self._graph_objects_by_id: if graph_id in self._graph_objects_by_id:
return self._graph_objects_by_id[graph_id] return self._graph_objects_by_id[graph_id]
else:
return None
return None
def _add_graph_obj(self, obj: Union[Operation, Signal], operation_id_type: str): def _add_graph_obj(self, obj: Union[Operation, Signal], operation_id_type: str):
graph_id = self._graph_id_generator.get_next_id(operation_id_type) graph_id = self._graph_id_generator.get_next_id(operation_id_type)
self._graph_objects_by_id[graph_id] = obj self._graph_objects_by_id[graph_id] = obj
return graph_id return graph_id
""" """@package docstring
B-ASIC Simulation Module. B-ASIC Simulation Module.
TODO: More info. TODO: More info.
""" """
from numbers import Number from numbers import Number
from typing import List, Dict from typing import List
class OperationState: class OperationState:
""" """Simulation state of an operation.
Simulation state of an operation.
TODO: More info. TODO: More info.
""" """
...@@ -17,16 +16,12 @@ class OperationState: ...@@ -17,16 +16,12 @@ class OperationState:
iteration: int iteration: int
def __init__(self): def __init__(self):
"""
Construct an OperationState.
"""
self.output_values = [] self.output_values = []
self.iteration = 0 self.iteration = 0
class SimulationState: class SimulationState:
""" """Simulation state.
Simulation state.
TODO: More info. TODO: More info.
""" """
...@@ -34,9 +29,6 @@ class SimulationState: ...@@ -34,9 +29,6 @@ class SimulationState:
iteration: int iteration: int
def __init__(self): def __init__(self):
"""
Construct a SimulationState.
"""
self.operation_states = {} self.operation_states = {}
self.iteration = 0 self.iteration = 0
......
""" """@package docstring
B-ASIC Operation Tree Traversing Module. B-ASIC Operation Tree Traversing Module.
TODO:
- Get a first operation or? an entire operation tree
- For each start point, follow it to the next operation from it's out port.
- If we are searching for a specific operation end.
- If we are searching for a specific type of operation add the operation to a list and continue.
- When we no more out ports can be traversed return results and end.
""" """
from typing import List, Optional from typing import List, Optional
...@@ -15,12 +9,7 @@ from b_asic.operation import Operation ...@@ -15,12 +9,7 @@ from b_asic.operation import Operation
class Traverse: class Traverse:
"""Traverse operation tree. """Traverse operation tree."""
TODO:
- More info.
- Check if a datastructure other than list suits better as return value.
- Implement the type check for operation.
"""
def __init__(self, operation: Operation): def __init__(self, operation: Operation):
"""Construct a TraverseTree.""" """Construct a TraverseTree."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment