From dd7cfccbae42b0f746676582eb6187d16d2bd557 Mon Sep 17 00:00:00 2001
From: Alessandro Comodi <acomodi@antmicro.com>
Date: Thu, 1 Jul 2021 11:56:55 +0200
Subject: interchange: phys: do not output nets which have no users

Signed-off-by: Alessandro Comodi <acomodi@antmicro.com>
---
 fpga_interchange/fpga_interchange.cpp | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

(limited to 'fpga_interchange/fpga_interchange.cpp')

diff --git a/fpga_interchange/fpga_interchange.cpp b/fpga_interchange/fpga_interchange.cpp
index 8d54335d..89f1f958 100644
--- a/fpga_interchange/fpga_interchange.cpp
+++ b/fpga_interchange/fpga_interchange.cpp
@@ -535,11 +535,22 @@ void FpgaInterchange::write_physical_netlist(const Context * ctx, const std::str
         phys_cell.setPhysType(PhysicalNetlist::PhysNetlist::PhysCellType::PORT);
     }
 
-    auto nets = phys_netlist.initPhysNets(ctx->nets.size());
+    int nets_to_remove = 0;
+    for(auto & net_pair : ctx->nets) {
+        auto &net = *net_pair.second;
+
+        if (net.users.empty())
+            nets_to_remove++;
+    }
+
+    auto nets = phys_netlist.initPhysNets(ctx->nets.size() - nets_to_remove);
     auto net_iter = nets.begin();
     for(auto & net_pair : ctx->nets) {
         auto &net = *net_pair.second;
 
+        if (net.users.empty())
+            continue;
+
         const CellInfo *driver_cell = net.driver.cell;
 
         auto net_out = *net_iter++;
-- 
cgit v1.2.3