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 47

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