Support --bbox-unsup parsing of 'with'

This commit is contained in:
Wilson Snyder 2020-06-06 11:11:23 -04:00
parent 893dee3434
commit a21947d887
8 changed files with 144 additions and 10 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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"); }
}

View File

@ -649,11 +649,11 @@ class AstSenTree;
//UNSUP %token<fl> yWILDCARD "wildcard"
%token<fl> yWIRE "wire"
//UNSUP %token<fl> yWITHIN "within"
//UNSUP %token<fl> yWITH__BRA "with-then-["
//UNSUP %token<fl> yWITH__CUR "with-then-{"
//UNSUP %token<fl> yWITH__ETC "with"
//UNSUP %token<fl> yWITH__LEX "with-in-lex"
//UNSUP %token<fl> yWITH__PAREN "with-then-("
%token<fl> yWITH__BRA "with-then-["
%token<fl> yWITH__CUR "with-then-{"
%token<fl> yWITH__ETC "with"
%token<fl> yWITH__LEX "with-in-lex"
%token<fl> yWITH__PAREN "with-then-("
%token<fl> yWOR "wor"
%token<fl> yWREAL "wreal"
%token<fl> yXNOR "xnor"
@ -3376,7 +3376,10 @@ funcRef<nodep>: // IEEE: part of tf_call
task_subroutine_callNoMethod<nodep>: // 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($<fl>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<nodep>: // function_subroutine_callNoMethod (as tas
function_subroutine_callNoMethod<nodep>: // 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($<fl>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<nodep>:
| yUNIQUE { $$ = new AstFuncRef($1, "unique", NULL); }
;
array_methodWith<nodep>:
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<nodep>: // ==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<nodep>: // 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

21
test_regress/t/t_with_bbox.pl Executable file
View File

@ -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;

View File

@ -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

19
test_regress/t/t_with_unsup.pl Executable file
View File

@ -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;

View File

@ -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