1#*************************************************************************************** 2# Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences 3# Copyright (c) 2020-2021 Peng Cheng Laboratory 4# 5# XiangShan is licensed under Mulan PSL v2. 6# You can use this software according to the terms and conditions of the Mulan PSL v2. 7# You may obtain a copy of Mulan PSL v2 at: 8# http://license.coscl.org.cn/MulanPSL2 9# 10# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 11# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 12# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 13# 14# See the Mulan PSL v2 for more details. 15#*************************************************************************************** 16 17TOP = XSTop 18FPGATOP = top.TopMain 19BUILD_DIR = ./build 20TOP_V = $(BUILD_DIR)/$(TOP).v 21SCALA_FILE = $(shell find ./src/main/scala -name '*.scala') 22TEST_FILE = $(shell find ./src/test/scala -name '*.scala') 23MEM_GEN = ./scripts/vlsi_mem_gen 24 25SIMTOP = top.SimTop 26IMAGE ?= temp 27CONFIG ?= DefaultConfig 28NUM_CORES ?= 1 29 30# co-simulation with DRAMsim3 31ifeq ($(WITH_DRAMSIM3),1) 32ifndef DRAMSIM3_HOME 33$(error DRAMSIM3_HOME is not set) 34endif 35override SIM_ARGS += --with-dramsim3 36endif 37 38TIMELOG = $(BUILD_DIR)/time.log 39TIME_CMD = time -a -o $(TIMELOG) 40 41.DEFAULT_GOAL = verilog 42 43help: 44 mill XiangShan.test.runMain $(SIMTOP) --help 45 46$(TOP_V): $(SCALA_FILE) 47 mkdir -p $(@D) 48 mill -i XiangShan.runMain $(FPGATOP) -td $(@D) \ 49 --config $(CONFIG) --full-stacktrace --output-file $(@F) \ 50 --disable-all --remove-assert \ 51 $(SIM_ARGS) \ 52 --num-cores $(NUM_CORES) 53 # $(MEM_GEN) $(@D)/$(@F).conf --tsmc28 --output_file $(@D)/tsmc28_sram.v > $(@D)/tsmc28_sram.v.conf 54 # $(MEM_GEN) $(@D)/$(@F).conf --output_file $(@D)/sim_sram.v 55 # sed -i -e 's/_\(aw\|ar\|w\|r\|b\)_\(\|bits_\)/_\1/g' $@ 56 # @git log -n 1 >> .__head__ 57 # @git diff >> .__diff__ 58 # @sed -i 's/^/\/\// ' .__head__ 59 # @sed -i 's/^/\/\//' .__diff__ 60 # @cat .__head__ .__diff__ $@ > .__out__ 61 # @mv .__out__ $@ 62 # @rm .__head__ .__diff__ 63 64deploy: build/top.zip 65 66 67build/top.zip: $(TOP_V) 68 @zip -r $@ $< $<.conf build/*.anno.json 69 70.PHONY: deploy build/top.zip 71 72verilog: $(TOP_V) 73 74SIM_TOP = SimTop 75SIM_TOP_V = $(BUILD_DIR)/$(SIM_TOP).v 76$(SIM_TOP_V): $(SCALA_FILE) $(TEST_FILE) 77 mkdir -p $(@D) 78 @echo "\n[mill] Generating Verilog files..." > $(TIMELOG) 79 @date -R | tee -a $(TIMELOG) 80 $(TIME_CMD) mill -i XiangShan.test.runMain $(SIMTOP) -td $(@D) \ 81 --config $(CONFIG) --full-stacktrace --output-file $(@F) \ 82 --num-cores $(NUM_CORES) $(SIM_ARGS) 83 #--infer-rw --repl-seq-mem -c:$(SIMTOP):-o:$(@D)/$(@F).conf \ 84 # $(MEM_GEN) $(@D)/$(@F).conf --output_file $(@D)/$(@F).sram.v 85 # @git log -n 1 >> .__head__ 86 # @git diff >> .__diff__ 87 # @sed -i 's/^/\/\// ' .__head__ 88 # @sed -i 's/^/\/\//' .__diff__ 89 #@cat .__head__ .__diff__ $@ $(@D)/$(@F).sram.v > .__out__ 90 # @mv .__out__ $@ 91 # @rm .__head__ .__diff__ 92 sed -i -e 's/$$fatal/xs_assert(`__LINE__)/g' $(SIM_TOP_V) 93 94sim-verilog: $(SIM_TOP_V) 95 96clean: 97 $(MAKE) -C ./difftest clean 98 rm -rf ./build 99 100init: 101 git submodule update --init 102 103bump: 104 git submodule foreach "git fetch origin&&git checkout master&&git reset --hard origin/master" 105 106bsp: 107 mill -i mill.bsp.BSP/install 108 109# verilator simulation 110emu: 111 $(MAKE) -C ./difftest emu SIM_TOP=SimTop DESIGN_DIR=$(NOOP_HOME) NUM_CORES=$(NUM_CORES) 112 113emu-run: 114 $(MAKE) -C ./difftest emu-run SIM_TOP=SimTop DESIGN_DIR=$(NOOP_HOME) NUM_CORES=$(NUM_CORES) 115 116# vcs simulation 117simv: 118 $(MAKE) -C ./difftest simv SIM_TOP=SimTop DESIGN_DIR=$(NOOP_HOME) NUM_CORES=$(NUM_CORES) 119 120.PHONY: verilog sim-verilog emu clean help init bump bsp $(REF_SO) 121 122