diff --git a/Changes b/Changes index 8c089b387..0a5f0c2f2 100644 --- a/Changes +++ b/Changes @@ -23,6 +23,7 @@ Verilator 4.215 devel * Fix split_var assign merging (#3177) (#3179). [Yutetsu TAKATSUKASA] * Fix nested generate if genblk naming (#3189). [yanx21] * Fix display of empty string constant (#3207). [Julie Schwartz] +* Fix %0 format on $value$plusargs. Verilator 4.214 2021-10-17 diff --git a/include/verilated.cpp b/include/verilated.cpp index 173f0fc7f..0386a40b9 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -1600,6 +1600,7 @@ IData VL_VALUEPLUSARGS_INW(int rbits, const std::string& ld, WDataOutP rwp) VL_M inPct = true; } else if (!inPct) { // Normal text prefix += *posp; + } else if (inPct && posp[0] == '0') { // %0 } else { // Format character switch (std::tolower(*posp)) { case '%': diff --git a/test_regress/t/t_sys_plusargs.v b/test_regress/t/t_sys_plusargs.v index 73600e6cd..55daf5085 100644 --- a/test_regress/t/t_sys_plusargs.v +++ b/test_regress/t/t_sys_plusargs.v @@ -23,11 +23,16 @@ module t; if ($test$plusargs("NOTTHERE")!==0) $stop; p_i = 10; - if ($value$plusargs("NOTTHERE%d", p_i)!==0) $stop; + if ($value$plusargs("NOTTHERE%d", p_i) !== 0) $stop; + if ($value$plusargs("NOTTHERE%0d", p_i) !== 0) $stop; if (p_i !== 10) $stop; p_i = 0; - if ($value$plusargs("INT=%d", p_i)!==1) $stop; + if ($value$plusargs("INT=%d", p_i) !== 1) $stop; + if (p_i !== 32'd1234) $stop; + + p_i = 0; + if ($value$plusargs("INT=%0d", p_i) !== 1) $stop; if (p_i !== 32'd1234) $stop; p_i = 0;