| 
									
										
										
										
											2021-03-07 20:57:27 +08:00
										 |  |  | TOP = XSTop | 
					
						
							|  |  |  | FPGATOP = top.TopMain | 
					
						
							| 
									
										
										
										
											2021-01-13 01:29:25 +08:00
										 |  |  | BUILD_DIR = ./build | 
					
						
							| 
									
										
										
										
											2019-02-06 22:33:01 +08:00
										 |  |  | TOP_V = $(BUILD_DIR)/$(TOP).v | 
					
						
							|  |  |  | SCALA_FILE = $(shell find ./src/main/scala -name '*.scala') | 
					
						
							| 
									
										
										
										
											2019-09-03 21:50:34 +08:00
										 |  |  | TEST_FILE = $(shell find ./src/test/scala -name '*.scala') | 
					
						
							| 
									
										
										
										
											2019-08-24 21:03:39 +08:00
										 |  |  | MEM_GEN = ./scripts/vlsi_mem_gen | 
					
						
							| 
									
										
										
										
											2019-02-06 22:33:01 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-19 21:19:20 +08:00
										 |  |  | SIMTOP = top.SimTop | 
					
						
							| 
									
										
										
										
											2019-05-10 14:18:21 +08:00
										 |  |  | IMAGE ?= temp | 
					
						
							| 
									
										
										
										
											2021-05-12 19:13:07 +08:00
										 |  |  | CONFIG ?= DefaultConfig | 
					
						
							| 
									
										
										
										
											2019-02-08 00:34:53 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-21 13:19:22 +08:00
										 |  |  | # co-simulation with DRAMsim3
 | 
					
						
							|  |  |  | ifeq ($(WITH_DRAMSIM3),1) | 
					
						
							|  |  |  | ifndef DRAMSIM3_HOME | 
					
						
							|  |  |  | $(error DRAMSIM3_HOME is not set) | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | override SIM_ARGS += --with-dramsim3 | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-23 15:07:41 +08:00
										 |  |  | TIMELOG = $(BUILD_DIR)/time.log | 
					
						
							|  |  |  | TIME_CMD = time -a -o $(TIMELOG) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-08 15:27:19 +08:00
										 |  |  | # remote machine with more cores to speedup c++ build
 | 
					
						
							| 
									
										
										
										
											2020-07-10 16:00:31 +08:00
										 |  |  | REMOTE ?= localhost | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-10 01:46:53 +08:00
										 |  |  | .DEFAULT_GOAL = verilog | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-24 22:28:16 +08:00
										 |  |  | help: | 
					
						
							| 
									
										
										
										
											2021-03-07 20:57:27 +08:00
										 |  |  | 	mill XiangShan.test.runMain $(SIMTOP) --help | 
					
						
							| 
									
										
										
										
											2019-02-24 22:28:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-06 22:33:01 +08:00
										 |  |  | $(TOP_V): $(SCALA_FILE) | 
					
						
							|  |  |  | 	mkdir -p $(@D) | 
					
						
							| 
									
										
										
										
											2021-05-12 19:13:07 +08:00
										 |  |  | 	mill XiangShan.test.runMain $(FPGATOP) -td $(@D) --config $(CONFIG) --full-stacktrace --output-file $(@F) --disable-all --remove-assert --infer-rw --repl-seq-mem -c:$(FPGATOP):-o:$(@D)/$(@F).conf $(SIM_ARGS) | 
					
						
							| 
									
										
										
										
											2021-01-27 16:54:12 +08:00
										 |  |  | 	$(MEM_GEN) $(@D)/$(@F).conf --tsmc28 --output_file $(@D)/tsmc28_sram.v > $(@D)/tsmc28_sram.v.conf | 
					
						
							| 
									
										
										
										
											2021-03-07 20:57:27 +08:00
										 |  |  | 	$(MEM_GEN) $(@D)/$(@F).conf --output_file $(@D)/sim_sram.v | 
					
						
							| 
									
										
										
										
											2020-11-14 17:07:29 +08:00
										 |  |  | 	# sed -i -e 's/_\(aw\|ar\|w\|r\|b\)_\(\|bits_\)/_\1/g' $@ | 
					
						
							| 
									
										
										
										
											2021-01-22 15:42:26 +08:00
										 |  |  | 	@git log -n 1 >> .__head__ | 
					
						
							|  |  |  | 	@git diff >> .__diff__ | 
					
						
							|  |  |  | 	@sed -i 's/^/\/\// ' .__head__ | 
					
						
							|  |  |  | 	@sed -i 's/^/\/\//' .__diff__ | 
					
						
							| 
									
										
										
										
											2021-03-09 09:00:12 +08:00
										 |  |  | 	@cat .__head__ .__diff__ $@ > .__out__ | 
					
						
							| 
									
										
										
										
											2021-01-22 15:42:26 +08:00
										 |  |  | 	@mv .__out__ $@ | 
					
						
							|  |  |  | 	@rm .__head__ .__diff__ | 
					
						
							| 
									
										
										
										
											2019-12-09 14:19:18 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | deploy: build/top.zip | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | build/top.zip: $(TOP_V) | 
					
						
							| 
									
										
										
										
											2019-11-18 10:26:19 +08:00
										 |  |  | 	@zip -r $@ $< $<.conf build/*.anno.json | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .PHONY: deploy build/top.zip | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-10 01:46:53 +08:00
										 |  |  | verilog: $(TOP_V) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-19 21:19:20 +08:00
										 |  |  | SIM_TOP   = SimTop | 
					
						
							| 
									
										
										
										
											2019-05-10 11:37:30 +08:00
										 |  |  | SIM_TOP_V = $(BUILD_DIR)/$(SIM_TOP).v | 
					
						
							| 
									
										
										
										
											2019-09-03 21:50:34 +08:00
										 |  |  | $(SIM_TOP_V): $(SCALA_FILE) $(TEST_FILE) | 
					
						
							| 
									
										
										
										
											2019-05-10 11:37:30 +08:00
										 |  |  | 	mkdir -p $(@D) | 
					
						
							| 
									
										
										
										
											2021-04-23 15:07:41 +08:00
										 |  |  | 	@echo "\n[mill] Generating Verilog files..." > $(TIMELOG) | 
					
						
							|  |  |  | 	@date -R | tee -a $(TIMELOG) | 
					
						
							| 
									
										
										
										
											2021-05-12 19:13:07 +08:00
										 |  |  | 	$(TIME_CMD) mill XiangShan.test.runMain $(SIMTOP) -td $(@D) --config $(CONFIG) --full-stacktrace --output-file $(@F) --infer-rw --repl-seq-mem -c:$(SIMTOP):-o:$(@D)/$(@F).conf $(SIM_ARGS) | 
					
						
							| 
									
										
										
										
											2021-04-01 12:57:37 +08:00
										 |  |  | 	$(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__ | 
					
						
							| 
									
										
										
										
											2020-12-29 10:12:02 +08:00
										 |  |  | 	sed -i -e 's/$$fatal/xs_assert(`__LINE__)/g' $(SIM_TOP_V) | 
					
						
							| 
									
										
										
										
											2019-05-10 11:37:30 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-23 22:14:02 +08:00
										 |  |  | sim-verilog: $(SIM_TOP_V) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-19 21:19:20 +08:00
										 |  |  | SIM_CSRC_DIR = $(abspath ./src/test/csrc/common) | 
					
						
							|  |  |  | SIM_CXXFILES = $(shell find $(SIM_CSRC_DIR) -name "*.cpp") | 
					
						
							| 
									
										
										
										
											2019-05-10 11:37:30 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-19 21:19:20 +08:00
										 |  |  | DIFFTEST_CSRC_DIR = $(abspath ./src/test/csrc/difftest) | 
					
						
							|  |  |  | DIFFTEST_CXXFILES = $(shell find $(DIFFTEST_CSRC_DIR) -name "*.cpp") | 
					
						
							| 
									
										
										
										
											2020-11-18 21:04:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-07 09:34:59 +08:00
										 |  |  | SIM_VSRC = $(shell find ./src/test/vsrc/common -name "*.v" -or -name "*.sv") | 
					
						
							| 
									
										
										
										
											2020-11-20 14:19:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-07 09:34:59 +08:00
										 |  |  | include verilator.mk | 
					
						
							|  |  |  | include vcs.mk | 
					
						
							| 
									
										
										
										
											2019-05-10 11:37:30 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-19 12:46:03 +08:00
										 |  |  | ifndef NEMU_HOME | 
					
						
							|  |  |  | $(error NEMU_HOME is not set) | 
					
						
							|  |  |  | endif | 
					
						
							| 
									
										
										
										
											2020-07-11 21:55:28 +08:00
										 |  |  | REF_SO := $(NEMU_HOME)/build/riscv64-nemu-interpreter-so | 
					
						
							| 
									
										
										
										
											2019-09-06 08:53:17 +08:00
										 |  |  | $(REF_SO): | 
					
						
							| 
									
										
										
										
											2019-09-11 20:28:49 +08:00
										 |  |  | 	$(MAKE) -C $(NEMU_HOME) ISA=riscv64 SHARE=1 | 
					
						
							| 
									
										
										
										
											2019-09-06 08:53:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-22 09:32:31 +08:00
										 |  |  | SEED ?= $(shell shuf -i 1-10000 -n 1) | 
					
						
							| 
									
										
										
										
											2019-12-17 23:31:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-13 01:29:25 +08:00
										 |  |  | VME_SOURCE ?= $(shell pwd)/build/$(TOP).v | 
					
						
							| 
									
										
										
										
											2021-04-19 21:19:20 +08:00
										 |  |  | VME_MODULES ?= | 
					
						
							| 
									
										
										
										
											2020-12-16 20:30:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-13 01:29:25 +08:00
										 |  |  | #-----------------------timing scripts-------------------------
 | 
					
						
							|  |  |  | # run "make vme/tap help=1" to get help info
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-13 01:16:56 +08:00
										 |  |  | # extract verilog module from TopMain.v
 | 
					
						
							|  |  |  | # usage: make vme VME_MODULES=Roq
 | 
					
						
							|  |  |  | TIMING_SCRIPT_PATH = ./timingScripts | 
					
						
							|  |  |  | vme: $(TOP_V) | 
					
						
							| 
									
										
										
										
											2021-01-13 01:29:25 +08:00
										 |  |  | 	make -C $(TIMING_SCRIPT_PATH) vme | 
					
						
							| 
									
										
										
										
											2021-01-13 01:16:56 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | # 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 | 
					
						
							| 
									
										
										
										
											2020-12-04 00:25:17 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | # 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)' | 
					
						
							| 
									
										
										
										
											2020-12-06 20:16:31 +08:00
										 |  |  | 	scp -r  $(REMOTE):~/phy_evaluation/remote_run/rpts ./build | 
					
						
							| 
									
										
										
										
											2020-12-04 00:25:17 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | # 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)' | 
					
						
							| 
									
										
										
										
											2020-12-06 20:16:31 +08:00
										 |  |  | 	scp -r  $(REMOTE):~/phy_evaluation/remote_run/rpts ./build | 
					
						
							| 
									
										
										
										
											2020-12-04 00:25:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-26 13:59:19 +08:00
										 |  |  | cache: | 
					
						
							| 
									
										
										
										
											2019-11-06 21:50:27 +08:00
										 |  |  | 	$(MAKE) emu IMAGE=Makefile | 
					
						
							| 
									
										
										
										
											2019-10-26 13:59:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-08 20:11:24 +08:00
										 |  |  | release-lock: | 
					
						
							|  |  |  | 	ssh -tt $(REMOTE) 'rm -f $(LOCK)' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-07 09:34:59 +08:00
										 |  |  | clean: vcs-clean | 
					
						
							| 
									
										
										
										
											2020-11-19 18:32:32 +08:00
										 |  |  | 	rm -rf ./build | 
					
						
							| 
									
										
										
										
											2019-02-10 01:46:53 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-20 20:09:37 +08:00
										 |  |  | init: | 
					
						
							|  |  |  | 	git submodule update --init | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-13 01:38:26 +08:00
										 |  |  | bump: | 
					
						
							|  |  |  | 	git submodule foreach "git fetch origin&&git checkout master&&git reset --hard origin/master" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bsp: | 
					
						
							|  |  |  | 	mill -i mill.contrib.BSP/install | 
					
						
							| 
									
										
										
										
											2021-04-19 21:19:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-23 22:14:02 +08:00
										 |  |  | .PHONY: verilog sim-verilog emu clean help init bump bsp $(REF_SO) | 
					
						
							| 
									
										
										
										
											2021-04-19 21:19:20 +08:00
										 |  |  | 
 |