Skip to content
Snippets Groups Projects
Commit 7dcacd09 authored by Simon Bjurek's avatar Simon Bjurek
Browse files

rendering of dont cares now working and example is completed.

parent ca4c30c0
No related branches found
No related tags found
No related merge requests found
Pipeline #156251 passed
......@@ -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),)
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"],
......
......@@ -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,
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment