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