2022-07-27 15:07:16 +08:00
|
|
|
####################
|
|
|
|
# Program #
|
|
|
|
####################
|
|
|
|
VERILATOR = verilator
|
|
|
|
VERILATOR_COVERAGE = verilator_coverage
|
|
|
|
|
|
|
|
|
|
|
|
####################
|
|
|
|
# Flags #
|
|
|
|
####################
|
2024-01-10 22:02:49 +08:00
|
|
|
VERILATOR_BUILD_FLAGS += -cc --exe --timing
|
2022-07-27 15:07:16 +08:00
|
|
|
VERILATOR_BUILD_FLAGS += -MMD
|
2024-01-10 22:02:49 +08:00
|
|
|
VERILATOR_BUILD_FLAGS += -O3 --x-assign unique --x-initial unique
|
|
|
|
VERILATOR_BUILD_FLAGS += -Wall -Wpedantic
|
2022-07-29 18:48:58 +08:00
|
|
|
VERILATOR_BUILD_FLAGS += --trace --trace-fst --trace-params --trace-structs --trace-underscore
|
2022-07-27 15:07:16 +08:00
|
|
|
VERILATOR_BUILD_FLAGS += --assert
|
|
|
|
VERILATOR_BUILD_FLAGS += --coverage
|
2023-09-22 23:36:19 +08:00
|
|
|
#VERILATOR_BUILD_FLAGS += --report-unoptflat
|
2022-07-27 15:07:16 +08:00
|
|
|
|
|
|
|
VERILATOR_COV_FLAGS += --annotate logs/annotated
|
|
|
|
VERILATOR_COV_FLAGS += --annotate-min 1
|
|
|
|
VERILATOR_COV_FLAGS += --write-info logs/coverage.info
|
|
|
|
VERILATOR_COV_FLAGS += logs/coverage.dat
|
|
|
|
|
2023-09-22 23:36:19 +08:00
|
|
|
VERILATOR_FLAGS += -sv -DSIMULATION_VERILATOR -DSIMULATION_PC
|
|
|
|
|
2022-07-27 15:07:16 +08:00
|
|
|
####################
|
|
|
|
# Sources #
|
|
|
|
####################
|
2023-09-22 23:36:19 +08:00
|
|
|
SOURCE = ./config.vlt $(wildcard ./model/*.v ./model/*.sv ../src/*.v ../src/*.sv ../src/**/*.v ../src/**/*.sv)
|
|
|
|
INCLUDE = $(addprefix -I, $(dir $(wildcard ../src/*/. ../src/**/*/.)))
|
2022-07-27 15:07:16 +08:00
|
|
|
VERILATOR_INPUT = -top testbench_top sim_main.cpp
|
|
|
|
|
2023-09-22 23:36:19 +08:00
|
|
|
TB_FUNC_SOURCE = $(wildcard ../resources/tb.sv ../resources/func_test/*.v ../resources/func_test/**/*.v)
|
2022-07-27 15:07:16 +08:00
|
|
|
|
|
|
|
####################
|
|
|
|
# Targets #
|
|
|
|
####################
|
2022-08-04 11:53:11 +08:00
|
|
|
.phony: lint verilate func_soft tlb_soft build coverage run clean
|
2022-07-27 15:07:16 +08:00
|
|
|
|
2023-06-11 19:48:37 +08:00
|
|
|
default: build
|
2022-07-27 15:07:16 +08:00
|
|
|
|
|
|
|
lint:
|
|
|
|
$(VERILATOR) --lint-only $(VERILATOR_FLAGS) $(INCLUDE) $(SOURCE) -top mycpu_top
|
|
|
|
|
2022-08-02 11:29:23 +08:00
|
|
|
verilate:
|
2023-09-22 23:36:19 +08:00
|
|
|
$(VERILATOR) $(VERILATOR_FLAGS) $(VERILATOR_BUILD_FLAGS) $(INCLUDE) $(SOURCE) $(TB_FUNC_SOURCE) $(VERILATOR_INPUT)
|
2022-07-27 15:07:16 +08:00
|
|
|
|
2022-08-04 11:53:11 +08:00
|
|
|
func_soft:
|
2023-06-11 19:48:37 +08:00
|
|
|
cd ../resources/soft/func && make clean && make && cp obj/inst_ram.mif ../../../sim && cp obj/data_ram.mif ../../../sim && cd ../../../sim
|
2022-08-04 11:53:11 +08:00
|
|
|
|
2024-01-10 22:02:49 +08:00
|
|
|
perf_soft:
|
|
|
|
cd ../resources/soft/perf_func && make clean && make && cp obj/allbench/axi_ram.mif ../../../sim && cd ../../../sim && mv axi_ram.mif inst_ram.mif
|
|
|
|
|
2022-08-04 11:53:11 +08:00
|
|
|
tlb_soft:
|
2023-06-11 19:48:37 +08:00
|
|
|
cd ../resources/soft/tlb_func && make clean && make && cp obj/inst_ram.mif ../../../sim && cp obj/data_ram.mif ../../../sim && cd ../../../sim
|
2022-08-04 11:53:11 +08:00
|
|
|
|
|
|
|
build: verilate
|
2024-01-10 22:02:49 +08:00
|
|
|
make -C obj_dir -f Vtestbench_top.mk -j `nproc`
|
2022-08-02 11:29:23 +08:00
|
|
|
|
2022-08-04 11:53:11 +08:00
|
|
|
coverage:
|
2022-07-27 15:07:16 +08:00
|
|
|
@rm -rf logs/annotated
|
|
|
|
$(VERILATOR_COVERAGE) $(VERILATOR_COV_FLAGS)
|
|
|
|
|
2022-08-04 11:53:11 +08:00
|
|
|
run: build
|
2022-07-27 15:07:16 +08:00
|
|
|
@rm -rf logs
|
2022-07-29 17:44:11 +08:00
|
|
|
obj_dir/Vtestbench_top
|
2023-06-11 19:48:37 +08:00
|
|
|
# gtkwave logs/trace.fst
|
2022-07-27 15:07:16 +08:00
|
|
|
|
|
|
|
clean:
|
2022-07-29 23:25:14 +08:00
|
|
|
-rm -rf obj_dir logs
|
2023-09-22 23:36:19 +08:00
|
|
|
|