From 2483b7440ffad1842949e226ca05ec8759a9453f Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Thu, 26 Dec 2024 21:20:24 -0500 Subject: [PATCH 1/2] Corrected an error in "ResolveAutomorphsByPin" where the code states to check that the nodes with matching names are pins, but never does. This results in an attempt to resolve automorphs by matching pin names AND net names. However, net names can match without the nets matching, as pointed out by Andrey Bondar (private communication). Fixed simply by adding the specified check that the node being name- matched is actually a pin. --- VERSION | 2 +- base/netcmp.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 268b24f..74884a5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.5.287 +1.5.288 diff --git a/base/netcmp.c b/base/netcmp.c index 0c3c37a..35b0bf9 100644 --- a/base/netcmp.c +++ b/base/netcmp.c @@ -6604,7 +6604,9 @@ int ResolveAutomorphsByPin() if (N1->hashval != orighash) continue; for (N2 = N1->next; N2 != NULL; N2 = N2->next) { if ((N2->graph != N1->graph) && - (*matchfunc)(N2->object->name, N1->object->name)) { + (*matchfunc)(N2->object->name, N1->object->name) && + (N1->object->type == PORT || N2->object->type == PORT)) { + if (Debug == TRUE) Printf("Symmetry group broken by name match (pin %s)\n", N2->object->name); Magic(newhash); From 6d2ef396efcb573bedf26c38f85dd952f3f549e0 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Fri, 27 Dec 2024 16:20:00 -0500 Subject: [PATCH 2/2] After giving the previous code change some more thought, I decided that it is beneficial to break symmetries by net name; it's just that net names should not be used before all symmetries related to pins have been broken. So I rewrote the compare routine to take an argument allowing or disallowing net name matches, and make one call to break symmetries by pin name followed by another call to break symmetries by net name. This still solves the original problem, but does not allow symmetries to be broken randomly on internal nets if names have been matched in both netlists. Otherwise the output may report nets that appear to be swapped, making the output confusing. --- VERSION | 2 +- base/netcmp.c | 7 ++++++- base/netcmp.h | 2 +- tcltk/tclnetgen.c | 8 +++++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index 74884a5..338640b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.5.288 +1.5.289 diff --git a/base/netcmp.c b/base/netcmp.c index 35b0bf9..0fa925a 100644 --- a/base/netcmp.c +++ b/base/netcmp.c @@ -6567,11 +6567,16 @@ void PrintAutomorphisms(void) * separating out those devices that are connected to matching pins * in each circuit. * + * If match_nets == TRUE, then also match internal nets by name. Pins + * should always be matched by name without considering nets first; + * once all symmetries related to pins have been broken, then matching + * symmetries by net can keep the output from looking confusing. + * * Return value is the same as VerifyMatching() *------------------------------------------------------------------------- */ -int ResolveAutomorphsByPin() +int ResolveAutomorphsByPin(int match_nets) { struct NodeClass *NC; struct Node *N; diff --git a/base/netcmp.h b/base/netcmp.h index 3aa7a82..6d90178 100644 --- a/base/netcmp.h +++ b/base/netcmp.h @@ -62,7 +62,7 @@ extern void RegroupDataStructures(); extern void FormatIllegalElementClasses(); extern void FormatIllegalNodeClasses(); extern int ResolveAutomorphsByProperty(); -extern int ResolveAutomorphsByPin(); +extern int ResolveAutomorphsByPin(int match_nets); extern void SummarizeElementClasses(struct ElementClass *EC); extern int remove_group_tags(struct objlist *ob); diff --git a/tcltk/tclnetgen.c b/tcltk/tclnetgen.c index da011f2..5071a02 100644 --- a/tcltk/tclnetgen.c +++ b/tcltk/tclnetgen.c @@ -2512,7 +2512,13 @@ _netcmp_run(ClientData clientData, if (automorphisms > 0) { // Next, attempt to resolve automorphisms uniquely by // using the pin names - automorphisms = ResolveAutomorphsByPin(); + automorphisms = ResolveAutomorphsByPin(FALSE); + } + if (automorphisms > 0) { + // Next, attempt to resolve automorphisms uniquely by + // using the net names (should only be done after + // resolving by pin). + automorphisms = ResolveAutomorphsByPin(TRUE); } if (automorphisms > 0) { // Anything left is truly indistinguishable