-
Notifications
You must be signed in to change notification settings - Fork 89
/
Makefile
139 lines (101 loc) · 2.54 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
BUILD_DIR = $(REPO_BUILD)/rtl
YOSYS = $(YOSYS_ROOT)/yosys
SYNTH_TARGETS =
LINT_TARGETS =
SIM_TARGETS =
TARGETS =
PROVE_TARGETS =
define map_build_dir
$(BUILD_DIR)/${1}
endef
define map_synth_verilog
$(call map_build_dir,${1})/${1}.synth.v
endef
define map_cmos_verilog
$(call map_build_dir,${1})/${1}.cmos.v
endef
define map_synth_rpt
$(call map_build_dir,${1})/${1}.rpt
endef
define map_lint_rpt
$(call map_build_dir,${1})/${1}.lint
endef
define map_waves
$(call map_build_dir,${1})/${1}.vcd
endef
define map_sim_exe
$(call map_build_dir,${1})/${1}.sim
endef
define map_sim_log
$(call map_build_dir,${1})/${1}.simlog
endef
define map_sby_file
$(call map_build_dir,${1})/${1}.sby
endef
#
# 1. Name
# 2. SBY file
# 3. RTL/TB source files
define add_prove_target
${1} : ${3}
mkdir -p $(dir $(call map_sby_file,${1}))
cp ${2} $(call map_sby_file,${1})
sby -f $(call map_sby_file,${1})
PROVE_TARGETS += ${1}
endef
#
# 1. Target Name
# 2. Source Files
# 3. Top Module
define add_synth_target
$(call map_synth_rpt,${1}) : ${2}
@mkdir -p $(call map_build_dir,${1})
$(YOSYS) -qQT \
-p "read_verilog ${2}" \
-p "proc" \
-p "synth -top ${3} -flatten" \
-p "abc -g cmos" \
-p "opt -fast" \
-p "write_verilog $(call map_cmos_verilog,${1})" \
-p "flatten" \
-p "tee -o $(call map_synth_rpt,${1}) stat -tech cmos" \
-p "tee -a $(call map_synth_rpt,${1}) ltp -noff" \
synth-${1} : $(call map_synth_rpt,${1}) $(call map_lint_rpt,${1})
$(call map_lint_rpt,${1}) : ${2}
@mkdir -p $(dir $(call map_lint_rpt,${1}))
@rm -f $${@}
verilator --top-module ${3} --lint-only $${^} | tee $${@}
lint-${1} : $(call map_lint_rpt,${1})
TARGETS += synth-${1} lint-${1}
SYNTH_TARGETS += synth-${1}
LINT_TARGETS += lint-${1}
endef
#
# 1. Target Name
# 2. Source Files
define add_sim_target
$(call map_sim_exe,${1}) : ${2}
mkdir -p $(dir $(call map_sim_exe,${1}))
iverilog -DWAVEFILE=$(call map_waves,${1}) \
-s${1}_tb -g2012 -o$${@} $${^}
$(call map_waves,${1}) : $(call map_sim_log,${1})
$(call map_sim_log,${1}) : $(call map_sim_exe,${1})
vvp $${^}
sim-${1} : $(call map_waves,${1})
SIM_TARGETS += sim-${1}
TARGETS += $(call map_sim_log,${1})
TARGETS += $(call map_waves,${1})
endef
#
# Import sub-makefiles
#
include crypto-fu/Makefile.in
all: $(TARGETS)
synth-all: $(SYNTH_TARGETS)
sim-all: $(SIM_TARGETS)
lint-all: $(LINT_TARGETS)
prove-all: $(PROVE_TARGETS)
print-synth-targets:
@echo $(SYNTH_TARGETS) | sed "s/ /\n/g"
print-sim-targets:
@echo $(SIM_TARGETS) | sed "s/ /\n/g"