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