Skip to content

Commit

Permalink
Corrected an error found by Sylvain Munaut and discussed on
Browse files Browse the repository at this point in the history
open-source-silicon slack on Nov. 3 in which the simple verilog
expression "assign name1 = name2[a:b]";  this revealed an error
where the parsing of "name2" was being incorrectly run with
GetBusTok() which must be called when the token starts with "[".
This problem existed both for the left-hand-side parsing and
the right-hand-side parsing, and has been fixed for both (where
either side may be a subset of a bus and the other a complete
bus).
  • Loading branch information
RTimothyEdwards committed Nov 15, 2024
1 parent 3b9dca0 commit 49c0de0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions base/verilog.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,10 +717,12 @@ int GetBus(char *astr, struct bus *wb)
return 0;
}

//--------------------------------------------------------------------
// Output a Verilog Module. Note that since Verilog does not describe
// low-level devices like transistors, capacitors, etc., then this
// format is limited to black-box subcircuits. Cells containing any
// such low-level devices are ignored.
//--------------------------------------------------------------------

void VerilogModule(struct nlist *tp)
{
Expand Down Expand Up @@ -1833,8 +1835,9 @@ void ReadVerilogFile(char *fname, int filenum, struct cellstack **CellStackPtr,
}
else { /* "assign" */
SkipTokComments(VLOG_PIN_CHECK_DELIMITERS);
if (GetBusTok(&wb) == 0) {
char *aptr = strvchr(nexttok, '[');
char *aptr = strvchr(nexttok, '[');
if (((aptr == NULL) && (GetBusTok(&wb) == 0)) ||
((aptr != NULL) && (GetBus(aptr, &wb) == 0))) {
if (aptr != NULL) {
*aptr = '\0';
/* Find object of first net in bus */
Expand Down Expand Up @@ -1909,8 +1912,9 @@ void ReadVerilogFile(char *fname, int filenum, struct cellstack **CellStackPtr,
break;
}
else {
if (GetBusTok(&wb2) == 0) {
char *aptr = strvchr(nexttok, '[');
char *aptr = strvchr(nexttok, '[');
if (((aptr == NULL) && (GetBusTok(&wb2) == 0)) ||
((aptr != NULL) && (GetBus(aptr, &wb2) == 0))) {
j = wb2.start;
if (aptr != NULL) {
*aptr = '\0';
Expand Down

0 comments on commit 49c0de0

Please sign in to comment.