From e03a524fcfc70b067aa1843274d0b6fb819c48b7 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 11 Apr 2019 00:47:36 +0200 Subject: [PATCH] WIP: netlist compare, bug fixes. --- src/db/db/dbNetlistCompare.cc | 52 +++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/src/db/db/dbNetlistCompare.cc b/src/db/db/dbNetlistCompare.cc index 530ef240c..6094148e9 100644 --- a/src/db/db/dbNetlistCompare.cc +++ b/src/db/db/dbNetlistCompare.cc @@ -1010,6 +1010,36 @@ NetDeviceGraph::derive_node_identities_from_node_set (const std::vector::max (); } + if (nodes.size () == 1 && other_nodes.size () == 1) { + + // a single candiate: just take this one -> this may render + // inexact matches, but further propagates net pairing + + if (! tentative) { + + size_t ni = node_index_for_net (nodes.front ()->net ()); + size_t other_ni = other.node_index_for_net (other_nodes.front ()->net ()); + + identify (ni, other_ni); + other.identify (other_ni, ni); + +#if defined(PRINT_DEBUG_NETCOMPARE) + tl::info << "deduced match (singular): " << nodes.front ()->net ()->expanded_name () << " vs. " << other_nodes.front ()->net ()->expanded_name (); +#endif + if (logger) { + logger->match_nets (nodes.front ()->net (), other_nodes.front ()->net ()); + } + + // unconditionally continue here. + derive_node_identities (ni, other, depth + 1, n_branch, logger, circuit_pin_mapper, false); + + } + + new_nodes += 1; + return new_nodes; + + } + if (picky) { if (nodes.size () != other_nodes.size ()) { @@ -1029,18 +1059,20 @@ NetDeviceGraph::derive_node_identities_from_node_set (const std::vectorhas_other ()) { + ++n1; + continue; + } else if ((*n2)->has_other ()) { + ++n2; + continue; + } + if (**n1 < **n2) { ++n1; continue; } else if (**n2 < **n1) { ++n2; continue; - } else if ((*n1)->has_other ()) { - ++n1; - continue; - } else if ((*n2)->has_other ()) { - ++n2; - continue; } std::vector::const_iterator nn1 = n1, nn2 = n2; @@ -1067,10 +1099,11 @@ NetDeviceGraph::derive_node_identities_from_node_set (const std::vector this may render // inexact matches, but further propagates net pairing - size_t ni = node_index_for_net ((*n1)->net ()); - size_t other_ni = other.node_index_for_net ((*n2)->net ()); if (! tentative) { + size_t ni = node_index_for_net ((*n1)->net ()); + size_t other_ni = other.node_index_for_net ((*n2)->net ()); + identify (ni, other_ni); other.identify (other_ni, ni); @@ -1585,6 +1618,9 @@ NetlistComparer::compare_circuits (const db::Circuit *c1, const db::Circuit *c2, break; } + std::sort (nodes.begin (), nodes.end (), CompareNodePtr ()); + std::sort (other_nodes.begin (), other_nodes.end (), CompareNodePtr ()); + size_t ni = g1.derive_node_identities_from_node_set (nodes, other_nodes, g2, 0, 1, mp_logger, mp_circuit_pin_mapper.get (), false /*not tentative*/, false /*don't require a full match*/); if (ni > 0 && ni != std::numeric_limits::max ()) { new_identities += ni;