From f8ed4e42e272a4fb6b69321114516b374d3d4183 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Wed, 8 Jun 2022 11:53:47 -0400 Subject: [PATCH] Corrected the parsing of verilog netlists to use the right delimiter set when parsing pin names (the correct delimiter set was used in one place but not in another). Extended the pin matching to include the minor hack of ignoring the backslash before backslash-escaped verilog names when there is otherwise no exact match, since many tools convert verilog to SPICE by removing the backslash and trailing space. This avoids pin mismatches in a known set of use cases. --- VERSION | 2 +- base/netcmp.c | 23 ++++++++++++++++------- base/verilog.c | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/VERSION b/VERSION index f4987e1..c51f771 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.5.221 +1.5.222 diff --git a/base/netcmp.c b/base/netcmp.c index 3d6324e..d2500e8 100644 --- a/base/netcmp.c +++ b/base/netcmp.c @@ -7223,7 +7223,7 @@ struct nlist *addproxies(struct hashlist *p, void *clientdata) int MatchPins(struct nlist *tc1, struct nlist *tc2, int dolist) { char *cover, *ctemp; - char *bangptr1, *bangptr2; + char *bangptr1, *bangptr2, *backslashptr1, *backslashptr2; struct objlist *ob1, *ob2, *obn, *obp, *ob1s, *ob2s, *obt; struct NodeClass *NC; struct Node *N1, *N2; @@ -7449,14 +7449,21 @@ int MatchPins(struct nlist *tc1, struct nlist *tc2, int dolist) /* This should not happen if unconnected pins are eliminated */ /* so apply only to black-box (CELL_PLACEHOLDER) entries. */ /* (Semi-hack: Allow "!" global flag) */ + /* (Another semi-hack: Ignore the leading backslash in */ + /* backslash-escaped verilog names. Removing the backslash */ + /* and ending space character is a common way to convert to */ + /* legal SPICE. */ ob1 = tc1->cell; - bangptr1 = strrchr(ob1->name, '!'); - if (bangptr1 && (*(bangptr1 + 1) == '\0')) - *bangptr1 = '\0'; - else bangptr1 = NULL; for (i = 0; i < numorig; i++) { + bangptr1 = strrchr(ob1->name, '!'); + if (bangptr1 && (*(bangptr1 + 1) == '\0')) + *bangptr1 = '\0'; + else bangptr1 = NULL; + + backslashptr1 = (*(ob1->name) == '\\') ? ob1->name + 1 : ob1->name; + if (*(cover + i) == (char)0) { j = 0; for (ob2 = tc2->cell; ob2 != NULL; ob2 = ob2->next) { @@ -7469,8 +7476,10 @@ int MatchPins(struct nlist *tc1, struct nlist *tc2, int dolist) *bangptr2 = '\0'; else bangptr2 = NULL; - name1 = ob1->name; - name2 = ob2->name; + backslashptr2 = (*(ob2->name) == '\\') ? ob2->name + 1 : ob2->name; + + name1 = backslashptr1; + name2 = backslashptr2; /* Recognize proxy pins as matching unconnected pins */ if (!strncmp(name1, "proxy", 5) && (ob2->node == -1)) name1 +=5; diff --git a/base/verilog.c b/base/verilog.c index 004c0cf..82dcb08 100644 --- a/base/verilog.c +++ b/base/verilog.c @@ -1669,7 +1669,7 @@ nextinst: // Read the pin list while (nexttok != NULL) { - SkipTokComments(VLOG_DELIMITERS); + SkipTokComments(VLOG_PIN_CHECK_DELIMITERS); if (match(nexttok, ")")) break; else if (match(nexttok, ",")) continue;