Skip to content

Commit

Permalink
Fix error parsing PSL statement split over multiple lines. Fixes xxx
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Jan 18, 2025
1 parent ecaeb36 commit cf1c9d9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
- Fixed a regression that caused some array aggregates to be incorrectly
reported as ambiguous (#1138).
- The Windows installer now bundles the Tcllib library (#1136).
- Fixed a bug where PSL directives in comments were parsed incorrectly
when split over multiple lines (#1135).

## Version 1.15.0 - 2025-01-11
- `--load` is now a global option and should be placed before the `-r`
Expand Down
11 changes: 4 additions & 7 deletions src/lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ COVERAGE_OFF {PRAGMA}(?i:coverage)[ \t]+(?i:off).*
COVERAGE_ON {PRAGMA}(?i:coverage)[ \t]+(?i:on).*
TRANSLATE_OFF {PRAGMA}(?i:pragma)[ \t]+(?i:translate_off).*
TRANSLATE_ON {PRAGMA}(?i:pragma)[ \t]+(?i:translate_on).*
PSL_COMMENT {PRAGMA}(?i:psl)[ \t]+
PSL_COMMENT {PRAGMA}(?i:psl)
PSL_CONT ^{SPACE}*({PSL_COMMENT}|"--")
UTF8_MB [\x80-\xff][\x80-\xbf]{1,3}
VLOG_NUMBER {INTEGER}?\'[bhd]{HEX}
Expand Down Expand Up @@ -352,6 +352,7 @@ BEFORE ?i:before

<PSL,INITIAL>"--" { comment_caller = YY_START; BEGIN(COMMENT); }
<VLOG,UDP>"//" { comment_caller = YY_START; BEGIN(COMMENT); }
{PSL_COMMENT}[^ \t\r\n] { comment_caller = YY_START; BEGIN(COMMENT); }
{PSL_COMMENT} { if (begin_psl_comment()) {
in_psl_comment = true;
BEGIN(PSL);
Expand All @@ -375,7 +376,7 @@ BEFORE ?i:before
<C_COMMENT>\n { /* Must match a single character */ }
<C_COMMENT>. { }

<PSL>; { in_psl_comment = false; TOKEN(tSEMI); }
<PSL>; { TOKEN(tSEMI); }
<PSL>{PSL_CONT} { /* Multi-line PSL comment */
if (!in_psl_comment) {
comment_caller = YY_START;
Expand Down Expand Up @@ -1183,6 +1184,7 @@ void scan_as_psl(void)
void scan_as_vhdl(void)
{
BEGIN(INITIAL);
in_psl_comment = false;
}

void scan_as_verilog(void)
Expand All @@ -1204,8 +1206,3 @@ void scan_as_sdf_expr(void)
{
BEGIN(SDF_EXPR);
}

bool is_scanned_as_psl(void)
{
return (YY_START == PSL);
}
2 changes: 0 additions & 2 deletions src/scan.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ void reset_vhdl_parser(void);
void reset_verilog_parser(void);
void reset_sdf_parser(void);

bool is_scanned_as_psl(void);

#define tEOF 0

#define tLPAREN '('
Expand Down
4 changes: 4 additions & 0 deletions test/psl/parse1.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ begin
-- psl assert always (x -> next x) abort y; -- OK
-- psl assert always (x -> (y or next x)); -- OK
-- psl assert (x or y) or (next x); -- OK

-- psl
-- assert always xxx; -- Error (issue #1135)
-- psl1111 assert assert assert; -- Not PSL
end architecture;
8 changes: 8 additions & 0 deletions test/psl/parse3.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,12 @@ begin
-- psl assert {a} |=> {{b[->3]} && {(a and not c)[+]}; not c and b};

-- psl assert {global_vect(1)}; -- OK (issue #1115)

-- psl -- OK (issue #1135)
-- assert always (
-- {
-- a = '1';
-- true
-- } |-> c = '0'
-- ) abort c = '1';
end architecture;
3 changes: 2 additions & 1 deletion test/test_psl.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (C) 2022-2024 Nick Gasson
// Copyright (C) 2022-2025 Nick Gasson
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -35,6 +35,7 @@ START_TEST(test_parse1)
{ 19, "no visible declaration for FFF" },
{ 28, "FOO already declared in this region" },
{ 34, "no visible declaration for XXXX" },
{ 41, "no visible declaration for XXX" },
{ -1, NULL }
};
expect_errors(expect);
Expand Down

0 comments on commit cf1c9d9

Please sign in to comment.