77 lines
2.1 KiB
Makefile
77 lines
2.1 KiB
Makefile
####################
|
|
# Program #
|
|
####################
|
|
VERILATOR = verilator
|
|
VERILATOR_COVERAGE = verilator_coverage
|
|
|
|
|
|
####################
|
|
# Flags #
|
|
####################
|
|
VERILATOR_BUILD_FLAGS =
|
|
# Generate C++ in executable form
|
|
VERILATOR_BUILD_FLAGS += -cc --exe
|
|
# Generate makefile dependencies (not shown as complicates the Makefile)
|
|
VERILATOR_BUILD_FLAGS += -MMD
|
|
# Optimize
|
|
VERILATOR_BUILD_FLAGS += -O3 -x-assign 0
|
|
# Warn abount lint issues; may not want this on less solid designs
|
|
VERILATOR_BUILD_FLAGS += -Wall
|
|
# Make waveforms
|
|
VERILATOR_BUILD_FLAGS += --trace
|
|
# Check SystemVerilog assertions
|
|
VERILATOR_BUILD_FLAGS += --assert
|
|
# Generate coverage analysis
|
|
VERILATOR_BUILD_FLAGS += --coverage
|
|
# Run make to compile model, with as many CPUs as are free
|
|
VERILATOR_BUILD_FLAGS += --build -j
|
|
|
|
# Simulation Defines
|
|
VERILATOR_FLAGS += -DSIMULATION_PC
|
|
|
|
# Create annotated source
|
|
VERILATOR_COV_FLAGS += --annotate logs/annotated
|
|
# A single coverage hit is considered good enough
|
|
VERILATOR_COV_FLAGS += --annotate-min 1
|
|
# Create LCOV info
|
|
VERILATOR_COV_FLAGS += --write-info logs/coverage.info
|
|
# Input file from Verilator
|
|
VERILATOR_COV_FLAGS += logs/coverage.dat
|
|
|
|
####################
|
|
# Sources #
|
|
####################
|
|
SOURCE = ./config.vlt $(wildcard ./model/*.v ./model/*.sv ../src/*.v ../src/*.sv ../src/**/*.v ../src/**/*.sv)
|
|
INCLUDE = $(addprefix -I, $(dir $(wildcard ../src/*/. ../src/**/*/.)))
|
|
VERILATOR_INPUT = -top testbench_top sim_main.cpp
|
|
|
|
FUNC_SOURCE = $(wildcard ../resources/tb.sv ../resources/func_test/*.v ../resources/func_test/**/*.v)
|
|
|
|
####################
|
|
# Targets #
|
|
####################
|
|
.phony: test func_test func_coverage run clean
|
|
|
|
default: run
|
|
|
|
test:
|
|
@echo $(SOURCE)
|
|
|
|
lint:
|
|
$(VERILATOR) --lint-only $(VERILATOR_FLAGS) $(INCLUDE) $(SOURCE) -top mycpu_top
|
|
|
|
func_test:
|
|
$(VERILATOR) $(VERILATOR_FLAGS) $(VERILATOR_BUILD_FLAGS) $(INCLUDE) $(SOURCE) $(FUNC_SOURCE) $(VERILATOR_INPUT)
|
|
|
|
func_coverage: func_test
|
|
@rm -rf logs/annotated
|
|
$(VERILATOR_COVERAGE) $(VERILATOR_COV_FLAGS)
|
|
|
|
run: func_test
|
|
@rm -rf logs
|
|
@mkdir -p logs
|
|
obj_dir/Vmycpu_top
|
|
|
|
clean:
|
|
-rm -rf obj_dir logs *.log *.dmp *.vpd core
|