Skip to content

Environment Setup and Makefile Target Errors #2277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
41 changes: 38 additions & 3 deletions dv/cs_registers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,46 @@ LDFLAGS = -shared
CC = $(CXX)

# Add svdpi include
TOOLDIR = $(subst bin/$(TOOL),,$(shell which $(TOOL)))
# Check if VERILATOR_ROOT is set, use it first if available
ifdef VERILATOR_ROOT
VERILATOR_INCLUDE = $(VERILATOR_ROOT)/include
else
# Try to find Verilator installation directory
TOOLDIR = $(subst bin/$(TOOL),,$(shell which $(TOOL) 2>/dev/null))

# Define list of possible Verilator include paths to check
VERILATOR_INCLUDE_PATHS := \
$(TOOLDIR)share/verilator/include \
$(TOOLDIR)share/verilator/include/vltstd \
/usr/share/verilator/include \
/usr/share/verilator/include/vltstd \
/usr/local/share/verilator/include \
/usr/local/share/verilator/include/vltstd \
/opt/verilator/share/verilator/include \
/opt/verilator/share/verilator/include/vltstd \
$(HOME)/verilator/include \
$(HOME)/verilator/include/vltstd

# Find first valid include path
VERILATOR_INCLUDE := $(firstword $(foreach dir,$(VERILATOR_INCLUDE_PATHS),$(if $(wildcard $(dir)/svdpi.h),$(dir),)))

# If include path not found, provide error messages
ifeq ($(VERILATOR_INCLUDE),)
$(warning WARNING: Could not find Verilator include directory with svdpi.h)
$(warning Searched in: $(VERILATOR_INCLUDE_PATHS))
$(warning You can manually specify it using: make build-csr-test INCLUDES="-I/path/to/verilator/include -I./env -I./rst_driver -I./reg_driver -I./model")
$(warning Or set VERILATOR_ROOT environment variable pointing to your Verilator installation)
VERILATOR_INCLUDE = # Leave empty or set a default fallback path if applicable
endif
endif

# Add appropriate includes based on tool
ifeq ($(TOOL),vcs)
INCLUDES += -I$(TOOLDIR)include
else
INCLUDES += -I$(TOOLDIR)share/verilator/include/vltstd
else ifeq ($(TOOL),verilator)
ifdef VERILATOR_INCLUDE
INCLUDES += -I$(VERILATOR_INCLUDE) -I$(VERILATOR_INCLUDE)/vltstd
endif
endif

.PHONY: all clean
Expand Down
4 changes: 2 additions & 2 deletions dv/cs_registers/tb_cs_registers.core
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ targets:
- '--trace-structs'
- '--trace-params'
- '--trace-max-array 1024'
- '-CFLAGS "-std=c++14 -Wall -DTOPLEVEL_NAME=tb_cs_registers -DVM_TRACE_FMT_FST -g"'
- '-LDFLAGS "-pthread -lutil -lelf"'
- '-CFLAGS "-std=c++14 -Wall -DTOPLEVEL_NAME=tb_cs_registers -DVM_TRACE_FMT_FST -g -fexceptions -I$(shell verilator --getenv VERILATOR_ROOT)/include -I$(shell verilator --getenv VERILATOR_ROOT)/include/vltstd"'
- '-LDFLAGS "-pthread -lutil -lelf -fexceptions"'
- "-Wall"
- '-Wno-fatal' # Do not fail on (style) issues, only warn about them.
2 changes: 1 addition & 1 deletion examples/simple_system/ibex_simple_system.core
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ targets:
- '--trace-structs'
- '--trace-params'
- '--trace-max-array 1024'
- '-CFLAGS "-std=c++14 -Wall -DVM_TRACE_FMT_FST -DTOPLEVEL_NAME=ibex_simple_system -g"'
- '-CFLAGS "-std=c++14 -Wall -fexceptions -DVM_TRACE_FMT_FST -DTOPLEVEL_NAME=ibex_simple_system -g"'
Copy link
Contributor

Choose a reason for hiding this comment

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

Rupert mentioned that this flag should be enabled by default. Do you know why you need this explicitly? Do you still need this after you changed to the lowRISC toolchain?

- '-LDFLAGS "-pthread -lutil -lelf"'
- "-Wall"
# RAM primitives wider than 64bit (required for ECC) fail to build in
Expand Down
6 changes: 6 additions & 0 deletions vendor/lowrisc_ip/dv/verilator/memutil_dpi.core
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ targets:
vcs_options:
- '-CFLAGS -I../../src/lowrisc_dv_verilator_memutil_dpi_0/cpp'
- '-lelf'
verilator:
verilator_options:
- '-CFLAGS'
- '-fexceptions'
- '-LDFLAGS'
- '-fexceptions'