From bd417aa54b4e75499c57a009fa75bbb6b463aece Mon Sep 17 00:00:00 2001 From: "R. Timothy Edwards" Date: Wed, 24 Dec 2025 11:31:43 -0500 Subject: [PATCH] Updating the version number to go along with the merge of pull request #478 from Mitch Bailey. Also edited the code from the PR for programming style. --- VERSION | 2 +- extflat/EFbuild.c | 50 +++++++++++++++++++++++++++++++---------------- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/VERSION b/VERSION index ca3a70bb..6e102d15 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.3.584 +8.3.585 diff --git a/extflat/EFbuild.c b/extflat/EFbuild.c index 79cd966d..1b7729b3 100644 --- a/extflat/EFbuild.c +++ b/extflat/EFbuild.c @@ -652,15 +652,20 @@ efBuildEquiv(def, nodeName1, nodeName2, resist, isspice) if (efWarn) efReadError("Merged nodes %s and %s\n", nodeName1, nodeName2); lostnode = efNodeMerge(&nn1->efnn_node, &nn2->efnn_node); - // keep the lowest valid port number + + /* Keep the lowest valid port number. This avoids preferring + * names generated by "extract unique" over the original port + * name. + */ if (nn1->efnn_port > 0) { - if (nn2->efnn_port > 0 && nn2->efnn_port < nn1->efnn_port) - nn1->efnn_port = nn2->efnn_port; + if ((nn2->efnn_port > 0) && (nn2->efnn_port < nn1->efnn_port)) + nn1->efnn_port = nn2->efnn_port; else - nn2->efnn_port = nn1->efnn_port; + nn2->efnn_port = nn1->efnn_port; } - else if (nn2->efnn_port > 0) nn1->efnn_port = nn2->efnn_port; + else if (nn2->efnn_port > 0) + nn1->efnn_port = nn2->efnn_port; /* Check if there are any device terminals pointing to the * node that was just removed. @@ -1950,30 +1955,41 @@ efNodeMerge(node1ptr, node2ptr) EFNodeName *nn, *nnlast, *nn1, *nn2; EFAttr *ap; int n; + int keep; /* Which node to keep (1 or 2; 0 = unknown) */ EFNode *keeping, *removing; /* Sanity check: ignore if same node */ if (*node1ptr == *node2ptr) return NULL; - /* Keep the node with the greater number of entries, and merge */ - /* the node with fewer entries into it. */ - /* If one node is a port, keep that node */ - /* If both nodes are ports, keep the lowest numbered port */ - /* Since duplicate ports always have higher numbers, this */ - /* should keep the original. */ + /* + * Keep the node with the greater number of entries, and merge + * the node with fewer entries into it. + * If one node is a port and the other isn't, keep the port node. + * If both nodes are ports, keep the lowest numbered port. Since + * ports generated by "extract unique" always have higher numbers, + * this will preserve the original name. This is necessary due to + * the "blindness" of "extract unique" to ports being merged + * through connecting geometry in descendent cells. The unique + * suffixes are overused, and ext2spice prunes the unnecessary + * entries but needs to preserve the original node name. + */ - int keep = 0; // unknown + keep = 0; nn1 = (*node1ptr)->efnode_name; nn2 = (*node2ptr)->efnode_name; - if ( nn1 && nn1->efnn_port > 0 ) + if (nn1 && (nn1->efnn_port > 0)) { - if ( nn2 && nn2->efnn_port > 0 && nn2->efnn_port < nn1->efnn_port ) keep = 2; - else keep = 1; + if (nn2 && (nn2->efnn_port > 0) && (nn2->efnn_port < nn1->efnn_port)) + keep = 2; + else + keep = 1; } - else if ( nn2 && nn2->efnn_port > 0 ) keep = 2; + else if (nn2 && nn2->efnn_port > 0) + keep = 2; - if (keep == 1 || ((keep == 0 && (*node1ptr)->efnode_num >= (*node2ptr)->efnode_num))) + if ((keep == 1) || ((keep == 0) && + ((*node1ptr)->efnode_num >= (*node2ptr)->efnode_num))) { keeping = *node1ptr; removing = *node2ptr;