From b1374e2bc86162f899fd32ec28e57f7ce3910ff9 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Mon, 4 Sep 2023 10:50:59 -0400 Subject: [PATCH 1/3] Made two changes to the verilog token parsing in netfile.c in response to Mitch Bailey's github issue #82: (1) When skipping comments, skip the contents of "(* ... *)" delimiters as well as "/* ... */" delimiters. (2) When checking for qflow's "\abcd\" names (final space replaced with a backslash for SPICE compatibility of names), make sure that the last "\" is followed by end- of-string. Otherwise names like "\a\bcd " will fail to parse correctly. --- VERSION | 2 +- base/netfile.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index b05db56..194f066 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.5.257 +1.5.258 diff --git a/base/netfile.c b/base/netfile.c index 9fcc41e..41bbad5 100644 --- a/base/netfile.c +++ b/base/netfile.c @@ -611,7 +611,8 @@ void SpiceTokNoNewline(void) } /*----------------------------------------------------------------------*/ -/* Skip to the next token, ignoring any C-style comments. */ +/* Skip to the next token, ignoring any C-style comments and verilog */ +/* "(* ... *)"-style comments. */ /*----------------------------------------------------------------------*/ void SkipTokComments(char *delimiter) @@ -627,6 +628,11 @@ void SkipTokComments(char *delimiter) SkipTok(delimiter); if (nexttok) SkipTok(delimiter); } + else if (match(nexttok, "(*")) { + while (nexttok && !match(nexttok, "*)")) + SkipTok(delimiter); + if (nexttok) SkipTok(delimiter); + } else break; } } @@ -731,7 +737,7 @@ char *strdtok(char *pstring, char *delim1, char *delim2) if (*s == '\\') { s++; while (*s != '\0') { - if ((*s == ' ') || (*s == '\\')) { + if ((*s == ' ') || ((*s == '\\') && (*(s + 1) == '\0'))) { s++; break; } From 619409556cd9b8ee63575cf9f8f6761e7ca10307 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Mon, 4 Sep 2023 14:40:30 -0400 Subject: [PATCH 2/3] Modified the handling of zero-valued resistors and voltage sources so that they are *not* removed to make a better match if they are shorting across two ports. If removed, then the port lists will get screwed up. It is better to let the subcircuits fail matching. Then, after the mismatched subcircuits are flattened, if the zero- valued resistor or voltage source no longer connects two ports, it can be safely removed to make a better match. --- base/flatten.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/base/flatten.c b/base/flatten.c index 1f3b7dc..63628fa 100644 --- a/base/flatten.c +++ b/base/flatten.c @@ -1948,6 +1948,29 @@ PrematchLists(char *name1, int file1, char *name2, int file2) break; } } + + /* Do NOT remove shorting devices that */ + /* connect two ports. Otherwise the */ + /* port lists get screwed up. It is */ + /* better in that case to force the */ + /* cells to be declared mismatched. */ + + if (ecomp->cell1->class != CLASS_ISOURCE) { + int found1 = FALSE; + int found2 = FALSE; + for (ob2 = tc1->cell; ob2; ob2 = ob2->next) { + if (!IsPort(ob2)) break; + else if (ob2->node == node1) + found1 = TRUE; + else if (ob2->node == node2) + found2 = TRUE; + if (found1 && found2) { + found = FALSE; + break; + } + } + } + if (found) break; } if (found) { From ce097d5d7641ab31196fd663b2720e4e70a82a92 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Mon, 4 Sep 2023 14:47:23 -0400 Subject: [PATCH 3/3] One minor change to the previous commit: The check for shorting devices between two ports is ignored for top-level cells, because the scrambled ports won't affect anything in that case, and the error will be reported as a port error, as it should. --- base/flatten.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/base/flatten.c b/base/flatten.c index 63628fa..d24da24 100644 --- a/base/flatten.c +++ b/base/flatten.c @@ -1954,8 +1954,12 @@ PrematchLists(char *name1, int file1, char *name2, int file2) /* port lists get screwed up. It is */ /* better in that case to force the */ /* cells to be declared mismatched. */ + /* This is ignored for a top-level cell */ + /* because it will just show up as a */ + /* port mismatch error as it should. */ - if (ecomp->cell1->class != CLASS_ISOURCE) { + if (!(tc1->flags & CELL_TOP) && + (ecomp->cell1->class != CLASS_ISOURCE)) { int found1 = FALSE; int found2 = FALSE; for (ob2 = tc1->cell; ob2; ob2 = ob2->next) {