1 |
39 |
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 design. ####
|
9 |
|
|
#### ####
|
10 |
|
|
#### To Do: ####
|
11 |
|
|
#### - Verilator tests ####
|
12 |
|
|
#### ####
|
13 |
|
|
#### Author(s): ####
|
14 |
|
|
#### - jb, jb@orsoc.se ####
|
15 |
|
|
#### ####
|
16 |
|
|
#### ####
|
17 |
|
|
######################################################################
|
18 |
|
|
#### ####
|
19 |
|
|
#### Copyright (C) 2009 Authors and OPENCORES.ORG ####
|
20 |
|
|
#### ####
|
21 |
|
|
#### This source file may be used and distributed without ####
|
22 |
|
|
#### restriction provided that this copyright statement is not ####
|
23 |
|
|
#### removed from the file and that any derivative work contains ####
|
24 |
|
|
#### the original copyright notice and the associated disclaimer. ####
|
25 |
|
|
#### ####
|
26 |
|
|
#### This source file is free software; you can redistribute it ####
|
27 |
|
|
#### and/or modify it under the terms of the GNU Lesser General ####
|
28 |
|
|
#### Public License as published by the Free Software Foundation; ####
|
29 |
|
|
#### either version 2.1 of the License, or (at your option) any ####
|
30 |
|
|
#### later version. ####
|
31 |
|
|
#### ####
|
32 |
|
|
#### This source is distributed in the hope that it will be ####
|
33 |
|
|
#### useful, but WITHOUT ANY WARRANTY; without even the implied ####
|
34 |
|
|
#### warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ####
|
35 |
|
|
#### PURPOSE. See the GNU Lesser General Public License for more ####
|
36 |
|
|
#### details. ####
|
37 |
|
|
#### ####
|
38 |
|
|
#### You should have received a copy of the GNU Lesser General ####
|
39 |
|
|
#### Public License along with this source; if not, download it ####
|
40 |
|
|
#### from http://www.opencores.org/lgpl.shtml ####
|
41 |
|
|
#### ####
|
42 |
|
|
######################################################################
|
43 |
22 |
julius |
|
44 |
39 |
julius |
# Use: Type "make rtl-tests" to run all of the tests on the RTL model
|
45 |
|
|
# run in the Icarus Verilog simulator.
|
46 |
|
|
|
47 |
|
|
# The results and output of the simulation are in the results path,
|
48 |
|
|
# in parallel to the simulation run and bin paths. This directory is
|
49 |
|
|
# not checked into the repository, but is created when simulations are
|
50 |
|
|
# run.
|
51 |
|
|
|
52 |
|
|
# To run an individual test, specify it in the variable TESTS when
|
53 |
|
|
# calling make, like "make rtl-tests TESTS="mmu-nocache mul-idcd-O2".
|
54 |
|
|
|
55 |
|
|
# VCD (value change dumps, usable in a waveform viewer, such as gtkwave
|
56 |
|
|
# to inspect the internals of the system graphically) files can be
|
57 |
|
|
# generated by calling the make with VCD=1, like "make rtl-tests VCD=1"
|
58 |
|
|
# and a vcd file will be created in the simulation results directory,
|
59 |
|
|
# and named according to the test run which generated it.
|
60 |
|
|
|
61 |
|
|
# The rtl simulations can also be run with Cadences NCSim by using
|
62 |
|
|
# rtl-nc-tests in the place of rtl-tests.
|
63 |
|
|
|
64 |
|
|
# It is possible to speed up the simulation slightly by disabling
|
65 |
|
|
# log output of the processor's state to files by defining
|
66 |
|
|
# NO_SIM_LOGGING, eg. make rtl-tests TESTS=except-icdc NO_SIM_LOGGING=1
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
# Name of the directory we're currently in
|
70 |
22 |
julius |
CUR_DIR=$(shell pwd)
|
71 |
39 |
julius |
|
72 |
|
|
# The root path of the whole project
|
73 |
22 |
julius |
PROJECT_ROOT=$(CUR_DIR)/../..
|
74 |
|
|
|
75 |
39 |
julius |
# Tests is only defined if it wasn't already defined when make was called
|
76 |
|
|
# This is the default list of every test that is currently possible
|
77 |
33 |
julius |
TESTS ?= basic-nocache cbasic-nocache-O2 dhry-nocache-O2 except-nocache mmu-nocache mul-nocache-O2 syscall-nocache tick-nocache uart-nocache basic-icdc cbasic-icdc-O2 dhry-icdc-O2 except-icdc mmu-icdc mul-icdc-O2 syscall-icdc tick-icdc uart-icdc
|
78 |
22 |
julius |
|
79 |
39 |
julius |
# Paths to other important parts of this test suite
|
80 |
22 |
julius |
SIM_DIR=$(PROJECT_ROOT)/sim
|
81 |
|
|
SIM_RUN_DIR=$(SIM_DIR)/run
|
82 |
|
|
SIM_BIN_DIR=$(SIM_DIR)/bin
|
83 |
|
|
SIM_RESULTS_DIR=$(SIM_DIR)/results
|
84 |
|
|
BENCH_DIR=$(PROJECT_ROOT)/bench
|
85 |
|
|
BACKEND_DIR=$(PROJECT_ROOT)/backend
|
86 |
|
|
BENCH_VERILOG_DIR=$(BENCH_DIR)/verilog
|
87 |
|
|
RTL_VERILOG_DIR=$(PROJECT_ROOT)/rtl/verilog
|
88 |
|
|
SW_DIR=$(PROJECT_ROOT)/sw
|
89 |
|
|
|
90 |
|
|
ICARUS=iverilog
|
91 |
|
|
ICARUS_VVP=vvp
|
92 |
|
|
ICARUS_COMMAND_FILE=icarus.scr
|
93 |
|
|
SIM_MEM_FILE="flash.in"
|
94 |
32 |
julius |
SIM_SUCCESS_MESSAGE=deaddead
|
95 |
22 |
julius |
|
96 |
|
|
.PHONY: prepare_rtl
|
97 |
|
|
prepare_rtl:
|
98 |
26 |
julius |
@cd $(RTL_VERILOG_DIR)/components/wb_sdram_ctrl && perl fizzim.pl -encoding onehot -terse < wb_sdram_ctrl_fsm.fzm > wb_sdram_ctrl_fsm.v
|
99 |
22 |
julius |
|
100 |
26 |
julius |
.PHONY: prepare_sw
|
101 |
|
|
prepare_sw:
|
102 |
|
|
@$(MAKE) -C $(SW_DIR)/support
|
103 |
|
|
@$(MAKE) -C $(SW_DIR)/utils
|
104 |
|
|
|
105 |
39 |
julius |
# Rough guide to how these tests work:
|
106 |
|
|
# First, the couple of custom, required, software tools under sw/utils are
|
107 |
|
|
# compiled, and then the software library files.
|
108 |
|
|
# Next the few verilog files that need preperation are taken care of.
|
109 |
|
|
# The test begins by starting a loop in bash using on the strings defined in
|
110 |
|
|
# TESTS. Each one corresponds to a certain module of software for the OpenRISC
|
111 |
|
|
# that is included in this test suite. Under the sw/ path is a set of paths,
|
112 |
|
|
# and all except the support/ and utils/ paths contain code which is run to test
|
113 |
|
|
# the OR1k used in this test suite. For each of these software modules, it is
|
114 |
|
|
# possible that different tests are done using the same module. These tests can
|
115 |
|
|
# vary by either using different levels of optimisation during compilation,
|
116 |
|
|
# and/or by having the OR1k's caches enabled or disabled.
|
117 |
|
|
# Each test has a unique name, and under the $(SIM_RESULTS_DIR), which is
|
118 |
|
|
# usually just ../results, log files, and optionally VCD files, are created for
|
119 |
|
|
# inspection later and are named according to the test. Inspect the file
|
120 |
|
|
# bench/verilog/or1200_monitor.v to find out in detail what each log consists of.
|
121 |
|
|
# For each test, a few things occur. First the software that will run inside
|
122 |
|
|
# the simulated OR1k system is compiled, converted to a format which can be read
|
123 |
|
|
# into the flash memory model via $readmemh() and linked to the sim/run
|
124 |
|
|
# directory as $(SIM_MEM_FILE), which currently is flash.in. Next a compilation
|
125 |
|
|
# script for icarus is generated, containing a list of all the RTL files and
|
126 |
|
|
# include directories. Next, an include file for the verilog testbench is
|
127 |
|
|
# generated, containing a string of the name of the current test, path to the
|
128 |
|
|
# results directory (for VCD generation) and any other things which might vary
|
129 |
|
|
# from test to test. This is not done by +define lines in the icarus script
|
130 |
|
|
# because of string handling incosistencies between different simulators and
|
131 |
|
|
# shells.
|
132 |
|
|
# Once all the files are generated, icarus is called to compile the rtl design,
|
133 |
|
|
# and then run it.
|
134 |
|
|
# Each of the tested software modules have code which will trigger the
|
135 |
|
|
# simulation to be stopped by use of the l.nop instruction with an immediate
|
136 |
|
|
# value of 1. When the simulation finishes, the simulation executable exits and
|
137 |
|
|
# the log of the simulation is inspected for the expected output. Currently, the
|
138 |
|
|
# string "deaddead" indicates that the software completed successfully. This is
|
139 |
|
|
# counted as the ORPSoC "passing" the test. In fact, whether the system did the
|
140 |
|
|
# right thing or not requires more inspection, but roughly this is a good
|
141 |
|
|
# indicator that nothing major went wrong.
|
142 |
|
|
# Once the current test is finished, the next begins with the compilation of its
|
143 |
|
|
# software and linking of the resulting hex file to the run path, etc.
|
144 |
|
|
rtl-tests: prepare_sw prepare_rtl
|
145 |
22 |
julius |
@if [ ! -d $(SIM_RESULTS_DIR) ]; then mkdir -p $(SIM_RESULTS_DIR); fi
|
146 |
33 |
julius |
@echo
|
147 |
|
|
@echo "Beginning loop that will complete the following tests: $(TESTS)"
|
148 |
|
|
@echo
|
149 |
31 |
julius |
@for TEST in $(TESTS); do \
|
150 |
33 |
julius |
echo "################################################################################"; \
|
151 |
|
|
echo; \
|
152 |
|
|
echo "\t#### Current test: $$TEST ####"; echo; \
|
153 |
32 |
julius |
echo "\t#### Compiling software ####"; echo; \
|
154 |
22 |
julius |
CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
|
155 |
|
|
$(MAKE) -C $$CURRENT_TEST_SW_DIR $$TEST; \
|
156 |
|
|
rm -f $(SIM_RUN_DIR)/$(SIM_MEM_FILE); \
|
157 |
|
|
ln -s $$CURRENT_TEST_SW_DIR/$$TEST.hex $(SIM_RUN_DIR)/$(SIM_MEM_FILE); \
|
158 |
|
|
sed < $(SIM_BIN_DIR)/$(ICARUS_COMMAND_FILE) > $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated \
|
159 |
|
|
-e s!\$$BENCH_DIR!$(BENCH_VERILOG_DIR)! \
|
160 |
|
|
-e s!\$$RTL_DIR!$(RTL_VERILOG_DIR)! \
|
161 |
|
|
-e s!\$$BACKEND_DIR!$(BACKEND_DIR)! \
|
162 |
|
|
-e \\!^//.*\$$!d -e \\!^\$$!d ; \
|
163 |
34 |
julius |
echo "+define+TEST_DEFINE_FILE=\"test_define.v\"" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
|
164 |
26 |
julius |
if [ ! -z $$VCD ]; \
|
165 |
|
|
then echo "+define+VCD" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
|
166 |
|
|
fi; \
|
167 |
34 |
julius |
echo "\`define TEST_NAME_STRING \"$$TEST\"" > $(SIM_RUN_DIR)/test_define.v; \
|
168 |
|
|
echo "\`define TEST_RESULTS_DIR \"$(SIM_RESULTS_DIR)/\" " >> $(SIM_RUN_DIR)/test_define.v; \
|
169 |
39 |
julius |
if [ -z $$NO_SIM_LOGGING ]; then \
|
170 |
|
|
echo "\`define OR1200_DISPLAY_ARCH_STATE" >> $(SIM_RUN_DIR)/test_define.v; \
|
171 |
|
|
fi; \
|
172 |
22 |
julius |
echo ; \
|
173 |
32 |
julius |
echo "\t#### Compiling RTL ####"; \
|
174 |
22 |
julius |
rm -f $(SIM_RUN_DIR)/a.out; \
|
175 |
|
|
$(ICARUS) -c $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated $(RTL_SIM_FLAGS); \
|
176 |
|
|
echo; \
|
177 |
32 |
julius |
echo "\t#### Beginning simulation ####"; \
|
178 |
33 |
julius |
time -p $(ICARUS_VVP) -l $(SIM_RESULTS_DIR)/$$TEST-vvp-out.log a.out ; \
|
179 |
36 |
julius |
if [ $$? -gt 0 ]; then exit $$?; fi; \
|
180 |
|
|
TEST_RESULT=`cat $(SIM_RESULTS_DIR)/$$TEST-general.log | grep report | grep $(SIM_SUCCESS_MESSAGE) -c`; \
|
181 |
33 |
julius |
echo; echo "\t####"; \
|
182 |
34 |
julius |
if [ $$TEST_RESULT -gt 0 ]; then \
|
183 |
32 |
julius |
echo "\t#### Test $$TEST PASSED ####";\
|
184 |
|
|
else echo "\t#### Test $$TEST FAILED ####";\
|
185 |
|
|
fi; \
|
186 |
33 |
julius |
echo "\t####"; echo; \
|
187 |
22 |
julius |
done
|
188 |
33 |
julius |
|
189 |
|
|
|
190 |
39 |
julius |
# Use NCSIM instead of icarus
|
191 |
|
|
rtl-nc-tests: prepare_sw prepare_rtl
|
192 |
35 |
julius |
@if [ ! -d $(SIM_RESULTS_DIR) ]; then mkdir -p $(SIM_RESULTS_DIR); fi
|
193 |
|
|
@echo
|
194 |
|
|
@echo "Beginning loop that will complete the following tests: $(TESTS)"
|
195 |
|
|
@echo
|
196 |
|
|
@for TEST in $(TESTS); do \
|
197 |
|
|
echo "################################################################################"; \
|
198 |
|
|
echo; \
|
199 |
|
|
echo "\t#### Current test: $$TEST ####"; echo; \
|
200 |
|
|
echo "\t#### Compiling software ####"; echo; \
|
201 |
|
|
CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
|
202 |
|
|
$(MAKE) -C $$CURRENT_TEST_SW_DIR $$TEST; \
|
203 |
|
|
rm -f $(SIM_RUN_DIR)/$(SIM_MEM_FILE); \
|
204 |
|
|
ln -s $$CURRENT_TEST_SW_DIR/$$TEST.hex $(SIM_RUN_DIR)/$(SIM_MEM_FILE); \
|
205 |
|
|
sed < $(SIM_BIN_DIR)/$(ICARUS_COMMAND_FILE) > $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated \
|
206 |
|
|
-e s!\$$BENCH_DIR!$(BENCH_VERILOG_DIR)! \
|
207 |
|
|
-e s!\$$RTL_DIR!$(RTL_VERILOG_DIR)! \
|
208 |
|
|
-e s!\$$BACKEND_DIR!$(BACKEND_DIR)! \
|
209 |
|
|
-e \\!^//.*\$$!d -e \\!^\$$!d ; \
|
210 |
|
|
echo "+define+TEST_DEFINE_FILE=\"test_define.v\"" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
|
211 |
|
|
if [ ! -z $$VCD ]; \
|
212 |
|
|
then echo "+define+VCD" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
|
213 |
|
|
echo "+access+r" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
|
214 |
|
|
fi; \
|
215 |
36 |
julius |
echo "+nocopyright" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
|
216 |
|
|
echo "+nowarn+MACRDF" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
|
217 |
35 |
julius |
echo "\`define TEST_NAME_STRING \"$$TEST\"" > $(SIM_RUN_DIR)/test_define.v; \
|
218 |
|
|
echo "\`define TEST_RESULTS_DIR \"$(SIM_RESULTS_DIR)/\" " >> $(SIM_RUN_DIR)/test_define.v; \
|
219 |
39 |
julius |
if [ -z $$NO_SIM_LOGGING ]; then \
|
220 |
|
|
echo "\`define OR1200_DISPLAY_ARCH_STATE" >> $(SIM_RUN_DIR)/test_define.v; \
|
221 |
|
|
fi; \
|
222 |
35 |
julius |
echo ; \
|
223 |
|
|
echo "\t#### Beginning simulation ####"; \
|
224 |
36 |
julius |
time -p ncverilog -f $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated -Q -l $(SIM_RESULTS_DIR)/$$TEST-ius-out.log $(RTL_SIM_FLAGS); \
|
225 |
|
|
if [ $$? -gt 0 ]; then exit $$?; fi; \
|
226 |
|
|
TEST_RESULT=`cat $(SIM_RESULTS_DIR)/$$TEST-general.log | grep report | grep $(SIM_SUCCESS_MESSAGE) -c`; \
|
227 |
35 |
julius |
echo; echo "\t####"; \
|
228 |
|
|
if [ $$TEST_RESULT -gt 0 ]; then \
|
229 |
|
|
echo "\t#### Test $$TEST PASSED ####";\
|
230 |
|
|
else echo "\t#### Test $$TEST FAILED ####";\
|
231 |
|
|
fi; \
|
232 |
|
|
echo "\t####"; echo; \
|
233 |
|
|
done
|
234 |
33 |
julius |
|
235 |
|
|
|
236 |
22 |
julius |
clean-sw:
|
237 |
|
|
@for TEST in $(TESTS); do \
|
238 |
|
|
echo "Current test: $$TEST"; \
|
239 |
|
|
CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
|
240 |
|
|
echo "Current test sw directory: " $$CURRENT_TEST_SW_DIR; \
|
241 |
|
|
$(MAKE) -C $$CURRENT_TEST_SW_DIR clean; \
|
242 |
|
|
done
|
243 |
31 |
julius |
$(MAKE) -C $(SW_DIR)/support clean
|
244 |
|
|
$(MAKE) -C $(SW_DIR)/utils clean
|
245 |
|
|
|
246 |
|
|
clean-sim:
|
247 |
34 |
julius |
rm -rf $(SIM_RESULTS_DIR) $(SIM_RUN_DIR)/*.*
|