/
Makefile
84 lines (63 loc) · 2.13 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
CHECK_RESULT = $(shell bash py-check.sh)
LD_LIBRARY_PATH=$(RISCV)/lib
base_dir = $(abspath ../..)
fpga_dir = $(abspath ..)
fpga_script_dir = $(fpga_dir)/scripts
build_dir = $(fpga_dir)/build
generated_dir = $(build_dir)/generated-src
CONFIG ?= LvNAConfigemu
NUMA_CONFIG ?=
SEED ?=
-include $(base_dir)/Makefrag
#--------------------------------------------------------------------
# Emulator generation
#--------------------------------------------------------------------
original_emu = $(base_dir)/emulator/emulator-$(PROJECT)-$(CONFIG)-debug
emu = $(build_dir)/emu
emu_bin_file = $(build_dir)/linux.bin
emu_gen_script = gen_bin.sh
emu_bin_hex_file = $(build_dir)/bin.txt
nohype_dtb = $(build_dir)/c0.dtb
nohype_dtb_hex_file = $(build_dir)/c0.dtb.txt
ifndef max_cycles
max_cycles=40000000
endif
ifdef HAS_MAX_CYCLES
OPT_MAX_CYCLE=-m $(max_cycles)
endif
$(fsdbfile): ../build/debug.vcd
vcd2fsdb ../build/debug.vcd
fsdbfile: $(fsdbfile)
verdi:
verdi -f ~/filelist.f -ssf debug.vcd.fsdb -nologo &
$(emu): $(original_emu)
source export.sh
echo $(original_emu)
ln -sf $< $@
$(original_emu):
$(MAKE) debug -C $(base_dir)/emulator CONFIG=$(CONFIG) \
generated_dir=$(generated_dir)
$(nohype_dtb): $(build_dir)/generated-src/freechips.rocketchip.system.$(CONFIG).dts
dtc $^ -O dtb -o emu.dtb
./gen_nohype_dtb emu.dtb $(build_dir) || echo "Please install python module 'pyfdt'"
rm emu.dtb
$(nohype_dtb_hex_file): $(nohype_dtb)
./gen_dtb_bin.sh $(build_dir)
$(emu_bin_hex_file): $(emu_bin_file)
mkdir -p $(@D)
bash $(emu_gen_script) $< $@
emu: $(emu)
ifdef DEBUG
DEBUG_ARGS = +jtag_rbb_enable=1 -r 4040
endif
run-emu: $(emu) $(emu_bin_hex_file) $(nohype_dtb_hex_file)
echo $(original_emu)
# cd $(dir $(emu)) && LD_LIBRARY_PATH=$(RISCV)/lib time $< $(DEBUG_ARGS) $(SEED) -v debug.vcd +verbose $(OPT_MAX_CYCLE) . 3>&1 1>&2 2>&3 \
cd $(dir $(emu)) && LD_LIBRARY_PATH=$(RISCV)/lib time $< $(DEBUG_ARGS) $(SEED) +verbose $(OPT_MAX_CYCLE) . 3>&1 1>&2 2>&3 \
| spike-dasm > $(dir $(emu))/emu.log
dtb-clean:
-rm -f $(build_dir)/c*.dtb{,.txt}
emu-clean:
-rm $(emu)
-$(MAKE) clean -C $(base_dir)/emulator
.PHONY: $(original_emu) emu run-emu emu-clean