diff --git a/Changes b/Changes index 2836a7462..a7c8590a2 100644 --- a/Changes +++ b/Changes @@ -17,6 +17,7 @@ Verilator 4.219 devel * Removed the deprecated "fl" attribute in XML output; use "loc" attribute instead. * Suppress WIDTH warning on negate using carry bit (#3295). [Peter Monsson] * Add trace dumpvars() call for selective runtime tracing (#3322). [Shunyao CAD] +* Add VERILATOR_VERSION_INTEGER for determining API (#3343). [Larry Doolittle] * Fix skipping public enum values with four-state values (#3303). * Fix $readmem file not found to be warning not error (#3310). [Alexander Grobman] * Fix class stringification on wide arrays (#3312). [Iru Cai] diff --git a/configure.ac b/configure.ac index 901a55757..2414ea278 100644 --- a/configure.ac +++ b/configure.ac @@ -22,6 +22,8 @@ AC_MSG_RESULT([configuring for $PACKAGE_STRING]) PACKAGE_VERSION_NUMBER=`AS_ECHO("$PACKAGE_VERSION") | sed 's/ .*//g'` AC_SUBST(PACKAGE_VERSION_NUMBER) AC_DEFINE_UNQUOTED([PACKAGE_VERSION_NUMBER_STRING],["$PACKAGE_VERSION_NUMBER"],[Package version as a number]) +VERILATOR_VERSION_INTEGER=`AS_ECHO("$PACKAGE_VERSION") | [sed 's/\([0-9]\)\.\([0-9][0-9][0-9]\) .*/\1\2000/g']` +AC_SUBST(VERILATOR_VERSION_INTEGER) # Ignore automake flags passed by Ubuntu builds AC_ARG_ENABLE([dependency-tracking], diff --git a/include/verilated.h b/include/verilated.h index 20bd0a71d..368be6bcc 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -33,6 +33,7 @@ // clang-format off #include "verilatedos.h" +#include "verilated_config.h" #if VM_SC # include "verilated_sc.h" // Get SYSTEMC_VERSION and time declarations #endif diff --git a/include/verilated_config.h.in b/include/verilated_config.h.in index 785e27a27..d64a0b9eb 100644 --- a/include/verilated_config.h.in +++ b/include/verilated_config.h.in @@ -20,6 +20,11 @@ // Autoconf substitutes this with the strings from AC_INIT. #define VERILATOR_PRODUCT "@PACKAGE_NAME@" -/// Verilator version name, e.g. "1.000 2000-01-01" +/// Verilator version name, e.g. "1.002 2000-01-01" // Autoconf substitutes this with the strings from AC_INIT. #define VERILATOR_VERSION "@PACKAGE_VERSION@" + +/// Verilator version number as integer +/// As major * 100000 + minor * 1000, e.g. 1002000 == 1.002 +// Autoconf substitutes this with the strings from AC_INIT. +#define VERILATOR_VERSION_INTEGER @VERILATOR_VERSION_INTEGER@ diff --git a/test_regress/t/t_wrapper_context.cpp b/test_regress/t/t_wrapper_context.cpp index 9e203673c..87332eb8c 100644 --- a/test_regress/t/t_wrapper_context.cpp +++ b/test_regress/t/t_wrapper_context.cpp @@ -15,6 +15,11 @@ #include VM_PREFIX_INCLUDE +// Check we properly define the version integer +#if VERILATOR_VERSION_INTEGER < 4219000 // Added in 4.219 +#error "VERILATOR_VERSION_INTEGER not set" +#endif + double sc_time_stamp() { return 0; } int errors = 0;