With -DVL_NO_LEGACY hide all outdated API routines

This commit is contained in:
Wilson Snyder 2021-02-22 22:59:23 -05:00
parent 6ada513fa5
commit 8c2ee6c5ab
8 changed files with 41 additions and 17 deletions

View File

@ -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;

View File

@ -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););

View File

@ -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<IData>(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 <unordered_map>
# define VL_INCLUDE_UNORDERED_SET <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 <unordered_map>
# define VL_INCLUDE_UNORDERED_SET <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)

View File

@ -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(

View File

@ -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

View File

@ -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();

View File

@ -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();

View File

@ -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<char*>("-- 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
}