From ca49a90ed67488a900761a68654bc7f4f261845c Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Fri, 31 Dec 2021 12:13:11 -0500 Subject: [PATCH 1/2] Merged changes from github issue #45 from Mitch Bailey. These changes speed up the time needed to flatten an instance, and add clarity to the output by specifying the file number for each cell name being modified during the pre-match stage. --- VERSION | 2 +- base/flatten.c | 71 +++++++++++++++++++++++--------------------------- 2 files changed, 33 insertions(+), 40 deletions(-) diff --git a/VERSION b/VERSION index 053625b..d76b1f6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.5.216 +1.5.217 diff --git a/base/flatten.c b/base/flatten.c index 567862c..83cc599 100644 --- a/base/flatten.c +++ b/base/flatten.c @@ -372,22 +372,16 @@ int flattenInstancesOf(char *name, int fnum, char *instance) /* update node numbers in child to unique numbers */ oldmax = 0; - for (tmp = ChildStart; tmp != NULL; tmp = tmp->next) + for (tmp = ChildStart; tmp != NULL; tmp = tmp->next) { if (tmp->node > oldmax) oldmax = tmp->node; - if (nextnode <= oldmax) nextnode = oldmax + 1; - - for (tmp = ChildStart; tmp != NULL; tmp = tmp->next) - if (tmp->node <= oldmax && tmp->node > 0) { - if (Debug) Printf("Update node %d --> %d\n", tmp->node, nextnode); - UpdateNodeNumbers(ChildStart, tmp->node, nextnode); - nextnode++; - } + if (tmp->node > 0) tmp->node += (nextnode - 1); + } + nextnode += oldmax; /* copy nodenumbers of ports from parent */ ob2 = ParentParams; - for (tmp = ChildStart; tmp != NULL; tmp = tmp->next) { - if (IsPort(tmp)) { - if (tmp->node > 0) { + for (tmp = ChildStart; tmp && IsPort(tmp); tmp = tmp->next) { + if (tmp->node > 0) { if (ob2->node == -1) { // Before commiting to attaching to a unconnected node, see @@ -413,17 +407,16 @@ int flattenInstancesOf(char *name, int fnum, char *instance) Printf("Update node %d --> %d\n", tmp->node, ob2->node); } UpdateNodeNumbers(ChildStart, tmp->node, ob2->node); - } + } - /* in pathological cases, the lengths of the port lists may - * change. This is an error, but that is no reason to allow - * the code to core dump. We avoid this by placing a - * superfluous check on ob2->type - */ - if (ob2 != NULL) ob2 = ob2->next; + /* in pathological cases, the lengths of the port lists may + * change. This is an error, but that is no reason to allow + * the code to core dump. We avoid this by placing a + * superfluous check on ob2->type + */ + if (ob2 != NULL) ob2 = ob2->next; - if (ob2 == NULL) break; - } + if (ob2 == NULL) break; } /* Using name == NULL to indicate that a .ext file is being */ @@ -1607,15 +1600,15 @@ PrematchLists(char *name1, int file1, char *name2, int file2) } if (match) { if (ecomp->cell1 && (ecomp->num1 > 0)) { - Fprintf(stdout, "Flattening instances of %s in cell %s" + Fprintf(stdout, "Flattening instances of %s in cell %s (%d)" " makes a better match\n", ecomp->cell1->name, - name1); + name1, file1); flattenInstancesOf(name1, file1, ecomp->cell1->name); } if (ecomp->cell2 && (ecomp->num2 > 0)) { - Fprintf(stdout, "Flattening instances of %s in cell %s" + Fprintf(stdout, "Flattening instances of %s in cell %s (%d)" " makes a better match\n", ecomp->cell2->name, - name2); + name2, file2); flattenInstancesOf(name2, file2, ecomp->cell2->name); } modified++; @@ -1696,9 +1689,9 @@ PrematchLists(char *name1, int file1, char *name2, int file2) } if (match) { if (ecomp->cell2) { - Fprintf(stdout, "Flattening instances of %s in cell %s" + Fprintf(stdout, "Flattening instances of %s in cell %s (%d)" " makes a better match\n", ecomp->cell2->name, - name2); + name2, file2); flattenInstancesOf(name2, file2, ecomp->cell2->name); } modified++; @@ -1754,9 +1747,9 @@ PrematchLists(char *name1, int file1, char *name2, int file2) } if (match) { if (ecomp->cell1) { - Fprintf(stdout, "Flattening instances of %s in cell %s" + Fprintf(stdout, "Flattening instances of %s in cell %s (%d)" " makes a better match\n", ecomp->cell1->name, - name1); + name1, file1); flattenInstancesOf(name1, file1, ecomp->cell1->name); } modified++; @@ -1837,9 +1830,9 @@ PrematchLists(char *name1, int file1, char *name2, int file2) } if (found) { Fprintf(stdout, "Removing zero-valued device " - "%s from cell %s makes a better match\n", - tsub1->name, - tc1->name); + "%s from cell %s (%d) makes a better " + "match\n", + tsub1->name, tc1->name, tc1->file); /* A current source is an open, while a */ /* resistor or voltage source is a short. */ @@ -1948,9 +1941,9 @@ PrematchLists(char *name1, int file1, char *name2, int file2) } if (found) { Fprintf(stdout, "Removing zero-valued device " - "%s from cell %s makes a better match\n", - tsub2->name, - tc2->name); + "%s from cell %s (%d) makes a better " + "match\n", + tsub2->name, tc2->name, tc2->file); /* merge node of endpoints */ if (ecomp->cell2->class != CLASS_ISOURCE) { @@ -2041,8 +2034,8 @@ PrematchLists(char *name1, int file1, char *name2, int file2) if (dstr) *dstr = '['; if ((ncomp == ecomp0X) && (ecomp0X->num2 <= ecompX0->num1)) { Fprintf(stdout, "Flattening instances of %s in cell %s" - " makes a better match\n", ecompX0->cell1->name, - name1); + "(%d) makes a better match\n", + ecompX0->cell1->name, name1, file1); flattenInstancesOf(name1, file1, ecompX0->cell1->name); ecompX0->num1 = 0; ecomp0X->num1 += ecompX0->num1; @@ -2067,8 +2060,8 @@ PrematchLists(char *name1, int file1, char *name2, int file2) if (dstr) *dstr = '['; if ((ncomp == ecompX0) && (ecompX0->num1 <= ecomp0X->num2)) { Fprintf(stdout, "Flattening instances of %s in cell %s" - " makes a better match\n", ecomp0X->cell2->name, - name2); + " (%d) makes a better match\n", + ecomp0X->cell2->name, name2, file2); flattenInstancesOf(name2, file2, ecomp0X->cell2->name); ecomp0X->num2 = 0; ecompX0->num2 += ecomp0X->num2; From 68ec2b2a7ccc51edc8885a185cc0834da444ac35 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Fri, 31 Dec 2021 13:30:13 -0500 Subject: [PATCH 2/2] Modified two print statements to change "%s(%d)" to "%s (%d)" as is my typographic preference. --- base/netgen.c | 6 ++++-- base/query.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/base/netgen.c b/base/netgen.c index dc15c7e..04e87d8 100644 --- a/base/netgen.c +++ b/base/netgen.c @@ -3441,7 +3441,8 @@ int CombineParallel(char *model, int file) } HashKill(&devdict); if (dcnt > 0) { - Fprintf(stdout, "Class %s(%d): Merged %d parallel devices.\n", model, file, dcnt); + Fprintf(stdout, "Class %s (%d): Merged %d parallel devices.\n", + model, file, dcnt); } FREE(nodecount); return dcnt; @@ -3739,7 +3740,8 @@ int CombineSeries(char *model, int file) } FREE(instlist); if (scnt > 0) { - Fprintf(stdout, "Class %s(%d): Merged %d series devices.\n", model, file, scnt); + Fprintf(stdout, "Class %s (%d): Merged %d series devices.\n", + model, file, scnt); } return scnt; } diff --git a/base/query.c b/base/query.c index a26a322..d8df617 100644 --- a/base/query.c +++ b/base/query.c @@ -810,7 +810,8 @@ void DescribeInstance(char *name, int file) disconnectednodes++; /* Don't report on ports marked "port_match_error", which is just confusing. */ if (strcmp(ob->name, "port_match_error")) { - Fprintf(stderr, "Cell %s(%d) disconnected node: %s\n", tp->name, tp->file, ob->name); + Fprintf(stderr, "Cell %s (%d) disconnected node: %s\n", + tp->name, tp->file, ob->name); } } }