-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
108 lines (79 loc) · 2.66 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Copyright 2022 ETH Zurich and University of Bologna.
# Solderpad Hardware License, Version 0.51, see LICENSE for details.
# SPDX-License-Identifier: SHL-0.51
NB_CORES ?= 4
include ../common.mk
include ../rtl.mk
TESTS_DIR = ./testlist
TESTLIST := $(dir $(wildcard $(TESTS_DIR)/*/.))
# Check that SW is aligned with the NB_CORES setting
SW_NBCORES_DEF = "\# define NB_CORES $(NB_CORES)"
.PHONY: nb_cores_sw
nb_cores_sw:
@if ! grep -q $(SW_NBCORES_DEF) ./sw/sys/crt.S; then \
sed -i 's/\# define NB_CORES [0-9]\+/\# define NB_CORES $(NB_CORES)/' ./sw/sys/crt.S; \
fi
.PHONY: nb_cores
nb_cores: nb_cores_sw nb_cores_rtl
# Compile the SW
COMMON_TEST_SW = ./sw
COMMON_TEST_SW_SRC = $(COMMON_TEST_SW)/src
COMMON_TEST_SW_INC = $(COMMON_TEST_SW)/include
# more folders might be added in the future
VPATH = $(COMMON_TEST_SW_SRC)
# more folders might be added in the future
SW_INCLUDES = $(foreach d, $(COMMON_TEST_SW_INC), -I$d)
# more folders might be added in the future
SW_SRCS += $(shell find $(COMMON_TEST_SW_SRC) -name *.c -exec basename {} \;)
OBJDIR = ./objs
OBJS = $(SW_SRCS:%.c=$(OBJDIR)/%.o)
objs:
mkdir -p $@
libs:
mkdir -p $@
$(OBJDIR)/%.o: %.c objs
$(RV_GCC) $(SW_INCLUDES) -Werror -falign-functions=32 -falign-jumps=32 -c $< -o $@
#
libs/libintegr.a: $(OBJS) libs
$(RV_AR) -rcs $@ $(OBJS)
sw : libs/libintegr.a nb_cores
for d in $(TESTLIST); do $(MAKE) --no-print-directory -C $$d sw; done
sw_all : libs/libintegr.a nb_cores
for d in $(TESTLIST); do $(MAKE) --no-print-directory -C $$d all; done
# Run the test(s)
TEST ?= all
# run all the tests
ifeq ($(TEST), all)
all: sw rtl
@for d in $(TESTLIST); do \
echo "Running test $$d"; \
$(MAKE) --no-print-directory -C $$d all; \
done
# run a single test
else
all: sw rtl
@if [ -d $(TESTS_DIR)/$(TEST) ]; then \
echo "Running test $(TESTS_DIR)/$(TEST)"; \
$(MAKE) --no-print-directory -C $(TESTS_DIR)/$(TEST) all; \
else \
echo "$(TEST) doesn't exist"; \
false; \
fi
endif
# run failed or not-executed tests
rerun: sw rtl
for d in $(TESTLIST); do if [ -e $$d/$(TEST_REPORT) ] and [ -e $$d/$(VERIFICATION_REPORT) ]; then if grep -q FAIL $$d/$(TEST_REPORT) ; then make -C $$d all; fi; else make -C $$d all; fi; done
# coverage
$(MERGED_UCDB):
$(VCOVER) merge -out $(MERGED_UCDB) $(COVERAGE_DIR)
report_coverage: $(MERGED_UCDB)
$(VCOVER) report -details -codeAll -output $(COVERAGE_REPORT) $(MERGED_UCDB)
$(VCOVER) report -details -html -codeAll -output $(COVERAGE_REPORT_HTML) $(MERGED_UCDB)
# Cleanup
clean_sw:
rm -rf objs
rm -rf libs
clean_tests:
for d in $(TESTLIST); do make -C $$d clean_test; done
clean: clean_sw clean_rtl clean_tests
.PHONY: all sw sw_all rerun clean clean_sw report_coverage