Skip to content

Commit

Permalink
verilator: add support for Verilator 4.228 (#126)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ptomsich authored and poemonsense committed Feb 26, 2024
1 parent e11f1e1 commit 1b1cd4b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/test/csrc/verilator/emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion verilator.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1b1cd4b

Please sign in to comment.