Makefile 4.1 KB
Newer Older
1 2
TOP = XSTop
FPGATOP = top.TopMain
L
Lingrui98 已提交
3
BUILD_DIR = ./build
Z
Zihao Yu 已提交
4 5
TOP_V = $(BUILD_DIR)/$(TOP).v
SCALA_FILE = $(shell find ./src/main/scala -name '*.scala')
6
TEST_FILE = $(shell find ./src/test/scala -name '*.scala')
Z
Zihao Yu 已提交
7
MEM_GEN = ./scripts/vlsi_mem_gen
Z
Zihao Yu 已提交
8

9
SIMTOP = top.SimTop
Z
Zihao Yu 已提交
10
IMAGE ?= temp
Z
Zihao Yu 已提交
11

12 13 14 15 16 17 18 19
# co-simulation with DRAMsim3
ifeq ($(WITH_DRAMSIM3),1)
ifndef DRAMSIM3_HOME
$(error DRAMSIM3_HOME is not set)
endif
override SIM_ARGS += --with-dramsim3
endif

Z
Zihao Yu 已提交
20 21 22
TIMELOG = $(BUILD_DIR)/time.log
TIME_CMD = time -a -o $(TIMELOG)

Y
Yinan Xu 已提交
23
# remote machine with more cores to speedup c++ build
24 25
REMOTE ?= localhost

Z
Zihao Yu 已提交
26 27
.DEFAULT_GOAL = verilog

Z
Zihao Yu 已提交
28
help:
29
	mill XiangShan.test.runMain $(SIMTOP) --help
Z
Zihao Yu 已提交
30

Z
Zihao Yu 已提交
31 32
$(TOP_V): $(SCALA_FILE)
	mkdir -p $(@D)
33
	mill XiangShan.test.runMain $(FPGATOP) -td $(@D) --full-stacktrace --output-file $(@F) --disable-all --remove-assert --infer-rw --repl-seq-mem -c:$(FPGATOP):-o:$(@D)/$(@F).conf $(SIM_ARGS)
34
	$(MEM_GEN) $(@D)/$(@F).conf --tsmc28 --output_file $(@D)/tsmc28_sram.v > $(@D)/tsmc28_sram.v.conf
35
	$(MEM_GEN) $(@D)/$(@F).conf --output_file $(@D)/sim_sram.v
Y
Yinan Xu 已提交
36
	# sed -i -e 's/_\(aw\|ar\|w\|r\|b\)_\(\|bits_\)/_\1/g' $@
37 38 39 40
	@git log -n 1 >> .__head__
	@git diff >> .__diff__
	@sed -i 's/^/\/\// ' .__head__
	@sed -i 's/^/\/\//' .__diff__
41
	@cat .__head__ .__diff__ $@ > .__out__
42 43
	@mv .__out__ $@
	@rm .__head__ .__diff__
44 45 46 47 48

deploy: build/top.zip


build/top.zip: $(TOP_V)
49 50 51 52
	@zip -r $@ $< $<.conf build/*.anno.json

.PHONY: deploy build/top.zip

Z
Zihao Yu 已提交
53 54
verilog: $(TOP_V)

55
SIM_TOP   = SimTop
Z
Zihao Yu 已提交
56
SIM_TOP_V = $(BUILD_DIR)/$(SIM_TOP).v
57
$(SIM_TOP_V): $(SCALA_FILE) $(TEST_FILE)
Z
Zihao Yu 已提交
58
	mkdir -p $(@D)
Z
Zihao Yu 已提交
59 60
	@echo "\n[mill] Generating Verilog files..." > $(TIMELOG)
	@date -R | tee -a $(TIMELOG)
61
	$(TIME_CMD) mill XiangShan.test.runMain $(SIMTOP) -td $(@D) --full-stacktrace --output-file $(@F) --infer-rw --repl-seq-mem -c:$(SIMTOP):-o:$(@D)/$(@F).conf $(SIM_ARGS)
62 63 64 65 66 67 68 69
	$(MEM_GEN) $(@D)/$(@F).conf --output_file $(@D)/$(@F).sram.v
	@git log -n 1 >> .__head__
	@git diff >> .__diff__
	@sed -i 's/^/\/\// ' .__head__
	@sed -i 's/^/\/\//' .__diff__
	@cat .__head__ .__diff__ $@ $(@D)/$(@F).sram.v > .__out__
	@mv .__out__ $@
	@rm .__head__ .__diff__
70
	sed -i -e 's/$$fatal/xs_assert(`__LINE__)/g' $(SIM_TOP_V)
Z
Zihao Yu 已提交
71

72 73
sim-verilog: $(SIM_TOP_V)

74 75
SIM_CSRC_DIR = $(abspath ./src/test/csrc/common)
SIM_CXXFILES = $(shell find $(SIM_CSRC_DIR) -name "*.cpp")
Z
Zihao Yu 已提交
76

77 78
DIFFTEST_CSRC_DIR = $(abspath ./src/test/csrc/difftest)
DIFFTEST_CXXFILES = $(shell find $(DIFFTEST_CSRC_DIR) -name "*.cpp")
79

80
SIM_VSRC = $(shell find ./src/test/vsrc/common -name "*.v" -or -name "*.sv")
Y
Yinan Xu 已提交
81

82 83
include verilator.mk
include vcs.mk
Z
Zihao Yu 已提交
84

Y
Yinan Xu 已提交
85 86 87
ifndef NEMU_HOME
$(error NEMU_HOME is not set)
endif
L
LinJiawei 已提交
88
REF_SO := $(NEMU_HOME)/build/riscv64-nemu-interpreter-so
Z
Zihao Yu 已提交
89
$(REF_SO):
90
	$(MAKE) -C $(NEMU_HOME) ISA=riscv64 SHARE=1
Z
Zihao Yu 已提交
91

92
SEED ?= $(shell shuf -i 1-10000 -n 1)
93

L
Lingrui98 已提交
94
VME_SOURCE ?= $(shell pwd)/build/$(TOP).v
95
VME_MODULES ?=
96

L
Lingrui98 已提交
97 98 99
#-----------------------timing scripts-------------------------
# run "make vme/tap help=1" to get help info

100 101 102 103
# extract verilog module from TopMain.v
# usage: make vme VME_MODULES=Roq
TIMING_SCRIPT_PATH = ./timingScripts
vme: $(TOP_V)
L
Lingrui98 已提交
104
	make -C $(TIMING_SCRIPT_PATH) vme
105 106 107 108 109

# get and sort timing analysis with total delay(start+end) and max delay(start or end)
# and print it out
tap:
	make -C $(TIMING_SCRIPT_PATH) tap
110 111 112 113 114

# usage: make phy_evaluate VME_MODULE=Roq REMOTE=100
phy_evaluate: vme
	scp -r ./build/extracted/* $(REMOTE):~/phy_evaluation/remote_run/rtl
	ssh -tt $(REMOTE) 'cd ~/phy_evaluation/remote_run && $(MAKE) evaluate DESIGN_NAME=$(VME_MODULE)'
115
	scp -r  $(REMOTE):~/phy_evaluation/remote_run/rpts ./build
116 117 118 119 120

# usage: make phy_evaluate_atc VME_MODULE=Roq REMOTE=100
phy_evaluate_atc: vme
	scp -r ./build/extracted/* $(REMOTE):~/phy_evaluation/remote_run/rtl
	ssh -tt $(REMOTE) 'cd ~/phy_evaluation/remote_run && $(MAKE) evaluate_atc DESIGN_NAME=$(VME_MODULE)'
121
	scp -r  $(REMOTE):~/phy_evaluation/remote_run/rpts ./build
122

Z
Zihao Yu 已提交
123
cache:
Z
Zihao Yu 已提交
124
	$(MAKE) emu IMAGE=Makefile
Z
Zihao Yu 已提交
125

L
LinJiawei 已提交
126 127 128
release-lock:
	ssh -tt $(REMOTE) 'rm -f $(LOCK)'

129
clean: vcs-clean
Y
Yinan Xu 已提交
130
	rm -rf ./build
Z
Zihao Yu 已提交
131

L
linjiawei 已提交
132 133 134
init:
	git submodule update --init

135 136 137 138 139
bump:
	git submodule foreach "git fetch origin&&git checkout master&&git reset --hard origin/master"

bsp:
	mill -i mill.contrib.BSP/install
140

141
.PHONY: verilog sim-verilog emu clean help init bump bsp $(REF_SO)
142