From 19f72795424664f936c2a2becd3f10a89f143b47 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 15 Sep 2023 22:05:55 -0400 Subject: [PATCH] Fix false INFINITELOOP on forever..mailbox.get() (#4323). --- Changes | 1 + src/V3Const.cpp | 11 ++++++++- test_regress/t/t_lint_infinite.pl | 23 ++++++++++++++++++ test_regress/t/t_lint_infinite.v | 36 ++++++++++++++++++++++++++++ test_regress/t/t_lint_infinite_bad.v | 1 + test_regress/t/t_uvm_todo.pl | 1 - 6 files changed, 71 insertions(+), 2 deletions(-) create mode 100755 test_regress/t/t_lint_infinite.pl create mode 100644 test_regress/t/t_lint_infinite.v diff --git a/Changes b/Changes index dbdee17e6..2c8535966 100644 --- a/Changes +++ b/Changes @@ -19,6 +19,7 @@ Verilator 5.015 devel * Support no-parentheses calls to static methods (#4432). [Krzysztof BoroĊ„ski] * Support 'let'. * Fix Windows filename format, etc (#3873) (#4421). [Anthony Donlon]. +* Fix false INFINITELOOP on forever..mailbox.get() (#4323). [Srinivasan Venkataramanan] * Fix data type of condition operation on class objects (#4345) (#4352). [Ryszard Rozak, Antmicro Ltd] * Fix ++/-- under statements (#4399). [Aleksander Kiryk, Antmicro Ltd] * Fix detection of mixed blocking and nonblocking assignment in nested assignments (#4404). [Ryszard Rozak, Antmicro Ltd] diff --git a/src/V3Const.cpp b/src/V3Const.cpp index b76c8244b..696fceb5e 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -3204,8 +3204,17 @@ private: iterateChildren(nodep); } - void visit(AstFuncRef* nodep) override { + void visit(AstNodeCCall* nodep) override { iterateChildren(nodep); + m_hasJumpDelay = true; // As don't analyze inside tasks for timing controls + } + void visit(AstNodeFTaskRef* nodep) override { + // Note excludes AstFuncRef as other visitor below + iterateChildren(nodep); + m_hasJumpDelay = true; // As don't analyze inside tasks for timing controls + } + void visit(AstFuncRef* nodep) override { + visit(static_cast(nodep)); if (m_params) { // Only parameters force us to do constant function call propagation replaceWithSimulation(nodep); } diff --git a/test_regress/t/t_lint_infinite.pl b/test_regress/t/t_lint_infinite.pl new file mode 100755 index 000000000..3364f1ed7 --- /dev/null +++ b/test_regress/t/t_lint_infinite.pl @@ -0,0 +1,23 @@ +#!/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); + +compile( + verilator_flags2 => ["--exe --main --timing"], + make_main => 0, + ); + +execute( + check_finished => 1, + ); + +ok(1); +1; diff --git a/test_regress/t/t_lint_infinite.v b/test_regress/t/t_lint_infinite.v new file mode 100644 index 000000000..305cd1e2d --- /dev/null +++ b/test_regress/t/t_lint_infinite.v @@ -0,0 +1,36 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2023 by Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +module t; + + mailbox #(int) mbox; + + task main(); + // See issue #4323; not an INFINITELOOP due to delay inside get() + forever begin + int i; + mbox.get(i); + $display("[%0t] Got %0d", $time, i); + end + endtask + + initial begin + mbox = new (1); + + #10; + fork + main(); + join_none + + #10; + mbox.put(10); + mbox.put(11); + + #10; + $write("*-* All Finished *-*\n"); + $finish; + end +endmodule diff --git a/test_regress/t/t_lint_infinite_bad.v b/test_regress/t/t_lint_infinite_bad.v index 4bf795db2..c3cc1cc1b 100644 --- a/test_regress/t/t_lint_infinite_bad.v +++ b/test_regress/t/t_lint_infinite_bad.v @@ -10,5 +10,6 @@ module t (); forever begin end // verilator lint_off UNSIGNED for (reg [31:0] i=0; i>=0; i=i+1) begin end + $display; // So loop not eaten end endmodule diff --git a/test_regress/t/t_uvm_todo.pl b/test_regress/t/t_uvm_todo.pl index d45b6064f..b71e06d09 100755 --- a/test_regress/t/t_uvm_todo.pl +++ b/test_regress/t/t_uvm_todo.pl @@ -15,7 +15,6 @@ compile( "-Wno-PKGNODECL -Wno-IMPLICITSTATIC -Wno-CONSTRAINTIGN -Wno-MISINDENT", "-Wno-CASEINCOMPLETE -Wno-CASTCONST -Wno-SYMRSVDWORD -Wno-WIDTHEXPAND -Wno-WIDTHTRUNC", "-Wno-REALCVT", # TODO note mostly related to $realtime - could suppress or fix upstream - "-Wno-INFINITELOOP" , # TODO issue #4323, false warning "-Wno-RANDC", # TODO issue #4349, add support "-Wno-ZERODLY", # TODO issue #4494, add support ],