diff --git a/Changes b/Changes index 5871eb4d7..dbc280b00 100644 --- a/Changes +++ b/Changes @@ -5,6 +5,8 @@ The contributors that suggested a given feature are shown in []. Thanks! * Verilator 4.037 devel +**** With --bbox-unsup continue parsing on many (not all) UVM constructs. + * Verilator 4.036 2020-06-06 diff --git a/src/V3ParseImp.cpp b/src/V3ParseImp.cpp index 08efef569..aba82f222 100644 --- a/src/V3ParseImp.cpp +++ b/src/V3ParseImp.cpp @@ -374,7 +374,8 @@ void V3ParseImp::lexToken() { || token == yGLOBAL__LEX // || token == yLOCAL__LEX // || token == yNEW__LEX // - || token == yVIRTUAL__LEX + || token == yVIRTUAL__LEX // + || token == yWITH__LEX // // Never put yID_* here; below symbol table resolution would break ) { if (debugFlex() >= 6) { @@ -431,6 +432,16 @@ void V3ParseImp::lexToken() { } else { token = yVIRTUAL__ETC; } + } else if (token == yWITH__LEX) { + if (nexttok == '(') { + token = yWITH__PAREN; + } else if (nexttok == '[') { + token = yWITH__BRA; + } else if (nexttok == '{') { + token = yWITH__CUR; + } else { + token = yWITH__ETC; + } } // If add to above "else if", also add to "if (token" further above } diff --git a/src/verilog.l b/src/verilog.l index a3d5bd0d0..639a908a4 100644 --- a/src/verilog.l +++ b/src/verilog.l @@ -557,7 +557,7 @@ vnum {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5} "void" { FL; return yVOID; } "wait_order" { ERROR_RSVD_WORD("SystemVerilog 2005"); } "wildcard" { ERROR_RSVD_WORD("SystemVerilog 2005"); } - "with" { ERROR_RSVD_WORD("SystemVerilog 2005"); } + "with" { FL; return yWITH__LEX; } "within" { ERROR_RSVD_WORD("SystemVerilog 2005"); } } diff --git a/src/verilog.y b/src/verilog.y index efec4e9ee..e8a2bc2d6 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -649,11 +649,11 @@ class AstSenTree; //UNSUP %token yWILDCARD "wildcard" %token yWIRE "wire" //UNSUP %token yWITHIN "within" -//UNSUP %token yWITH__BRA "with-then-[" -//UNSUP %token yWITH__CUR "with-then-{" -//UNSUP %token yWITH__ETC "with" -//UNSUP %token yWITH__LEX "with-in-lex" -//UNSUP %token yWITH__PAREN "with-then-(" +%token yWITH__BRA "with-then-[" +%token yWITH__CUR "with-then-{" +%token yWITH__ETC "with" +%token yWITH__LEX "with-in-lex" +%token yWITH__PAREN "with-then-(" %token yWOR "wor" %token yWREAL "wreal" %token yXNOR "xnor" @@ -3376,7 +3376,10 @@ funcRef: // IEEE: part of tf_call task_subroutine_callNoMethod: // function_subroutine_callNoMethod (as task) // // IEEE: tf_call taskRef { $$ = $1; } - //UNSUP funcRef yWITH__PAREN '(' expr ')' { /*UNSUP*/ } + // // funcref below not task ref to avoid conflict, must later handle either + | funcRef yWITH__PAREN '(' expr ')' { $$ = $1; BBUNSUP($2, "Unsupported: 'with' on task call"); } + // // can call as method and yWITH without parenthesis + | id yWITH__PAREN '(' expr ')' { $$ = new AstFuncRef($1, *$1, NULL); BBUNSUP($2, "Unsupported: 'with' on function call"); } | system_t_call { $$ = $1; } // // IEEE: method_call requires a "." so is in expr // // IEEE: ['std::'] not needed, as normal std package resolution will find it @@ -3389,7 +3392,9 @@ task_subroutine_callNoMethod: // function_subroutine_callNoMethod (as tas function_subroutine_callNoMethod: // IEEE: function_subroutine_call (as function) // // IEEE: tf_call funcRef { $$ = $1; } - //UNSUP funcRef yWITH__PAREN '(' expr ')' { /*UNSUP*/ } + | funcRef yWITH__PAREN '(' expr ')' { $$ = $1; BBUNSUP($2, "Unsupported: 'with' on function call"); } + // // can call as method and yWITH without parenthesis + | id yWITH__PAREN '(' expr ')' { $$ = new AstFuncRef($1, *$1, NULL); BBUNSUP($2, "Unsupported: 'with' on function call"); } | system_f_call { $$ = $1; } // // IEEE: method_call requires a "." so is in expr // // IEEE: ['std::'] not needed, as normal std package resolution will find it @@ -3861,6 +3866,14 @@ array_methodNoRoot: | yUNIQUE { $$ = new AstFuncRef($1, "unique", NULL); } ; +array_methodWith: + array_methodNoRoot { $$ = $1; } + | array_methodNoRoot parenE yWITH__PAREN '(' expr ')' + { $$ = $1; BBUNSUP($5, "Unsupported: 'with' on method call"); } + | array_methodNoRoot '(' expr ')' yWITH__PAREN '(' expr ')' + { $$ = $1; BBUNSUP($7, "Unsupported: 'with' on method call"); } + ; + dpi_import_export: // ==IEEE: dpi_import_export yIMPORT yaSTRING dpi_tf_import_propertyE dpi_importLabelE function_prototype ';' { $$ = $5; if (*$4 != "") $5->cname(*$4); @@ -4023,7 +4036,7 @@ expr: // IEEE: part of expression/constant_expression/primary // // method_call | ~l~expr '.' function_subroutine_callNoMethod { $$ = new AstDot($2, false, $1, $3); } // // method_call:array_method requires a '.' - | ~l~expr '.' array_methodNoRoot { $$ = new AstDot($2, false, $1, $3); } + | ~l~expr '.' array_methodWith { $$ = new AstDot($2, false, $1, $3); } // // // IEEE: let_expression // // see funcRef diff --git a/test_regress/t/t_with_bbox.pl b/test_regress/t/t_with_bbox.pl new file mode 100755 index 000000000..cc3646920 --- /dev/null +++ b/test_regress/t/t_with_bbox.pl @@ -0,0 +1,21 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003 by Wilson Snyder. This program is free software; you can +# redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios(vlt => 1); + +top_filename("t/t_with_unsup.v"); + +lint( + verilator_flags => ["--bbox-unsup"], + fails => 1, + ); + +ok(1); +1; diff --git a/test_regress/t/t_with_unsup.out b/test_regress/t/t_with_unsup.out new file mode 100644 index 000000000..59caaa74c --- /dev/null +++ b/test_regress/t/t_with_unsup.out @@ -0,0 +1,31 @@ +%Error: t/t_with_unsup.v:19:31: Unsupported: 'with' on function call + 19 | found = aliases.find(i) with (i == to_find); + | ^~~~ +%Error: t/t_with_unsup.v:21:23: Unsupported: 'with' on task call + 21 | aliases.find(i) with (i == to_find); + | ^~~~ +%Error: t/t_with_unsup.v:24:28: Unsupported: 'with' on function call + 24 | found = aliases.find with (item == i); + | ^~~~ +%Error: t/t_with_unsup.v:25:20: Unsupported: 'with' on function call + 25 | aliases.find with (item == i); + | ^~~~ +%Error: t/t_with_unsup.v:29:36: Unsupported: 'with' on method call + 29 | found = aliases.unique with (id); + | ^~ +%Error: t/t_with_unsup.v:30:38: Unsupported: 'with' on method call + 30 | found = aliases.unique() with (id); + | ^~ +%Error: t/t_with_unsup.v:31:39: Unsupported: 'with' on method call + 31 | found = aliases.unique(i) with (id); + | ^~ +%Error: t/t_with_unsup.v:32:32: Unsupported: 'with' on method call + 32 | found = aliases.or with (id); + | ^~ +%Error: t/t_with_unsup.v:33:33: Unsupported: 'with' on method call + 33 | found = aliases.and with (id); + | ^~ +%Error: t/t_with_unsup.v:34:33: Unsupported: 'with' on method call + 34 | found = aliases.xor with (id); + | ^~ +%Error: Exiting due to diff --git a/test_regress/t/t_with_unsup.pl b/test_regress/t/t_with_unsup.pl new file mode 100755 index 000000000..ce380f717 --- /dev/null +++ b/test_regress/t/t_with_unsup.pl @@ -0,0 +1,19 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003 by Wilson Snyder. This program is free software; you can +# redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios(simulator => 1); + +lint( + fails => $Self->{vlt_all}, + expect_filename => $Self->{golden_filename}, + ); + +ok(1); +1; diff --git a/test_regress/t/t_with_unsup.v b/test_regress/t/t_with_unsup.v new file mode 100644 index 000000000..1c9c1a2d7 --- /dev/null +++ b/test_regress/t/t_with_unsup.v @@ -0,0 +1,37 @@ +// DESCRIPTION: Verilator: Verilog Test module for SystemVerilog 'alias' +// +// Simple bi-directional alias test. +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2020 by Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +module t (/*AUTOARG*/); + + initial begin + int tofind; + int aliases[$]; + int found[$]; + int id; + int i; + aliases = '{ 1, 4, 6, 8}; + tofind = 6; + found = aliases.find(i) with (i == to_find); + // And as function + aliases.find(i) with (i == to_find); + + // No parenthesis + found = aliases.find with (item == i); + aliases.find with (item == i); + + // Unique (array method) + id = 4; + found = aliases.unique with (id); + found = aliases.unique() with (id); + found = aliases.unique(i) with (id); + found = aliases.or with (id); + found = aliases.and with (id); + found = aliases.xor with (id); + end + +endmodule