From 13c45c6d0c7535ccb9cd12c49bac67b7bf777d48 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Mon, 12 Nov 2018 16:32:33 -0500 Subject: [PATCH] Encountered a problem with parsing non-inlined ports of a module and tracked it down to a "to be completed" comment in the source code. So it is now completed. --- base/verilog.c | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/base/verilog.c b/base/verilog.c index ab406ad..302a716 100644 --- a/base/verilog.c +++ b/base/verilog.c @@ -825,10 +825,47 @@ skip_endmodule: } else if (match(nexttok, "input") || match(nexttok, "output") || match(nexttok, "inout")) { + struct bus wb; - // To be completed: Duplicate parsing of ports, except as statements - // and not in the module pin list. - SkipNewLine(VLOG_DELIMITERS); + // Parsing of ports as statements not in the module pin list. + wb.start = wb.end = -1; + while (1) { + SkipTokComments(VLOG_DELIMITERS); + if (EndParseFile()) break; + + if (match(nexttok, ";")) { + // End of statement + break; + } + else if (match(nexttok, "[")) { + if (GetBusTok(&wb) != 0) { + // Didn't parse as a bus, so wing it + wb.start = wb.end = -1; + Port(nexttok); + } + } + else if (!match(nexttok, ",")) { + if (wb.start != -1) { + if (wb.start > wb.end) { + for (i = wb.start; i >= wb.end; i--) { + sprintf(portname, "%s[%d]", nexttok, i); + Port(portname); + } + } + else { + for (i = wb.start; i <= wb.end; i++) { + sprintf(portname, "%s[%d]", nexttok, i); + Port(portname); + } + } + wb.start = wb.end = -1; + } + else { + Port(nexttok); + } + } + hasports = 1; + } } else if (match(nexttok, "endmodule")) {