60 lines
1.6 KiB
Makefile
60 lines
1.6 KiB
Makefile
GENHTML = genhtml
|
|
|
|
VERILATOR = verilator
|
|
VERILATOR_COVERAGE = verilator_coverage
|
|
|
|
VERILATOR_FLAGS =
|
|
# Generate C++ in executable form
|
|
VERILATOR_FLAGS += -cc --exe
|
|
# Generate makefile dependencies (not shown as complicates the Makefile)
|
|
VERILATOR_FLAGS += -MMD
|
|
# Optimize
|
|
VERILATOR_FLAGS += -Os -x-assign 0
|
|
# Warn abount lint issues; may not want this on less solid designs
|
|
VERILATOR_FLAGS += -Wall
|
|
# Make waveforms
|
|
VERILATOR_FLAGS += --trace
|
|
# Check SystemVerilog assertions
|
|
VERILATOR_FLAGS += --assert
|
|
# Generate coverage analysis
|
|
VERILATOR_FLAGS += --coverage
|
|
# Run make to compile model, with as many CPUs as are free
|
|
VERILATOR_FLAGS += --build -j
|
|
|
|
# Get rid of annoying warnings
|
|
VERILATOR_FLAGS += -Wno-UNOPT -Wno-UNOPTFLAT -Wno-BLKSEQ
|
|
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
|
|
|
|
SOURCE = $(wildcard ../model/*.v ../model/*.sv ../src/*.v ../src/*.sv ../src/**/*.v ../src/**/*.sv)
|
|
INCLUDE = $(addprefix -I, $(dir $(wildcard ../src/*/. ../src/**/*/.)))
|
|
# Input files for Verilator
|
|
VERILATOR_INPUT = $(INCLUDE) $(SOURCE) -top mycpu_top sim_main.cpp
|
|
|
|
default: run
|
|
|
|
test:
|
|
echo $(INCLUDE)
|
|
|
|
verilate:
|
|
$(VERILATOR) $(VERILATOR_FLAGS) $(VERILATOR_INPUT)
|
|
|
|
run: verilate
|
|
@rm -rf logs
|
|
@mkdir -p logs
|
|
obj_dir/Vmycpu_top
|
|
|
|
coverage: verilate
|
|
@rm -rf logs/annotated
|
|
$(VERILATOR_COVERAGE) $(VERILATOR_COV_FLAGS)
|
|
|
|
clean:
|
|
-rm -rf obj_dir logs *.log *.dmp *.vpd core
|