diff --git a/b_asic/core_operations.py b/b_asic/core_operations.py index 0a321f90f0782c84cc39a19d28d015449e6efd0e..175c59d12c4ff4b49be18f995c9d8eb14c778149 100644 --- a/b_asic/core_operations.py +++ b/b_asic/core_operations.py @@ -1696,6 +1696,37 @@ class DontCare(AbstractOperation): def __str__(self) -> str: return "dontcare" + def get_plot_coordinates( + self, + ) -> tuple[tuple[tuple[float, float], ...], tuple[tuple[float, float], ...]]: + # Doc-string inherited + return ( + ( + (-0.5, 0), + (-0.5, 1), + (-0.25, 1), + (0, 0.5), + (-0.25, 0), + (-0.5, 0), + ), + ( + (-0.5, 0), + (-0.5, 1), + (-0.25, 1), + (0, 0.5), + (-0.25, 0), + (-0.5, 0), + ), + ) + + def get_input_coordinates(self) -> tuple[tuple[float, float], ...]: + # doc-string inherited + return tuple() + + def get_output_coordinates(self) -> tuple[tuple[float, float], ...]: + # doc-string inherited + return ((0, 0.5),) + class Sink(AbstractOperation): r""" @@ -1740,3 +1771,34 @@ class Sink(AbstractOperation): def __str__(self) -> str: return "sink" + + def get_plot_coordinates( + self, + ) -> tuple[tuple[tuple[float, float], ...], tuple[tuple[float, float], ...]]: + # Doc-string inherited + return ( + ( + (-0.5, 0), + (-0.5, 1), + (-0.25, 1), + (0, 0.5), + (-0.25, 0), + (-0.5, 0), + ), + ( + (-0.5, 0), + (-0.5, 1), + (-0.25, 1), + (0, 0.5), + (-0.25, 0), + (-0.5, 0), + ), + ) + + def get_input_coordinates(self) -> tuple[tuple[float, float], ...]: + # doc-string inherited + return tuple() + + def get_output_coordinates(self) -> tuple[tuple[float, float], ...]: + # doc-string inherited + return ((0, 0.5),) diff --git a/b_asic/scheduler.py b/b_asic/scheduler.py index 22052b60116d2ca70a258c7d91dc5a8c50deb94c..4f1a58f27a72f41031b1517752bfd188a04ecb16 100644 --- a/b_asic/scheduler.py +++ b/b_asic/scheduler.py @@ -1,6 +1,7 @@ from abc import ABC, abstractmethod from typing import TYPE_CHECKING, Optional, cast +from b_asic.core_operations import DontCare from b_asic.port import OutputPort from b_asic.special_operations import Delay, Input, Output from b_asic.types import TypeName @@ -123,11 +124,16 @@ class ListScheduler(Scheduler, ABC): self._handle_outputs(schedule) schedule.remove_delays() - # move all inputs and outputs ALAP now that operations have moved + # move all inputs ALAP now that operations have moved for input_op in schedule.sfg.find_by_type_name(Input.type_name()): input_op = cast(Input, input_op) schedule.move_operation_alap(input_op.graph_id) + # move all dont cares ALAP + for dc_op in schedule.sfg.find_by_type_name(DontCare.type_name()): + dc_op = cast(DontCare, dc_op) + schedule.move_operation_alap(dc_op.graph_id) + @staticmethod def _candidate_is_schedulable( start_times: dict["GraphID"], diff --git a/examples/ldlt_matrix_inverse.py b/examples/ldlt_matrix_inverse.py index b859fec2e239fb05c7667747519a6090667a6a93..3921afe4a17d07626d4850496009023e494f9d36 100644 --- a/examples/ldlt_matrix_inverse.py +++ b/examples/ldlt_matrix_inverse.py @@ -6,7 +6,7 @@ LDLT Matrix Inversion Algorithm """ from b_asic.architecture import Architecture, Memory, ProcessingElement -from b_asic.core_operations import MADS, Constant, Reciprocal +from b_asic.core_operations import MADS, DontCare, Reciprocal from b_asic.core_schedulers import ( ALAPScheduler, ASAPScheduler, @@ -17,8 +17,9 @@ from b_asic.core_schedulers import ( ) from b_asic.schedule import Schedule from b_asic.sfg_generators import ldlt_matrix_inverse +from b_asic.special_operations import Input, Output -sfg = ldlt_matrix_inverse(N=3, is_complex=False) +sfg = ldlt_matrix_inverse(N=3) # %% # The SFG is @@ -26,10 +27,10 @@ sfg # %% # Set latencies and execution times. -sfg.set_latency_of_type(Constant.type_name(), 0) +sfg.set_latency_of_type(DontCare.type_name(), 0) # REMOVE!!! sfg.set_latency_of_type(MADS.type_name(), 3) sfg.set_latency_of_type(Reciprocal.type_name(), 2) -sfg.set_execution_time_of_type(Constant.type_name(), 0) +sfg.set_execution_time_of_type(DontCare.type_name(), 0) # REMOVE!!! sfg.set_execution_time_of_type(MADS.type_name(), 1) sfg.set_execution_time_of_type(Reciprocal.type_name(), 1) @@ -37,56 +38,56 @@ sfg.set_execution_time_of_type(Reciprocal.type_name(), 1) # Create an ASAP schedule. schedule = Schedule(sfg, scheduler=ASAPScheduler()) print("Scheduling time:", schedule.schedule_time) -# schedule.show() +schedule.show() # %% # Create an ALAP schedule. schedule = Schedule(sfg, scheduler=ALAPScheduler()) print("Scheduling time:", schedule.schedule_time) -# schedule.show() +schedule.show() # %% # Create an EarliestDeadline schedule that satisfies the resource constraints. resources = {MADS.type_name(): 1, Reciprocal.type_name(): 1} schedule = Schedule(sfg, scheduler=EarliestDeadlineScheduler(resources)) print("Scheduling time:", schedule.schedule_time) -# schedule.show() +schedule.show() # %% # Create a LeastSlackTime schedule that satisfies the resource constraints. schedule = Schedule(sfg, scheduler=LeastSlackTimeScheduler(resources)) print("Scheduling time:", schedule.schedule_time) -# schedule.show() +schedule.show() # %% # Create a MaxFanOutScheduler schedule that satisfies the resource constraints. schedule = Schedule(sfg, scheduler=MaxFanOutScheduler(resources)) print("Scheduling time:", schedule.schedule_time) -# schedule.show() +schedule.show() # %% # Create a HybridScheduler schedule that satisfies the resource constraints. schedule = Schedule(sfg, scheduler=HybridScheduler(resources)) print("Scheduling time:", schedule.schedule_time) -# schedule.edit() +schedule.show() # %% operations = schedule.get_operations() -mads = operations.get_by_type_name("mads") +mads = operations.get_by_type_name(MADS.type_name()) mads.show(title="MADS executions") -reciprocals = operations.get_by_type_name("rec") +reciprocals = operations.get_by_type_name(Reciprocal.type_name()) reciprocals.show(title="Reciprocal executions") -consts = operations.get_by_type_name("c") -consts.show(title="Const executions") -inputs = operations.get_by_type_name("in") +dont_cares = operations.get_by_type_name(DontCare.type_name()) +dont_cares.show(title="Dont-care executions") +inputs = operations.get_by_type_name(Input.type_name()) inputs.show(title="Input executions") -outputs = operations.get_by_type_name("out") +outputs = operations.get_by_type_name(Output.type_name()) outputs.show(title="Output executions") mads_pe = ProcessingElement(mads, entity_name="mad") reciprocal_pe = ProcessingElement(reciprocals, entity_name="rec") -const_pe = ProcessingElement(consts, entity_name="c") +dont_care_pe = ProcessingElement(dont_cares, entity_name="dc") pe_in = ProcessingElement(inputs, entity_name='input') pe_out = ProcessingElement(outputs, entity_name='output') @@ -110,7 +111,7 @@ direct.show(title="Direct interconnects") # %% arch = Architecture( - {mads_pe, reciprocal_pe, const_pe, pe_in, pe_out}, + {mads_pe, reciprocal_pe, dont_care_pe, pe_in, pe_out}, memories, direct_interconnects=direct, )