From ad55564905cd188810f79c7abb92adf69bbf7023 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 29 Jun 2020 20:22:39 -0400 Subject: [PATCH] Parser: Move disable fork and wait fork down into elaborate stage --- src/V3AstNodes.h | 16 ++++++++++++++++ src/V3Width.cpp | 8 ++++++++ src/verilog.y | 4 ++-- test_regress/t/t_fork_disable.out | 13 +++++++++++++ test_regress/t/t_fork_disable.pl | 20 ++++++++++++++++++++ test_regress/t/t_fork_disable.v | 22 ++++++++++++++++++++++ 6 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 test_regress/t/t_fork_disable.out create mode 100755 test_regress/t/t_fork_disable.pl create mode 100644 test_regress/t/t_fork_disable.v diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 2a9f00e65..1fcc89a7c 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -4337,6 +4337,22 @@ public: } }; +class AstDisableFork : public AstNodeStmt { + // A "disable fork" statement +public: + AstDisableFork(FileLine* fl) + : ASTGEN_SUPER(fl) {} + ASTNODE_NODE_FUNCS(DisableFork) +}; + +class AstWaitFork : public AstNodeStmt { + // A "wait fork" statement +public: + AstWaitFork(FileLine* fl) + : ASTGEN_SUPER(fl) {} + ASTNODE_NODE_FUNCS(WaitFork) +}; + class AstReturn : public AstNodeStmt { public: explicit AstReturn(FileLine* fl, AstNode* lhsp = NULL) diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 0172750c1..129f4ec36 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -568,6 +568,14 @@ private: // TBD might support only normal join, if so complain about other join flavors } } + virtual void visit(AstDisableFork* nodep) VL_OVERRIDE { + nodep->v3warn(E_UNSUPPORTED, "Unsupported: disable fork statements"); + VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); + } + virtual void visit(AstWaitFork* nodep) VL_OVERRIDE { + nodep->v3warn(E_UNSUPPORTED, "Unsupported: wait fork statements"); + VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); + } virtual void visit(AstToLowerN* nodep) VL_OVERRIDE { if (m_vup->prelim()) { iterateCheckString(nodep, "LHS", nodep->lhsp(), BOTH); diff --git a/src/verilog.y b/src/verilog.y index 856fa2978..793911f67 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -3039,7 +3039,7 @@ statement_item: // IEEE: statement_item // // // IEEE: disable_statement | yDISABLE idAny/*hierarchical_identifier-task_or_block*/ ';' { $$ = new AstDisable($1,*$2); } - | yDISABLE yFORK ';' { $$ = NULL; BBUNSUP($1, "Unsupported: disable fork statements"); } + | yDISABLE yFORK ';' { $$ = new AstDisableFork($1); } // // IEEE: event_trigger | yP_MINUSGT idDotted/*hierarchical_identifier-event*/ ';' { // AssignDly because we don't have stratified queue, and need to @@ -3080,7 +3080,7 @@ statement_item: // IEEE: statement_item // // // IEEE: wait_statement | yWAIT '(' expr ')' stmtBlock { $$ = NULL; BBUNSUP($1, "Unsupported: wait statements"); } - | yWAIT yFORK ';' { $$ = NULL; BBUNSUP($1, "Unsupported: wait fork statements"); } + | yWAIT yFORK ';' { $$ = new AstWaitFork($1); } //UNSUP yWAIT_ORDER '(' hierarchical_identifierList ')' action_block { UNSUP } // // // IEEE: procedural_assertion_statement diff --git a/test_regress/t/t_fork_disable.out b/test_regress/t/t_fork_disable.out new file mode 100644 index 000000000..20a700eb3 --- /dev/null +++ b/test_regress/t/t_fork_disable.out @@ -0,0 +1,13 @@ +%Error-UNSUPPORTED: t/t_fork_disable.v:12:7: Unsupported: fork statements + : ... In instance t + 12 | fork + | ^~~~ +%Error-UNSUPPORTED: t/t_fork_disable.v:16:7: Unsupported: disable fork statements + : ... In instance t + 16 | disable fork; + | ^~~~~~~ +%Error-UNSUPPORTED: t/t_fork_disable.v:17:7: Unsupported: wait fork statements + : ... In instance t + 17 | wait fork; + | ^~~~ +%Error: Exiting due to diff --git a/test_regress/t/t_fork_disable.pl b/test_regress/t/t_fork_disable.pl new file mode 100755 index 000000000..89ffd046b --- /dev/null +++ b/test_regress/t/t_fork_disable.pl @@ -0,0 +1,20 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2019 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(linter => 1); + +lint( + verilator_flags2 => ['--lint-only'], + fails => 1, + expect_filename => $Self->{golden_filename}, + ); + +ok(1); +1; diff --git a/test_regress/t/t_fork_disable.v b/test_regress/t/t_fork_disable.v new file mode 100644 index 000000000..f404a53c2 --- /dev/null +++ b/test_regress/t/t_fork_disable.v @@ -0,0 +1,22 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// 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*/); + + logic never; + + initial begin + fork + #10; + #10; + join_none + disable fork; + wait fork; + $write("*-* All Finished *-*\n"); + $finish; + end + +endmodule