From f3a95c74fe5d864a254c9fd0cd77b76abc4b0277 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Wed, 12 Dec 2018 17:23:35 -0500 Subject: [PATCH] Corrected hierarchical SPICE extraction to reset the subcircuit name-to-number mapping used for the HSPICE format between subcircuits. Otherwise, subcircuits with the same instance ID remain in the table and may cause nodes to be output with a name that collides with other names in the same subcircuit. This only affects output in HSPICE format. --- ext2spice/ext2hier.c | 13 +++++++++++++ ext2spice/ext2spice.c | 10 +++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ext2spice/ext2hier.c b/ext2spice/ext2hier.c index faacbc55..6f600f2d 100644 --- a/ext2spice/ext2hier.c +++ b/ext2spice/ext2hier.c @@ -44,6 +44,10 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/ #include "utils/runstats.h" #include "ext2spice/ext2spice.h" +/* These global values are defined in ext2spice.c */ +extern HashTable subcktNameTable; +extern DQueue subcktNameQueue; + // Structure passed to esHierVisit typedef struct _defflagsdata { @@ -1871,6 +1875,15 @@ esHierVisit(hc, cdata) esSbckNum = 0; esNodeNum = 10; + /* Reset the subcircuit hash table, if using HSPICE format */ + if (esFormat == HSPICE) + { + HashInit(&subcktNameTable, 32, HT_STRINGKEYS); +#ifndef UNSORTED_SUBCKT + DQInit(&subcktNameQueue, 64); +#endif + } + EFFlatDone(); return 0; } diff --git a/ext2spice/ext2spice.c b/ext2spice/ext2spice.c index e31f7de9..1129300b 100644 --- a/ext2spice/ext2spice.c +++ b/ext2spice/ext2spice.c @@ -1369,6 +1369,10 @@ subcktVisit(use, hierName, is_top) /* Retain instance name unless esDoRenumber is set, or format is Spice2 */ if (use->use_id == NULL || esDoRenumber == TRUE || esFormat == SPICE2) { + /* NOTE: This really needs to update subcktNameTable so that */ + /* it tracks between instance names and node names, when using */ + /* HSPICE format + esDoRenumber. */ + fprintf(esSpiceF, "X%d", esSbckNum++); tchars = 5; } @@ -3268,10 +3272,10 @@ char *efHNSprintfPrefix(hierName, str) * nodeHspiceName -- * * Convert the hierarchical node name used in Berkeley spice - * to a name understodd by hspice and hopefully by the user. + * to a name understood by hspice and hopefully by the user. * * Results: - * A somewhat meaningfull node name + * A somewhat meaningful node name * * Side effects: * Mucks with the hash table above. @@ -3306,7 +3310,7 @@ int nodeHspiceName(s) sf = p + 1; /* - * look up prefix in the hash table ad create it if doesnt exist + * look up prefix in the hash table and create it if doesn't exist */ if ((he = HashLookOnly(&subcktNameTable, s)) == NULL) {