forked from librecores/riscv-sodor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
146 lines (104 loc) · 4.8 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#=======================================================================
# UCB Chisel C++ Simulator Generator: Makefile
#-----------------------------------------------------------------------
# Christopher Celio ([email protected])
#
# This makefile will generate a processor emulator from chisel code.
#
# Many different processors are provided. To switch between which processor(s)
# you would like to build, simply set the $(targets) variable as appropriate.
all_targets := rv32_1stage rv32_2stage rv32_3stage rv32_5stage rv32_ucode
targets := $(all_targets)
# To switch between which processor the Makefile would like to build, it will
# change the bash environment variable $MK_TARGET_PROC as follows:
# "export MK_TARGET_PROC=rv32_1stage"
# "export MK_TARGET_PROC=rv32_2stage"
# "export MK_TARGET_PROC=rv32_5stage"
# "export MK_TARGET_PROC=rv32_ucode"
RISCV := /opt/riscv
srcDir := $(abspath .)
buildIncludeDir := $(RISCV)/include
buildLibDir := $(RISCV)/lib
buildDir := $(abspath .)
# Paths to different source trees
chiseldir :=
CXX := g++
SBT := java -Xmx4096M -Xss8M -XX:MaxPermSize=128M -jar $(srcDir)/sbt-launch.jar $(SBT_FLAGS)
MK_TARGET_PROC?=rv32_1stage
prerequisites := $(if $(chiseldir),chisel-timestamp)
all: $(prerequisites) $(patsubst %,emulator/%/emulator,$(targets))
compile:
$(SBT) "project ${MK_TARGET_PROC}" compile
shell:
$(SBT) "project ${MK_TARGET_PROC}" shell
debug:
$(SBT) "project ${MK_TARGET_PROC}" "last run"
console:
$(SBT) "project ${MK_TARGET_PROC}" console
run-emulator: $(patsubst %,emulator/%/generated-src/timestamp,$(targets))
run-emulator-debug: $(patsubst %,emulator/%/generated-src-debug/timestamp,$(targets))
clean-tests:
make -C $(patsubst %,emulator/%,$(all_targets)) clean-tests
clean:
-find -type d -name target -exec rm -rf {} \+
for d in $(patsubst %,emulator/%,$(all_targets)) ; do \
make -C $$d clean ; \
done
$(RM) test-results.xml
reports: test-results.xml report-cpi report-bp report-stats
report-cpi: $(patsubst %,%-report-cpi,$(targets))
report-bp: $(patsubst %,%-report-bp,$(targets))
report-stats: $(patsubst %,%-report-stats,$(targets))
chisel-timestamp: $(wildcard $(chiseldir)/src/main/scala/*.scala)
cd $(chiseldir) && $(SBT) publish-local
date > $@
test-results.xml: $(wildcard $(patsubst %,emulator/%/output/*.out,$(targets)))
$(srcDir)/project/check $^ > test-results.xml
%-report-cpi:
-grep CPI emulator/$(patsubst %-report-cpi,%,$@)/output/*.out
%-report-bp:
-grep Acc emulator/$(patsubst %-report-bp,%,$@)/output/*.out
%-report-stats:
-grep "#" emulator/$(patsubst %-report-stats,%,$@)/output/*.out
emulator/%/generated-src/timestamp: emulator/%/emulator
@echo
@echo running basedir/Makefile: make run-emulator
@echo
make -C $(dir $<) run
date > $@
emulator/%/generated-src-debug/timestamp: emulator/%/emulator-debug
@echo
@echo running basedir/Makefile: make run-emulator-debug
@echo
make -C $(dir $<) run-debug
date > $@
emulator/%/emulator: $(prerequisites)
make -C $(dir $@)
emulator/%/emulator-debug: $(prerequisites)
make -C $(dir $@) emulator-debug
.PHONY: run-emulator target clean clean-tests
# Because we are using recursive makefiles and emulator is an actual file.
emulator/rv32_1stage/emulator: $(wildcard $(srcDir)/src/common/*.scala) \
$(wildcard $(srcDir)/src/rv32_1stage/*.scala)
emulator/rv32_2stage/emulator: $(wildcard $(srcDir)/src/common/*.scala) \
$(wildcard $(srcDir)/src/rv32_2stage/*.scala)
emulator/rv32_3stage/emulator: $(wildcard $(srcDir)/src/common/*.scala) \
$(wildcard $(srcDir)/src/rv32_3stage/*.scala)
emulator/rv32_5stage/emulator: $(wildcard $(srcDir)/src/common/*.scala) \
$(wildcard $(srcDir)/src/rv32_5stage/*.scala)
emulator/rv32_ucode/emulator: $(wildcard $(srcDir)/src/common/*.scala) \
$(wildcard $(srcDir)/src/rv32_ucode/*.scala)
emulator/rv32_1stage/emulator-debug: $(wildcard $(srcDir)/src/common/*.scala) \
$(wildcard $(srcDir)/src/rv32_1stage/*.scala)
emulator/rv32_2stage/emulator-debug: $(wildcard $(srcDir)/src/common/*.scala) \
$(wildcard $(srcDir)/src/rv32_2stage/*.scala)
emulator/rv32_3stage/emulator-debug: $(wildcard $(srcDir)/src/common/*.scala) \
$(wildcard $(srcDir)/src/rv32_3stage/*.scala)
emulator/rv32_5stage/emulator-debug: $(wildcard $(srcDir)/src/common/*.scala) \
$(wildcard $(srcDir)/src/rv32_5stage/*.scala)
emulator/rv32_ucode/emulator-debug: $(wildcard $(srcDir)/src/common/*.scala) \
$(wildcard $(srcDir)/src/rv32_ucode/*.scala)
.PHONY: jenkins-build
jenkins-build:
make clean run-emulator
make reports