From 1b1cd4b9d36478317a95d0c7776e876278e5ca94 Mon Sep 17 00:00:00 2001 From: Philipp Tomsich Date: Wed, 30 Aug 2023 06:31:05 -0700 Subject: [PATCH] verilator: add support for Verilator 4.228 (#126) We can check VERILATOR_VERSION_INTEGER from include/verilated_config.h for the numeric Verilator version (e.g., 4.228 becomes 4228000), so there is no need for our own symbolic macros (e.g., VERILATOR_4_210). This commit: - replaces the usage of our newly defined macros and directly tests the VERILATOR_VERSION_INTEGER macro - adds support for the VlThreadPool(...) signature used in 4.228 and newer of Verilator Signed-off-by: Philipp Tomsich --- src/test/csrc/verilator/emu.cpp | 4 +++- verilator.mk | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/test/csrc/verilator/emu.cpp b/src/test/csrc/verilator/emu.cpp index 138822614..1ec4edc1c 100644 --- a/src/test/csrc/verilator/emu.cpp +++ b/src/test/csrc/verilator/emu.cpp @@ -734,7 +734,9 @@ void Emulator::snapshot_load(const char *filename) { void Emulator::fork_child_init() { #if EMU_THREAD > 1 -#ifdef VERILATOR_4_210 +#if VERILATOR_VERSION_INTEGER >= 4228000 + dut_ptr->vlSymsp->__Vm_threadPoolp = new VlThreadPool(dut_ptr->contextp(), EMU_THREAD - 1); +#elif VERILATOR_VERSION_INTEGER >= 4210000 dut_ptr->vlSymsp->__Vm_threadPoolp = new VlThreadPool(dut_ptr->contextp(), EMU_THREAD - 1, 0); #else dut_ptr->__Vm_threadPoolp = new VlThreadPool(dut_ptr->contextp(), EMU_THREAD - 1, 0); diff --git a/verilator.mk b/verilator.mk index 91b9424bf..cd3ee795c 100644 --- a/verilator.mk +++ b/verilator.mk @@ -42,9 +42,10 @@ endif # Verilator version check VERILATOR_VER_CMD = verilator --version | cut -f2 -d' ' | tr -d '.' +VERILATOR_VERSION = $(shell `$(VERILATOR_VER_CMD)`) + VERILATOR_4_210 := $(shell expr `$(VERILATOR_VER_CMD)` \>= 4210) ifeq ($(VERILATOR_4_210),1) -EMU_CXXFLAGS += -DVERILATOR_4_210 VEXTRA_FLAGS += --instr-count-dpi 1 endif VERILATOR_5_000 := $(shell expr `$(VERILATOR_VER_CMD)` \>= 5000)