2024-04-17 01:54:11 +00:00
|
|
|
SHELL := /bin/bash
|
2024-04-12 03:02:20 +00:00
|
|
|
.PHONY: profile run questa clean
|
|
|
|
|
2024-04-17 01:54:11 +00:00
|
|
|
# verilator configurations
|
2024-04-12 03:02:20 +00:00
|
|
|
OPT=
|
|
|
|
PARAMS?=-DVERILATOR=1 --no-trace-top
|
|
|
|
NONPROF?=--stats
|
|
|
|
WALLYCONF?=rv64gc
|
|
|
|
TEST?=arch64i
|
|
|
|
|
2024-04-17 01:54:11 +00:00
|
|
|
# constants
|
2024-04-17 16:52:54 +00:00
|
|
|
# assume WALLY variable is correctly configured in the shell environment
|
2024-04-17 01:54:11 +00:00
|
|
|
WORKING_DIR=${WALLY}/sim/verilator
|
|
|
|
TARGET=$(WORKING_DIR)/target
|
2024-04-17 16:52:54 +00:00
|
|
|
# INCLUDE_PATH are pathes that Verilator should search for files it needs
|
2024-04-17 01:54:11 +00:00
|
|
|
INCLUDE_PATH="-I${WALLY}/config/shared" "-I${WALLY}/config/$(WALLYCONF)" "-I${WALLY}/config/deriv/$(WALLYCONF)"
|
2024-04-17 16:52:54 +00:00
|
|
|
# SOURCES are source files
|
|
|
|
SOURCES=${WALLY}/src/cvw.sv ${WALLY}/testbench/testbench.sv ${WALLY}/testbench/common/*.sv ${WALLY}/src/*/*.sv ${WALLY}/src/*/*/*.sv
|
|
|
|
# DEPENDENCIES are configuration files and source files, which leads to recompilation of executables
|
|
|
|
DEPENDENCIES=${WALLY}/config/shared/*.vh $(SOURCES)
|
2024-04-17 01:54:11 +00:00
|
|
|
|
2024-04-12 03:02:20 +00:00
|
|
|
default: run
|
|
|
|
|
|
|
|
profile: obj_dir_profiling/Vtestbench_$(WALLYCONF)
|
|
|
|
$(WORKING_DIR)/obj_dir_profiling/Vtestbench_$(WALLYCONF) +TEST=$(TEST)
|
|
|
|
mv gmon.out gmon_$(WALLYCONF).out
|
|
|
|
gprof $(WORKING_DIR)/obj_dir_profiling/Vtestbench_$(WALLYCONF) gmon_$(WALLYCONF).out > gmon_$(WALLYCONF).log
|
|
|
|
verilator_profcfunc gmon_$(WALLYCONF).log > gmon_$(WALLYCONF).log2
|
2024-04-12 03:16:13 +00:00
|
|
|
mkdir -p $(WORKING_DIR)/logs_profiling
|
|
|
|
mv gmon_$(WALLYCONF)* $(WORKING_DIR)/logs_profiling
|
|
|
|
echo "Please check $(WORKING_DIR)/logs_profiling/gmon_$(WALLYCONF)* for logs and output files."
|
2024-04-12 03:02:20 +00:00
|
|
|
|
|
|
|
run: obj_dir_non_profiling/Vtestbench_$(WALLYCONF)
|
2024-04-12 03:16:13 +00:00
|
|
|
mkdir -p $(WORKING_DIR)/logs
|
|
|
|
time $(WORKING_DIR)/obj_dir_non_profiling/Vtestbench_$(WALLYCONF) +TEST=$(TEST) 2>&1 > $(WORKING_DIR)/logs/$(WALLYCONF)_$(TEST).log
|
|
|
|
echo "Please check $(WORKING_DIR)/logs/$(WALLYCONF)_$(TEST).log for logs and output files."
|
2024-04-12 03:02:20 +00:00
|
|
|
|
2024-04-17 01:54:11 +00:00
|
|
|
obj_dir_non_profiling/Vtestbench_$(WALLYCONF): $(DEPENDENCIES)
|
2024-04-12 03:02:20 +00:00
|
|
|
mkdir -p obj_dir_non_profiling
|
|
|
|
time verilator \
|
|
|
|
--Mdir obj_dir_non_profiling -o Vtestbench_$(WALLYCONF) \
|
2024-04-12 21:59:04 +00:00
|
|
|
-cc --binary \
|
2024-04-12 03:02:20 +00:00
|
|
|
$(OPT) $(PARAMS) $(NONPROF) \
|
2024-04-12 21:59:04 +00:00
|
|
|
--timescale "1ns/1ns" --timing --top-module testbench --relative-includes \
|
2024-04-17 01:54:11 +00:00
|
|
|
$(INCLUDE_PATH) \
|
2024-04-12 21:59:04 +00:00
|
|
|
wrapper.c \
|
2024-04-17 16:52:54 +00:00
|
|
|
$(SOURCES)
|
2024-04-12 03:02:20 +00:00
|
|
|
|
2024-04-17 01:54:11 +00:00
|
|
|
obj_dir_profiling/Vtestbench_$(WALLYCONF): $(DEPENDENCIES)
|
2024-04-12 03:02:20 +00:00
|
|
|
mkdir -p obj_dir_profiling
|
|
|
|
time verilator \
|
|
|
|
--Mdir obj_dir_profiling -o Vtestbench_$(WALLYCONF) \
|
2024-04-12 21:59:04 +00:00
|
|
|
-cc --binary \
|
2024-04-12 03:02:20 +00:00
|
|
|
--prof-cfuncs $(OPT) $(PARAMS) \
|
2024-04-12 21:59:04 +00:00
|
|
|
--timescale "1ns/1ns" --timing --top-module testbench --relative-includes \
|
2024-04-17 01:54:11 +00:00
|
|
|
$(INCLUDE_PATH) \
|
2024-04-12 21:59:04 +00:00
|
|
|
wrapper.c \
|
2024-04-17 16:52:54 +00:00
|
|
|
$(SOURCES)
|
2024-04-12 03:02:20 +00:00
|
|
|
|
|
|
|
questa:
|
|
|
|
time vsim -c -do "do ${WALLY}/sim/wally-batch.do $(WALLYCONF) $(TEST)"
|
|
|
|
|
|
|
|
clean:
|
2024-04-12 03:16:13 +00:00
|
|
|
rm -rf $(WORKING_DIR)/obj_dir_non_profiling $(WORKING_DIR)/obj_dir_profiling $(WORKING_DIR)/logs $(WORKING_DIR)/logs_profiling
|