From 9d7c4d9af3db39f4a2df7a0b0c5d09fedd277eac Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 11 Nov 2022 17:18:59 -0500 Subject: [PATCH] Fix wait 0. --- Changes | 1 + src/V3Timing.cpp | 4 ++- test_regress/t/t_lint_wait_bad.out | 17 +++++---- test_regress/t/t_timing_wait.v | 57 ++++++++++++++++-------------- 4 files changed, 44 insertions(+), 35 deletions(-) diff --git a/Changes b/Changes index d54ef90b1..c12d111f4 100644 --- a/Changes +++ b/Changes @@ -19,6 +19,7 @@ Verilator 5.003 devel * Fix return type of $countbits functions to int (#3725). [Ryszard Rozak, Antmicro Ltd] * Fix missing UNUSED warnings with --coverage (#3736). [alejandro-castro-ortegon] * Fix tracing parameters overridden with -G (#3723). [Iztok Jeras] +* Fix wait 0. Verilator 5.002 2022-10-29 diff --git a/src/V3Timing.cpp b/src/V3Timing.cpp index 85549de04..30eb3d410 100644 --- a/src/V3Timing.cpp +++ b/src/V3Timing.cpp @@ -709,11 +709,13 @@ private: awaitp->dtypeSetVoid(); nodep->replaceWith(awaitp->makeStmt()); if (stmtsp) VL_DO_DANGLING(stmtsp->deleteTree(), stmtsp); + VL_DO_DANGLING(condp->deleteTree(), condp); } else if (stmtsp) { // Just put the statements there nodep->replaceWith(stmtsp); + } else { + nodep->unlinkFrBack(); } - VL_DO_DANGLING(condp->deleteTree(), condp); } else if (needDynamicTrigger(condp)) { // No point in making a sentree, just use the expression as sensitivity // Put the event control in an if so we only wait if the condition isn't met already diff --git a/test_regress/t/t_lint_wait_bad.out b/test_regress/t/t_lint_wait_bad.out index 5ceecf26d..3b06a1c50 100644 --- a/test_regress/t/t_lint_wait_bad.out +++ b/test_regress/t/t_lint_wait_bad.out @@ -1,12 +1,15 @@ -%Warning-WAITCONST: t/t_timing_wait.v:47:13: Wait statement condition is constant - 47 | wait(0 < 1) $write("*-* All Finished *-*\n"); - | ^ +%Warning-WAITCONST: t/t_timing_wait.v:48:12: Wait statement condition is constant + 48 | wait(1); + | ^ ... For warning description see https://verilator.org/warn/WAITCONST?v=latest ... Use "/* verilator lint_off WAITCONST */" and lint_on around source to disable this message. -%Warning-WAITCONST: t/t_timing_wait.v:51:17: Wait statement condition is constant - 51 | initial wait(0) $stop; +%Warning-WAITCONST: t/t_timing_wait.v:50:14: Wait statement condition is constant + 50 | wait(0 < 1) $write("*-* All Finished *-*\n"); + | ^ +%Warning-WAITCONST: t/t_timing_wait.v:54:17: Wait statement condition is constant + 54 | initial wait(0) $stop; | ^ -%Warning-WAITCONST: t/t_timing_wait.v:52:19: Wait statement condition is constant - 52 | initial wait(1 == 0) $stop; +%Warning-WAITCONST: t/t_timing_wait.v:55:19: Wait statement condition is constant + 55 | initial wait(1 == 0) $stop; | ^~ %Error: Exiting due to diff --git a/test_regress/t/t_timing_wait.v b/test_regress/t/t_timing_wait.v index abfda1c09..bcf33dcb1 100644 --- a/test_regress/t/t_timing_wait.v +++ b/test_regress/t/t_timing_wait.v @@ -16,36 +16,39 @@ module t; int c = 0; initial begin - `WRITE_VERBOSE("start with a==0, b==0, c==0\n"); - #2 a = 1; `WRITE_VERBOSE("assign 1 to a\n"); - #1 a = 2; `WRITE_VERBOSE("assign 2 to a\n"); // a==2 - #1 a = 0; `WRITE_VERBOSE("assign 0 to a\n"); - #1 a = 2; `WRITE_VERBOSE("assign 2 to a\n"); // 1a - #1 c = 3; `WRITE_VERBOSE("assign 3 to c\n"); - #1 c = 4; `WRITE_VERBOSE("assign 4 to c\n"); // a+bc - b = 5; + `WRITE_VERBOSE("start with a==0, b==0, c==0\n"); + #2 a = 1; `WRITE_VERBOSE("assign 1 to a\n"); + #1 a = 2; `WRITE_VERBOSE("assign 2 to a\n"); // a==2 + #1 a = 0; `WRITE_VERBOSE("assign 0 to a\n"); + #1 a = 2; `WRITE_VERBOSE("assign 2 to a\n"); // 1a + #1 c = 3; `WRITE_VERBOSE("assign 3 to c\n"); + #1 c = 4; `WRITE_VERBOSE("assign 4 to c\n"); // a+bc + b = 5; end initial begin - #1 `WRITE_VERBOSE("waiting for a==2\n"); - wait(a == 2) if (a != 2) $stop; - `WRITE_VERBOSE("waiting for a<2\n"); - wait(a < 2) if (a >= 2) $stop; - `WRITE_VERBOSE("waiting for a==0\n"); - wait(a == 0) if (a != 0) $stop; - `WRITE_VERBOSE("waiting for 1 1 && a < 3) if (a <= 1 || a >= 3) $stop; - `WRITE_VERBOSE("waiting for b>a\n"); - wait(b > a) if (b <= a) $stop; - `WRITE_VERBOSE("waiting for a+b= c) $stop; - `WRITE_VERBOSE("waiting for ac\n"); - wait(a < b && b > c) if (a >= b || b <= c) $stop; - wait(0 < 1) $write("*-* All Finished *-*\n"); - $finish; + #1 `WRITE_VERBOSE("waiting for a==2\n"); + wait(a == 2) if (a != 2) $stop; + `WRITE_VERBOSE("waiting for a<2\n"); + wait(a < 2) if (a >= 2) $stop; + `WRITE_VERBOSE("waiting for a==0\n"); + wait(a == 0) if (a != 0) $stop; + `WRITE_VERBOSE("waiting for 1 1 && a < 3) if (a <= 1 || a >= 3) $stop; + `WRITE_VERBOSE("waiting for b>a\n"); + wait(b > a) if (b <= a) $stop; + `WRITE_VERBOSE("waiting for a+b= c) $stop; + `WRITE_VERBOSE("waiting for ac\n"); + wait(a < b && b > c) if (a >= b || b <= c) $stop; + + wait(1); + + wait(0 < 1) $write("*-* All Finished *-*\n"); + $finish; end initial wait(0) $stop;