From 6d6da9cf5c0ae6ec6e72a5687640cd52a160a38c Mon Sep 17 00:00:00 2001 From: "D. Mitch Bailey" Date: Wed, 13 Oct 2021 01:15:15 -0700 Subject: [PATCH 1/3] Remove disconnected ports after flattening. --- base/flatten.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/base/flatten.c b/base/flatten.c index f21c807..9c7cef0 100644 --- a/base/flatten.c +++ b/base/flatten.c @@ -599,6 +599,39 @@ int flattenInstancesOf(char *name, int fnum, char *instance) } CacheNodeNames(ThisCell); ThisCell->dumped = 1; /* indicate cell has been flattened */ + { // Remove disconnected ports. New block to ensure isolated scope. + // Fprintf(stdout, "DEBUG: check pins for %s of %d\n", name, fnum); + struct objlist *myObject_p, *myPort_p; + struct objlist *myFirstPin_p, *myPin_p; + int myDeleteCount = 0; + + myFirstPin_p = NULL; + // Save first pin definition so we don't have to search for each port + for ( myObject_p = ThisCell->cell; myObject_p != NULL; myObject_p = myObject_p->next ) { + if ( myObject_p->type >= FIRSTPIN ) { + myFirstPin_p = myObject_p; + break; + } + } + if ( myFirstPin_p != NULL ) { // not a black box. Black boxes contain no pins. + // For each port, check for pin connection. If none, mark for deletion. + // Assumes that all ports occur at the beginning of the list + for ( myPort_p = ThisCell->cell; myPort_p != NULL && IsPort(myPort_p); myPort_p = myPort_p->next ) { + for ( myPin_p = myFirstPin_p; myPin_p != NULL; myPin_p = myPin_p->next ) { + if ( myPort_p->node == myPin_p->node ) { // only need to find one connection + break; + } + } + if ( myPin_p == NULL ) { // mark disconnected ports + myDeleteCount++; + myPort_p->node = -2; + } + } + if ( myDeleteCount > 0 ) { // delete disconnected ports + CleanupPins(name, fnum); + } + } + } return numflat; } From 42b1acc564e0380454d8d0aa365270be4739f13a Mon Sep 17 00:00:00 2001 From: "D. Mitch Bailey" Date: Wed, 13 Oct 2021 21:00:49 -0700 Subject: [PATCH 2/3] Flatten unmatched cells that don't contain instances from the other file. --- base/flatten.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/base/flatten.c b/base/flatten.c index 9c7cef0..8dd7d34 100644 --- a/base/flatten.c +++ b/base/flatten.c @@ -1615,7 +1615,8 @@ PrematchLists(char *name1, int file1, char *name2, int file2) } } else { - match = 0; + // cell exists in one circuit but not the other, so flatten it. + // match = 0; break; } } From 6ceeddf09610e641b6787e0224a162a872fe1b7a Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Thu, 14 Oct 2021 11:22:20 -0400 Subject: [PATCH 3/3] Minor syntactical editing of pull request #33, and updated version to go along with the merge of the pull request (from Mitch Bailey). --- VERSION | 2 +- base/flatten.c | 72 ++++++++++++++++++++++++++------------------------ 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/VERSION b/VERSION index 137ac1e..4b0033d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.5.203 +1.5.204 diff --git a/base/flatten.c b/base/flatten.c index 8dd7d34..5b3f610 100644 --- a/base/flatten.c +++ b/base/flatten.c @@ -259,13 +259,16 @@ int flattenInstancesOf(char *name, int fnum, char *instance) struct objlist *ChildObjList, *ChildListEnd; struct objlist *ChildStart, *ChildEnd, *ParentEnd, *ParentNext; struct nlist *ThisCell; - struct nlist *ChildCell; + struct nlist *ChildCell; struct objlist *tmp, *ob2, *ob3; - int notdone, rnodenum; - char tmpstr[1024]; - int nextnode, oldmax, numflat = 0; + int notdone, rnodenum; + char tmpstr[1024]; + int nextnode, oldmax, numflat = 0; + struct objlist *myObject_p, *myPort_p; + struct objlist *myFirstPin_p, *myPin_p; + int myDeleteCount = 0; #if !OLDPREFIX - int prefixlength; + int prefixlength; #endif if (name == NULL) { @@ -599,37 +602,36 @@ int flattenInstancesOf(char *name, int fnum, char *instance) } CacheNodeNames(ThisCell); ThisCell->dumped = 1; /* indicate cell has been flattened */ - { // Remove disconnected ports. New block to ensure isolated scope. - // Fprintf(stdout, "DEBUG: check pins for %s of %d\n", name, fnum); - struct objlist *myObject_p, *myPort_p; - struct objlist *myFirstPin_p, *myPin_p; - int myDeleteCount = 0; - myFirstPin_p = NULL; - // Save first pin definition so we don't have to search for each port - for ( myObject_p = ThisCell->cell; myObject_p != NULL; myObject_p = myObject_p->next ) { - if ( myObject_p->type >= FIRSTPIN ) { - myFirstPin_p = myObject_p; - break; + // Remove disconnected ports. + // Fprintf(stdout, "DEBUG: check pins for %s of %d\n", name, fnum); + + myFirstPin_p = NULL; + + // Save first pin definition so we don't have to search for each port + for (myObject_p = ThisCell->cell; myObject_p != NULL; myObject_p = myObject_p->next) { + if (myObject_p->type >= FIRSTPIN) { + myFirstPin_p = myObject_p; + break; + } + } + if (myFirstPin_p != NULL) { // Not a black box. Black boxes contain no pins. + // For each port, check for pin connection. If none, mark for deletion. + // Assumes that all ports occur at the beginning of the list + for (myPort_p = ThisCell->cell; myPort_p != NULL && IsPort(myPort_p); + myPort_p = myPort_p->next ) { + for (myPin_p = myFirstPin_p; myPin_p != NULL; myPin_p = myPin_p->next) { + if (myPort_p->node == myPin_p->node) { // only need to find one connection + break; + } + } + if (myPin_p == NULL) { // mark disconnected ports + myDeleteCount++; + myPort_p->node = -2; } } - if ( myFirstPin_p != NULL ) { // not a black box. Black boxes contain no pins. - // For each port, check for pin connection. If none, mark for deletion. - // Assumes that all ports occur at the beginning of the list - for ( myPort_p = ThisCell->cell; myPort_p != NULL && IsPort(myPort_p); myPort_p = myPort_p->next ) { - for ( myPin_p = myFirstPin_p; myPin_p != NULL; myPin_p = myPin_p->next ) { - if ( myPort_p->node == myPin_p->node ) { // only need to find one connection - break; - } - } - if ( myPin_p == NULL ) { // mark disconnected ports - myDeleteCount++; - myPort_p->node = -2; - } - } - if ( myDeleteCount > 0 ) { // delete disconnected ports - CleanupPins(name, fnum); - } + if (myDeleteCount > 0) { // delete disconnected ports + CleanupPins(name, fnum); } } return numflat; @@ -1615,8 +1617,8 @@ PrematchLists(char *name1, int file1, char *name2, int file2) } } else { - // cell exists in one circuit but not the other, so flatten it. - // match = 0; + // Apply recursive flattening when a cell exists in + // one circuit but not the other. break; } }