From 44def159cc1babb18a29f71e4961df85d230afef Mon Sep 17 00:00:00 2001 From: Maciej Dudek Date: Tue, 21 Sep 2021 20:48:50 +0200 Subject: Fix AC-3 algorithm Signed-off-by: Maciej Dudek --- fpga_interchange/arch_pack_clusters.cc | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'fpga_interchange') diff --git a/fpga_interchange/arch_pack_clusters.cc b/fpga_interchange/arch_pack_clusters.cc index b7892fa2..74823b8e 100644 --- a/fpga_interchange/arch_pack_clusters.cc +++ b/fpga_interchange/arch_pack_clusters.cc @@ -505,23 +505,28 @@ bool reduce(uint32_t x, uint32_t y, const ClusterPOD *cluster, dictconnection_graph[x].connections[counter].edges){ - if (!x_cell->ports.count(IdString(edge.cell_pin)) || !y_cell->ports.count(IdString(edge.other_cell_pin))) + if (!x_cell->ports.count(IdString(edge.cell_pin)) || !y_cell->ports.count(IdString(edge.other_cell_pin))){ + found = false; break; + } const auto x_net = x_cell->ports[IdString(edge.cell_pin)].net; const auto y_net = y_cell->ports[IdString(edge.other_cell_pin)].net; - if (x_net != y_net) + if (x_net != y_net){ + found = false; break; + } bool x_driver = x_net->driver.cell == x_cell; bool y_driver = y_net->driver.cell == y_cell; - if ((edge.dir != 0 || !y_driver) && (edge.dir != 1 || !x_driver) && (edge.dir != 2 || y_driver || x_driver)) + if ((edge.dir != 0 || !y_driver) && (edge.dir != 1 || !x_driver) && (edge.dir != 2 || y_driver || x_driver)){ + found = false; break; - found = true; + } } - if (found){ + if (found) break; - } } if (!found) remove_cell.push_back(x_cell); @@ -544,9 +549,12 @@ void binary_constraint_check(const ClusterPOD *cluster, uint32_t x,y; x = arc.first; y = arc.second; if (reduce(x, y, cluster, idx_to_cells, ctx)){ - for (const auto &connection : cluster->connection_graph[arc.first].connections) - if (connection.target_idx != y) - workqueue.push(std::pair(arc.first, connection.target_idx)); + for (const auto &node : cluster->connection_graph){ + if (node.idx != arc.first) + for (const auto &connection : node.connections) + if (connection.target_idx == arc.first) + workqueue.push(std::pair(node.idx, arc.first)); + } } } } -- cgit v1.2.3