From 4457248ecd507dbe913e4d6b2fa630e13c64349c Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Sun, 9 Feb 2025 21:26:54 -0500 Subject: [PATCH] Corrected a long-standing issue with permutation, which turned out to be caused by failing to have a systematic way of determining which pin's hash value would be used for the hash value of all the pins. Because equivalent cells in the two netlists may have pins in different order, it was possible that they might end up with different hashes. This was solved simply by always taking the larger hash value of the two pins belonging to the permutable pair. Now permutation works correctly for arbitrary subcircuits. (Previously it worked for low-level components like MOSFETs because the pin order is always the same.) --- VERSION | 2 +- base/netcmp.c | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/VERSION b/VERSION index fb380af..d8f6f88 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.5.291 +1.5.292 diff --git a/base/netcmp.c b/base/netcmp.c index c209fe1..23fe3ee 100644 --- a/base/netcmp.c +++ b/base/netcmp.c @@ -1217,7 +1217,8 @@ SortFanoutLists(nlist1, nlist2) f2 -= 1; matched[f1] = -1; total++; - if (f2 != f1) { + if ((f2 != f1) && (nlist2->flist[f1].permute != 0) && + (nlist2->flist[f2].permute != 0)) { temp = nlist2->flist[f2]; nlist2->flist[f2] = nlist2->flist[f1]; nlist2->flist[f1] = temp; @@ -1251,7 +1252,8 @@ SortFanoutLists(nlist1, nlist2) f1 -= 1; matched[f2] = -1; total++; - if (f1 != f2) { + if ((f1 != f2) && (nlist1->flist[f1].permute != 0) && + (nlist1->flist[f2].permute != 0)) { temp = nlist1->flist[f1]; nlist1->flist[f1] = nlist1->flist[f2]; nlist1->flist[f2] = temp; @@ -7013,10 +7015,21 @@ int Permute() return (0); } - /* update magic numbers */ - for (NL = E->nodelist; NL != NULL; NL = NL->next) - if (NL->pin_magic == one) - NL->pin_magic = two; + /* Update magic numbers. To ensure that this works */ + /* regardless of the pin order of the pins in each */ + /* netlist, always set both pins to the larger of */ + /* the two pin_magic values. */ + + if (one > two) { + for (NL = E->nodelist; NL != NULL; NL = NL->next) + if (NL->pin_magic == two) + NL->pin_magic = one; + } + else { + for (NL = E->nodelist; NL != NULL; NL = NL->next) + if (NL->pin_magic == one) + NL->pin_magic = two; + } } } }