From ec0e097fcf65f4fdd359b2bd0b4e7bd98ee8d3ed Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Sun, 22 Oct 2023 10:36:54 -0400 Subject: [PATCH] Corrected the code from version 258 which was supposed to handle the removal of zero-valued devices between ports on the top level (from version 254 they are ignored for levels under the top to prevent port order from getting scrambled). An invalid check was being made to determine if the cells being compared were the top of the compare queue. This has been fixed. --- VERSION | 2 +- base/flatten.c | 26 +++++++++++++++++++++++++- base/netcmp.c | 19 +++++++++++-------- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/VERSION b/VERSION index e30bd8b..f509226 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.5.259 +1.5.260 diff --git a/base/flatten.c b/base/flatten.c index d24da24..a42e03c 100644 --- a/base/flatten.c +++ b/base/flatten.c @@ -1632,6 +1632,7 @@ PrematchLists(char *name1, int file1, char *name2, int file2) ECompList *list0X, *listX0; int hascontents1, hascontents2; int match, modified = 0; + int not_top; if (file1 == -1) tc1 = LookupCell(name1); @@ -1902,6 +1903,8 @@ PrematchLists(char *name1, int file1, char *name2, int file2) // Remove non-matching zero-value devices. This can // be done on a per-instance basis. + not_top = (PeekCompareQueueTop(NULL, NULL, NULL, NULL) == -1) ? FALSE : TRUE; + ecomp = (ECompare *)HashFirst(&compdict); while (ecomp != NULL) { if ((ecomp->num1 != ecomp->num2) && (ecomp->cell1 != NULL) && @@ -1958,7 +1961,7 @@ PrematchLists(char *name1, int file1, char *name2, int file2) /* because it will just show up as a */ /* port mismatch error as it should. */ - if (!(tc1->flags & CELL_TOP) && + if ((not_top == TRUE) && (ecomp->cell1->class != CLASS_ISOURCE)) { int found1 = FALSE; int found2 = FALSE; @@ -2096,6 +2099,27 @@ PrematchLists(char *name1, int file1, char *name2, int file2) break; } } + + /* (See comments above about removing shorts */ + /* between two ports.) */ + + if ((not_top == TRUE) && + (ecomp->cell2->class != CLASS_ISOURCE)) { + int found1 = FALSE; + int found2 = FALSE; + for (ob1 = tc2->cell; ob1; ob1 = ob1->next) { + if (!IsPort(ob1)) break; + else if (ob1->node == node1) + found1 = TRUE; + else if (ob1->node == node2) + found2 = TRUE; + if (found1 && found2) { + found = FALSE; + break; + } + } + } + if (found) break; } if (found) { diff --git a/base/netcmp.c b/base/netcmp.c index d055c47..1c9e81a 100644 --- a/base/netcmp.c +++ b/base/netcmp.c @@ -3773,20 +3773,23 @@ int CreateCompareQueue(char *name1, int file1, char *name2, int file2) return 0; } -/*----------------------------------------------*/ -/* Read the top of the compare queue, but do */ -/* not alter the stack. */ -/*----------------------------------------------*/ +/*----------------------------------------------------------------*/ +/* Read the top of the compare queue, but do not alter the stack. */ +/* Return -1 if there is no compare queue. This is a way to */ +/* check if the current cells being checked are the topmost in */ +/* the queue. Call with all NULL values for a quick check for a */ +/* top-level compare. */ +/*----------------------------------------------------------------*/ int PeekCompareQueueTop(char **name1, int *file1, char **name2, int *file2) { if (CompareQueue == NULL) return -1; - *name1 = CompareQueue->class1; - *file1 = CompareQueue->file1; - *name2 = CompareQueue->class2; - *file2 = CompareQueue->file2; + if (name1) *name1 = CompareQueue->class1; + if (file1) *file1 = CompareQueue->file1; + if (name2) *name2 = CompareQueue->class2; + if (file2) *file2 = CompareQueue->file2; return 0; }