diff --git a/Changes b/Changes index dbc9eb50d..d9e6ad37c 100644 --- a/Changes +++ b/Changes @@ -18,6 +18,7 @@ Verilator 5.039 devel * Add SPECIFYIGN warning for specify constructs that were previously silently ignored. * Add enum base data type, and wire data type checking per IEEE. * Add error on missing forward declarations (#6206). [Alex Solomatnikov] +* Add `-DVERILATOR=1` definition to compiler flags when using verilated.mk. * Support member-level triggers for virtual interfaces (#5166) (#6148). [Yilou Wang] * Support randomization of scope variables with 'std::randomize()' (#5438) (#6185). [Yilou Wang] * Support disabling a fork in additional contexts (#5432 partial) (#6174) (#6183). [Ryszard Rozak, Antmicro Ltd.] diff --git a/docs/guide/exe_verilator.rst b/docs/guide/exe_verilator.rst index 3ed785b6d..1a1c3d802 100644 --- a/docs/guide/exe_verilator.rst +++ b/docs/guide/exe_verilator.rst @@ -32,7 +32,9 @@ Summary: makefile's VPATH the appropriate directory to find the file. See also :vlopt:`-CFLAGS` and :vlopt:`-LDFLAGS` options, which are - useful when the C++ files need special compiler flags. + useful when the C++ files need special compiler flags. The compiler + flags add by default `-DVERILATOR=1`, so an `#ifdef VERILATOR` may be + used to conditionally preprocess .cpp code for different simulators. .. option:: diff --git a/include/verilated.mk.in b/include/verilated.mk.in index a7a1f021c..fe1b081e1 100644 --- a/include/verilated.mk.in +++ b/include/verilated.mk.in @@ -84,6 +84,7 @@ VK_CPPFLAGS_ALWAYS += \ -MMD \ -I$(VERILATOR_ROOT)/include \ -I$(VERILATOR_ROOT)/include/vltstd \ + -DVERILATOR=1 \ -DVM_COVERAGE=$(VM_COVERAGE) \ -DVM_SC=$(VM_SC) \ -DVM_TIMING=$(VM_TIMING) \ diff --git a/test_regress/Makefile_obj b/test_regress/Makefile_obj index 81620d2f1..ac40f9146 100644 --- a/test_regress/Makefile_obj +++ b/test_regress/Makefile_obj @@ -22,9 +22,6 @@ VPATH += ../.. ####################################################################### -# Needed by DPI tests -CPPFLAGS += -DVERILATOR=1 - # Debugging CPPFLAGS += -DVL_DEBUG=1 # Assertions disabled as SystemC libraries are not clean