mirror of
https://github.com/verilator/verilator.git
synced 2026-10-02 16:13:34 +02:00
tests: Add VM_PREFIX_INCLUDE_DPI (#8386)
This commit is contained in:
@@ -360,32 +360,6 @@ AC_DEFUN([_MY_CXX_CHECK_OPT],
|
||||
_MY_CXX_CHECK_IFELSE($2, $1="$$1 $2")
|
||||
])
|
||||
|
||||
# _MY_CXX_CHECK_IS_CLANG_VERSION(variable,min-version,max-version)
|
||||
# Check if the C++ compiler is Clang, with version >= min-version and
|
||||
# < max-version. Versions are given as 'major.minor.patch'. An empty
|
||||
# bound means unbounded at that end.
|
||||
# Set variable to yes or no accordingly.
|
||||
AC_DEFUN([_MY_CXX_CHECK_IS_CLANG_VERSION],
|
||||
[AC_MSG_CHECKING([whether $CXX is Clang >= m4_default([$2],[any]) and < m4_default([$3],[any])])
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
#if !defined(__clang__)
|
||||
# error "Not Clang"
|
||||
#endif
|
||||
#define _MY_VER(maj, min, pat) ((maj) * 1000000 + (min) * 1000 + (pat))
|
||||
#define _MY_CLANG_VER _MY_VER(__clang_major__, __clang_minor__, __clang_patchlevel__)
|
||||
#if _MY_CLANG_VER < _MY_VER(]]m4_quote(m4_translit(m4_default([$2],[0.0.0]),[.],[,]))[[)
|
||||
# error "Clang older than min-version"
|
||||
#endif
|
||||
#if _MY_CLANG_VER >= _MY_VER(]]m4_quote(m4_translit(m4_default([$3],[99999.0.0]),[.],[,]))[[)
|
||||
# error "Clang not older than max-version"
|
||||
#endif
|
||||
]])],
|
||||
[$1=yes],
|
||||
[$1=no])
|
||||
AC_MSG_RESULT($$1)
|
||||
])
|
||||
|
||||
AC_DEFUN([_MY_CXX_CHECK_CORO_SET],
|
||||
[# _MY_CXX_CHECK_CORO_SET(variable,option)
|
||||
# Check if compiler supports coroutines with specific option. If it does,
|
||||
@@ -471,8 +445,6 @@ AC_DEFUN([_MY_LDLIBS_CHECK_SET],
|
||||
fi
|
||||
])
|
||||
|
||||
_MY_CXX_CHECK_IS_CLANG_VERSION(CXX_IS_CLANG_18, 18.0.0, 19.0.0)
|
||||
|
||||
# Add the coverage flags early as they influence later checks.
|
||||
if test "$CFG_WITH_DEV_GCOV" = "yes"; then
|
||||
CFG_GCOV_CXX="$CXX"
|
||||
@@ -658,13 +630,7 @@ m4_foreach([cflag],[
|
||||
# CMake will test what flags work itself, so pass all flags through to it
|
||||
CFG_CXX_FLAGS_CMAKE="$CFG_CXX_FLAGS_CMAKE cflag"
|
||||
])
|
||||
if test "$CXX_IS_CLANG_18" = "yes"; then
|
||||
# Clang 18 only: disable the SLP vectorizer; see verilator/verilator#8379
|
||||
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_ALWAYS,-fno-slp-vectorize)
|
||||
CFG_CXX_FLAGS_CMAKE="$CFG_CXX_FLAGS_CMAKE -fno-slp-vectorize"
|
||||
fi
|
||||
AC_SUBST(CFG_CXXFLAGS_NO_UNUSED)
|
||||
AC_SUBST(CFG_CXXFLAGS_ALWAYS)
|
||||
AC_SUBST(CFG_CXX_FLAGS_CMAKE)
|
||||
|
||||
# Find multithread linker flags
|
||||
|
||||
@@ -40,6 +40,30 @@ model:
|
||||
internals, including ``/* verilator public_flat */`` items.
|
||||
|
||||
|
||||
.. _model header include macros:
|
||||
|
||||
Model Header Include Macros
|
||||
---------------------------
|
||||
|
||||
Code compiled with the generated :file:`{prefix}.mk`, or with the CMake
|
||||
``verilate()`` command, gets preprocessor macros that expand to the model
|
||||
header includes, so user C++ need not hard-code the :vlopt:`--prefix`:
|
||||
|
||||
.. code-block:: C++
|
||||
|
||||
#include VM_PREFIX_INCLUDE // e.g. <Vtop.h>
|
||||
#include VM_PREFIX_INCLUDE_DPI // e.g. <Vtop__Dpi.h>
|
||||
|
||||
``VM_PREFIX_INCLUDE_DPI`` is defined only when Verilator generates the
|
||||
:file:`{prefix}__Dpi.h` header, which is the case for designs with DPI and
|
||||
also for public-signal access such as :vlopt:`--public-flat-rw`. Using it
|
||||
otherwise is a compile-time error.
|
||||
|
||||
A target built from several models defines each macro once, naming the
|
||||
first model, as one target has one set of preprocessor definitions. Code
|
||||
that must reach a second model's header names it directly.
|
||||
|
||||
|
||||
.. _porting from pre 4.210:
|
||||
|
||||
Model interface changes in version 4.210
|
||||
@@ -207,6 +231,9 @@ command line, or the link), you'd then:
|
||||
#include "Vour__Dpi.h"
|
||||
int add(int a, int b) { return a+b; }
|
||||
|
||||
Rather than hard-coding the prefix, ``#include VM_PREFIX_INCLUDE_DPI`` may
|
||||
be used instead; see :ref:`Model Header Include Macros`.
|
||||
|
||||
|
||||
DPI System Task/Functions
|
||||
-------------------------
|
||||
|
||||
+10
-3
@@ -38,8 +38,6 @@ CFG_CXXFLAGS_STD = @CFG_CXXFLAGS_STD@
|
||||
CFG_CXXFLAGS_STD_NEWEST = @CFG_CXXFLAGS_STD_NEWEST@
|
||||
# Compiler flags to use to turn off unused and generated code warnings, such as -Wno-div-by-zero
|
||||
CFG_CXXFLAGS_NO_UNUSED = @CFG_CXXFLAGS_NO_UNUSED@
|
||||
# Compiler flags to always use
|
||||
CFG_CXXFLAGS_ALWAYS = @CFG_CXXFLAGS_ALWAYS@
|
||||
# Compiler flags that turn on extra warnings
|
||||
CFG_CXXFLAGS_WEXTRA = @CFG_CXXFLAGS_WEXTRA@
|
||||
# Compiler flags that enable coroutine support
|
||||
@@ -100,7 +98,16 @@ VK_CPPFLAGS_ALWAYS += \
|
||||
-DVM_TRACE_SAIF=$(VM_TRACE_SAIF) \
|
||||
-DVM_VPI=$(VM_VPI) \
|
||||
$(CFG_CXXFLAGS_NO_UNUSED) \
|
||||
$(CFG_CXXFLAGS_ALWAYS) \
|
||||
|
||||
# Left undefined when there is no generated model, so misuse fails at compile time
|
||||
ifneq ($(VM_PREFIX_INCLUDE),)
|
||||
VK_CPPFLAGS_ALWAYS += -DVM_PREFIX_INCLUDE="$(VM_PREFIX_INCLUDE)"
|
||||
endif
|
||||
|
||||
# Left undefined when the design has no DPI, so misuse fails at compile time
|
||||
ifneq ($(VM_PREFIX_INCLUDE_DPI),)
|
||||
VK_CPPFLAGS_ALWAYS += -DVM_PREFIX_INCLUDE_DPI="$(VM_PREFIX_INCLUDE_DPI)"
|
||||
endif
|
||||
|
||||
ifeq ($(CFG_WITH_CCWARN),yes) # Local... Else don't burden users
|
||||
VK_CPPFLAGS_WALL += -Wall $(CFG_CXXFLAGS_WEXTRA) -Werror
|
||||
|
||||
+9
-2
@@ -664,10 +664,17 @@ public:
|
||||
of.putSet("VM_SC_TARGET_ARCH", V3Options::getenvSYSTEMC_ARCH());
|
||||
|
||||
of.puts("\n### Vars...\n");
|
||||
of.puts("# Design prefix (from --prefix)\n");
|
||||
of.putSet("VM_PREFIX", v3Global.opt.prefix());
|
||||
of.puts("# Module prefix (from --prefix)\n");
|
||||
of.putSet("VM_MODPREFIX", v3Global.opt.modPrefix());
|
||||
of.puts("# Design prefix (from --prefix)\n");
|
||||
of.putSet("VM_PREFIX", v3Global.opt.prefix());
|
||||
of.puts("# Design header include, for '#include VM_PREFIX_INCLUDE' (from --prefix)\n");
|
||||
of.putSet("VM_PREFIX_INCLUDE", "<" + v3Global.opt.prefix() + ".h>");
|
||||
if (v3Global.dpi()) {
|
||||
of.puts("# DPI header include, for '#include VM_PREFIX_INCLUDE_DPI';"
|
||||
" undefined if no DPI\n");
|
||||
of.putSet("VM_PREFIX_INCLUDE_DPI", "<" + v3Global.opt.prefix() + "__Dpi.h>");
|
||||
}
|
||||
|
||||
of.puts("# User CFLAGS (from -CFLAGS on Verilator command line)\n");
|
||||
of.puts("VM_USER_CFLAGS = \\\n");
|
||||
|
||||
@@ -94,6 +94,7 @@ class V3EmitMkJsonEmitter final {
|
||||
.putList("ldflags", v3Global.opt.ldLibs())
|
||||
.put("system_c", v3Global.opt.systemC())
|
||||
.put("coverage", v3Global.opt.coverage())
|
||||
.put("dpi", v3Global.dpi())
|
||||
.put("use_timing", v3Global.usesTiming())
|
||||
.put("threads", v3Global.opt.threads())
|
||||
.put("trace", v3Global.opt.trace())
|
||||
|
||||
@@ -137,6 +137,5 @@ target_compile_definitions(
|
||||
PRIVATE
|
||||
"TEST_OBJ_DIR=${CMAKE_CURRENT_BINARY_DIR}"
|
||||
"VM_PREFIX=${TEST_PREFIX}"
|
||||
"VM_PREFIX_INCLUDE=<${TEST_PREFIX}.h>"
|
||||
"${TEST_NAME_UC}"
|
||||
)
|
||||
|
||||
@@ -30,7 +30,6 @@ CPPFLAGS += -DVL_DEBUG=1
|
||||
# Needed by tracing routines
|
||||
CPPFLAGS += -DTEST_OBJ_DIR=$(TEST_OBJ_DIR)
|
||||
CPPFLAGS += -DVM_PREFIX=$(VM_PREFIX)
|
||||
CPPFLAGS += -DVM_PREFIX_INCLUDE="<$(VM_PREFIX).h>"
|
||||
CPPFLAGS += -DVM_PREFIX_ROOT_INCLUDE="<$(VM_PREFIX)___024root.h>"
|
||||
CPPFLAGS += $(CPPFLAGS_DRIVER)
|
||||
CPPFLAGS += $(CPPFLAGS_DRIVER2)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
//*************************************************************************
|
||||
|
||||
#include "Vt_dpi_accessors.h"
|
||||
#include "Vt_dpi_accessors__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include "svdpi.h"
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "svdpi.h"
|
||||
|
||||
#if defined(VERILATOR) // Verilator
|
||||
# include "Vt_dpi_arg_inout_type__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
typedef long long sv_longint_t;
|
||||
typedef unsigned long long sv_longint_unsigned_t;
|
||||
# define NO_SHORTREAL
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "svdpi.h"
|
||||
|
||||
#if defined(VERILATOR) // Verilator
|
||||
# include "Vt_dpi_arg_inout_unpack__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
typedef long long sv_longint_t;
|
||||
typedef unsigned long long sv_longint_unsigned_t;
|
||||
# define NO_SHORTREAL
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "svdpi.h"
|
||||
|
||||
#if defined(VERILATOR) // Verilator
|
||||
# include "Vt_dpi_arg_input_type__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
typedef long long sv_longint_t;
|
||||
typedef unsigned long long sv_longint_unsigned_t;
|
||||
# define NO_SHORTREAL
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "svdpi.h"
|
||||
|
||||
#if defined(VERILATOR) // Verilator
|
||||
# include "Vt_dpi_arg_input_unpack__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
typedef long long sv_longint_t;
|
||||
typedef unsigned long long sv_longint_unsigned_t;
|
||||
typedef const void** sv_chandle_array_ptr_t;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "svdpi.h"
|
||||
|
||||
#if defined(VERILATOR) // Verilator
|
||||
# include "Vt_dpi_arg_output_type__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
typedef long long sv_longint_t;
|
||||
typedef unsigned long long sv_longint_unsigned_t;
|
||||
# define NO_SHORTREAL
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "svdpi.h"
|
||||
|
||||
#if defined(VERILATOR) // Verilator
|
||||
# include "Vt_dpi_arg_output_unpack__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
typedef long long sv_longint_t;
|
||||
typedef unsigned long long sv_longint_unsigned_t;
|
||||
# define NO_SHORTREAL
|
||||
|
||||
@@ -17,11 +17,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR)
|
||||
# ifdef T_DPI_CONTEXT_NOOPT
|
||||
# include "Vt_dpi_context_noopt__Dpi.h"
|
||||
# else
|
||||
# include "Vt_dpi_context__Dpi.h"
|
||||
# endif
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(VCS)
|
||||
# include "../vc_hdrs.h"
|
||||
#elif defined(CADENCE)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//*************************************************************************
|
||||
#include "Vt_dpi_decl__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
|
||||
char* func(const char* arg) {
|
||||
static char str[] = "abc";
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR)
|
||||
# include "Vt_dpi_display__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(VCS)
|
||||
# include "../vc_hdrs.h"
|
||||
#elif defined(CADENCE)
|
||||
|
||||
@@ -19,11 +19,7 @@
|
||||
//======================================================================
|
||||
|
||||
#if defined(VERILATOR)
|
||||
#ifdef T_DPI_EXPORT_NOOPT
|
||||
#include "Vt_dpi_export_noopt__Dpi.h"
|
||||
#else
|
||||
#include "Vt_dpi_export__Dpi.h"
|
||||
#endif
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(VCS)
|
||||
#include "../vc_hdrs.h"
|
||||
#elif defined(CADENCE)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
//======================================================================
|
||||
|
||||
#include "Vt_dpi_export_context2_bad__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
|
||||
//======================================================================
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR)
|
||||
# include "Vt_dpi_export_context_bad__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(VCS)
|
||||
# include "../vc_hdrs.h"
|
||||
#elif defined(CADENCE)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
//======================================================================
|
||||
|
||||
#include "Vt_dpi_export_scope_bad__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
|
||||
#ifdef NEED_EXTERNS
|
||||
extern "C" {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
//======================================================================
|
||||
|
||||
#include "Vt_dpi_export_scope_flat__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
|
||||
#ifdef NEED_EXTERNS
|
||||
extern "C" {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR)
|
||||
# include "Vt_dpi_if_cond__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(VCS)
|
||||
# include "../vc_hdrs.h"
|
||||
#elif defined(NC)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR)
|
||||
# include "Vt_dpi_imp_gen__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(VCS)
|
||||
# include "../vc_hdrs.h"
|
||||
#elif defined(CADENCE)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR)
|
||||
# include "Vt_dpi_import__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(VCS)
|
||||
# include "../vc_hdrs.h"
|
||||
#elif defined(CADENCE)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
// Include the Verilator-generated DPI header so the C prototype matches
|
||||
// the SystemVerilog import expectations.
|
||||
#include "Vt_dpi_inline_new__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR)
|
||||
# include "Vt_dpi_lib__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(VCS)
|
||||
# include "../vc_hdrs.h"
|
||||
#elif defined(NC)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR)
|
||||
# include "Vt_dpi_open__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(VCS)
|
||||
# include "../vc_hdrs.h"
|
||||
#elif defined(NC)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR)
|
||||
# include "Vt_dpi_open_elem__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(VCS)
|
||||
# include "../vc_hdrs.h"
|
||||
#elif defined(NC)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR)
|
||||
# include "Vt_dpi_open_oob_bad__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#else
|
||||
# error "Unknown simulator for DPI test"
|
||||
#endif
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR) // Verilator
|
||||
# include "Vt_dpi_open_query__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(VCS) // VCS
|
||||
# include "../vc_hdrs.h"
|
||||
#elif defined(NCSC) // NC
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR)
|
||||
# include "Vt_dpi_open_vecval__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(VCS)
|
||||
# include "../vc_hdrs.h"
|
||||
#elif defined(NC)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR)
|
||||
# include "Vt_dpi_openfirst__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(VCS)
|
||||
# include "../vc_hdrs.h"
|
||||
#elif defined(NC)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//======================================================================
|
||||
|
||||
#ifdef VERILATOR
|
||||
#include "Vt_dpi_qw__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#else
|
||||
extern "C" {
|
||||
extern void set_value(const svBitVecVal* v);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR) // Verilator
|
||||
# include "Vt_dpi_result_type__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
typedef long long sv_longint_t;
|
||||
typedef unsigned long long sv_longint_unsigned_t;
|
||||
# define NO_SHORTREAL
|
||||
|
||||
@@ -18,13 +18,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR)
|
||||
# if defined(T_DPI_SHORTCIRCUIT)
|
||||
# include "Vt_dpi_shortcircuit__Dpi.h"
|
||||
# elif defined(T_DPI_SHORTCIRCUIT2)
|
||||
# include "Vt_dpi_shortcircuit2__Dpi.h"
|
||||
# else
|
||||
# error "Unknown test"
|
||||
# endif
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(VCS)
|
||||
# include "../vc_hdrs.h"
|
||||
#elif defined(CADENCE)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR)
|
||||
# include "Vt_dpi_string__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(VCS)
|
||||
# include "../vc_hdrs.h"
|
||||
#elif defined(CADENCE)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR)
|
||||
# include "Vt_dpi_sys__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(VCS)
|
||||
# include "../vc_hdrs.h"
|
||||
#elif defined(CADENCE)
|
||||
|
||||
@@ -20,11 +20,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR)
|
||||
# ifdef T_DPI_THREADS_COLLIDE
|
||||
# include "Vt_dpi_threads_collide__Dpi.h"
|
||||
# else
|
||||
# include "Vt_dpi_threads__Dpi.h"
|
||||
# endif
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(VCS)
|
||||
# include "../vc_hdrs.h"
|
||||
#elif defined(CADENCE)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR)
|
||||
# include "Vt_dpi_vams__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(VCS)
|
||||
# include "../vc_hdrs.h"
|
||||
#elif defined(CADENCE)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR)
|
||||
# include "Vt_embed1__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(VCS)
|
||||
# include "../vc_hdrs.h"
|
||||
#elif defined(CADENCE)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR)
|
||||
# include "Vt_flag_ldflags__Dpi.h"
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#else
|
||||
# error "Unknown simulator for DPI test"
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
//
|
||||
//*************************************************************************
|
||||
|
||||
#include "Vt_flag_lib_dpi__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include "svdpi.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@@ -18,13 +18,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR)
|
||||
# ifdef T_FUNC_WIDE_OUT
|
||||
# include "Vt_func_wide_out__Dpi.h"
|
||||
# elif defined(T_FUNC_WIDE_OUT_NOINL)
|
||||
# include "Vt_func_wide_out_noinl__Dpi.h"
|
||||
# else
|
||||
# error "Unknown test"
|
||||
# endif
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(VCS)
|
||||
# include "../vc_hdrs.h"
|
||||
#else
|
||||
|
||||
@@ -15,4 +15,7 @@ test.compile()
|
||||
|
||||
test.execute()
|
||||
|
||||
# Hosts the no-DPI case for VM_PREFIX_INCLUDE_DPI; keep this design free of DPI and public
|
||||
test.file_grep_not(test.obj_dir + "/" + test.vm_prefix + ".mk", r'VM_PREFIX_INCLUDE_DPI')
|
||||
|
||||
test.passes()
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
//*************************************************************************
|
||||
|
||||
#include "Vt_opt_dead__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
|
||||
void dpii_Keep() {}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
//*************************************************************************
|
||||
|
||||
#include "Vt_opt_lift_expr__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include "svdpi.h"
|
||||
|
||||
svLogic impure_0() { return sv_0; }
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
//*************************************************************************
|
||||
|
||||
#include <Vt_order_dpi_export_1.h>
|
||||
#include <Vt_order_dpi_export_1__Dpi.h>
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include <svdpi.h>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
//*************************************************************************
|
||||
|
||||
#include <Vt_order_dpi_export_2.h>
|
||||
#include <Vt_order_dpi_export_2__Dpi.h>
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include <svdpi.h>
|
||||
|
||||
void toggle_other_clk(svBit val) { set_other_clk(val); }
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
//*************************************************************************
|
||||
|
||||
#include <Vt_order_dpi_export_3.h>
|
||||
#include <Vt_order_dpi_export_3__Dpi.h>
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include <svdpi.h>
|
||||
|
||||
void toggle_other_clk(svBit val) { set_other_clk(val); }
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
//*************************************************************************
|
||||
|
||||
#include <Vt_order_dpi_export_4.h>
|
||||
#include <Vt_order_dpi_export_4__Dpi.h>
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include <svdpi.h>
|
||||
|
||||
void toggle_other_clk(svBit val) { set_other_clk(val); }
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
//*************************************************************************
|
||||
|
||||
#include <Vt_order_dpi_export_5.h>
|
||||
#include <Vt_order_dpi_export_5__Dpi.h>
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include <svdpi.h>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
//*************************************************************************
|
||||
|
||||
#include <Vt_order_dpi_export_6.h>
|
||||
#include <Vt_order_dpi_export_6__Dpi.h>
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include <svdpi.h>
|
||||
|
||||
void toggle_other_clk(svBit val) { set_other_clk(val); }
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
//*************************************************************************
|
||||
|
||||
#include <Vt_order_dpi_export_7.h>
|
||||
#include <Vt_order_dpi_export_7__Dpi.h>
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include <svdpi.h>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
//*************************************************************************
|
||||
|
||||
#include <Vt_order_dpi_export_8__Dpi.h>
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include <svdpi.h>
|
||||
|
||||
void call_set_x(svBit val) { set_x(val); }
|
||||
|
||||
@@ -18,11 +18,7 @@
|
||||
|
||||
// clang-format off
|
||||
#if defined(VERILATOR)
|
||||
# ifdef T_PROTECT_IDS_KEY
|
||||
# include "Vt_protect_ids_key__Dpi.h"
|
||||
# else
|
||||
# include "Vt_protect_ids__Dpi.h"
|
||||
# endif
|
||||
# include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(VCS)
|
||||
# include "../vc_hdrs.h"
|
||||
#elif defined(CADENCE)
|
||||
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env python3
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms of either the GNU Lesser General Public License Version 3
|
||||
# or the Perl Artistic License Version 2.0.
|
||||
# SPDX-FileCopyrightText: 2026 Wilson Snyder
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
import vltest_bootstrap
|
||||
|
||||
test.scenarios('vlt')
|
||||
test.top_filename = "t/t_dpi_decl.v"
|
||||
|
||||
test.compile(v_flags2=["t/t_dpi_decl.cpp"], verilator_make_gmake=False, verilator_make_cmake=True)
|
||||
|
||||
test.execute()
|
||||
|
||||
test.passes()
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "verilated_vpi.h"
|
||||
|
||||
#include "Vt_vpi_const_type.h"
|
||||
#include "Vt_vpi_const_type__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include "svdpi.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "verilated_vpi.h"
|
||||
|
||||
#include "Vt_vpi_escape.h"
|
||||
#include "Vt_vpi_escape__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include "svdpi.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "verilated_vpi.h"
|
||||
|
||||
#include "Vt_vpi_get.h"
|
||||
#include "Vt_vpi_get__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include "svdpi.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "verilated_vpi.h"
|
||||
|
||||
#include "Vt_vpi_memory.h"
|
||||
#include "Vt_vpi_memory__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include "svdpi.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "verilated_vpi.h"
|
||||
|
||||
#include "Vt_vpi_module.h"
|
||||
#include "Vt_vpi_module__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include "svdpi.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "verilated_vpi.h"
|
||||
|
||||
#include "Vt_vpi_module_empty.h"
|
||||
#include "Vt_vpi_module_empty__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include "svdpi.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "verilated_vpi.h"
|
||||
|
||||
#include "Vt_vpi_multidim.h"
|
||||
#include "Vt_vpi_multidim__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include "svdpi.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "verilated_vpi.h"
|
||||
|
||||
#include "Vt_vpi_package.h"
|
||||
#include "Vt_vpi_package__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include "svdpi.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#ifdef T_VPI_PARAM
|
||||
#include "Vt_vpi_param.h"
|
||||
#include "Vt_vpi_param__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#elif defined(T_VPI_PUBLIC_PARAMS)
|
||||
#include "Vt_vpi_public_params.h"
|
||||
#else
|
||||
|
||||
@@ -22,15 +22,7 @@
|
||||
#include "verilated_vpi.h"
|
||||
|
||||
#include VM_PREFIX_INCLUDE
|
||||
#ifdef T_VPI_PUBLIC_DEPTH
|
||||
#include "Vt_vpi_public_depth__Dpi.h"
|
||||
#elif defined(T_VPI_PUBLIC_DEPTH_OFF)
|
||||
#include "Vt_vpi_public_depth_off__Dpi.h"
|
||||
#elif defined(T_VPI_PUBLIC_OFF)
|
||||
#include "Vt_vpi_public_off__Dpi.h"
|
||||
#else
|
||||
#error "Bad test"
|
||||
#endif
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include "svdpi.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <cstdio>
|
||||
//#include "verilated.h"
|
||||
|
||||
#include "Vt_vpi_release_dup_bad__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
|
||||
//======================================================================
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "verilated_vpi.h"
|
||||
|
||||
#include "Vt_vpi_time_cb.h"
|
||||
#include "Vt_vpi_time_cb__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include "svdpi.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "verilated_vcd_c.h"
|
||||
|
||||
#include "Vt_vpi_unimpl.h"
|
||||
#include "Vt_vpi_unimpl__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include "svdpi.h"
|
||||
// No verilated_vpi.h, make sure can link without it
|
||||
|
||||
|
||||
@@ -20,19 +20,8 @@
|
||||
#include "verilated_vcd_c.h"
|
||||
#include "verilated_vpi.h"
|
||||
|
||||
#ifdef T_VPI_VAR2
|
||||
#include "Vt_vpi_var2.h"
|
||||
#include "Vt_vpi_var2__Dpi.h"
|
||||
#elif defined(T_VPI_VAR3)
|
||||
#include "Vt_vpi_var3.h"
|
||||
#include "Vt_vpi_var3__Dpi.h"
|
||||
#elif defined(T_VPI_FORCEABLE_VAR)
|
||||
#include "Vt_vpi_forceable_var.h"
|
||||
#include "Vt_vpi_forceable_var__Dpi.h"
|
||||
#else
|
||||
#include "Vt_vpi_var.h"
|
||||
#include "Vt_vpi_var__Dpi.h"
|
||||
#endif
|
||||
#include VM_PREFIX_INCLUDE
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
|
||||
#include "svdpi.h"
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "verilated_vpi.h"
|
||||
|
||||
#include "Vt_vpi_zero_time_cb.h"
|
||||
#include "Vt_vpi_zero_time_cb__Dpi.h"
|
||||
#include VM_PREFIX_INCLUDE_DPI
|
||||
#include "svdpi.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
@@ -31,8 +31,7 @@ def run(test, *, verilator_flags2=()):
|
||||
]
|
||||
flags.extend(verilator_flags2)
|
||||
|
||||
cflags = (f'-DVM_PREFIX={test.vm_prefix} '
|
||||
f"-DVM_PREFIX_INCLUDE='<{test.vm_prefix}.h>' ")
|
||||
cflags = f'-DVM_PREFIX={test.vm_prefix} '
|
||||
|
||||
# Compile and run without lib-create
|
||||
test.compile(verilator_flags2=[test.pli_filename] + flags +
|
||||
|
||||
@@ -468,6 +468,7 @@ function(verilate TARGET)
|
||||
json_get_list(JOPTIONS_LDFLAGS "${MANIFEST}" options ldflags)
|
||||
json_get_bool(JOPTIONS_SYSTEM_C "${MANIFEST}" options system_c)
|
||||
json_get_bool(JOPTIONS_COVERAGE "${MANIFEST}" options coverage)
|
||||
json_get_bool(JOPTIONS_DPI "${MANIFEST}" options dpi)
|
||||
json_get_bool(JOPTIONS_USE_TIMING "${MANIFEST}" options use_timing)
|
||||
json_get_int(JOPTIONS_THREADS "${MANIFEST}" options threads)
|
||||
json_get_bool(JOPTIONS_TRACE_FST "${MANIFEST}" options trace_fst)
|
||||
@@ -505,6 +506,8 @@ function(verilate TARGET)
|
||||
"set(${VERILATE_PREFIX}_SC ${JOPTIONS_SYSTEM_C})\n"
|
||||
"# Coverage output mode? 0/1 (from --coverage)\n"
|
||||
"set(${VERILATE_PREFIX}_COVERAGE ${JOPTIONS_COVERAGE})\n"
|
||||
"# DPI generated? 0/1\n"
|
||||
"set(${VERILATE_PREFIX}_DPI ${JOPTIONS_DPI})\n"
|
||||
"# Timing mode? 0/1\n"
|
||||
"set(${VERILATE_PREFIX}_TIMING ${JOPTIONS_USE_TIMING})\n"
|
||||
"# Threaded output mode? 1/N threads (from --threads)\n"
|
||||
@@ -741,6 +744,23 @@ function(verilate TARGET)
|
||||
VM_TRACE_FST=$<BOOL:$<TARGET_PROPERTY:VERILATOR_TRACE_FST>>
|
||||
VM_TRACE_SAIF=$<BOOL:$<TARGET_PROPERTY:VERILATOR_TRACE_SAIF>>
|
||||
)
|
||||
# verilate() may be called repeatedly on one target, each call with its own
|
||||
# prefix, so only the first model defines these; redefining them would warn
|
||||
# (error under -Werror) on every translation unit of the target
|
||||
get_target_property(VERILATE_DEFINITIONS ${TARGET} COMPILE_DEFINITIONS)
|
||||
if(NOT VERILATE_DEFINITIONS MATCHES "(^|;)VM_PREFIX_INCLUDE=")
|
||||
target_compile_definitions(
|
||||
${TARGET}
|
||||
PRIVATE "VM_PREFIX_INCLUDE=<${VERILATE_PREFIX}.h>"
|
||||
)
|
||||
if(${VERILATE_PREFIX}_DPI)
|
||||
# Left undefined when the design has no DPI, so misuse fails at compile time
|
||||
target_compile_definitions(
|
||||
${TARGET}
|
||||
PRIVATE "VM_PREFIX_INCLUDE_DPI=<${VERILATE_PREFIX}__Dpi.h>"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries(${TARGET} PUBLIC ${${VERILATE_PREFIX}_USER_LDLIBS})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user