Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions verilator.mk
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ ifneq ($(FUZZER_LIB), )
EMU = $(BUILD_DIR)/fuzzer
endif

# Verilator binary
VERILATOR ?= verilator

# Verilator version check
VERILATOR_VER_CMD = verilator --version 2> /dev/null | cut -f2 -d' ' | tr -d '.'
VERILATOR_VER_CMD = $(VERILATOR) --version 2> /dev/null | cut -f2 -d' ' | tr -d '.'
VERILATOR_4_210 := $(shell expr `$(VERILATOR_VER_CMD)` \>= 4210 2> /dev/null)
ifeq ($(VERILATOR_4_210),1)
EMU_CXXFLAGS += -DVERILATOR_4_210
Expand Down Expand Up @@ -136,7 +139,9 @@ endif
@mkdir -p $(@D)
@echo -e "\n[verilator] Generating C++ files..." >> $(TIMELOG)
@date -R | tee -a $(TIMELOG)
$(TIME_CMD) verilator $(VERILATOR_FLAGS) -Mdir $(@D) $^ $(EMU_DEPS)
$(TIME_CMD) $(VERILATOR) $(VERILATOR_FLAGS) --Mdir $(@D) $^ $(EMU_DEPS)
@sed -i -e 's/$(subst /,\/,$(NOOP_HOME))/$$(NOOP_HOME)/g' \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this

Copy link
Copy Markdown
Contributor Author

@forever043 forever043 Apr 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. fix wrong -Mdir to --Mdir (although it work now)
  2. use VERILATOR variable instead of verilator to support override outside
  3. change abs-path in generated VSimTop.mk to $(NOOP_HOME)/xxx, then we can move the build directory to other place by reset NOOP_HOME env

all these changes are pre-requirements of docker build support OpenXiangShan/PR#4538

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. change abs-path in generated VSimTop.mk to $(NOOP_HOME)/xxx, then we can move the build directory to other place by reset NOOP_HOME env

I see. But this would require that NOOP_HOME is always specified, even after verilator exits. I'm not sure if this is OK?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. change abs-path in generated VSimTop.mk to $(NOOP_HOME)/xxx, then we can move the build directory to other place by reset NOOP_HOME env

I see. But this would require that NOOP_HOME is always specified, even after verilator exits. I'm not sure if this is OK?

NOOP_HOME was not required, the abs-path was set as default in VSimTop.mk
e.g.:

NOOP_HOME ?= /xxx/yyy
default: $(NOOP_HOME)/emu
...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great

-e '/^default:/i\NOOP_HOME ?= $(subst /,\/,$(NOOP_HOME))\n' $@
ifneq ($(VERILATOR_5_000),1)
@sed -i 's/private/public/g' $(EMU_DIR)/VSimTop.h
@sed -i 's/const vlSymsp/vlSymsp/g' $(EMU_DIR)/VSimTop.h
Expand Down Expand Up @@ -217,6 +222,7 @@ endif # ifdef PGO_WORKLOAD
@sync -d $(BUILD_DIR) -d $(EMU_DIR)

emu: $(EMU)
emu-mk: $(EMU_MK)

COVERAGE_DATA ?= $(shell find $(BUILD_DIR) -maxdepth 1 -name "*.dat")
COVERAGE_DIR ?= $(DESIGN_DIR)/$(basename $(notdir $(COVERAGE_DATA)))
Expand Down