Makefile 3.6 KB
Newer Older
L
Lemover 已提交
1 2
#***************************************************************************************
# Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences
Y
Yinan Xu 已提交
3
# Copyright (c) 2020-2021 Peng Cheng Laboratory
L
Lemover 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16
#
# XiangShan is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#          http://license.coscl.org.cn/MulanPSL2
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
#
# See the Mulan PSL v2 for more details.
#***************************************************************************************

17 18
TOP = XSTop
FPGATOP = top.TopMain
L
Lingrui98 已提交
19
BUILD_DIR = ./build
Z
Zihao Yu 已提交
20 21
TOP_V = $(BUILD_DIR)/$(TOP).v
SCALA_FILE = $(shell find ./src/main/scala -name '*.scala')
22
TEST_FILE = $(shell find ./src/test/scala -name '*.scala')
Z
Zihao Yu 已提交
23
MEM_GEN = ./scripts/vlsi_mem_gen
Z
Zihao Yu 已提交
24

25 26
SIMTOP  = top.SimTop
IMAGE  ?= temp
27
CONFIG ?= DefaultConfig
28
NUM_CORES ?= 1
Z
Zihao Yu 已提交
29

30 31 32 33 34 35 36 37
# co-simulation with DRAMsim3
ifeq ($(WITH_DRAMSIM3),1)
ifndef DRAMSIM3_HOME
$(error DRAMSIM3_HOME is not set)
endif
override SIM_ARGS += --with-dramsim3
endif

38 39 40 41 42
# emu for the release version
RELEASE_ARGS = --disable-all --remove-assert --fpga-platform
DEBUG_ARGS   = --enable-difftest
ifeq ($(RELEASE),1)
override SIM_ARGS += $(RELEASE_ARGS)
43 44
else
override SIM_ARGS += $(DEBUG_ARGS)
45 46
endif

Z
Zihao Yu 已提交
47 48 49
TIMELOG = $(BUILD_DIR)/time.log
TIME_CMD = time -a -o $(TIMELOG)

Z
Zihao Yu 已提交
50 51
.DEFAULT_GOAL = verilog

Z
Zihao Yu 已提交
52
help:
53
	mill XiangShan.test.runMain $(SIMTOP) --help
Z
Zihao Yu 已提交
54

Z
Zihao Yu 已提交
55 56
$(TOP_V): $(SCALA_FILE)
	mkdir -p $(@D)
57
	mill -i XiangShan.runMain $(FPGATOP) -td $(@D)                      \
58
		--config $(CONFIG) --full-stacktrace --output-file $(@F)    \
59
		--infer-rw --repl-seq-mem -c:$(FPGATOP):-o:$(@D)/$(@F).conf \
60 61
		--gen-mem-verilog full --num-cores $(NUM_CORES)             \
		$(RELEASE_ARGS)
62 63 64 65 66 67 68 69
	sed -i -e 's/_\(aw\|ar\|w\|r\|b\)_\(\|bits_\)/_\1/g' $@
	@git log -n 1 >> .__head__
	@git diff >> .__diff__
	@sed -i 's/^/\/\// ' .__head__
	@sed -i 's/^/\/\//' .__diff__
	@cat .__head__ .__diff__ $@ > .__out__
	@mv .__out__ $@
	@rm .__head__ .__diff__
70

Z
Zihao Yu 已提交
71 72
verilog: $(TOP_V)

73
SIM_TOP   = SimTop
Z
Zihao Yu 已提交
74
SIM_TOP_V = $(BUILD_DIR)/$(SIM_TOP).v
75
$(SIM_TOP_V): $(SCALA_FILE) $(TEST_FILE)
Z
Zihao Yu 已提交
76
	mkdir -p $(@D)
Z
Zihao Yu 已提交
77 78
	@echo "\n[mill] Generating Verilog files..." > $(TIMELOG)
	@date -R | tee -a $(TIMELOG)
79
	$(TIME_CMD) mill -i XiangShan.test.runMain $(SIMTOP) -td $(@D)      \
80
		--config $(CONFIG) --full-stacktrace --output-file $(@F)    \
81
		--infer-rw --repl-seq-mem -c:$(SIMTOP):-o:$(@D)/$(@F).conf  \
82
		--gen-mem-verilog full --num-cores $(NUM_CORES)             \
83
		$(SIM_ARGS)
84 85 86 87 88 89 90
	@git log -n 1 >> .__head__
	@git diff >> .__diff__
	@sed -i 's/^/\/\// ' .__head__
	@sed -i 's/^/\/\//' .__diff__
	@cat .__head__ .__diff__ $@ > .__out__
	@mv .__out__ $@
	@rm .__head__ .__diff__
91
	sed -i -e 's/$$fatal/xs_assert(`__LINE__)/g' $(SIM_TOP_V)
Z
Zihao Yu 已提交
92

93 94
sim-verilog: $(SIM_TOP_V)

95 96
clean:
	$(MAKE) -C ./difftest clean
Y
Yinan Xu 已提交
97
	rm -rf ./build
Z
Zihao Yu 已提交
98

L
linjiawei 已提交
99 100
init:
	git submodule update --init
J
Jiawei Lin 已提交
101
	cd rocket-chip && git submodule update --init api-config-chipsalliance hardfloat
L
linjiawei 已提交
102

103 104 105 106
bump:
	git submodule foreach "git fetch origin&&git checkout master&&git reset --hard origin/master"

bsp:
J
Jiawei Lin 已提交
107
	mill -i mill.bsp.BSP/install
108

109 110 111 112 113 114 115 116 117 118 119
# verilator simulation
emu:
	$(MAKE) -C ./difftest emu SIM_TOP=SimTop DESIGN_DIR=$(NOOP_HOME) NUM_CORES=$(NUM_CORES)

emu-run:
	$(MAKE) -C ./difftest emu-run SIM_TOP=SimTop DESIGN_DIR=$(NOOP_HOME) NUM_CORES=$(NUM_CORES)

# vcs simulation
simv:
	$(MAKE) -C ./difftest simv SIM_TOP=SimTop DESIGN_DIR=$(NOOP_HOME) NUM_CORES=$(NUM_CORES)

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