From 11de6fffe46cc0e949498957184fa46b340b4f68 Mon Sep 17 00:00:00 2001
From: Simon Bjurek <simbj106@student.liu.se>
Date: Mon, 24 Mar 2025 14:15:09 +0100
Subject: [PATCH] added latency tie-breaker for
 Schedule.sort_y_locations_on_start_times()

---
 b_asic/schedule.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/b_asic/schedule.py b/b_asic/schedule.py
index 37e211da..b88e7aef 100644
--- a/b_asic/schedule.py
+++ b/b_asic/schedule.py
@@ -1089,10 +1089,17 @@ class Schedule:
         move_y_location
         set_y_location
         """
-        for i, graph_id in enumerate(
-            sorted(self._start_times, key=self._start_times.get)
-        ):
+
+        def sort_key(graph_id):
+            op = self._sfg.find_by_id(graph_id)
+            return (
+                self._start_times[op.graph_id],
+                -self._sfg.find_by_id(graph_id).latency,
+            )
+
+        for i, graph_id in enumerate(sorted(self._start_times, key=sort_key)):
             self.set_y_location(graph_id, i)
+
         for graph_id in self._start_times:
             op = cast(Operation, self._sfg.find_by_id(graph_id))
             # Position Outputs and Sinks adjacent to the operation generating them
-- 
GitLab