diff --git a/include/verilated.cpp b/include/verilated.cpp index 8b4a2e28a..d309d1a41 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -915,6 +915,10 @@ void Verilated::commandArgs(int argc, const char** argv) { VerilatedImp::commandArgs(argc,argv); } +void Verilated::scopesDump() { + VerilatedImp::scopesDump(); +} + //=========================================================================== // VerilatedModule:: Methods diff --git a/include/verilated.h b/include/verilated.h index abfbddff7..a1e8d8f4d 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -186,10 +186,16 @@ public: /// Enable/disable assertions static void assertOn(bool flag) { s_assertOn=flag; } static bool assertOn() { return s_assertOn; } + /// Record command line arguments, for retrieval by $test$plusargs/$value$plusargs static void commandArgs(int argc, const char** argv); static void commandArgs(int argc, char** argv) { commandArgs(argc,(const char**)argv); } + /// For debugging, print text list of all scope names with + /// dpiImport/Export context. This function may change in future + /// releases - contact the authors before production use. + static void scopesDump(); + // METHODS - INTERNAL USE ONLY // Internal: Create a new module name by concatenating two strings static const char* catName(const char* n1, const char* n2); // Returns new'ed data diff --git a/include/verilatedimp.h b/include/verilatedimp.h index f647e722a..acfa358c6 100644 --- a/include/verilatedimp.h +++ b/include/verilatedimp.h @@ -137,7 +137,15 @@ public: // But only for verilated*.cpp ScopeNameMap::iterator it=s_s.m_nameMap.find(scopep->name()); if (it != s_s.m_nameMap.end()) s_s.m_nameMap.erase(it); } - + static void scopesDump() { + VL_PRINTF("scopesDump:\n"); + for (ScopeNameMap::iterator it=s_s.m_nameMap.begin(); + it!=s_s.m_nameMap.end(); ++it) { + const VerilatedScope* scopep = it->second; + VL_PRINTF(" %s\n", scopep->name()); + } + VL_PRINTF("\n"); + } }; #endif // Guard diff --git a/test_regress/t/t_dpi_context_c.cpp b/test_regress/t/t_dpi_context_c.cpp index 04c7063e3..8f5516405 100644 --- a/test_regress/t/t_dpi_context_c.cpp +++ b/test_regress/t/t_dpi_context_c.cpp @@ -32,6 +32,10 @@ # error "Unknown simulator for DPI test" #endif +#ifdef VERILATOR +# include "verilated.h" +#endif + #ifdef NEED_EXTERNS extern "C" { @@ -50,6 +54,13 @@ int dpic_line() { return 0; } +#ifdef VERILATOR + static int didDump = 0; + if (didDump++ == 0) { + Verilated::scopesDump(); + } +#endif + const char* scopenamep = svGetNameFromScope(scope); if (!scopenamep) { printf("%%Warning: svGetNameFromScope failed\n");