1 |
6 |
julius |
######################################################################
|
2 |
|
|
#### ####
|
3 |
|
|
#### ORPSoCv2 Testbenches Makefile ####
|
4 |
|
|
#### ####
|
5 |
|
|
#### Description ####
|
6 |
|
|
#### ORPSoCv2 Testbenches Makefile, containing rules for ####
|
7 |
|
|
#### configuring and running different tests on the current ####
|
8 |
|
|
#### ORPSoC(v2) design. ####
|
9 |
|
|
#### ####
|
10 |
|
|
#### To do: ####
|
11 |
|
|
#### ####
|
12 |
|
|
#### Author(s): ####
|
13 |
360 |
julius |
#### - Julius Baxter, julius@opencores.org ####
|
14 |
6 |
julius |
#### ####
|
15 |
|
|
#### ####
|
16 |
|
|
######################################################################
|
17 |
|
|
#### ####
|
18 |
348 |
julius |
#### Copyright (C) 2009,2010 Authors and OPENCORES.ORG ####
|
19 |
6 |
julius |
#### ####
|
20 |
|
|
#### This source file may be used and distributed without ####
|
21 |
|
|
#### restriction provided that this copyright statement is not ####
|
22 |
|
|
#### removed from the file and that any derivative work contains ####
|
23 |
|
|
#### the original copyright notice and the associated disclaimer. ####
|
24 |
|
|
#### ####
|
25 |
|
|
#### This source file is free software; you can redistribute it ####
|
26 |
|
|
#### and/or modify it under the terms of the GNU Lesser General ####
|
27 |
|
|
#### Public License as published by the Free Software Foundation; ####
|
28 |
|
|
#### either version 2.1 of the License, or (at your option) any ####
|
29 |
|
|
#### later version. ####
|
30 |
|
|
#### ####
|
31 |
|
|
#### This source is distributed in the hope that it will be ####
|
32 |
|
|
#### useful, but WITHOUT ANY WARRANTY; without even the implied ####
|
33 |
|
|
#### warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ####
|
34 |
|
|
#### PURPOSE. See the GNU Lesser General Public License for more ####
|
35 |
|
|
#### details. ####
|
36 |
|
|
#### ####
|
37 |
|
|
#### You should have received a copy of the GNU Lesser General ####
|
38 |
|
|
#### Public License along with this source; if not, download it ####
|
39 |
|
|
#### from http://www.opencores.org/lgpl.shtml ####
|
40 |
|
|
#### ####
|
41 |
|
|
######################################################################
|
42 |
|
|
|
43 |
360 |
julius |
# Name of the directory we're currently in
|
44 |
|
|
CUR_DIR=$(shell pwd)
|
45 |
6 |
julius |
|
46 |
360 |
julius |
# The root path of the whole project
|
47 |
|
|
PROJECT_ROOT ?=$(CUR_DIR)/../..
|
48 |
6 |
julius |
|
49 |
362 |
julius |
DESIGN_NAME=orpsoc
|
50 |
|
|
RTL_TESTBENCH_TOP=$(DESIGN_NAME)_testbench
|
51 |
|
|
# Top level files for DUT and testbench
|
52 |
|
|
DUT_TOP=$(RTL_VERILOG_DIR)/$(DESIGN_NAME)_top/$(DESIGN_NAME)_top.v
|
53 |
|
|
BENCH_TOP=$(BENCH_VERILOG_DIR)/$(DESIGN_NAME)_testbench.v
|
54 |
|
|
|
55 |
360 |
julius |
# Need this for individual test variables to not break
|
56 |
|
|
TEST ?= or1200-simple
|
57 |
6 |
julius |
|
58 |
468 |
julius |
TESTS ?= or1200-simple \
|
59 |
|
|
or1200-basic \
|
60 |
|
|
or1200-cbasic \
|
61 |
|
|
or1200-dctest \
|
62 |
|
|
or1200-float \
|
63 |
|
|
or1200-mmu \
|
64 |
|
|
or1200-except \
|
65 |
|
|
or1200-mac \
|
66 |
499 |
julius |
or1200-ext \
|
67 |
502 |
julius |
or1200-cy \
|
68 |
|
|
or1200-ov \
|
69 |
530 |
julius |
or1200-sf \
|
70 |
468 |
julius |
or1200-ffl1 \
|
71 |
|
|
or1200-linkregtest \
|
72 |
|
|
or1200-tick \
|
73 |
|
|
or1200-ticksyscall \
|
74 |
|
|
uart-simple
|
75 |
6 |
julius |
|
76 |
360 |
julius |
# Gets turned into verilog `define
|
77 |
|
|
SIM_TYPE=RTL
|
78 |
6 |
julius |
|
79 |
360 |
julius |
# Paths to other important parts of this test suite
|
80 |
|
|
RTL_DIR = $(PROJECT_ROOT)/rtl
|
81 |
|
|
RTL_VERILOG_DIR = $(RTL_DIR)/verilog
|
82 |
|
|
RTL_VERILOG_INCLUDE_DIR = $(RTL_VERILOG_DIR)/include
|
83 |
|
|
#RTL_VHDL_DIR = $(RTL_DIR)/vhdl
|
84 |
6 |
julius |
|
85 |
360 |
julius |
PROJECT_VERILOG_DEFINES=$(RTL_VERILOG_INCLUDE_DIR)/$(DESIGN_NAME)-defines.v
|
86 |
|
|
# Detect technology to use for the simulation
|
87 |
468 |
julius |
DESIGN_DEFINES=$(shell cat $(PROJECT_VERILOG_DEFINES) | \
|
88 |
|
|
sed s://.*::g | sed s:\`:\#:g | sed 's:^[ ]*::' | \
|
89 |
|
|
awk '{print};/^\#define/{printf "_%s=%s\n",$$2,$$2}' | \
|
90 |
|
|
grep -v PERIOD | cpp -P | sed s:^_::g | sed s:=$$::g )
|
91 |
6 |
julius |
|
92 |
360 |
julius |
# Rule to look at what defines are being extracted from main file
|
93 |
|
|
print-defines:
|
94 |
|
|
@echo echo; echo "\t### Design defines ###"; echo
|
95 |
|
|
@echo "\tParsing "$(PROJECT_VERILOG_DEFINES)" and exporting:"
|
96 |
|
|
@echo $(DESIGN_DEFINES)
|
97 |
6 |
julius |
|
98 |
360 |
julius |
# Simulation directories
|
99 |
|
|
SIM_DIR ?=$(PROJECT_ROOT)/sim
|
100 |
362 |
julius |
SIM_VLT_DIR ?=$(SIM_DIR)/vlt
|
101 |
360 |
julius |
RTL_SIM_DIR=$(SIM_DIR)
|
102 |
|
|
RTL_SIM_RUN_DIR=$(RTL_SIM_DIR)/run
|
103 |
|
|
RTL_SIM_BIN_DIR=$(RTL_SIM_DIR)/bin
|
104 |
|
|
RTL_SIM_RESULTS_DIR=$(RTL_SIM_DIR)/out
|
105 |
6 |
julius |
|
106 |
360 |
julius |
# Testbench paths
|
107 |
6 |
julius |
BENCH_DIR=$(PROJECT_ROOT)/bench
|
108 |
|
|
BENCH_VERILOG_DIR=$(BENCH_DIR)/verilog
|
109 |
403 |
julius |
BENCH_VERILOG_INCLUDE_DIR=$(BENCH_VERILOG_DIR)/include
|
110 |
360 |
julius |
#BENCH_VHDL_DIR=$(BENCH_DIR)/vhdl
|
111 |
362 |
julius |
BENCH_SYSC_DIR=$(BENCH_DIR)/sysc
|
112 |
|
|
BENCH_SYSC_SRC_DIR=$(BENCH_SYSC_DIR)/src
|
113 |
|
|
BENCH_SYSC_INCLUDE_DIR=$(BENCH_SYSC_DIR)/include
|
114 |
360 |
julius |
|
115 |
362 |
julius |
|
116 |
360 |
julius |
# System software dir
|
117 |
6 |
julius |
SW_DIR=$(PROJECT_ROOT)/sw
|
118 |
360 |
julius |
# BootROM code, which generates a verilog array select values
|
119 |
|
|
BOOTROM_FILE=bootrom.v
|
120 |
|
|
BOOTROM_SW_DIR=$(SW_DIR)/bootrom
|
121 |
|
|
BOOTROM_SRC=$(shell ls $(BOOTROM_SW_DIR)/* | grep -v $(BOOTROM_FILE))
|
122 |
|
|
BOOTROM_VERILOG=$(BOOTROM_SW_DIR)/$(BOOTROM_FILE)
|
123 |
|
|
$(BOOTROM_VERILOG): $(BOOTROM_SRC)
|
124 |
|
|
$(Q)echo; echo "\t### Generating bootup ROM ###"; echo
|
125 |
|
|
$(Q)$(MAKE) -C $(BOOTROM_SW_DIR) $(BOOTROM_FILE)
|
126 |
6 |
julius |
|
127 |
360 |
julius |
# Suffix of file to check after each test for the string
|
128 |
|
|
TEST_OUT_FILE_SUFFIX=-general.log
|
129 |
|
|
TEST_OK_STRING=8000000d
|
130 |
6 |
julius |
|
131 |
360 |
julius |
# Dynamically generated verilog file defining configuration for various things
|
132 |
|
|
TEST_DEFINES_VLG=test-defines.v
|
133 |
57 |
julius |
# Set V=1 when calling make to enable verbose output
|
134 |
|
|
# mainly for debugging purposes.
|
135 |
|
|
ifeq ($(V), 1)
|
136 |
|
|
Q=
|
137 |
360 |
julius |
QUIET=
|
138 |
57 |
julius |
else
|
139 |
360 |
julius |
Q ?=@
|
140 |
|
|
QUIET=-quiet
|
141 |
57 |
julius |
endif
|
142 |
|
|
|
143 |
360 |
julius |
# Modelsim variables
|
144 |
|
|
MGC_VSIM=vsim
|
145 |
|
|
MGC_VLOG_COMP=vlog
|
146 |
|
|
MGC_VHDL_COMP=vcom
|
147 |
|
|
MODELSIM=modelsim
|
148 |
6 |
julius |
|
149 |
360 |
julius |
# Icarus variables
|
150 |
|
|
ICARUS_COMPILE=iverilog
|
151 |
|
|
ICARUS_RUN=vvp
|
152 |
|
|
ICARUS_SCRIPT=icarus.scr
|
153 |
|
|
ICARUS_SIM_EXE=vlogsim.elf
|
154 |
|
|
ICARUS=icarus
|
155 |
58 |
julius |
|
156 |
360 |
julius |
#Default simulator is Icarus Verilog
|
157 |
|
|
# Set SIMULATOR=modelsim to use Modelsim
|
158 |
|
|
# Set SIMULATOR=ncverilog to use Cadence's NC-Verilog - TODO
|
159 |
|
|
# Set SIMULATOR=icarus to use Icarus Verilog (Default)
|
160 |
68 |
julius |
|
161 |
58 |
julius |
SIMULATOR ?= $(ICARUS)
|
162 |
|
|
|
163 |
360 |
julius |
# VPI debugging interface variables
|
164 |
|
|
VPI_SRC_C_DIR=$(BENCH_VERILOG_DIR)/vpi/c
|
165 |
397 |
julius |
VPI_SRC_VERILOG_DIR=$(BENCH_VERILOG_DIR)/vpi/verilog
|
166 |
360 |
julius |
VPI_SRCS=$(shell ls $(VPI_SRC_C_DIR)/*.[ch])
|
167 |
58 |
julius |
|
168 |
360 |
julius |
# Modelsim VPI compile variables
|
169 |
|
|
MODELTECH_VPILIB=msim_jp_vpi.sl
|
170 |
|
|
# Icarus VPI compile target
|
171 |
|
|
ICARUS_VPILIB=jp_vpi
|
172 |
58 |
julius |
|
173 |
360 |
julius |
#
|
174 |
|
|
# Modelsim-specific settings
|
175 |
|
|
#
|
176 |
|
|
VOPT_ARGS=$(QUIET) -suppress 2241
|
177 |
55 |
julius |
# If VCD dump is desired, tell Modelsim not to optimise
|
178 |
|
|
# away everything.
|
179 |
|
|
ifeq ($(VCD), 1)
|
180 |
485 |
julius |
# If certain versions of modelsim don't have the vopt executable, define
|
181 |
|
|
# MGC_NO_VOPT=1 when running.
|
182 |
|
|
ifeq ($(MGC_NO_VOPT), 1)
|
183 |
|
|
MGC_VSIM_ARGS +=-voptargs="+acc=rnp"
|
184 |
|
|
MGC_VOPT_CMD=echo
|
185 |
|
|
MGC_VSIM_TGT=orpsoc_testbench
|
186 |
|
|
else
|
187 |
360 |
julius |
VOPT_ARGS=+acc=rnpqv
|
188 |
485 |
julius |
MGC_VOPT_CMD= vopt $(QUIET) $(RTL_TESTBENCH_TOP) $(VOPT_ARGS) -o tb
|
189 |
|
|
MGC_VSIM_TGT=tb
|
190 |
55 |
julius |
endif
|
191 |
485 |
julius |
|
192 |
|
|
else
|
193 |
|
|
|
194 |
|
|
ifeq ($(MGC_NO_VOPT), 1)
|
195 |
|
|
MGC_VSIM_ARGS += -vopt
|
196 |
|
|
MGC_VOPT_CMD=echo
|
197 |
|
|
MGC_VSIM_TGT=orpsoc_testbench
|
198 |
|
|
else
|
199 |
|
|
VOPT_ARGS=+acc=rnpqv
|
200 |
|
|
MGC_VOPT_CMD= vopt $(QUIET) $(RTL_TESTBENCH_TOP) $(VOPT_ARGS) -o tb
|
201 |
|
|
MGC_VSIM_TGT=tb
|
202 |
|
|
endif
|
203 |
|
|
|
204 |
|
|
|
205 |
|
|
endif
|
206 |
360 |
julius |
# VSIM commands
|
207 |
|
|
# Suppressed warnings - 3009: Failed to open $readmemh() file
|
208 |
475 |
julius |
# Suppressed warnings - 3009: Module 'blah' does not have a `timescale
|
209 |
|
|
# directive in effect, but previous modules do.
|
210 |
|
|
# Suppressed warnings - 8598: Non-positive replication multiplier inside
|
211 |
|
|
# concat. Replication will be ignored
|
212 |
485 |
julius |
MGC_VSIM_ARGS += -suppress 7 -suppress 3009 -suppress 8598 -c $(QUIET) \
|
213 |
475 |
julius |
-do "set StdArithNoWarnings 1; run -all; exit"
|
214 |
397 |
julius |
# Options required when VPI option used
|
215 |
360 |
julius |
ifeq ($(VPI), 1)
|
216 |
397 |
julius |
MGC_VPI_LIB=$(VPI_SRC_C_DIR)/$(MODELTECH_VPILIB)
|
217 |
|
|
MGC_VSIM_ARGS += -pli $(VPI_SRC_C_DIR)/$(MODELTECH_VPILIB)
|
218 |
|
|
|
219 |
|
|
ICARUS_VPI_LIB=$(VPI_SRC_C_DIR)/$(ICARUS_VPILIB)
|
220 |
|
|
ICARUS_VPI_ARGS=-M$(VPI_SRC_C_DIR) -m$(ICARUS_VPILIB)
|
221 |
58 |
julius |
endif
|
222 |
397 |
julius |
# Rule to make the VPI library for Modelsim
|
223 |
|
|
$(MGC_VPI_LIB): $(VPI_SRCS)
|
224 |
360 |
julius |
$(MAKE) -C $(VPI_SRC_C_DIR) $(MODELTECH_VPILIB)
|
225 |
58 |
julius |
|
226 |
397 |
julius |
# Rule to make VPI library for Icarus Verilog
|
227 |
|
|
$(ICARUS_VPI_LIB): $(VPI_SRCS)
|
228 |
360 |
julius |
$(MAKE) -C $(VPI_SRC_C_DIR) $(ICARUS_VPILIB)
|
229 |
77 |
rherveille |
|
230 |
397 |
julius |
# Manually add the VPI bench verilog path
|
231 |
|
|
BENCH_VERILOG_SRC_SUBDIRS += $(VPI_SRC_VERILOG_DIR)
|
232 |
|
|
|
233 |
360 |
julius |
#
|
234 |
|
|
# Verilog DUT source variables
|
235 |
|
|
#
|
236 |
|
|
# A list of paths under rtl/verilog we wish to exclude for module searching
|
237 |
|
|
VERILOG_MODULES_EXCLUDE= include components
|
238 |
475 |
julius |
VERILOG_MODULES_EXCLUDE_LIST_E=$(shell for exclude in \
|
239 |
|
|
$(VERILOG_MODULES_EXCLUDE); do echo "-e $$exclude"; done)
|
240 |
|
|
RTL_VERILOG_MODULES=$(shell ls $(RTL_VERILOG_DIR) | grep -v \
|
241 |
|
|
$(VERILOG_MODULES_EXCLUDE_LIST_E) )
|
242 |
360 |
julius |
# Specific files to exclude, currently none.
|
243 |
|
|
#VERILOG_EXCLUDE=
|
244 |
475 |
julius |
#VERILOG_EXCLUDE_LIST_E=$(shell for exclude in $(VERILOG_EXCLUDE); \
|
245 |
|
|
do echo "-e $$exclude"; done)
|
246 |
360 |
julius |
# List of verilog source files, minus excluded files
|
247 |
475 |
julius |
#RTL_VERILOG_SRC=$(shell for module in $(RTL_VERILOG_MODULES); do \
|
248 |
|
|
if [ -d $(RTL_VERILOG_DIR)/$$module ]; then \
|
249 |
|
|
ls $(RTL_VERILOG_DIR)/$$module/*.v | grep -v \
|
250 |
|
|
$(VERILOG_EXCLUDE_LIST_E); \
|
251 |
|
|
fi; done)
|
252 |
360 |
julius |
# List of verilog source files, ignoring excludes
|
253 |
475 |
julius |
RTL_VERILOG_SRC=$(shell for module in $(RTL_VERILOG_MODULES); do \
|
254 |
|
|
if [ -d $(RTL_VERILOG_DIR)/$$module ]; then \
|
255 |
|
|
ls $(RTL_VERILOG_DIR)/$$module/*.v; \
|
256 |
|
|
fi; done)
|
257 |
6 |
julius |
|
258 |
360 |
julius |
# List of verilog includes
|
259 |
|
|
RTL_VERILOG_INCLUDES=$(shell ls $(RTL_VERILOG_INCLUDE_DIR)/*.*)
|
260 |
6 |
julius |
|
261 |
360 |
julius |
print-verilog-src:
|
262 |
|
|
@echo echo; echo "\t### Verilog source ###"; echo
|
263 |
|
|
@echo $(RTL_VERILOG_SRC)
|
264 |
51 |
julius |
|
265 |
360 |
julius |
# Rules to make RTL we might need
|
266 |
|
|
# Expects modules, if they need making, to have their top verilog file to
|
267 |
|
|
# correspond to their module name, and the directory should have a make file
|
268 |
|
|
# and rule which works for this command.
|
269 |
|
|
# Add name of module to this list, currently only does verilog ones.
|
270 |
|
|
# Rule 'rtl' is called just before generating DUT modelsim compilation script
|
271 |
|
|
RTL_TO_CHECK=
|
272 |
|
|
rtl:
|
273 |
|
|
$(Q)for module in $(RTL_TO_CHECK); do \
|
274 |
|
|
$(MAKE) -C $(RTL_VERILOG_DIR)/$$module $$module.v; \
|
275 |
|
|
done
|
276 |
6 |
julius |
|
277 |
55 |
julius |
#
|
278 |
360 |
julius |
# VHDL DUT source variables
|
279 |
55 |
julius |
#
|
280 |
360 |
julius |
# VHDL modules
|
281 |
|
|
#RTL_VHDL_MODULES=$(shell ls $(RTL_VHDL_DIR))
|
282 |
|
|
# VHDL sources
|
283 |
475 |
julius |
#RTL_VHDL_SRC=$(shell for module in $(RTL_VHDL_MODULES); do \
|
284 |
|
|
if [ -d $(RTL_VHDL_DIR)/$$module ]; then \
|
285 |
|
|
ls $(RTL_VHDL_DIR)/$$module/*.vhd; \
|
286 |
|
|
fi; done)
|
287 |
360 |
julius |
#print-vhdl-src:
|
288 |
|
|
# @echo echo; echo "\t### VHDL modules and source ###"; echo
|
289 |
|
|
# @echo "modules: "; echo $(RTL_VHDL_MODULES); echo
|
290 |
|
|
# @echo "source: "$(RTL_VHDL_SRC)
|
291 |
6 |
julius |
|
292 |
40 |
julius |
|
293 |
360 |
julius |
# Testbench verilog source
|
294 |
475 |
julius |
BENCH_VERILOG_SRC=$(shell ls $(BENCH_VERILOG_DIR)/*.v | grep -v \
|
295 |
|
|
$(DESIGN_NAME)_testbench )
|
296 |
40 |
julius |
|
297 |
362 |
julius |
print-bench-src:
|
298 |
|
|
$(Q)echo "\tBench verilog source"; \
|
299 |
|
|
echo $(BENCH_VERILOG_SRC)
|
300 |
|
|
|
301 |
360 |
julius |
# Testbench source subdirectory detection
|
302 |
475 |
julius |
BENCH_VERILOG_SRC_SUBDIRS +=$(shell for file in `ls $(BENCH_VERILOG_DIR)`; do \
|
303 |
|
|
if [ -d $(BENCH_VERILOG_DIR)/$$file ]; then \
|
304 |
|
|
echo $(BENCH_VERILOG_DIR)/$$file; \
|
305 |
|
|
fi; done)
|
306 |
40 |
julius |
|
307 |
360 |
julius |
# Compile script generation rules:
|
308 |
40 |
julius |
|
309 |
475 |
julius |
modelsim_dut.scr: rtl $(RTL_VERILOG_SRC) $(RTL_VERILOG_INCLUDES) \
|
310 |
|
|
$(BOOTROM_VERILOG)
|
311 |
360 |
julius |
$(Q)echo "+incdir+"$(RTL_VERILOG_INCLUDE_DIR) > $@;
|
312 |
|
|
$(Q)echo "+incdir+"$(BOOTROM_SW_DIR) >> $@;
|
313 |
403 |
julius |
$(Q)echo "+incdir+"$(BENCH_VERILOG_INCLUDE_DIR) >> $@;
|
314 |
360 |
julius |
$(Q)echo "+libext+.v" >> $@;
|
315 |
475 |
julius |
$(Q)for module in $(RTL_VERILOG_MODULES); do \
|
316 |
|
|
if [ -d $(RTL_VERILOG_DIR)/$$module ]; then \
|
317 |
|
|
echo "-y " $(RTL_VERILOG_DIR)/$$module >> $@; \
|
318 |
|
|
fi; done
|
319 |
360 |
julius |
$(Q)echo >> $@
|
320 |
6 |
julius |
|
321 |
360 |
julius |
modelsim_bench.scr: $(BENCH_VERILOG_SRC)
|
322 |
|
|
$(Q)echo "+incdir+"$(BENCH_VERILOG_DIR) > $@;
|
323 |
475 |
julius |
$(Q)for path in $(BENCH_VERILOG_SRC_SUBDIRS); do \
|
324 |
|
|
echo "+incdir+"$$path >> $@; \
|
325 |
|
|
done
|
326 |
|
|
$(Q)for path in $(BENCH_VERILOG_SRC_SUBDIRS); do \
|
327 |
|
|
echo "-y "$$path >> $@; \
|
328 |
|
|
done
|
329 |
360 |
julius |
$(Q)echo "+incdir+"$(RTL_VERILOG_INCLUDE_DIR) >> $@;
|
330 |
|
|
$(Q)echo "+libext+.v" >> $@;
|
331 |
|
|
$(Q)for vsrc in $(BENCH_VERILOG_SRC); do echo $$vsrc >> $@; done
|
332 |
|
|
$(Q)echo >> $@
|
333 |
6 |
julius |
|
334 |
360 |
julius |
# Compile DUT into "work" library
|
335 |
|
|
work: modelsim_dut.scr #$(RTL_VHDL_SRC)
|
336 |
|
|
$(Q)if [ ! -e $@ ]; then vlib $@; fi
|
337 |
|
|
# $(Q)echo; echo "\t### Compiling VHDL design library ###"; echo
|
338 |
|
|
# $(Q)vcom -93 $(QUIET) $(RTL_VHDL_SRC)
|
339 |
|
|
$(Q)echo; echo "\t### Compiling Verilog design library ###"; echo
|
340 |
|
|
$(Q)vlog $(QUIET) -f $< $(DUT_TOP)
|
341 |
6 |
julius |
|
342 |
360 |
julius |
# Single compile rule
|
343 |
|
|
.PHONY : $(MODELSIM)
|
344 |
397 |
julius |
$(MODELSIM): modelsim_bench.scr $(TEST_DEFINES_VLG) $(MGC_VPI_LIB) work
|
345 |
360 |
julius |
$(Q)echo; echo "\t### Compiling testbench ###"; echo
|
346 |
362 |
julius |
$(Q)vlog $(QUIET) -nologo -incr $(BENCH_TOP) -f $<
|
347 |
485 |
julius |
$(Q)$(MGC_VOPT_CMD)
|
348 |
360 |
julius |
$(Q)echo; echo "\t### Launching simulation ###"; echo
|
349 |
485 |
julius |
$(Q)vsim $(VOPT_ARGS) $(MGC_VSIM_ARGS) $(MGC_VSIM_TGT)
|
350 |
6 |
julius |
|
351 |
360 |
julius |
#
|
352 |
|
|
# Icarus Verilog simulator build and run rules
|
353 |
|
|
#
|
354 |
|
|
.PHONY: $(ICARUS_SCRIPT)
|
355 |
475 |
julius |
$(ICARUS_SCRIPT): $(RTL_VERILOG_SRC) $(RTL_VERILOG_INCLUDES) \
|
356 |
|
|
$(BOOTROM_VERILOG) $(BENCH_VERILOG_SRC)
|
357 |
360 |
julius |
$(Q)echo "# Icarus Verilog simulation script" > $@
|
358 |
|
|
$(Q)echo "# Auto generated. Any alterations will be written over!" >> $@
|
359 |
|
|
$(Q)echo "+incdir+"$(RTL_VERILOG_INCLUDE_DIR) > $@;
|
360 |
|
|
$(Q)echo "+incdir+"$(BENCH_VERILOG_DIR) >> $@;
|
361 |
|
|
$(Q)echo "+incdir+"$(BOOTROM_SW_DIR) >> $@;
|
362 |
475 |
julius |
$(Q)for path in $(BENCH_VERILOG_SRC_SUBDIRS); do \
|
363 |
|
|
echo "+incdir+"$$path >> $@; \
|
364 |
|
|
done
|
365 |
|
|
$(Q)for path in $(BENCH_VERILOG_SRC_SUBDIRS); do \
|
366 |
|
|
echo "-y "$$path >> $@; \
|
367 |
|
|
done
|
368 |
|
|
$(Q)for module in $(RTL_VERILOG_MODULES); do \
|
369 |
|
|
echo "-y " $(RTL_VERILOG_DIR)/$$module >> $@; \
|
370 |
|
|
done
|
371 |
362 |
julius |
$(Q)echo "-y" $(BENCH_VERILOG_DIR) >> $@;
|
372 |
|
|
$(Q)echo $(BENCH_TOP) >> $@;
|
373 |
360 |
julius |
$(Q) echo >> $@
|
374 |
6 |
julius |
|
375 |
360 |
julius |
# Icarus design compilation rule
|
376 |
|
|
$(ICARUS_SIM_EXE): $(ICARUS_SCRIPT) $(TEST_DEFINES_VLG)
|
377 |
|
|
$(Q)echo; echo "\t### Compiling ###"; echo
|
378 |
|
|
$(Q) $(ICARUS_COMPILE) -s$(RTL_TESTBENCH_TOP) -c $< -o $@
|
379 |
49 |
julius |
|
380 |
360 |
julius |
# Icarus simulation run rule
|
381 |
|
|
$(ICARUS): $(ICARUS_SIM_EXE) $(ICARUS_VPI_LIB)
|
382 |
|
|
$(Q)echo; echo "\t### Launching simulation ###"; echo
|
383 |
|
|
$(Q) $(ICARUS_RUN) $(ICARUS_VPI_ARGS) -l ../out/$(ICARUS_RUN).log $<
|
384 |
63 |
julius |
|
385 |
49 |
julius |
|
386 |
|
|
|
387 |
360 |
julius |
.PHONY: rtl-test
|
388 |
425 |
julius |
rtl-test: clean-sim-test-sw sw-vmem clean-test-defines $(TEST_DEFINES_VLG) \
|
389 |
360 |
julius |
$(SIMULATOR)
|
390 |
6 |
julius |
|
391 |
360 |
julius |
# Run an RTL test followed by checking of generated results
|
392 |
|
|
rtl-test-with-check: rtl-test
|
393 |
|
|
$(Q)$(MAKE) check-test-log; \
|
394 |
|
|
if [ $$? -ne 0 ]; then \
|
395 |
|
|
echo; echo "\t### "$(TEST)" test FAIL ###"; echo; \
|
396 |
|
|
else \
|
397 |
|
|
echo; echo "\t### "$(TEST)" test OK ###"; echo; \
|
398 |
|
|
fi
|
399 |
6 |
julius |
|
400 |
360 |
julius |
# Do check, don't print anything out
|
401 |
|
|
rtl-test-with-check-no-print: rtl-test check-test-log
|
402 |
6 |
julius |
|
403 |
360 |
julius |
# Main RTL test loop
|
404 |
|
|
rtl-tests:
|
405 |
|
|
$(Q)for test in $(TESTS); do \
|
406 |
|
|
export TEST=$$test; \
|
407 |
|
|
$(MAKE) rtl-test-with-check-no-print; \
|
408 |
|
|
if [ $$? -ne 0 ]; then break; fi; \
|
409 |
|
|
echo; echo "\t### $$test test OK ###"; echo; \
|
410 |
6 |
julius |
done
|
411 |
|
|
|
412 |
|
|
|
413 |
360 |
julius |
.PHONY: check-test-log
|
414 |
|
|
check-test-log:
|
415 |
|
|
$(Q)echo "#!/bin/bash" > $@
|
416 |
|
|
$(Q)echo "function check-test-log { if [ \`grep -c -i "$(TEST_OK_STRING)" "$(RTL_SIM_RESULTS_DIR)"/"$(TEST)$(TEST_OUT_FILE_SUFFIX)"\` -gt 0 ]; then return 0; else return 1; fi; }" >> $@
|
417 |
|
|
$(Q)echo "check-test-log" >> $@
|
418 |
|
|
$(Q)chmod +x $@
|
419 |
|
|
$(Q) echo; echo "\t### Checking simulation results for "$(TEST)" test ###"; echo;
|
420 |
|
|
$(Q)./$@
|
421 |
6 |
julius |
|
422 |
403 |
julius |
# Include the test-defines.v generation rule
|
423 |
|
|
include ../bin/definesgen.inc
|
424 |
6 |
julius |
|
425 |
403 |
julius |
#
|
426 |
|
|
# Software make rules (called recursively)
|
427 |
|
|
#
|
428 |
51 |
julius |
|
429 |
403 |
julius |
# Path for the current test
|
430 |
393 |
julius |
TEST_SW_DIR=$(SW_DIR)/tests/$(shell echo $(TEST) | cut -d "-" -f 1)/sim
|
431 |
6 |
julius |
|
432 |
468 |
julius |
# This file name corresponds to the VMEM file the RAM models will attempt to
|
433 |
|
|
# load via $readmemh().
|
434 |
500 |
julius |
SIM_DIR_VMEM_IMAGE ?=sram.vmem
|
435 |
6 |
julius |
|
436 |
468 |
julius |
ifeq ($(USER_ELF),)
|
437 |
|
|
ELF_FILE=$(TEST_SW_DIR)/$(TEST).elf
|
438 |
|
|
else
|
439 |
|
|
ELF_FILE=$(USER_ELF)
|
440 |
|
|
ELF_FILE_NOTDIR=$(notdir $(USER_ELF))
|
441 |
|
|
ELF_FILE_NOTDIR_BASENAME=$(basename $(ELF_FILE_NOTDIR))
|
442 |
|
|
endif
|
443 |
6 |
julius |
|
444 |
468 |
julius |
# Rules allowing user to specify a pre-existing VMEM file to load into the
|
445 |
|
|
# simulation, instead of compiling a test.
|
446 |
|
|
ifeq ($(USER_VMEM),)
|
447 |
|
|
VMEM_FILE=$(TEST_SW_DIR)/$(TEST).vmem
|
448 |
|
|
.PHONY: $(VMEM_FILE)
|
449 |
|
|
|
450 |
|
|
|
451 |
|
|
# If USER_ELF was specified, then we need a slightly different way of
|
452 |
|
|
# generating the VMEM file from it than a usual test
|
453 |
|
|
ifeq ($(USER_ELF),)
|
454 |
500 |
julius |
$(SIM_DIR_VMEM_IMAGE): $(VMEM_FILE)
|
455 |
360 |
julius |
$(Q)if [ -L $@ ]; then unlink $@; fi
|
456 |
468 |
julius |
$(Q)if [ -e $@ ]; then rm $@; fi
|
457 |
360 |
julius |
$(Q)ln -s $< $@
|
458 |
468 |
julius |
else
|
459 |
500 |
julius |
$(SIM_DIR_VMEM_IMAGE): $(USER_ELF)
|
460 |
468 |
julius |
$(Q)$(MAKE) -C $(SW_DIR)/lib \
|
461 |
|
|
USER_ELF_BIN=`pwd`/$(ELF_FILE_NOTDIR_BASENAME).bin \
|
462 |
|
|
USER_ELF_VMEM=`pwd`/$(ELF_FILE_NOTDIR_BASENAME).vmem \
|
463 |
|
|
gen-user-elf-vmem
|
464 |
|
|
$(Q)cp -v $(ELF_FILE_NOTDIR_BASENAME).vmem $@
|
465 |
6 |
julius |
|
466 |
468 |
julius |
TEST=$(ELF_FILE_NOTDIR_BASENAME)
|
467 |
|
|
endif
|
468 |
|
|
|
469 |
|
|
else
|
470 |
|
|
VMEM_FILE=$(USER_VMEM)
|
471 |
|
|
USER_VMEM_NOTDIR=$(notdir $(USER_VMEM))
|
472 |
|
|
TEST=$(basename $(USER_VMEM_NOTDIR))
|
473 |
|
|
|
474 |
500 |
julius |
$(SIM_DIR_VMEM_IMAGE): $(VMEM_FILE)
|
475 |
468 |
julius |
cp -v $< $@
|
476 |
|
|
|
477 |
|
|
endif
|
478 |
|
|
|
479 |
|
|
|
480 |
|
|
|
481 |
|
|
|
482 |
|
|
.PHONY : sw-vmem sw-elf
|
483 |
500 |
julius |
sw-vmem: $(SIM_DIR_VMEM_IMAGE)
|
484 |
468 |
julius |
|
485 |
360 |
julius |
$(TEST_SW_DIR)/$(TEST).vmem:
|
486 |
|
|
$(Q) echo; echo "\t### Compiling software ###"; echo;
|
487 |
|
|
$(Q)$(MAKE) -C $(TEST_SW_DIR) $(TEST).vmem
|
488 |
63 |
julius |
|
489 |
425 |
julius |
# Compile ELF and copy it here
|
490 |
468 |
julius |
sw-elf: $(ELF_FILE)
|
491 |
425 |
julius |
$(Q)cp -v $< .
|
492 |
|
|
|
493 |
|
|
$(TEST_SW_DIR)/$(TEST).elf:
|
494 |
|
|
$(Q) echo; echo "\t### Compiling software ###"; echo;
|
495 |
|
|
$(Q)$(MAKE) -C $(TEST_SW_DIR) $(TEST).elf
|
496 |
|
|
|
497 |
|
|
|
498 |
397 |
julius |
# Rule to force generation of the processed orpsoc-defines.h file
|
499 |
|
|
processed-verilog-headers-in-c-for-vlt:
|
500 |
|
|
$(Q)$(MAKE) -C $(SW_DIR)/lib processed-verilog-headers
|
501 |
|
|
# Now copy the file into the Verilated model build path
|
502 |
|
|
$(Q)cp $(SW_DIR)/lib/include/orpsoc-defines.h $(SIM_VLT_DIR)
|
503 |
|
|
|
504 |
435 |
julius |
# Create test software disassembly
|
505 |
|
|
|
506 |
|
|
sw-dis: $(TEST_SW_DIR)/$(TEST).dis
|
507 |
|
|
$(Q)cp -v $< .
|
508 |
|
|
|
509 |
|
|
$(TEST_SW_DIR)/$(TEST).dis:
|
510 |
|
|
$(Q)$(MAKE) -C $(TEST_SW_DIR) $(TEST).dis
|
511 |
|
|
|
512 |
|
|
|
513 |
360 |
julius |
#
|
514 |
|
|
# Cleaning rules
|
515 |
|
|
#
|
516 |
362 |
julius |
clean: clean-sim clean-sim-test-sw clean-bootrom clean-vlt clean-out clean-sw
|
517 |
63 |
julius |
|
518 |
360 |
julius |
clean-sim:
|
519 |
|
|
$(Q) echo; echo "\t### Cleaning simulation run directory ###"; echo;
|
520 |
|
|
$(Q)rm -rf *.* lib_* work transcript check-test-log
|
521 |
468 |
julius |
$(Q) if [ -e $(VPI_SRC_C_DIR) ]; then \
|
522 |
|
|
$(MAKE) -C $(VPI_SRC_C_DIR) clean; \
|
523 |
|
|
fi
|
524 |
6 |
julius |
|
525 |
360 |
julius |
clean-bootrom:
|
526 |
|
|
$(MAKE) -C $(BOOTROM_SW_DIR) clean
|
527 |
6 |
julius |
|
528 |
360 |
julius |
clean-out:
|
529 |
|
|
$(Q)rm -rf $(RTL_SIM_RESULTS_DIR)/*.*
|
530 |
6 |
julius |
|
531 |
363 |
julius |
# Clean away verilator build path and objects in SystemC path
|
532 |
362 |
julius |
clean-vlt:
|
533 |
|
|
$(Q)rm -rf $(SIM_VLT_DIR)
|
534 |
475 |
julius |
$(Q)$(MAKE) -C $(BENCH_SYSC_SRC_DIR) -f \
|
535 |
|
|
$(BENCH_SYSC_SRC_DIR)/Modules.make clean
|
536 |
362 |
julius |
|
537 |
360 |
julius |
clean-test-defines:
|
538 |
|
|
$(Q)rm -f $(TEST_DEFINES_VLG)
|
539 |
6 |
julius |
|
540 |
360 |
julius |
clean-sim-test-sw:
|
541 |
500 |
julius |
$(Q)if [ -L $(SIM_DIR_VMEM_IMAGE) ]; then unlink $(SIM_DIR_VMEM_IMAGE); fi
|
542 |
6 |
julius |
|
543 |
|
|
clean-sw:
|
544 |
360 |
julius |
$(Q) echo; echo "\t### Cleaning simulation sw directories ###"; echo;
|
545 |
449 |
julius |
$(Q) $(MAKE) -C $(SW_DIR)/lib distclean
|
546 |
6 |
julius |
|
547 |
36 |
julius |
clean-rtl:
|
548 |
360 |
julius |
$(Q) echo; echo "\t### Cleaning generated verilog RTL ###"; echo;
|
549 |
|
|
for module in $(RTL_TO_CHECK); do \
|
550 |
|
|
$(MAKE) -C $(RTL_VERILOG_DIR)/$$module clean; \
|
551 |
|
|
done
|
552 |
44 |
julius |
|
553 |
360 |
julius |
# Removes any checked out RTL
|
554 |
|
|
distclean: clean
|
555 |
|
|
$(Q) echo; echo "\t### Cleaning generated verilog RTL ###"; echo;
|
556 |
|
|
$(Q)for module in $(RTL_TO_CHECK); do \
|
557 |
|
|
$(MAKE) -C $(RTL_VERILOG_DIR)/$$module distclean; \
|
558 |
|
|
done
|
559 |
362 |
julius |
|
560 |
|
|
################################################################################
|
561 |
|
|
# Verilator model build rules
|
562 |
|
|
################################################################################
|
563 |
|
|
|
564 |
|
|
VLT_EXE=Vorpsoc_top
|
565 |
|
|
VLT_SCRIPT=verilator.scr
|
566 |
|
|
|
567 |
|
|
# Script for Verilator
|
568 |
475 |
julius |
$(SIM_VLT_DIR)/$(VLT_SCRIPT): $(RTL_VERILOG_SRC) $(RTL_VERILOG_INCLUDES) \
|
569 |
|
|
$(BOOTROM_VERILOG)
|
570 |
362 |
julius |
$(Q)echo "\tGenerating Verilator script"
|
571 |
|
|
$(Q)echo "# Verilator sources script" > $@
|
572 |
|
|
$(Q)echo "# Auto generated. Any alterations will be written over!" >> $@
|
573 |
|
|
$(Q)echo "+incdir+"$(RTL_VERILOG_INCLUDE_DIR) > $@;
|
574 |
|
|
$(Q)echo "+incdir+"$(BOOTROM_SW_DIR) >> $@;
|
575 |
|
|
$(Q)echo "+incdir+"$(SIM_RUN_DIR) >> $@;
|
576 |
475 |
julius |
$(Q)for module in $(RTL_VERILOG_MODULES); do \
|
577 |
|
|
echo "-y " $(RTL_VERILOG_DIR)/$$module >> $@; \
|
578 |
|
|
done
|
579 |
362 |
julius |
$(Q)echo $(DUT_TOP) >> $@;
|
580 |
|
|
$(Q) echo >> $@
|
581 |
|
|
|
582 |
|
|
|
583 |
|
|
SYSC_LIB_ARCH_DIR=$(shell ls $$SYSTEMC | grep "lib-")
|
584 |
|
|
|
585 |
|
|
|
586 |
|
|
# List of System C models - use this list to link the sources into the Verilator
|
587 |
|
|
# build directory
|
588 |
|
|
SYSC_MODELS=OrpsocAccess MemoryLoad
|
589 |
|
|
|
590 |
363 |
julius |
ifdef VLT_LINT
|
591 |
|
|
VLT_FLAGS +=--lint-only
|
592 |
|
|
endif
|
593 |
|
|
|
594 |
362 |
julius |
ifdef VLT_DEBUG
|
595 |
|
|
VLT_DEBUG_COMPILE_FLAGS = -g
|
596 |
|
|
# Enabling the following generates a TON of debugging
|
597 |
|
|
# when running verilator. Not so helpful.
|
598 |
363 |
julius |
#VLT_FLAGS = --debug --dump-tree
|
599 |
362 |
julius |
VLT_SYSC_DEBUG_DEFINE = VLT_DEBUG=1
|
600 |
|
|
endif
|
601 |
|
|
|
602 |
363 |
julius |
# This will build a verilator model that will generate profiling information
|
603 |
|
|
# suitable for gprof
|
604 |
|
|
# Run it through gprof after exection with: gprof Vorpsoc_top > gprof.out
|
605 |
|
|
# then run this through the Verilator tool with:
|
606 |
|
|
# verilator_profcfunc gprof.out > vprof.out
|
607 |
|
|
ifdef VLT_EXECUTION_PROFILE_BUILD
|
608 |
|
|
VLT_CPPFLAGS +=-g -pg
|
609 |
|
|
# Maybe add these to VLT_CPPFLAGS: -ftest-coverage -fprofile-arcs
|
610 |
|
|
VLT_FLAGS +=-profile-cfuncs
|
611 |
|
|
endif
|
612 |
|
|
|
613 |
|
|
# If set on the command line we build the cycle accurate model which will
|
614 |
|
|
# generate verilator-specific profiling information. This is useful for
|
615 |
|
|
# checking the efficiency of the model - not really useful for checking code
|
616 |
|
|
# or the function of the model.
|
617 |
|
|
ifdef VLT_DO_PERFORMANCE_PROFILE_BUILD
|
618 |
475 |
julius |
VLT_CPPFLAGS += -fprofile-generate -fbranch-probabilities -fvpt \
|
619 |
|
|
-funroll-loops -fpeel-loops -ftracer
|
620 |
362 |
julius |
else
|
621 |
|
|
VLT_CPPFLAGS +=-fprofile-use -Wcoverage-mismatch
|
622 |
|
|
endif
|
623 |
|
|
|
624 |
363 |
julius |
# Set VLT_IN_GDB=1 when making if going to run the cycle accurate model
|
625 |
|
|
# executable in GDB.
|
626 |
362 |
julius |
ifdef VLT_IN_GDB
|
627 |
|
|
VLT_CPPFLAGS +=-g -O0
|
628 |
|
|
else
|
629 |
|
|
# The default optimisation flag applied to all of the cycle accurate model files
|
630 |
|
|
VLT_CPPFLAGS +=-O3
|
631 |
|
|
endif
|
632 |
|
|
|
633 |
|
|
# VCD Enabled by default when building, enable it at runtime
|
634 |
|
|
VLT_FLAGS +=-trace
|
635 |
|
|
TRACE_FLAGS=-DVM_TRACE=1 -I${SYSTEMPERL}/src
|
636 |
|
|
|
637 |
363 |
julius |
# Verilator tuning
|
638 |
|
|
# Inlining:
|
639 |
|
|
VLT_FLAGS +=--inline-mult 1
|
640 |
|
|
# Optimisation option for Verilator scripts
|
641 |
|
|
VLT_FLAGS +=-O3
|
642 |
475 |
julius |
# X-assign - at reset, all signals are set to random values, helps find
|
643 |
|
|
# reset bugs
|
644 |
363 |
julius |
VLT_FLAGS +=-x-assign unique
|
645 |
|
|
|
646 |
362 |
julius |
VLT_TRACEOBJ = verilated_vcd_c
|
647 |
|
|
|
648 |
363 |
julius |
|
649 |
362 |
julius |
# This is the list of extra models we'll issue make commands for
|
650 |
|
|
# Included is the SystemPerl trace model
|
651 |
|
|
SYSC_MODELS_BUILD=$(SYSC_MODELS) $(VLT_TRACEOBJ)
|
652 |
|
|
|
653 |
|
|
# List of sources for rule sensitivity
|
654 |
|
|
SYSC_MODEL_SOURCES=$(shell ls $(BENCH_SYSC_SRC_DIR)/*.cpp)
|
655 |
|
|
SYSC_MODEL_SOURCES +=$(shell ls $(BENCH_SYSC_INCLUDE_DIR)/*.h)
|
656 |
|
|
|
657 |
475 |
julius |
VLT_MODULES_OBJS=$(shell for mod in $(SYSC_MODELS_BUILD); do \
|
658 |
|
|
echo $(SIM_VLT_DIR)/$$mod.o; \
|
659 |
|
|
done)
|
660 |
362 |
julius |
|
661 |
475 |
julius |
VLT_MODEL_LINKS=$(shell for SYSCMODEL in $(SYSC_MODELS); do \
|
662 |
|
|
echo $(SIM_VLT_DIR)/$$SYSCMODEL.cpp; \
|
663 |
|
|
done)
|
664 |
362 |
julius |
|
665 |
|
|
# Make Verilator build path if it doesn't exist
|
666 |
|
|
$(SIM_VLT_DIR):
|
667 |
|
|
mkdir -p $@
|
668 |
|
|
|
669 |
|
|
# Dummy files the RTL requires: timescale.v
|
670 |
|
|
DUMMY_FILES_FOR_VLT=$(SIM_VLT_DIR)/timescale.v
|
671 |
|
|
$(DUMMY_FILES_FOR_VLT):
|
672 |
|
|
$(Q)for file in $@; do if [ ! -e $$file ]; then touch $$file; fi; done
|
673 |
|
|
|
674 |
397 |
julius |
build-vlt: rtl $(SIM_VLT_DIR) $(DUMMY_FILES_FOR_VLT) $(VLT_MODEL_LINKS) \
|
675 |
|
|
processed-verilog-headers-in-c-for-vlt $(SIM_VLT_DIR)/$(VLT_EXE)
|
676 |
362 |
julius |
|
677 |
|
|
# Main Cycle-accurate build rule
|
678 |
|
|
prepare-vlt: build-vlt
|
679 |
|
|
@echo;echo "\tCycle-accurate model compiled successfully"
|
680 |
|
|
@echo;echo "\tRun the executable with the -h option for usage instructions:";echo
|
681 |
|
|
$(SIM_VLT_DIR)/$(VLT_EXE) -h
|
682 |
|
|
@echo;echo
|
683 |
|
|
|
684 |
475 |
julius |
$(SIM_VLT_DIR)/$(VLT_EXE): $(SIM_VLT_DIR)/lib$(VLT_EXE).a \
|
685 |
|
|
$(SIM_VLT_DIR)/OrpsocMain.o
|
686 |
|
|
# Final linking of the simulation executable. Order of libraries here is
|
687 |
|
|
# important!
|
688 |
362 |
julius |
$(Q)echo; echo "\tGenerating simulation executable"; echo
|
689 |
475 |
julius |
$(Q)cd $(SIM_VLT_DIR) && \
|
690 |
|
|
g++ $(VLT_DEBUG_COMPILE_FLAGS) \
|
691 |
|
|
$(VLT_CPPFLAGS) -I$(BENCH_SYSC_INCLUDE_DIR) -I$(SIM_VLT_DIR) \
|
692 |
|
|
-I$(VERILATOR_ROOT)/include -I$(SYSTEMC)/include -o $(VLT_EXE) \
|
693 |
|
|
-L. -L$(BENCH_SYSC_SRC_DIR) -L$(SYSTEMC)/$(SYSC_LIB_ARCH_DIR) \
|
694 |
|
|
OrpsocMain.o -l$(VLT_EXE) -lmodules -lsystemc
|
695 |
362 |
julius |
|
696 |
475 |
julius |
# Now compile the top level systemC "testbench" module from the systemC source
|
697 |
|
|
# path
|
698 |
362 |
julius |
$(SIM_VLT_DIR)/OrpsocMain.o: $(BENCH_SYSC_SRC_DIR)/OrpsocMain.cpp
|
699 |
|
|
@echo; echo "\tCompiling top level SystemC testbench"; echo
|
700 |
475 |
julius |
cd $(SIM_VLT_DIR) && \
|
701 |
|
|
g++ $(VLT_DEBUG_COMPILE_FLAGS) $(VLT_CPPFLAGS) $(TRACE_FLAGS) \
|
702 |
|
|
-I$(BENCH_SYSC_INCLUDE_DIR) -I$(SIM_VLT_DIR) \
|
703 |
|
|
-I$(VERILATOR_ROOT)/include -I$(SYSTEMC)/include -c \
|
704 |
|
|
$(BENCH_SYSC_SRC_DIR)/OrpsocMain.cpp
|
705 |
362 |
julius |
|
706 |
475 |
julius |
$(SIM_VLT_DIR)/lib$(VLT_EXE).a: $(SIM_VLT_DIR)/$(VLT_EXE)__ALL.a \
|
707 |
|
|
$(VLT_MODULES_OBJS) $(SIM_VLT_DIR)/verilated.o
|
708 |
|
|
# Now archive all of the libraries from verilator witht he other modules we
|
709 |
|
|
# might have
|
710 |
362 |
julius |
@echo; echo "\tArchiving libraries into lib"$(VLT_EXE)".a"; echo
|
711 |
|
|
$(Q)cd $(SIM_VLT_DIR) && \
|
712 |
|
|
cp $(VLT_EXE)__ALL.a lib$(VLT_EXE).a && \
|
713 |
|
|
ar rcs lib$(VLT_EXE).a verilated.o; \
|
714 |
|
|
for SYSCMODEL in $(SYSC_MODELS_BUILD); do \
|
715 |
|
|
ar rcs lib$(VLT_EXE).a $$SYSCMODEL.o; \
|
716 |
|
|
done
|
717 |
|
|
|
718 |
|
|
$(SIM_VLT_DIR)/verilated.o: $(SYSC_MODEL_SOURCES)
|
719 |
|
|
@echo; echo "\tCompiling verilated.o"; echo
|
720 |
|
|
$(Q)cd $(SIM_VLT_DIR) && \
|
721 |
|
|
export CXXFLAGS=$(VLT_DEBUG_COMPILE_FLAGS); \
|
722 |
|
|
export USER_CPPFLAGS="$(VLT_CPPFLAGS)"; \
|
723 |
|
|
export USER_LDDFLAGS="$(VLT_CPPFLAGS)"; \
|
724 |
|
|
$(MAKE) -f $(VLT_EXE).mk verilated.o
|
725 |
|
|
|
726 |
|
|
print-sysmod-objs:
|
727 |
|
|
$(Q)echo $(VLT_MODULES_OBJS):
|
728 |
|
|
|
729 |
|
|
$(VLT_MODULES_OBJS):
|
730 |
|
|
# Compile the module files
|
731 |
|
|
@echo; echo "\tCompiling SystemC models"
|
732 |
|
|
$(Q)cd $(SIM_VLT_DIR) && \
|
733 |
|
|
for SYSCMODEL in $(SYSC_MODELS_BUILD); do \
|
734 |
|
|
echo;echo "\t$$SYSCMODEL"; echo; \
|
735 |
|
|
export CXXFLAGS=$(VLT_DEBUG_COMPILE_FLAGS); \
|
736 |
|
|
export USER_CPPFLAGS="$(VLT_CPPFLAGS) -I$(BENCH_SYSC_INCLUDE_DIR)"; \
|
737 |
|
|
export USER_LDDFLAGS="$(VLT_CPPFLAGS)"; \
|
738 |
|
|
$(MAKE) -f $(VLT_EXE).mk $$SYSCMODEL.o; \
|
739 |
|
|
done
|
740 |
|
|
|
741 |
475 |
julius |
$(SIM_VLT_DIR)/$(VLT_EXE)__ALL.a: $(SIM_VLT_DIR)/$(VLT_EXE).mk \
|
742 |
|
|
$(SYSC_MODEL_SOURCES)
|
743 |
362 |
julius |
@echo; echo "\tCompiling main design"; echo
|
744 |
|
|
$(Q)cd $(SIM_VLT_DIR) && \
|
745 |
|
|
export USER_CPPFLAGS="$(VLT_CPPFLAGS)"; \
|
746 |
|
|
export USER_LDDFLAGS="$(VLT_CPPFLAGS)"; \
|
747 |
|
|
$(MAKE) -f $(VLT_EXE).mk $(VLT_EXE)__ALL.a
|
748 |
|
|
|
749 |
475 |
julius |
$(SIM_VLT_DIR)/$(VLT_EXE).mk: $(SIM_VLT_DIR)/$(VLT_SCRIPT) \
|
750 |
|
|
$(BENCH_SYSC_SRC_DIR)/libmodules.a
|
751 |
362 |
julius |
# Now call verilator to generate the .mk files
|
752 |
|
|
$(Q)echo; echo "\tGenerating makefiles with Verilator"; echo
|
753 |
|
|
$(Q)cd $(SIM_VLT_DIR) && \
|
754 |
475 |
julius |
verilator -language 1364-2001 --top-module orpsoc_top -Mdir . -sc \
|
755 |
|
|
$(VLT_FLAGS) -I$(BENCH_SYSC_INCLUDE_DIR) -I$(BENCH_SYSC_SRC_DIR) \
|
756 |
|
|
-f $(SIM_VLT_DIR)/$(VLT_SCRIPT)
|
757 |
362 |
julius |
|
758 |
|
|
# SystemC modules library
|
759 |
|
|
$(BENCH_SYSC_SRC_DIR)/libmodules.a:
|
760 |
|
|
@echo; echo "\tCompiling SystemC modules"; echo
|
761 |
|
|
$(Q)export VLT_CPPFLAGS="$(VLT_CPPFLAGS)"; \
|
762 |
475 |
julius |
$(MAKE) -C $(BENCH_SYSC_SRC_DIR) \
|
763 |
|
|
-f $(BENCH_SYSC_SRC_DIR)/Modules.make $(VLT_SYSC_DEBUG_DEFINE)
|
764 |
362 |
julius |
|
765 |
|
|
print-vlt-model-link-paths:
|
766 |
|
|
$(Q)echo $(VLT_MODEL_LINKS)
|
767 |
|
|
|
768 |
|
|
$(VLT_MODEL_LINKS):
|
769 |
|
|
# Link all the required system C model files into the verilator work dir
|
770 |
476 |
julius |
$(Q)for SYSCMODEL in $(SYSC_MODELS); do \
|
771 |
362 |
julius |
if [ ! -e $(SIM_VLT_DIR)/$$SYSCMODEL.cpp ]; then \
|
772 |
476 |
julius |
echo \
|
773 |
|
|
"\tLinking SystemC model $$SYSCMODEL Verilator model build path"; \
|
774 |
475 |
julius |
ln -s $(BENCH_SYSC_SRC_DIR)/$$SYSCMODEL.cpp \
|
775 |
|
|
$(SIM_VLT_DIR)/$$SYSCMODEL.cpp; \
|
776 |
|
|
ln -s $(BENCH_SYSC_INCLUDE_DIR)/$$SYSCMODEL.h \
|
777 |
|
|
$(SIM_VLT_DIR)/$$SYSCMODEL.h; \
|
778 |
362 |
julius |
fi; \
|
779 |
|
|
done
|
780 |
|
|
|
781 |
|
|
|
782 |
|
|
################################################################################
|
783 |
|
|
# Verilator model test rules
|
784 |
|
|
################################################################################
|
785 |
|
|
|
786 |
425 |
julius |
vlt-test: build-vlt clean-sim-test-sw sw-vmem
|
787 |
362 |
julius |
$(SIM_VLT_DIR)/$(VLT_EXE) $(TEST)
|
788 |
|
|
|
789 |
|
|
vlt-tests:
|
790 |
|
|
$(Q)for test in $(TESTS); do \
|
791 |
|
|
export TEST=$$test; \
|
792 |
|
|
$(MAKE) vlt-test; \
|
793 |
|
|
if [ $$? -ne 0 ]; then break; fi; \
|
794 |
|
|
echo; echo "\t### $$test test OK ###"; echo; \
|
795 |
|
|
done
|
796 |
|
|
|
797 |
|
|
|
798 |
|
|
|
799 |
|
|
###############################################################################
|
800 |
|
|
# Verilator profiled model build rules
|
801 |
|
|
###############################################################################
|
802 |
476 |
julius |
# To run this, first run a "make prepare-vlt-profiled"
|
803 |
362 |
julius |
# This new make target copies athe results of the profiling back to the right
|
804 |
|
|
# paths before we create everything again
|
805 |
|
|
###############################################################################
|
806 |
|
|
.PHONY: prepare-vlt-profiled
|
807 |
363 |
julius |
prepare-vlt-profiled: $(SIM_VLT_DIR)/OrpsocMain.gcda \
|
808 |
|
|
clean-vlt-after-profile-run \
|
809 |
|
|
rtl $(SIM_VLT_DIR) $(DUMMY_FILES_FOR_VLT) $(VLT_MODEL_LINKS) \
|
810 |
|
|
$(SIM_VLT_DIR)/$(VLT_EXE)
|
811 |
362 |
julius |
|
812 |
|
|
$(SIM_VLT_DIR)/OrpsocMain.gcda: $(SIM_VLT_DIR)/$(VLT_EXE)-for-profiling
|
813 |
397 |
julius |
$(MAKE) -C $(SW_DIR)/apps/dhry dhry.elf NUM_RUNS=5000
|
814 |
|
|
$(SIM_VLT_DIR)/$(VLT_EXE) -f $(SW_DIR)/apps/dhry/dhry.elf
|
815 |
362 |
julius |
|
816 |
363 |
julius |
# Clean all compiled things
|
817 |
|
|
clean-vlt-after-profile-run:
|
818 |
|
|
$(Q)echo "\tCleaning away compiled cycle-accurate files"
|
819 |
|
|
$(Q)rm -f $(SIM_VLT_DIR)/*.[oa] $(SIM_VLT_DIR)/$(VLT_EXE)
|
820 |
|
|
$(Q)rm -f $(BENCH_SYSC_SRC_DIR)/*.[oa]
|
821 |
|
|
|
822 |
|
|
#.PHONY: $(SIM_VLT_DIR)/$(VLT_EXE)-for-profiling
|
823 |
362 |
julius |
$(SIM_VLT_DIR)/$(VLT_EXE)-for-profiling:
|
824 |
363 |
julius |
$(MAKE) build-vlt VLT_DO_PERFORMANCE_PROFILE_BUILD=1
|
825 |
362 |
julius |
|
826 |
|
|
.PHONY: vlt-restore-profileoutput
|
827 |
|
|
vlt-restore-profileoutput:
|
828 |
|
|
@echo;echo "\tRestoring profiling outputs"; echo
|
829 |
|
|
$(Q)mkdir -p ../vlt
|
830 |
|
|
$(Q)cp /tmp/*.gc* $(SIM_VLT_DIR)
|
831 |
|
|
$(Q)cp /tmp/*.gc* $(BENCH_SYSC_SRC_DIR)
|
832 |
363 |
julius |
|
833 |
|
|
|
834 |
|
|
lint-vlt: $(SIM_VLT_DIR) rtl $(DUMMY_FILES_FOR_VLT) $(SIM_VLT_DIR)/$(VLT_SCRIPT)
|
835 |
|
|
$(Q)echo; echo "\tLinting design with Verilator"; echo
|
836 |
|
|
$(Q)cd $(SIM_VLT_DIR) && \
|
837 |
475 |
julius |
verilator -language 1364-2001 --top-module orpsoc_top --lint-only \
|
838 |
|
|
-Mdir . -sc $(VLT_FLAGS) -I$(BENCH_SYSC_INCLUDE_DIR) \
|
839 |
|
|
-I$(BENCH_SYSC_SRC_DIR) -f $(SIM_VLT_DIR)/$(VLT_SCRIPT)
|
840 |
425 |
julius |
|
841 |
|
|
################################################################################
|
842 |
|
|
# Architectural simulator test rules
|
843 |
|
|
################################################################################
|
844 |
|
|
|
845 |
|
|
ARCH_SIM_EXE ?=or32-elf-sim
|
846 |
475 |
julius |
ARCH_SIM_CFG ?= ../bin/refdesign-or1ksim.cfg
|
847 |
425 |
julius |
ARCH_SIM_OPTS ?= -q
|
848 |
|
|
|
849 |
|
|
.PHONY: rtl-test
|
850 |
|
|
sim-test: clean-sim-test-sw sw-elf
|
851 |
431 |
julius |
$(Q)echo; echo "\t### Launching simulation ###"; echo
|
852 |
425 |
julius |
$(Q)$(ARCH_SIM_EXE) $(ARCH_SIM_OPTS) -f $(ARCH_SIM_CFG) $(TEST).elf > \
|
853 |
|
|
$(RTL_SIM_RESULTS_DIR)/$(TEST)$(TEST_OUT_FILE_SUFFIX)
|
854 |
|
|
|
855 |
|
|
# Run tests in simulation, check output
|
856 |
|
|
sim-test-with-check: sim-test check-test-log
|
857 |
|
|
|
858 |
|
|
# Main architectural simulations test loop
|
859 |
|
|
sim-tests:
|
860 |
|
|
$(Q)for test in $(TESTS); do \
|
861 |
|
|
export TEST=$$test; \
|
862 |
|
|
$(MAKE) sim-test-with-check; \
|
863 |
|
|
if [ $$? -ne 0 ]; then break; fi; \
|
864 |
|
|
echo; echo "\t### $$test test OK ###"; echo; \
|
865 |
|
|
done
|