cvw/sim/verilator/Makefile

74 lines
3.0 KiB
Makefile
Raw Normal View History

2024-04-20 21:12:55 +00:00
# Verilator Makefile for WALLY
# Kunlin Han, Rose Thompson, David Harris 2024
# SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
SHELL := /bin/bash
2024-04-12 03:02:20 +00:00
.PHONY: profile run questa clean
# verilator configurations
2024-04-12 03:02:20 +00:00
OPT=
PARAMS?=-DVERILATOR=1 --no-trace-top
NONPROF?=--stats
VERILATOR_DIR=${WALLY}/sim/verilator
2024-04-12 03:02:20 +00:00
SOURCE=${WALLY}/config/shared/*.vh ${WALLY}/config/${WALLYCONF} ${WALLY}/src/cvw.sv ${WALLY}/testbench/testbench.sv ${WALLY}/testbench/common/*.sv ${WALLY}/src/*/*.sv ${WALLY}/src/*/*/*.sv
2024-04-22 18:35:18 +00:00
2024-04-12 03:02:20 +00:00
WALLYCONF?=rv64gc
TEST?=arch64i
# constants
# assume WALLY variable is correctly configured in the shell environment
WORKING_DIR=${WALLY}/sim/verilator
TARGET=$(WORKING_DIR)/target
# INCLUDE_PATH are pathes that Verilator should search for files it needs
INCLUDE_PATH="-I${WALLY}/config/shared" "-I${WALLY}/config/$(WALLYCONF)" "-I${WALLY}/config/deriv/$(WALLYCONF)"
# 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-12 03:02:20 +00:00
default: run
profile: obj_dir_profiling/Vtestbench_$(WALLYCONF)
$(VERILATOR_DIR)/obj_dir_profiling/Vtestbench_$(WALLYCONF) +TEST=$(TEST)
2024-04-12 03:02:20 +00:00
mv gmon.out gmon_$(WALLYCONF).out
gprof $(VERILATOR_DIR)/obj_dir_profiling/Vtestbench_$(WALLYCONF) gmon_$(WALLYCONF).out > gmon_$(WALLYCONF).log
2024-04-12 03:02:20 +00:00
verilator_profcfunc gmon_$(WALLYCONF).log > gmon_$(WALLYCONF).log2
mkdir -p $(VERILATOR_DIR)/logs_profiling
mv gmon_$(WALLYCONF)* $(VERILATOR_DIR)/logs_profiling
echo "Please check $(VERILATOR_DIR)/logs_profiling/gmon_$(WALLYCONF)* for logs and output files."
2024-04-12 03:02:20 +00:00
run: wkdir/$(WALLYCONF)_$(TEST)/Vtestbench
mkdir -p $(VERILATOR_DIR)/logs
2024-04-22 19:16:06 +00:00
# wkdir/$(WALLYCONF)_$(TEST)/Vtestbench +TEST=$(TEST) 2>&1 > $(VERILATOR_DIR)/logs/$(WALLYCONF)_$(TEST).log
wkdir/$(WALLYCONF)_$(TEST)/Vtestbench +TEST=$(TEST)
# echo "Please check $(VERILATOR_DIR)/logs/$(WALLYCONF)_$(TEST).log for logs and output files."
2024-04-12 03:02:20 +00:00
2024-04-22 18:35:18 +00:00
wkdir/$(WALLYCONF)_$(TEST)/Vtestbench: $(SOURCE)
verilator \
--Mdir wkdir/$(WALLYCONF)_$(TEST) -o Vtestbench \
--binary \
2024-04-12 03:02:20 +00:00
$(OPT) $(PARAMS) $(NONPROF) \
--timescale "1ns/1ns" --timing --top-module testbench --relative-includes \
2024-04-12 03:02:20 +00:00
"-I${WALLY}/config/shared" "-I${WALLY}/config/$(WALLYCONF)" \
${WALLY}/sim/verilator/wrapper.c \
2024-04-12 03:02:20 +00:00
${WALLY}/src/cvw.sv ${WALLY}/testbench/testbench.sv ${WALLY}/testbench/common/*.sv ${WALLY}/src/*/*.sv ${WALLY}/src/*/*/*.sv
2024-04-22 18:35:18 +00:00
2024-04-12 03:02:20 +00:00
obj_dir_profiling/Vtestbench_$(WALLYCONF): $(DEPENDENCIES)
2024-04-12 03:02:20 +00:00
mkdir -p obj_dir_profiling
verilator \
2024-04-12 03:02:20 +00:00
--Mdir obj_dir_profiling -o Vtestbench_$(WALLYCONF) \
--binary \
2024-04-12 03:02:20 +00:00
--prof-cfuncs $(OPT) $(PARAMS) \
--timescale "1ns/1ns" --timing --top-module testbench --relative-includes \
$(INCLUDE_PATH) \
wrapper.c \
$(SOURCES)
2024-04-12 03:02:20 +00:00
questa:
vsim -c -do "do ${WALLY}/sim/wally-batch.do $(WALLYCONF) $(TEST)"
2024-04-12 03:02:20 +00:00
clean:
rm -rf $(VERILATOR_DIR)/wkdir $(VERILATOR_DIR)/obj_dir_profiling $(VERILATOR_DIR)/logs $(VERILATOR_DIR)/logs_profiling