diff --git a/Changes b/Changes index 833ae3180..e4f064092 100644 --- a/Changes +++ b/Changes @@ -14,6 +14,7 @@ Verilator 5.027 devel **Minor:** * Fix fusing macro arguments to not ignore whitespace (#5061). [Tudor Timi] +* Fix mis-removing $value$plusargs calls (#5127) (#5137). [Seth Pellegrino] Verilator 5.026 2024-06-15 diff --git a/docs/CONTRIBUTORS b/docs/CONTRIBUTORS index 0b9636486..70a6c08a1 100644 --- a/docs/CONTRIBUTORS +++ b/docs/CONTRIBUTORS @@ -177,6 +177,7 @@ Samuel Riedel Sean Cross Sebastien Van Cauwenberghe Sergi Granell +Seth Pellegrino Srinivasan Venkataramanan Stefan Wallentowitz Stephen Henry diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index db5e6ae5c..f2657d703 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -311,7 +311,7 @@ class DeadVisitor final : public VNVisitor { // still get deleted. } void visit(AstNode* nodep) override { - if (nodep->isOutputter()) m_sideEffect = true; + if (!m_sideEffect && !nodep->isPure()) m_sideEffect = true; iterateChildren(nodep); checkAll(nodep); } diff --git a/test_regress/t/t_sys_plusargs.v b/test_regress/t/t_sys_plusargs.v index 148cc00f1..1ca4f29bd 100644 --- a/test_regress/t/t_sys_plusargs.v +++ b/test_regress/t/t_sys_plusargs.v @@ -14,6 +14,7 @@ module t; string sv_str; reg [7*8:1] p_in; string sv_in; + integer unread; // never read initial begin if ($test$plusargs("PLUS")!==1) $stop; @@ -119,6 +120,14 @@ module t; if ($value$plusargs("INT=%d", p_i)) ; if (p_i !== 32'd1234) $stop; + // bug5127 - assign side effect test + p_i = 0; + p_r = 0; + unread = $value$plusargs("INT=%d", p_i); + unread = $value$plusargs("REAL=%e", p_r); + if (p_i !== 32'd1234) $stop; + if (p_r !== 1.2345) $stop; + $write("*-* All Finished *-*\n"); $finish; end