From ae6f5844da867be7ef7cbf481603bc783f68b82f Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 4 May 2013 10:29:54 -0400 Subject: [PATCH] Add Verilated::internalsDump() --- include/verilated.cpp | 4 ++++ include/verilated.h | 5 +++++ include/verilated_imp.h | 30 ++++++++++++++++++++++++++++-- test_regress/t/t_dpi_export_c.cpp | 2 +- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/include/verilated.cpp b/include/verilated.cpp index 7c4e83c3d..123a5e9a4 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -1075,6 +1075,10 @@ const char* Verilated::commandArgsPlusMatch(const char* prefixp) { return VerilatedImp::argPlusMatch(prefixp).c_str(); } +void Verilated::internalsDump() { + VerilatedImp::internalsDump(); +} + void Verilated::scopesDump() { VerilatedImp::scopesDump(); } diff --git a/include/verilated.h b/include/verilated.h index 91efed3dd..c39200d9c 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -294,6 +294,11 @@ public: static const char* productName() { return VERILATOR_PRODUCT; } static const char* productVersion() { return VERILATOR_VERSION; } + /// For debugging, print much of the Verilator internal state. + /// The output of this function may change in future + /// releases - contact the authors before production use. + static void internalsDump(); + /// 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. diff --git a/include/verilated_imp.h b/include/verilated_imp.h index e56fde626..8fe20e119 100644 --- a/include/verilated_imp.h +++ b/include/verilated_imp.h @@ -78,6 +78,18 @@ public: // But only for verilated*.cpp m_fdps[2] = stderr; } ~VerilatedImp() {} + static void internalsDump() { + VL_PRINTF("internalsDump:\n"); + VL_PRINTF(" Argv:"); + for (ArgVec::iterator it=s_s.m_argVec.begin(); it!=s_s.m_argVec.end(); ++it) { + VL_PRINTF(" %s",it->c_str()); + } + VL_PRINTF("\n"); + VL_PRINTF(" Version: %s %s\n", Verilated::productName(), Verilated::productVersion()); + scopesDump(); + exportsDump(); + userDump(); + } // METHODS - arguments static void commandArgs(int argc, const char** argv) { @@ -129,6 +141,14 @@ private: } } } + static void userDump() { + bool first = true; + for (UserMap::iterator it=s_s.m_userMap.begin(); it!=s_s.m_userMap.end(); ++it) { + if (first) { VL_PRINTF(" userDump:\n"); first=false; } + VL_PRINTF(" DPI_USER_DATA scope %p key %p: %p\n", + it->first.first, it->first.second, it->second); + } + } public: // But only for verilated*.cpp // METHODS - scope name @@ -150,9 +170,8 @@ 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"); + 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; scopep->scopeDump(); @@ -194,6 +213,13 @@ public: // But only for verilated*.cpp } return "*UNKNOWN*"; } + static void exportsDump() { + bool first = true; + for (ExportNameMap::iterator it=s_s.m_exportMap.begin(); it!=s_s.m_exportMap.end(); ++it) { + if (first) { VL_PRINTF(" exportDump:\n"); first=false; } + VL_PRINTF(" DPI_EXPORT_NAME %05d: %s\n", it->second, it->first); + } + } // We don't free up m_exportMap until the end, because we can't be sure // what other models are using the assigned funcnum's. diff --git a/test_regress/t/t_dpi_export_c.cpp b/test_regress/t/t_dpi_export_c.cpp index 6d5c2cdd5..54c41b018 100644 --- a/test_regress/t/t_dpi_export_c.cpp +++ b/test_regress/t/t_dpi_export_c.cpp @@ -99,7 +99,7 @@ int dpix_run_tests() { static int didDump = 0; if (didDump++ == 0) { # ifdef TEST_VERBOSE - Verilated::scopesDump(); + Verilated::internalsDump(); # endif } #endif