From 6457b4ca7b90c59a886ed623d321504131ebeeb6 Mon Sep 17 00:00:00 2001
From: David Shah <dave@ds0.me>
Date: Tue, 10 Nov 2020 10:09:08 +0000
Subject: nexus: Swap sort order to make some lookups easier

Signed-off-by: David Shah <dave@ds0.me>
---
 nexus/arch.cc         | 4 ++--
 nexus/arch.h          | 2 +-
 nexus/bba_version.inc | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

(limited to 'nexus')

diff --git a/nexus/arch.cc b/nexus/arch.cc
index a25fc95e..78e10e16 100644
--- a/nexus/arch.cc
+++ b/nexus/arch.cc
@@ -731,8 +731,8 @@ bool Arch::lookup_cell_delay(int type_idx, IdString from_port, IdString to_port,
     const auto &ct = speed_grade->cell_types[type_idx];
     int dly_idx = db_binary_search(
             ct.prop_delays.get(), ct.num_prop_delays,
-            [](const CellPropDelayPOD &pd) { return std::make_pair(pd.from_port, pd.to_port); },
-            std::make_pair(from_port.index, to_port.index));
+            [](const CellPropDelayPOD &pd) { return std::make_pair(pd.to_port, pd.from_port); },
+            std::make_pair(to_port.index, from_port.index));
     if (dly_idx == -1)
         return false;
     delay.min_delay = ct.prop_delays[dly_idx].min_delay;
diff --git a/nexus/arch.h b/nexus/arch.h
index 2d68ebeb..cbe39316 100644
--- a/nexus/arch.h
+++ b/nexus/arch.h
@@ -276,7 +276,7 @@ NPNR_PACKED_STRUCT(struct IdStringDBPOD {
 // Timing structures are generally sorted using IdString indices as keys for fast binary searches
 // All delays are integer picoseconds
 
-// Sort key: (from_port, to_port) for binary search by IdString
+// Sort key: (to_port, from_port) for binary search by IdString
 NPNR_PACKED_STRUCT(struct CellPropDelayPOD {
     int32_t from_port;
     int32_t to_port;
diff --git a/nexus/bba_version.inc b/nexus/bba_version.inc
index 45a4fb75..ec635144 100644
--- a/nexus/bba_version.inc
+++ b/nexus/bba_version.inc
@@ -1 +1 @@
-8
+9
-- 
cgit v1.2.3