Newer
Older
B-ASIC Operation Module.
TODO: More info.
"""
from abc import ABC, abstractmethod
from numbers import Number
from typing import List, Dict, Optional, Any, TYPE_CHECKING
if TYPE_CHECKING:
from b_asic.port import InputPort, OutputPort
from b_asic.simulation import SimulationState

Jacob Wahlman
committed
from b_asic.graph_id import GraphIDType
"""Get a list of all input ports."""
"""Get a list of all output ports."""
pass
@abstractmethod
def input_count(self) -> int:
"""Get the number of input ports."""
pass
@abstractmethod
def output_count(self) -> int:
"""Get the number of output ports."""
"""Get the input port at index i."""
"""Get the output port at index i."""
pass
@abstractmethod
def params(self) -> Dict[str, Optional[Any]]:
"""Get a dictionary of all parameter values."""
pass
@abstractmethod
def param(self, name: str) -> Optional[Any]:
Returns None if the parameter is not defined.
"""
pass
@abstractmethod
def set_param(self, name: str, value: Any) -> None:
The parameter must be defined.
"""
pass
@abstractmethod
def evaluate_outputs(self, state: "SimulationState") -> List[Number]:
"""Simulate the circuit until its iteration count matches that of the simulation state,
then return the resulting output vector.
"""
pass
@abstractmethod
"""Split the operation into multiple operations.
If splitting is not possible, this may return a list containing only the operation itself.
"""
pass

Jacob Wahlman
committed
@abstractmethod
def type_name(self) -> "GraphIDType":

Jacob Wahlman
committed
"""Returns a string representing the operation name of the operation."""
pass
@abstractmethod
def neighbours(self) -> "List[Operation]":
"""Return all operations that are connected by signals to this operation.

Jacob Wahlman
committed
If no neighbours are found this returns an empty list
"""