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 45

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