From 6a8f1226d191a8240ecbe759899235f152cf882f Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Thu, 2 Dec 2021 11:38:46 -0500 Subject: [PATCH] Corrected a problem with implicit substrate ports and connections; implicit substrate connections under some conditions were not added to the subcircuit pin list. When this was corrected, the call to the subcircuit was missing the implicit substrate port. When that was corrected, the implicit substrate port printed was the subcircuit's local node name, not the connection from above in the hierarchy. The underlying problem was that the substrate was marked as a port in a node record that was in another (flattened and unused) def and so not seen when enumerating the def's node list. It's possible that the better solution is that the efNodeHashTable() should be enumerated to write subcircuit ports, not def->def_nodes. However, now, by using EFHNLook(), the corresponding entry in efNodeHashTable() is found and used. --- VERSION | 2 +- ext2spice/ext2spice.c | 37 +++++++++++++++++++++++++++++-------- extflat/EFbuild.c | 16 +++++++++------- extflat/EFflat.c | 1 + 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/VERSION b/VERSION index 2010f71d..400c7bc2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.3.234 +8.3.235 diff --git a/ext2spice/ext2spice.c b/ext2spice/ext2spice.c index ce69c8fa..c7d93b5b 100644 --- a/ext2spice/ext2spice.c +++ b/ext2spice/ext2spice.c @@ -1496,7 +1496,8 @@ subcktVisit(use, hierName, is_top) snode != &def->def_firstn; snode = (EFNode *) snode->efnode_next) { - if (snode->efnode_flags & EF_SUBS_PORT) + if ((snode->efnode_flags & EF_SUBS_PORT) && + !(snode->efnode_flags & EF_PORT)) { nodeName = snode->efnode_name; if (nodeName->efnn_port < 0) @@ -1519,15 +1520,15 @@ subcktVisit(use, hierName, is_top) /* Port numbers need not start at zero or be contiguous. */ /* They will be printed in numerical order. */ - nodeList = (EFNodeName **)mallocMagic((portmax + 1) * sizeof(EFNodeName *)); - for (portidx = 0; portidx <= portmax; portidx++) + nodeList = (EFNodeName **)mallocMagic((imp_max + 1) * sizeof(EFNodeName *)); + for (portidx = 0; portidx <= imp_max; portidx++) nodeList[portidx] = (EFNodeName *)NULL; for (snode = (EFNode *) def->def_firstn.efnode_next; snode != &def->def_firstn; snode = (EFNode *) snode->efnode_next) { - if (!(snode->efnode_flags & EF_PORT)) continue; + if (!(snode->efnode_flags & (EF_PORT | EF_SUBS_PORT))) continue; for (nodeName = snode->efnode_name; nodeName != NULL; nodeName = nodeName->efnn_next) { @@ -1537,6 +1538,7 @@ subcktVisit(use, hierName, is_top) portidx = nodeName->efnn_port; if (portidx < 0) continue; + if (portidx > portmax) portmax = portidx; if (nodeList[portidx] == NULL) { nodeList[portidx] = nodeName; @@ -1548,7 +1550,7 @@ subcktVisit(use, hierName, is_top) } } - for (portidx = 0; portidx <= portmax; portidx++) + for (portidx = 0; portidx <= imp_max; portidx++) { nodeName = nodeList[portidx]; @@ -1574,13 +1576,14 @@ subcktVisit(use, hierName, is_top) /* Look for all implicit substrate connections that are */ /* declared as local node names, and put them last. */ - portorder = portmax; + portorder = portmax + 1; while (portorder <= imp_max) { for (snode = (EFNode *) def->def_firstn.efnode_next; snode != &def->def_firstn; snode = (EFNode *) snode->efnode_next) { + if (snode->efnode_flags & EF_PORT) continue; if (!(snode->efnode_flags & EF_SUBS_PORT)) continue; nodeName = snode->efnode_name; if (nodeName->efnn_port == portorder) @@ -1865,11 +1868,26 @@ topVisit(def, doStub) HashStartSearch(&hs); while (he = HashNext(&def->def_nodes, &hs)) { + HashEntry *he2; + EFNode *nnode; + sname = (EFNodeName *) HashGetValue(he); if (sname == NULL) continue; - snode = sname->efnn_node; - if (snode && (snode->efnode_flags & EF_SUBS_PORT)) + /* efAddOneConn() may have changed flags only in the entry */ + /* in efNodeHashTable() which is accessed by EFHNLook(). */ + he2 = EFHNLook(sname->efnn_hier, (char *) NULL, "topVisit"); + if (he2 != NULL) + { + snode = ((EFNodeName *)HashGetValue(he2))->efnn_node; + if (snode != sname->efnn_node) + sname->efnn_node->efnode_flags |= snode->efnode_flags; + } + else + snode = sname->efnn_node; + + if (snode && (snode->efnode_flags & EF_SUBS_PORT) && + !(snode->efnode_flags & EF_PORT)) { if (snode->efnode_name->efnn_port < 0) { @@ -1885,6 +1903,9 @@ topVisit(def, doStub) EFHNSprintf(stmp, snode->efnode_name->efnn_hier); fprintf(esSpiceF, " %s", stmp); snode->efnode_name->efnn_port = portorder++; + if (snode != sname->efnn_node) + sname->efnn_node->efnode_name->efnn_port = + snode->efnode_name->efnn_port; tchars += strlen(stmp) + 1; } } diff --git a/extflat/EFbuild.c b/extflat/EFbuild.c index 88281ea9..63120dbb 100644 --- a/extflat/EFbuild.c +++ b/extflat/EFbuild.c @@ -1122,13 +1122,7 @@ EFGetPortMax(def, imp_max) snode != &def->def_firstn; snode = (EFNode *) snode->efnode_next) { - if (imp_max && (snode->efnode_flags & EF_SUBS_PORT)) - { - nodeName = snode->efnode_name; - portorder = nodeName->efnn_port; - if (portorder > (*imp_max)) (*imp_max) = portorder; - } - else if (snode->efnode_flags & EF_PORT) + if (snode->efnode_flags & EF_PORT) { for (nodeName = snode->efnode_name; nodeName != NULL; nodeName = nodeName->efnn_next) @@ -1137,7 +1131,15 @@ EFGetPortMax(def, imp_max) if (portorder > portmax) portmax = portorder; } } + else if (imp_max && (snode->efnode_flags & EF_SUBS_PORT)) + { + nodeName = snode->efnode_name; + portorder = nodeName->efnn_port; + if (portorder > (*imp_max)) (*imp_max) = portorder; + } } + if (imp_max) + if (portmax > (*imp_max)) (*imp_max) = portmax; return portmax; } diff --git a/extflat/EFflat.c b/extflat/EFflat.c index 485dd14c..8c9f52b4 100644 --- a/extflat/EFflat.c +++ b/extflat/EFflat.c @@ -641,6 +641,7 @@ efAddOneConn(hc, name1, name2, conn, doWarn) if (he2 == NULL) return 0; newnode = ((EFNodeName *) HashGetValue(he2))->efnn_node; + if (node != newnode) efNodeMerge(&node, &newnode); }