-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathMakefile
140 lines (104 loc) · 3.95 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Copyright 2023 ETH Zurich and University of Bologna
# Solderpad Hardware License, Version 0.51, see LICENSE for details.
# SPDX-License-Identifier: SHL-0.51
ROOT_DIR = $(strip $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))))
HOSTNAME := $(shell hostname)
ETH_HOST = $(shell echo $(HOSTNAME) | grep -q "\.ee\.ethz\.ch$$" && echo 1 || echo 0)
ifeq ($(ETH_HOST),1)
QUESTA ?= questa-2023.4-zr
else
QUESTA ?=
endif
BENDER ?= bender
VSIM ?= $(QUESTA) vsim
VOPT ?= $(QUESTA) vopt
VLIB ?= $(QUESTA) vlib
top_level ?= pulp_cluster_tb
library ?= work
elf-bin ?= stimuli.riscv
bwruntest = $(ROOT_DIR)/pulp-runtime/scripts/bwruntests.py
REGRESSIONS := $(ROOT_DIR)/regression_tests
VLOG_ARGS += -suppress vlog-2583 -suppress vlog-13314 -suppress vlog-13233 -timescale \"1 ns / 1 ps\" \"+incdir+$(shell pwd)/include\"
define generate_vsim
echo 'set ROOT [file normalize [file dirname [info script]]/$3]' > $1
$(BENDER) script vsim --vlog-arg="$(VLOG_ARGS)" $2 | grep -v "set ROOT" >> $1
echo >> $1
endef
######################
# Nonfree components #
######################
NONFREE_REMOTE ?= [email protected]:pulp-restricted/pulp-cluster-nonfree.git
NONFREE_COMMIT ?= 67079fe
nonfree-init:
git clone $(NONFREE_REMOTE) nonfree
cd nonfree && git checkout $(NONFREE_COMMIT)
################
# Dependencies #
################
.PHONY: init
init: checkout
.PHONY: checkout
## Checkout/update dependencies using Bender
checkout:
$(BENDER) checkout
touch Bender.lock
make scripts/compile.tcl
Bender.lock:
$(BENDER) checkout
touch Bender.lock
######
# SW #
######
.PHONY: sw-init sw-clean
sw-init: pulp-runtime fault_injection_sim regression_tests
sw-clean:
@rm -rf pulp-runtime fault_injection_sim regression_test
## Clone pulp-runtime as SW stack
PULP_RUNTIME_REMOTE ?= https://github.com/pulp-platform/pulp-runtime.git
PULP_RUNTIME_COMMIT ?= b3c239c # branch: lg/upstream
pulp-runtime:
git clone $(PULP_RUNTIME_REMOTE) $@
cd $@ && git checkout $(PULP_RUNTIME_COMMIT)
## Clone fault injection scripts
FAULT_SIM_REMOTE ?= https://github.com/pulp-platform/InjectaFault.git
FAULT_SIM_COMMIT ?= 84ddcff # branch: rt/rename-var
fault_injection_sim:
git clone $(FAULT_SIM_REMOTE) $@
cd $@ && git checkout $(FAULT_SIM_COMMIT)
## Clone regression tests
REGRESSION_TESTS_REMOTE ?= https://github.com/pulp-platform/regression_tests.git
REGRESSION_TESTS_COMMIT ?= d43cb0d # branch: lg/upstream
regression_tests:
git clone $(REGRESSION_TESTS_REMOTE) $@
cd $@ && git checkout $(REGRESSION_TESTS_COMMIT)
cd $@ && git submodule update --init --recursive
########################
# Build and simulation #
########################
.PHONY: sim-clean compile build run
sim-clean:
rm -rf scripts/compile.tcl
rm -rf work
include bender-common.mk
include bender-sim.mk
scripts/compile.tcl: | Bender.lock
$(call generate_vsim, $@, $(common_defs) $(common_targs) $(sim_defs) $(sim_targs),..)
echo 'vlog "$(realpath $(ROOT_DIR))/tb/dpi/elfloader.cpp" -ccflags "-std=c++11"' >> $@
include bender-synth.mk
scripts/synth-compile.tcl: | Bender.lock
$(BENDER) script synopsys $(common_targs) $(common_defs) $(synth_targs) $(synth_defs) > $@
$(library):
$(QUESTA) vlib $(library)
compile: $(library)
@test -f Bender.lock || { echo "ERROR: Bender.lock file does not exist. Did you run make checkout in bender mode?"; exit 1; }
@test -f scripts/compile.tcl || { echo "ERROR: scripts/compile.tcl file does not exist. Did you run make scripts in bender mode?"; exit 1; }
$(VSIM) -c -do 'quit -code [source scripts/compile.tcl]'
build: compile
$(VOPT) $(compile_flag) -suppress 3053 -suppress 8885 -work $(library) $(top_level) -o $(top_level)_optimized +acc
run:
$(VSIM) +permissive -suppress 3053 -suppress 8885 -lib $(library) +MAX_CYCLES=$(max_cycles) +UVM_TESTNAME=$(test_case) +APP=$(elf-bin) +notimingchecks +nospecify -t 1ps \
${top_level}_optimized +permissive-off ++$(elf-bin) ++$(target-options) ++$(cl-bin) | tee sim.log
####################
# Regression tests #
####################
include regression.mk