Skip to content
Snippets Groups Projects
Commit 579bf5d2 authored by Hugo Winbladh's avatar Hugo Winbladh Committed by Oscar Gustafsson
Browse files

Add method to reconstruct an SFG from a schedule, and algorithm to simplify delays

parent c2b55947
No related branches found
No related tags found
1 merge request!420Add method to reconstruct SFG from a schedule
......@@ -760,6 +760,13 @@ class Schedule:
del self._laps[delay_input_id]
delay_list = self._sfg.find_by_type_name(Delay.type_name())
def _reintroduce_delays(self) -> SFG:
reconstructed_sfg = self._sfg()
for signal_id,lap in self._laps.items():
for delays in range(lap):
reconstructed_sfg = reconstructed_sfg.insert_operation_after(signal_id, Delay())
return reconstructed_sfg()
def _schedule_alap(self) -> None:
"""Schedule the operations using as-late-as-possible scheduling."""
precedence_list = self._sfg.get_precedence_list()
......
......@@ -736,6 +736,27 @@ class SFG(AbstractOperation):
# Recreate the newly coupled SFG so that all attributes are correct.
return sfg_copy()
def simplify_delay_element_placement(self) -> "SFG":
sfg_copy = self()
for delay_element in sfg_copy.find_by_type_name(Delay.type_name()):
neighboring_delays = []
if len(delay_element.inputs[0].signals) > 0:
for signal in delay_element.inputs[0].signals[0].source.signals:
if isinstance(signal.destination.operation, Delay):
neighboring_delays.append(signal.destination.operation)
if delay_element in neighboring_delays:
neighboring_delays.remove(delay_element)
for delay in neighboring_delays:
for output in delay.outputs[0].signals:
output.set_source(delay_element.outputs[0])
in_sig = delay.input(0).signals[0]
delay.input(0).remove_signal(in_sig)
in_sig.source.remove_signal(in_sig)
return sfg_copy()
def _insert_operation_after_operation(
self, output_operation: Operation, new_operation: Operation
):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment