From ae89e399a38ba044a282479c36451b7bbedffa70 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 16 May 2016 21:57:49 -0400 Subject: [PATCH] Fix to string, msg1890. --- Changes | 2 ++ include/verilated.cpp | 8 ++++++++ include/verilated_heavy.h | 1 + test_regress/t/t_sys_plusargs.v | 5 +++++ 4 files changed, 16 insertions(+) diff --git a/Changes b/Changes index f6bd6a0ee..42cb51797 100644 --- a/Changes +++ b/Changes @@ -21,6 +21,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix core dump on Arch Linux/GCC 6.1.1, bug1058. [Jannis Harder] +**** Fix $value$plusargs to string, msg1890. [Frederic Requin] + * Verilator 3.882 2016-03-01 diff --git a/include/verilated.cpp b/include/verilated.cpp index f46b6d6e9..1cef48cc2 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -1077,6 +1077,14 @@ IData VL_TESTPLUSARGS_I(const char* formatp) { else return 1; } +IData VL_VALUEPLUSARGS_IN(int, const char* prefixp, char, string& ldr) { + const string& match = VerilatedImp::argPlusMatch(prefixp); + const char* dp = match.c_str() + 1 /*leading + */ + strlen(prefixp); + if (match == "") return 0; + ldr = string(dp); + return 1; +} + IData VL_VALUEPLUSARGS_IW(int rbits, const char* prefixp, char fmt, WDataOutP rwp) { const string& match = VerilatedImp::argPlusMatch(prefixp); const char* dp = match.c_str() + 1 /*leading + */ + strlen(prefixp); diff --git a/include/verilated_heavy.h b/include/verilated_heavy.h index cddfe72c1..6b9d431b9 100644 --- a/include/verilated_heavy.h +++ b/include/verilated_heavy.h @@ -66,5 +66,6 @@ extern void VL_READMEM_N(bool hex, int width, int depth, int array_lsb, int fnwo extern IData VL_SSCANF_INX(int lbits, const string& ld, const char* formatp, ...); extern void VL_SFORMAT_X(int obits_ignored, string &output, const char* formatp, ...); extern string VL_SFORMATF_NX(const char* formatp, ...); +extern IData VL_VALUEPLUSARGS_IN(int rbits, const char* prefixp, char fmt, string& ldr); #endif // Guard diff --git a/test_regress/t/t_sys_plusargs.v b/test_regress/t/t_sys_plusargs.v index c8908ed0d..1c3381f6f 100644 --- a/test_regress/t/t_sys_plusargs.v +++ b/test_regress/t/t_sys_plusargs.v @@ -7,6 +7,7 @@ module t; integer p_i; reg [7*8:1] p_str; + string sv_str; initial begin if ($test$plusargs("PLUS")!==1) $stop; @@ -32,6 +33,10 @@ module t; $display("str='%s'",p_str); if (p_str !== "T=1234") $stop; + if ($value$plusargs("IN%s", sv_str)!==1) $stop; + $display("str='%s'",sv_str); + if (sv_str != "T=1234") $stop; + $write("*-* All Finished *-*\n"); $finish; end