From 8c2ee6c5ab87c1fca380c2d2bbcb8275d474425b Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 22 Feb 2021 22:59:23 -0500 Subject: [PATCH] With -DVL_NO_LEGACY hide all outdated API routines --- include/verilated.h | 2 ++ include/verilated_vpi.cpp | 2 ++ include/verilatedos.h | 39 ++++++++++++++-------- test_regress/t/t_flag_main.pl | 2 ++ test_regress/t/t_flag_main.v | 2 +- test_regress/t/t_scope_map.cpp | 3 -- test_regress/t/t_verilated_legacy.cpp | 3 ++ test_regress/t/t_vpi_release_dup_bad_c.cpp | 5 +++ 8 files changed, 41 insertions(+), 17 deletions(-) diff --git a/include/verilated.h b/include/verilated.h index 1c90643db..ac43160ed 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -496,7 +496,9 @@ public: static void addFlushCb(VoidPCb cb, void* datap) VL_MT_SAFE; static void removeFlushCb(VoidPCb cb, void* datap) VL_MT_SAFE; static void runFlushCallbacks() VL_MT_SAFE; +#ifndef VL_NO_LEGACY static void flushCall() VL_MT_SAFE { runFlushCallbacks(); } // Deprecated +#endif /// Callbacks to run prior to termination static void addExitCb(VoidPCb cb, void* datap) VL_MT_SAFE; static void removeExitCb(VoidPCb cb, void* datap) VL_MT_SAFE; diff --git a/include/verilated_vpi.cpp b/include/verilated_vpi.cpp index 1ed63e9a0..e48809e54 100644 --- a/include/verilated_vpi.cpp +++ b/include/verilated_vpi.cpp @@ -2112,10 +2112,12 @@ PLI_INT32 vpi_chk_error(p_vpi_error_info error_info_p) { return _error_info_p->level; // return error severity level } +#ifndef VL_NO_LEGACY PLI_INT32 vpi_free_object(vpiHandle object) { // vpi_free_object is IEEE deprecated, use vpi_release_handle return vpi_release_handle(object); } +#endif PLI_INT32 vpi_release_handle(vpiHandle object) { VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_release_handle %p\n", object);); diff --git a/include/verilatedos.h b/include/verilatedos.h index d4625e643..b83d5f1bc 100644 --- a/include/verilatedos.h +++ b/include/verilatedos.h @@ -39,6 +39,7 @@ # define VL_ATTR_PRINTF(fmtArgNum) __attribute__((format(printf, (fmtArgNum), (fmtArgNum) + 1))) # define VL_ATTR_PURE __attribute__((pure)) # define VL_ATTR_UNUSED __attribute__((unused)) +# define VL_ATTR_WEAK __attribute__((weak)) # define VL_FUNC __func__ # if defined(__clang__) && defined(VL_THREADED) # define VL_ACQUIRE(...) __attribute__((acquire_capability(__VA_ARGS__))) @@ -87,6 +88,9 @@ #ifndef VL_ATTR_UNUSED # define VL_ATTR_UNUSED ///< Function that may be never used #endif +#ifndef VL_ATTR_WEAK +# define VL_ATTR_WEAK ///< Function external that is optionally defined +#endif #ifndef VL_FUNC # define VL_FUNC "__func__" ///< Name of current function for error macros #endif @@ -133,8 +137,10 @@ # define VL_THREAD_LOCAL ///< Use new C++ static local thread #endif -#define VL_THREAD ///< Deprecated -#define VL_STATIC_OR_THREAD static ///< Deprecated +#ifndef VL_NO_LEGACY +# define VL_THREAD ///< Deprecated +# define VL_STATIC_OR_THREAD static ///< Deprecated +#endif #define VL_PURE ///< Comment tag that Function is pure (and thus also VL_MT_SAFE) #define VL_MT_SAFE ///< Comment tag that function is threadsafe when VL_THREADED @@ -144,7 +150,9 @@ #define VL_MT_UNSAFE_ONE ///< Comment tag that function is not threadsafe when VL_THREADED, ///< protected to make sure single-caller -#define VL_ULL(c) (c##ULL) ///< Add appropriate suffix to 64-bit constant (deprecated) +#ifndef VL_NO_LEGACY +# define VL_ULL(c) (c##ULL) ///< Add appropriate suffix to 64-bit constant (deprecated) +#endif // This is not necessarily the same as #UL, depending on what the IData typedef is. #define VL_UL(c) (static_cast(c##UL)) ///< Add appropriate suffix to 32-bit constant @@ -184,16 +192,18 @@ // C++-2011 #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(VL_CPPCHECK) +# ifndef VL_NO_LEGACY // These are deprecated historical defines. We leave them in case users referenced them. -# define VL_EQ_DELETE = delete -# define vl_unique_ptr std::unique_ptr -# define vl_unordered_map std::unordered_map -# define vl_unordered_set std::unordered_set -# define VL_INCLUDE_UNORDERED_MAP -# define VL_INCLUDE_UNORDERED_SET -# define VL_FINAL final -# define VL_MUTABLE mutable -# define VL_OVERRIDE override +# define VL_EQ_DELETE = delete +# define vl_unique_ptr std::unique_ptr +# define vl_unordered_map std::unordered_map +# define vl_unordered_set std::unordered_set +# define VL_INCLUDE_UNORDERED_MAP +# define VL_INCLUDE_UNORDERED_SET +# define VL_FINAL final +# define VL_MUTABLE mutable +# define VL_OVERRIDE override +# endif #else # error "Verilator requires a C++11 or newer compiler" #endif @@ -358,12 +368,15 @@ typedef unsigned long long vluint64_t; ///< 64-bit unsigned type #define VL_BYTESIZE 8 ///< Bits in a CData / byte #define VL_SHORTSIZE 16 ///< Bits in a SData / short #define VL_IDATASIZE 32 ///< Bits in a IData / word -#define VL_WORDSIZE VL_IDATASIZE ///< Legacy define #define VL_QUADSIZE 64 ///< Bits in a QData / quadword #define VL_EDATASIZE 32 ///< Bits in a EData (WData entry) #define VL_EDATASIZE_LOG2 5 ///< log2(VL_EDATASIZE) #define VL_CACHE_LINE_BYTES 64 ///< Bytes in a cache line (for alignment) +#ifndef VL_NO_LEGACY +# define VL_WORDSIZE VL_IDATASIZE ///< Legacy define +#endif + /// Bytes this number of bits needs (1 bit=1 byte) #define VL_BYTES_I(nbits) (((nbits) + (VL_BYTESIZE - 1)) / VL_BYTESIZE) /// Words/EDatas this number of bits needs (1 bit=1 word) diff --git a/test_regress/t/t_flag_main.pl b/test_regress/t/t_flag_main.pl index 397fea235..381004460 100755 --- a/test_regress/t/t_flag_main.pl +++ b/test_regress/t/t_flag_main.pl @@ -15,6 +15,8 @@ compile( verilator_make_cmake => 0, verilator_make_gmake => 0, make_main => 0, + # Check that code --main produces uses only most modern API features + make_flags => 'CPPFLAGS_ADD=-DVL_NO_LEGACY', ); execute( diff --git a/test_regress/t/t_flag_main.v b/test_regress/t/t_flag_main.v index ef63ab8ca..cfbfe9164 100644 --- a/test_regress/t/t_flag_main.v +++ b/test_regress/t/t_flag_main.v @@ -6,7 +6,7 @@ module t(/*AUTOARG*/); initial begin - $write("[%0t] Hello", $time); // Check timestamp works + $write("[%0t] Hello\n", $time); // Check timestamp works $write("*-* All Finished *-*\n"); $finish; end diff --git a/test_regress/t/t_scope_map.cpp b/test_regress/t/t_scope_map.cpp index b27cb4c97..912150699 100644 --- a/test_regress/t/t_scope_map.cpp +++ b/test_regress/t/t_scope_map.cpp @@ -115,9 +115,6 @@ int main(int argc, char** argv, char** env) { tfp->dump((unsigned int)(main_time)); ++main_time; - // Code coverage of historical flush function - Verilated::flushCall(); - for (VerilatedScopeNameMap::const_iterator it = scopeMapp->begin(); it != scopeMapp->end(); ++it) { VerilatedVarNameMap* varNameMap = it->second->varsp(); diff --git a/test_regress/t/t_verilated_legacy.cpp b/test_regress/t/t_verilated_legacy.cpp index 5536d586d..b46f6c296 100644 --- a/test_regress/t/t_verilated_legacy.cpp +++ b/test_regress/t/t_verilated_legacy.cpp @@ -76,6 +76,9 @@ int main(int argc, char** argv, char** env) { CHECK_RESULT_CSTR(Verilated::productName(), Verilated::productName()); CHECK_RESULT_CSTR(Verilated::productVersion(), Verilated::productVersion()); + if (Verilated::timeunit()) {} + if (Verilated::timeprecision()) {} + VM_PREFIX* topp = new VM_PREFIX(); topp->eval(); diff --git a/test_regress/t/t_vpi_release_dup_bad_c.cpp b/test_regress/t/t_vpi_release_dup_bad_c.cpp index 2d05cb61d..1ade9eaac 100644 --- a/test_regress/t/t_vpi_release_dup_bad_c.cpp +++ b/test_regress/t/t_vpi_release_dup_bad_c.cpp @@ -23,6 +23,11 @@ void dpii_check() { // Verilated::scopesDump(); mod = vpi_handle_by_name((PLI_BYTE8*)"top.t", NULL); if (!mod) vpi_printf(const_cast("-- Cannot vpi_find module\n")); +#ifdef VL_NO_LEGACY + vpi_release_handle(mod); + vpi_release_handle(mod); +#else vpi_free_object(mod); // using vpi_free_object instead of vpi_release_handle for coverage vpi_free_object(mod); // error: double free +#endif }