OpenCores
URL https://opencores.org/ocsvn/test_project/test_project/trunk

Subversion Repositories test_project

[/] [test_project/] [trunk/] [sim/] [bin/] [Makefile] - Blame information for rev 43

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
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 41 julius
VLT_COMMAND_FILE=verilator.scr
94 22 julius
SIM_MEM_FILE="flash.in"
95 32 julius
SIM_SUCCESS_MESSAGE=deaddead
96 22 julius
 
97
.PHONY: prepare_rtl
98
prepare_rtl:
99 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
100 43 julius
        @cd $(RTL_VERILOG_DIR) && sed '/defparam/!s/\([a-zA-Z0-9_]\)\.//g' intercon.vm > intercon.v
101 22 julius
 
102 26 julius
.PHONY: prepare_sw
103
prepare_sw:
104
        @$(MAKE) -C $(SW_DIR)/support
105
        @$(MAKE) -C $(SW_DIR)/utils
106
 
107 39 julius
# Rough guide to how these tests work:
108
# First, the couple of custom, required, software tools under sw/utils are
109
# compiled, and then the software library files.
110
# Next the few verilog files that need preperation are taken care of.
111
# The test begins by starting a loop in bash using on the strings defined in
112
# TESTS. Each one corresponds to a certain module of software for the OpenRISC
113
# that is included in this test suite. Under the sw/ path is a set of paths,
114
# and all except the support/ and utils/ paths contain code which is run to test
115
# the OR1k used in this test suite. For each of these software modules, it is
116
# possible that different tests are done using the same module. These tests can
117
# vary by either using different levels of optimisation during compilation,
118
# and/or by having the OR1k's caches enabled or disabled.
119
# Each test has a unique name, and under the $(SIM_RESULTS_DIR), which is
120
# usually just ../results, log files, and optionally VCD files, are created for
121
# inspection later and are named according to the test. Inspect the file
122
# bench/verilog/or1200_monitor.v to find out in detail what each log consists of.
123
# For each test, a few things occur. First the software that will run inside
124
# the simulated OR1k system is compiled, converted to a format which can be read
125
# into the flash memory model via $readmemh() and linked to the sim/run
126
# directory as $(SIM_MEM_FILE), which currently is flash.in. Next a compilation
127
# script for icarus is generated, containing a list of all the RTL files and
128
# include directories. Next, an include file for the verilog testbench is
129
# generated, containing a string of the name of the current test, path to the
130
# results directory (for VCD generation) and any other things which might vary
131
# from test to test. This is not done by +define lines in the icarus script
132
# because of string handling incosistencies between different simulators and
133
# shells.
134
# Once all the files are generated, icarus is called to compile the rtl design,
135
# and then run it.
136
# Each of the tested software modules have code which will trigger the
137
# simulation to be stopped by use of the l.nop instruction with an immediate
138
# value of 1. When the simulation finishes, the simulation executable exits and
139
# the log of the simulation is inspected for the expected output. Currently, the
140
# string "deaddead" indicates that the software completed successfully. This is
141
# counted as the ORPSoC "passing" the test. In fact, whether the system did the
142
# right thing or not requires more inspection, but roughly this is a good
143
# indicator that nothing major went wrong.
144
# Once the current test is finished, the next begins with the compilation of its
145
# software and linking of the resulting hex file to the run path, etc.
146
rtl-tests: prepare_sw prepare_rtl
147 22 julius
        @if [ ! -d $(SIM_RESULTS_DIR) ]; then mkdir -p $(SIM_RESULTS_DIR); fi
148 33 julius
        @echo
149
        @echo "Beginning loop that will complete the following tests: $(TESTS)"
150
        @echo
151 31 julius
        @for TEST in $(TESTS); do \
152 33 julius
                echo "################################################################################"; \
153
                echo; \
154
                echo "\t#### Current test: $$TEST ####"; echo; \
155 32 julius
                echo "\t#### Compiling software ####"; echo; \
156 22 julius
                CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
157
                $(MAKE) -C $$CURRENT_TEST_SW_DIR $$TEST; \
158
                rm -f $(SIM_RUN_DIR)/$(SIM_MEM_FILE); \
159
                ln -s $$CURRENT_TEST_SW_DIR/$$TEST.hex $(SIM_RUN_DIR)/$(SIM_MEM_FILE); \
160
                sed < $(SIM_BIN_DIR)/$(ICARUS_COMMAND_FILE) > $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated \
161
                        -e s!\$$BENCH_DIR!$(BENCH_VERILOG_DIR)!              \
162
                        -e s!\$$RTL_DIR!$(RTL_VERILOG_DIR)!                  \
163
                        -e s!\$$BACKEND_DIR!$(BACKEND_DIR)!                  \
164
                        -e \\!^//.*\$$!d -e \\!^\$$!d ; \
165 34 julius
                echo "+define+TEST_DEFINE_FILE=\"test_define.v\"" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
166 26 julius
                if [ ! -z $$VCD ]; \
167
                        then echo "+define+VCD" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
168
                fi; \
169 34 julius
                echo "\`define TEST_NAME_STRING \"$$TEST\"" > $(SIM_RUN_DIR)/test_define.v; \
170
                echo "\`define TEST_RESULTS_DIR \"$(SIM_RESULTS_DIR)/\" " >> $(SIM_RUN_DIR)/test_define.v; \
171 39 julius
                if [ -z $$NO_SIM_LOGGING ]; then \
172
                        echo "\`define OR1200_DISPLAY_ARCH_STATE" >> $(SIM_RUN_DIR)/test_define.v; \
173
                fi; \
174 22 julius
                echo ; \
175 32 julius
                echo "\t#### Compiling RTL ####"; \
176 22 julius
                rm -f $(SIM_RUN_DIR)/a.out; \
177 43 julius
                $(ICARUS) -sorpsoc_testbench -c $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated $(RTL_SIM_FLAGS); \
178 22 julius
                echo; \
179 32 julius
                echo "\t#### Beginning simulation ####"; \
180 33 julius
                time -p $(ICARUS_VVP) -l $(SIM_RESULTS_DIR)/$$TEST-vvp-out.log a.out ; \
181 36 julius
                if [ $$? -gt 0 ]; then exit $$?; fi; \
182
                TEST_RESULT=`cat $(SIM_RESULTS_DIR)/$$TEST-general.log | grep report | grep $(SIM_SUCCESS_MESSAGE) -c`; \
183 33 julius
                echo; echo "\t####"; \
184 34 julius
                if [ $$TEST_RESULT -gt 0 ]; then \
185 32 julius
                        echo "\t#### Test $$TEST PASSED ####";\
186
                else    echo "\t#### Test $$TEST FAILED ####";\
187
                fi; \
188 33 julius
                echo "\t####"; echo; \
189 22 julius
        done
190 33 julius
 
191
 
192 39 julius
# Use NCSIM instead of icarus
193
rtl-nc-tests: prepare_sw prepare_rtl
194 35 julius
        @if [ ! -d $(SIM_RESULTS_DIR) ]; then mkdir -p $(SIM_RESULTS_DIR); fi
195
        @echo
196
        @echo "Beginning loop that will complete the following tests: $(TESTS)"
197
        @echo
198
        @for TEST in $(TESTS); do \
199
                echo "################################################################################"; \
200
                echo; \
201
                echo "\t#### Current test: $$TEST ####"; echo; \
202
                echo "\t#### Compiling software ####"; echo; \
203
                CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
204
                $(MAKE) -C $$CURRENT_TEST_SW_DIR $$TEST; \
205
                rm -f $(SIM_RUN_DIR)/$(SIM_MEM_FILE); \
206
                ln -s $$CURRENT_TEST_SW_DIR/$$TEST.hex $(SIM_RUN_DIR)/$(SIM_MEM_FILE); \
207
                sed < $(SIM_BIN_DIR)/$(ICARUS_COMMAND_FILE) > $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated \
208
                        -e s!\$$BENCH_DIR!$(BENCH_VERILOG_DIR)!              \
209
                        -e s!\$$RTL_DIR!$(RTL_VERILOG_DIR)!                  \
210
                        -e s!\$$BACKEND_DIR!$(BACKEND_DIR)!                  \
211
                        -e \\!^//.*\$$!d -e \\!^\$$!d ; \
212
                echo "+define+TEST_DEFINE_FILE=\"test_define.v\"" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
213
                if [ ! -z $$VCD ]; \
214
                        then echo "+define+VCD" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
215
                        echo "+access+r" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
216
                fi; \
217 36 julius
                echo "+nocopyright" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
218
                echo "+nowarn+MACRDF" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
219 35 julius
                echo "\`define TEST_NAME_STRING \"$$TEST\"" > $(SIM_RUN_DIR)/test_define.v; \
220
                echo "\`define TEST_RESULTS_DIR \"$(SIM_RESULTS_DIR)/\" " >> $(SIM_RUN_DIR)/test_define.v; \
221 39 julius
                if [ -z $$NO_SIM_LOGGING ]; then \
222
                        echo "\`define OR1200_DISPLAY_ARCH_STATE" >> $(SIM_RUN_DIR)/test_define.v; \
223
                fi; \
224 35 julius
                echo ; \
225
                echo "\t#### Beginning simulation ####"; \
226 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); \
227
                if [ $$? -gt 0 ]; then exit $$?; fi; \
228
                TEST_RESULT=`cat $(SIM_RESULTS_DIR)/$$TEST-general.log | grep report | grep $(SIM_SUCCESS_MESSAGE) -c`; \
229 35 julius
                echo; echo "\t####"; \
230
                if [ $$TEST_RESULT -gt 0 ]; then \
231
                        echo "\t#### Test $$TEST PASSED ####";\
232
                else    echo "\t#### Test $$TEST FAILED ####";\
233
                fi; \
234
                echo "\t####"; echo; \
235
        done
236 33 julius
 
237
 
238 41 julius
 
239
vlt-tests: prepare_sw prepare_rtl prepare_vlt
240
        @if [ ! -d $(SIM_RESULTS_DIR) ]; then mkdir -p $(SIM_RESULTS_DIR); fi
241
        @echo
242
        @echo "Beginning loop that will complete the following tests: $(TESTS)"
243
        @echo
244
        @for TEST in $(TESTS); do \
245
                echo "################################################################################"; \
246
                echo; \
247
                echo "\t#### Current test: $$TEST ####"; echo; \
248
                echo "\t#### Compiling software ####"; echo; \
249
                CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
250
                $(MAKE) -C $$CURRENT_TEST_SW_DIR $$TEST; \
251
                rm -f $(SIM_RUN_DIR)/$(SIM_MEM_FILE); \
252
                ln -s $$CURRENT_TEST_SW_DIR/$$TEST.hex $(SIM_RUN_DIR)/$(SIM_MEM_FILE); \
253
                echo ; \
254
                echo "\t#### Compiling RTL ####"; \
255
                rm -f $(SIM_RUN_DIR)/a.out; \
256
                $(ICARUS) -c $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated $(RTL_SIM_FLAGS); \
257
                echo; \
258
                echo "\t#### Beginning simulation ####"; \
259
                time -p $(ICARUS_VVP) -l $(SIM_RESULTS_DIR)/$$TEST-vvp-out.log a.out ; \
260
                if [ $$? -gt 0 ]; then exit $$?; fi; \
261
                TEST_RESULT=`cat $(SIM_RESULTS_DIR)/$$TEST-general.log | grep report | grep $(SIM_SUCCESS_MESSAGE) -c`; \
262
                echo; echo "\t####"; \
263
                if [ $$TEST_RESULT -gt 0 ]; then \
264
                        echo "\t#### Test $$TEST PASSED ####";\
265
                else    echo "\t#### Test $$TEST FAILED ####";\
266
                fi; \
267
                echo "\t####"; echo; \
268
        done
269
 
270 43 julius
prepare_vlt: prepare_rtl
271 41 julius
        sed < $(SIM_BIN_DIR)/$(VLT_COMMAND_FILE) > $(SIM_RUN_DIR)/$(VLT_COMMAND_FILE).generated \
272
                        -e s!\$$BENCH_DIR!$(BENCH_VERILOG_DIR)!              \
273
                        -e s!\$$RTL_DIR!$(RTL_VERILOG_DIR)!                  \
274
                        -e s!\$$BACKEND_DIR!$(BACKEND_DIR)!                  \
275
                        -e \\!^//.*\$$!d -e \\!^\$$!d;
276 42 julius
        verilator -language 1364-2001 -Wno-lint --top-module orpsoc_top -Mdir . -sc -f $(VLT_COMMAND_FILE).generated
277 41 julius
 
278
 
279 22 julius
clean-sw:
280
        @for TEST in $(TESTS); do \
281
                echo "Current test: $$TEST"; \
282
                CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
283
                echo "Current test sw directory: " $$CURRENT_TEST_SW_DIR; \
284
                $(MAKE) -C $$CURRENT_TEST_SW_DIR clean; \
285
        done
286 31 julius
        $(MAKE) -C $(SW_DIR)/support clean
287
        $(MAKE) -C $(SW_DIR)/utils clean
288
 
289
clean-sim:
290 34 julius
        rm -rf $(SIM_RESULTS_DIR) $(SIM_RUN_DIR)/*.*

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.