From aaf8003dc0332470e596ae5f74ccaffb4e6f3732 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson <oscar.gustafsson@gmail.com> Date: Mon, 24 Apr 2023 14:38:28 +0200 Subject: [PATCH] Implement print_slacks --- b_asic/schedule.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/b_asic/schedule.py b/b_asic/schedule.py index a92f6a36..b2b43931 100644 --- a/b_asic/schedule.py +++ b/b_asic/schedule.py @@ -264,7 +264,27 @@ class Schedule: def print_slacks(self) -> None: """Print the slack times for all operations in the schedule.""" - raise NotImplementedError + res = [ + ( + op.graph_id, + self.backward_slack(op.graph_id), + self.forward_slack(op.graph_id), + ) + for op in self._sfg.operations + ] + res = [ + ( + r[0], + f"{r[1]}".rjust(8) if r[1] < sys.maxsize else "oo".rjust(8), + f"{r[2]}".rjust(8) if r[2] < sys.maxsize else "oo".rjust(8), + ) + for r in res + ] + + print("Graph ID | Backward | Forward") + print("---------|----------|---------") + for r in res: + print(f"{r[0]:8} | {r[1]} | {r[2]}") def set_schedule_time(self, time: int) -> "Schedule": """ -- GitLab