From 56a03e1a1027d39612fa72200148e99bdb993405 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 3 Feb 2010 06:33:00 -0500 Subject: [PATCH] Add vl_mc_scan_plusargs --- include/verilated.cpp | 6 ++++++ include/verilated.h | 1 + include/verilated_imp.h | 5 +++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/verilated.cpp b/include/verilated.cpp index 2d04d44eb..79a5691f3 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -913,6 +913,12 @@ IData VL_VALUEPLUSARGS_IW(int rbits, const char* prefixp, char fmt, WDataOutP rw return 1; } +const char* vl_mc_scan_plusargs(const char* prefixp) { + string match = VerilatedImp::argPlusMatch(prefixp); + if (match == "") return 0; + else return match.c_str()+strlen(prefixp)+1; // +1 to skip the "+" +} + //=========================================================================== // Heavy functions diff --git a/include/verilated.h b/include/verilated.h index 79f73b0be..803c09305 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -303,6 +303,7 @@ extern void VL_SFORMAT_X(int obits, void* destp, const char* formatp, ...); extern IData VL_TESTPLUSARGS_I(const char* formatp); extern IData VL_VALUEPLUSARGS_IW(int rbits, const char* prefixp, char fmt, WDataOutP rwp); +extern const char* vl_mc_scan_plusargs(const char* prefixp); // PLIish //========================================================================= // Base macros diff --git a/include/verilated_imp.h b/include/verilated_imp.h index 843dba947..71b03f222 100644 --- a/include/verilated_imp.h +++ b/include/verilated_imp.h @@ -80,6 +80,7 @@ public: // But only for verilated*.cpp s_s.m_argVecLoaded = true; // Can't just test later for empty vector, no arguments is ok } static string argPlusMatch(const char* prefixp) { + // Note prefixp does not include the leading "+" size_t len = strlen(prefixp); if (VL_UNLIKELY(!s_s.m_argVecLoaded)) { s_s.m_argVecLoaded = true; // Complain only once @@ -134,7 +135,7 @@ public: // But only for verilated*.cpp } static inline const VerilatedScope* scopeFind(const char* namep) { ScopeNameMap::iterator it=s_s.m_nameMap.find(namep); - if (it != s_s.m_nameMap.end()) return it->second; + if (VL_LIKELY(it != s_s.m_nameMap.end())) return it->second; else return NULL; } static void scopeErase(const VerilatedScope* scopep) { @@ -174,7 +175,7 @@ public: // But only for verilated*.cpp } static int exportFind(const char* namep) { ExportNameMap::iterator it=s_s.m_exportMap.find(namep); - if (it != s_s.m_exportMap.end()) return it->second; + if (VL_LIKELY(it != s_s.m_exportMap.end())) return it->second; string msg = (string("%Error: Testbench C called ")+namep +" but no such DPI export function name exists in ANY model"); vl_fatal("unknown",0,"", msg.c_str());