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 56

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 55 julius
# Usage:
45
#
46
#       make rtl-tests
47
#
48
#       Run the software tests in the RTL model of the ORPSoC being
49
#       simulated with an event-driven simulator like Icarus. Also
50
#       possible to use Cadence's Verilog simulators with the
51
#       "rtl-nc-tests" target.
52
#
53
#       make vlt-tests
54
#
55
#       Run all the software tests in the RTL model which has been
56
#       converted into a cycle-accurate SystemC model with Verilator.
57
#
58 39 julius
 
59 55 julius
# Simulation results:
60
#
61
# The results and output of the event-driven simulations are in the
62
# results path, in parallel to the simulation run and bin paths.
63 39 julius
 
64 55 julius
# Specific tests:
65
#
66 39 julius
# To run an individual test, specify it in the variable TESTS when
67 55 julius
# calling make, eg:
68
#
69
#        make rtl-tests TESTS="mmu-nocache mul-idcd-O2"
70 39 julius
 
71 55 julius
# UART printf:
72
#
73
# It is possible to enable printf to the console via the UART when
74
# running the event-driven simulators. To do this define UART_PRINTF=1
75
# when calling make. The SystemC cycle-acccurate model uses this by
76
# default.
77
 
78
# VCDs:
79
#
80 39 julius
# VCD (value change dumps, usable in a waveform viewer, such as gtkwave
81
# to inspect the internals of the system graphically) files can be
82 55 julius
# generated by defining a variable VCD, eg.
83
#
84
#       make rtl-tests VCD=1
85
#
86
# and a dump file will be created in the simulation results directory,
87
# and named according to the test run which generated it. This is
88
# possible for both event-driven and cycle-accurate simulations.
89
# However the cycle-accurate
90 39 julius
 
91
# The rtl simulations can also be run with Cadences NCSim by using
92
# rtl-nc-tests in the place of rtl-tests.
93
 
94
# It is possible to speed up the simulation slightly by disabling
95
# log output of the processor's state to files by defining
96
# NO_SIM_LOGGING, eg. make rtl-tests TESTS=except-icdc NO_SIM_LOGGING=1
97
 
98
 
99
# Name of the directory we're currently in
100 22 julius
CUR_DIR=$(shell pwd)
101 39 julius
 
102
# The root path of the whole project
103 22 julius
PROJECT_ROOT=$(CUR_DIR)/../..
104
 
105 39 julius
# Tests is only defined if it wasn't already defined when make was called
106
# This is the default list of every test that is currently possible
107 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
108 22 julius
 
109 39 julius
# Paths to other important parts of this test suite
110 22 julius
SIM_DIR=$(PROJECT_ROOT)/sim
111
SIM_RUN_DIR=$(SIM_DIR)/run
112
SIM_BIN_DIR=$(SIM_DIR)/bin
113
SIM_RESULTS_DIR=$(SIM_DIR)/results
114 44 julius
SIM_VLT_DIR=$(SIM_DIR)/vlt
115 22 julius
BENCH_DIR=$(PROJECT_ROOT)/bench
116
BACKEND_DIR=$(PROJECT_ROOT)/backend
117
BENCH_VERILOG_DIR=$(BENCH_DIR)/verilog
118 44 julius
BENCH_SYSC_DIR=$(BENCH_DIR)/sysc
119 47 julius
BENCH_SYSC_SRC_DIR=$(BENCH_SYSC_DIR)/src
120
BENCH_SYSC_INCLUDE_DIR=$(BENCH_SYSC_DIR)/include
121 22 julius
RTL_VERILOG_DIR=$(PROJECT_ROOT)/rtl/verilog
122
SW_DIR=$(PROJECT_ROOT)/sw
123
 
124
ICARUS=iverilog
125
ICARUS_VVP=vvp
126
ICARUS_COMMAND_FILE=icarus.scr
127 41 julius
VLT_COMMAND_FILE=verilator.scr
128 32 julius
SIM_SUCCESS_MESSAGE=deaddead
129 22 julius
 
130 56 julius
ARCH_SIM_EXE=or32-elf-sim
131
ARCH_SIM_CFG_FILE=or1ksim-orpsocv2.cfg
132
 
133 45 julius
# If USE_SDRAM is defined we'll add it to the simulator's defines on the
134
# command line becuase it's used by many different modules and it's easier
135
# to do it this way than make them all include a file.
136
ifdef USE_SDRAM
137
RTL_SIM_FLAGS += "-D USE_SDRAM=$(USE_SDRAM)"
138
endif
139
SIM_FLASH_MEM_FILE="flash.in"
140
FLASH_MEM_FILE_SUFFIX="-twobyte-sizefirst.hex"
141
SIM_SRAM_MEM_FILE="sram.vmem"
142
 
143 52 julius
TESTS_PASSED=0
144
TESTS_PERFORMED=0;
145
 
146
################################################################################
147
# Event-driven simulator build rules (Icarus, NCSim)
148
################################################################################
149
 
150 22 julius
.PHONY: prepare_rtl
151
prepare_rtl:
152 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
153 43 julius
        @cd $(RTL_VERILOG_DIR) && sed '/defparam/!s/\([a-zA-Z0-9_]\)\.//g' intercon.vm > intercon.v
154 22 julius
 
155 52 julius
 
156
ifdef UART_PRINTF
157
TEST_SW_MAKE_OPTS=UART_PRINTF=1
158
endif
159
 
160 26 julius
.PHONY: prepare_sw
161
prepare_sw:
162 52 julius
        @$(MAKE) -C $(SW_DIR)/support all $(TEST_SW_MAKE_OPTS)
163
        @$(MAKE) -C $(SW_DIR)/utils all
164 26 julius
 
165 54 julius
# A rule with UART_PRINTF hard defined ... used by verilator make sw
166 53 julius
prepare_sw_uart_printf:
167
        @$(MAKE) -C $(SW_DIR)/support all UART_PRINTF=1 $(TEST_SW_MAKE_OPTS)
168
        @$(MAKE) -C $(SW_DIR)/utils all
169 52 julius
 
170 53 julius
 
171 39 julius
# Rough guide to how these tests work:
172
# First, the couple of custom, required, software tools under sw/utils are
173
# compiled, and then the software library files.
174
# Next the few verilog files that need preperation are taken care of.
175
# The test begins by starting a loop in bash using on the strings defined in
176
# TESTS. Each one corresponds to a certain module of software for the OpenRISC
177
# that is included in this test suite. Under the sw/ path is a set of paths,
178 45 julius
# and all except the support/ and utils/ paths contain code which is run to
179
# test the OR1k used in this test suite. For each of these software modules,
180
# it is possible that different tests are done using the same module. These
181
# tests can vary by either using different levels of optimisation during
182
# compilation, and/or by having the OR1k's caches enabled or disabled.
183 39 julius
# Each test has a unique name, and under the $(SIM_RESULTS_DIR), which is
184
# usually just ../results, log files, and optionally VCD files, are created for
185
# inspection later and are named according to the test. Inspect the file
186 45 julius
# bench/verilog/or1200_monitor.v to find out in detail what each log consists
187
# of.
188 39 julius
# For each test, a few things occur. First the software that will run inside
189 45 julius
# the simulated OR1k system is compiled, converted to a format which can be
190
# read
191 39 julius
# into the flash memory model via $readmemh() and linked to the sim/run
192 45 julius
# directory as $(SIM_FLASH_MEM_FILE), which currently is flash.in. Next a
193
# compilation script for icarus is generated, containing a list of all the
194
# RTL files and include directories. Next, an include file for the verilog
195
# testbench is generated, containing a string of the name of the current
196
# test, path to the results directory (for VCD generation) and any other
197
# things which might vary from test to test. This is not done by +define
198
# lines in the icarus script because of string handling incosistencies
199
# between different simulators and shells.
200
# Once all the files are generated, icarus is called to compile the rtl
201
# design, and then run it. Each of the tested software modules have code which
202
# will trigger the simulation to be stopped by use of the l.nop instruction
203
# with an immediate value of 1. When the simulation finishes, the simulation
204
# executable exits and the log of the simulation is inspected for the expected
205
# output. Currently, the string "deaddead" indicates that the software
206
# completed successfully. This is counted as the ORPSoC "passing" the test. In
207
# fact, whether the system did the right thing or not requires more
208
# inspection, but roughly this is a good indicator that nothing major went
209
# wrong.
210 39 julius
# Once the current test is finished, the next begins with the compilation of its
211
# software and linking of the resulting hex file to the run path, etc.
212 45 julius
# Main RAM setup - (RTL simulation with Icarus/NCSim only!):
213
# Define USE_SDRAM to enable the external SDRAM, otherwise the simulation
214
# defaults to an internal SRAM. Eg. $ make rtl-tests USE_SDRAM=1 VCD=1
215
# Verilator defaults to internal memories
216 39 julius
rtl-tests: prepare_sw prepare_rtl
217 22 julius
        @if [ ! -d $(SIM_RESULTS_DIR) ]; then mkdir -p $(SIM_RESULTS_DIR); fi
218 33 julius
        @echo
219
        @echo "Beginning loop that will complete the following tests: $(TESTS)"
220
        @echo
221 31 julius
        @for TEST in $(TESTS); do \
222 33 julius
                echo "################################################################################"; \
223
                echo; \
224
                echo "\t#### Current test: $$TEST ####"; echo; \
225 32 julius
                echo "\t#### Compiling software ####"; echo; \
226 22 julius
                CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
227 52 julius
                $(MAKE) -C $$CURRENT_TEST_SW_DIR $$TEST $(TEST_SW_MAKE_OPTS); \
228 45 julius
                rm -f $(SIM_RUN_DIR)/$(SIM_FLASH_MEM_FILE); \
229
                rm -f $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
230
                ln -s $$CURRENT_TEST_SW_DIR/$$TEST$(FLASH_MEM_FILE_SUFFIX) $(SIM_RUN_DIR)/$(SIM_FLASH_MEM_FILE); \
231
                ln -s $$CURRENT_TEST_SW_DIR/$$TEST.vmem $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
232 22 julius
                sed < $(SIM_BIN_DIR)/$(ICARUS_COMMAND_FILE) > $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated \
233
                        -e s!\$$BENCH_DIR!$(BENCH_VERILOG_DIR)!              \
234
                        -e s!\$$RTL_DIR!$(RTL_VERILOG_DIR)!                  \
235
                        -e s!\$$BACKEND_DIR!$(BACKEND_DIR)!                  \
236
                        -e \\!^//.*\$$!d -e \\!^\$$!d ; \
237 34 julius
                echo "+define+TEST_DEFINE_FILE=\"test_define.v\"" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
238 26 julius
                if [ ! -z $$VCD ]; \
239
                        then echo "+define+VCD" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
240
                fi; \
241 54 julius
                if [ ! -z $$UART_PRINTF ]; \
242
                        then echo "+define+UART_PRINTF" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
243
                fi; \
244 34 julius
                echo "\`define TEST_NAME_STRING \"$$TEST\"" > $(SIM_RUN_DIR)/test_define.v; \
245
                echo "\`define TEST_RESULTS_DIR \"$(SIM_RESULTS_DIR)/\" " >> $(SIM_RUN_DIR)/test_define.v; \
246 39 julius
                if [ -z $$NO_SIM_LOGGING ]; then \
247
                        echo "\`define OR1200_DISPLAY_ARCH_STATE" >> $(SIM_RUN_DIR)/test_define.v; \
248
                fi; \
249 22 julius
                echo ; \
250 32 julius
                echo "\t#### Compiling RTL ####"; \
251 22 julius
                rm -f $(SIM_RUN_DIR)/a.out; \
252 43 julius
                $(ICARUS) -sorpsoc_testbench -c $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated $(RTL_SIM_FLAGS); \
253 22 julius
                echo; \
254 32 julius
                echo "\t#### Beginning simulation ####"; \
255 33 julius
                time -p $(ICARUS_VVP) -l $(SIM_RESULTS_DIR)/$$TEST-vvp-out.log a.out ; \
256 36 julius
                if [ $$? -gt 0 ]; then exit $$?; fi; \
257
                TEST_RESULT=`cat $(SIM_RESULTS_DIR)/$$TEST-general.log | grep report | grep $(SIM_SUCCESS_MESSAGE) -c`; \
258 33 julius
                echo; echo "\t####"; \
259 34 julius
                if [ $$TEST_RESULT -gt 0 ]; then \
260 52 julius
                        echo "\t#### Test $$TEST PASSED ####";TESTS_PASSED=`expr $$TESTS_PASSED + 1`;\
261 32 julius
                else    echo "\t#### Test $$TEST FAILED ####";\
262
                fi; \
263 33 julius
                echo "\t####"; echo; \
264 52 julius
                TESTS_PERFORMED=`expr $$TESTS_PERFORMED + 1`;\
265
        done; \
266
        echo "Test results: "$$TESTS_PASSED" out of "$$TESTS_PERFORMED" tests passed"; echo
267 33 julius
 
268
 
269 52 julius
 
270 39 julius
# Use NCSIM instead of icarus
271
rtl-nc-tests: prepare_sw prepare_rtl
272 35 julius
        @if [ ! -d $(SIM_RESULTS_DIR) ]; then mkdir -p $(SIM_RESULTS_DIR); fi
273
        @echo
274
        @echo "Beginning loop that will complete the following tests: $(TESTS)"
275
        @echo
276
        @for TEST in $(TESTS); do \
277
                echo "################################################################################"; \
278
                echo; \
279
                echo "\t#### Current test: $$TEST ####"; echo; \
280
                echo "\t#### Compiling software ####"; echo; \
281
                CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
282
                $(MAKE) -C $$CURRENT_TEST_SW_DIR $$TEST; \
283 45 julius
                rm -f $(SIM_RUN_DIR)/$(SIM_FLASH_MEM_FILE); \
284
                rm -f $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
285
                ln -s $$CURRENT_TEST_SW_DIR/$$TEST_twobyte_sizefirst.hex $(SIM_RUN_DIR)/$(SIM_FLASH_MEM_FILE); \
286
                ln -s $$CURRENT_TEST_SW_DIR/$$TEST_fourbyte.hex $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
287 35 julius
                sed < $(SIM_BIN_DIR)/$(ICARUS_COMMAND_FILE) > $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated \
288
                        -e s!\$$BENCH_DIR!$(BENCH_VERILOG_DIR)!              \
289
                        -e s!\$$RTL_DIR!$(RTL_VERILOG_DIR)!                  \
290
                        -e s!\$$BACKEND_DIR!$(BACKEND_DIR)!                  \
291
                        -e \\!^//.*\$$!d -e \\!^\$$!d ; \
292
                echo "+define+TEST_DEFINE_FILE=\"test_define.v\"" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
293
                if [ ! -z $$VCD ]; \
294
                        then echo "+define+VCD" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
295
                        echo "+access+r" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
296
                fi; \
297 54 julius
                if [ ! -z $$UART_PRINTF ]; \
298
                        then echo "+define+UART_PRINTF" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
299
                fi; \
300 45 julius
                if [ ! -z $$USE_SDRAM ]; then \
301
                        echo "\`define USE_SDRAM" >> $(SIM_RUN_DIR)/test_define.v; \
302
                fi; \
303 36 julius
                echo "+nocopyright" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
304
                echo "+nowarn+MACRDF" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
305 35 julius
                echo "\`define TEST_NAME_STRING \"$$TEST\"" > $(SIM_RUN_DIR)/test_define.v; \
306
                echo "\`define TEST_RESULTS_DIR \"$(SIM_RESULTS_DIR)/\" " >> $(SIM_RUN_DIR)/test_define.v; \
307 39 julius
                if [ -z $$NO_SIM_LOGGING ]; then \
308
                        echo "\`define OR1200_DISPLAY_ARCH_STATE" >> $(SIM_RUN_DIR)/test_define.v; \
309
                fi; \
310 35 julius
                echo ; \
311
                echo "\t#### Beginning simulation ####"; \
312 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); \
313
                if [ $$? -gt 0 ]; then exit $$?; fi; \
314
                TEST_RESULT=`cat $(SIM_RESULTS_DIR)/$$TEST-general.log | grep report | grep $(SIM_SUCCESS_MESSAGE) -c`; \
315 35 julius
                echo; echo "\t####"; \
316
                if [ $$TEST_RESULT -gt 0 ]; then \
317 54 julius
                        echo "\t#### Test $$TEST PASSED ####";TESTS_PASSED=`expr $$TESTS_PASSED + 1`;\
318 35 julius
                else    echo "\t#### Test $$TEST FAILED ####";\
319
                fi; \
320
                echo "\t####"; echo; \
321 54 julius
                TESTS_PERFORMED=`expr $$TESTS_PERFORMED + 1`;\
322
        done; \
323
        echo "Test results: "$$TESTS_PASSED" out of "$$TESTS_PERFORMED" tests passed"; echo
324 33 julius
 
325 52 julius
################################################################################
326
# Verilator model build rules
327
################################################################################
328 48 julius
 
329 52 julius
 
330
 
331
 
332
# List of System C models - use this list to link the sources into the Verilator
333 50 julius
# build directory
334 48 julius
SYSC_MODELS=OrpsocAccess TraceSC
335
 
336 55 julius
ifdef VCD
337
VLT_FLAGS +=-trace
338
endif
339
 
340 52 julius
# Only need the trace target if we are tracing
341
ifneq (,$(findstring -trace, $(VLT_FLAGS)))
342
VLT_TRACEOBJ = SpTraceVcdC
343
endif
344
 
345 50 julius
# This is the list of extra models we'll issue make commands for
346
# Included is the SystemPerl trace model
347 52 julius
SYSC_MODELS_BUILD=$(SYSC_MODELS) $(VLT_TRACEOBJ)
348 50 julius
 
349 52 julius
prepare_vlt: prepare_rtl vlt_model_links $(SIM_VLT_DIR)/Vorpsoc_top
350
 
351
$(SIM_VLT_DIR)/Vorpsoc_top: $(SIM_VLT_DIR)/libVorpsoc_top.a $(SIM_VLT_DIR)/OrpsocMain.o
352
# Final linking of the simulation executable. Order of libraries here is important!
353
        @echo; echo "\tGenerating simulation executable"; echo
354
        cd $(SIM_VLT_DIR) && g++ -I$(BENCH_SYSC_INCLUDE_DIR) -I$(SIM_VLT_DIR) -I$(VERILATOR_ROOT)/include -I$(SYSTEMC)/include -o Vorpsoc_top -L. -L$(BENCH_SYSC_SRC_DIR) -L$(SYSTEMC)/lib-linux64 OrpsocMain.o -lVorpsoc_top -lmodules -lsystemc
355
 
356
$(SIM_VLT_DIR)/OrpsocMain.o:
357
# Now compile the top level systemC "testbench" module
358
        @echo; echo "\tCompiling top level SystemC testbench"; echo
359 48 julius
        cd $(SIM_VLT_DIR) && g++ -I$(BENCH_SYSC_INCLUDE_DIR) -I$(SIM_VLT_DIR) -I$(VERILATOR_ROOT)/include -I$(SYSTEMC)/include -c $(BENCH_SYSC_SRC_DIR)/OrpsocMain.cpp
360 52 julius
 
361
$(SIM_VLT_DIR)/libVorpsoc_top.a: $(SIM_VLT_DIR)/Vorpsoc_top__ALL.a vlt_modules_compile $(SIM_VLT_DIR)/verilated.o
362 48 julius
# Now archive all of the libraries from verilator witht he other modules we might have
363 52 julius
        @echo; echo "\tArchiving libraries into libVorpsoc_top.a"; echo
364
        @cd $(SIM_VLT_DIR) && \
365 48 julius
        cp Vorpsoc_top__ALL.a libVorpsoc_top.a && \
366
        ar rcs libVorpsoc_top.a verilated.o; \
367 50 julius
        for SYSCMODEL in $(SYSC_MODELS_BUILD); do \
368 48 julius
                ar rcs libVorpsoc_top.a $$SYSCMODEL.o; \
369
        done
370 41 julius
 
371 52 julius
$(SIM_VLT_DIR)/verilated.o:
372
        @echo; echo "\tCompiling verilated.o"; echo
373
        @cd $(SIM_VLT_DIR) && \
374
        $(MAKE) -f Vorpsoc_top.mk verilated.o
375 41 julius
 
376 52 julius
.PHONY: vlt_modules_compile
377
vlt_modules_compile:
378
# Compile the module files
379
        @echo; echo "\tCompiling SystemC models"
380
        @cd $(SIM_VLT_DIR) && \
381
        for SYSCMODEL in $(SYSC_MODELS_BUILD); do \
382
                echo;echo "\t$$SYSCMODEL"; echo; \
383
                $(MAKE) -f Vorpsoc_top.mk $$SYSCMODEL.o; \
384
        done
385
 
386
$(SIM_VLT_DIR)/Vorpsoc_top__ALL.a: $(SIM_VLT_DIR)/Vorpsoc_top.mk
387
        @echo; echo "\tCompiling main design"; echo
388
        @cd $(SIM_VLT_DIR) && \
389
        $(MAKE) -f Vorpsoc_top.mk Vorpsoc_top__ALL.a
390
 
391
$(SIM_VLT_DIR)/Vorpsoc_top.mk: $(SIM_VLT_DIR)/$(VLT_COMMAND_FILE).generated $(SIM_VLT_DIR)/libmodules.a
392
# Now call verilator to generate the .mk files
393 53 julius
        @echo; echo "\tGenerating makefiles with Verilator"; echo
394 52 julius
        cd $(SIM_VLT_DIR) && \
395
        verilator -language 1364-2001 -Wno-lint --top-module orpsoc_top -Mdir . -sc $(VLT_FLAGS) -I$(BENCH_SYSC_INCLUDE_DIR) -I$(BENCH_SYSC_SRC_DIR) -f $(VLT_COMMAND_FILE).generated
396
 
397 47 julius
# SystemC modules library
398
$(SIM_VLT_DIR)/libmodules.a:
399 52 julius
        @echo; echo "\tCompiling SystemC modules"; echo
400
        @$(MAKE) -C $(BENCH_SYSC_SRC_DIR) -f $(BENCH_SYSC_SRC_DIR)/Modules.make
401 47 julius
 
402 52 julius
 
403
# Verilator command script
404
# Generate the compile script to give Verilator
405
$(SIM_VLT_DIR)/$(VLT_COMMAND_FILE).generated:
406
        @echo; echo "\tGenerating verilator compile script"; echo
407
        @sed < $(SIM_BIN_DIR)/$(VLT_COMMAND_FILE) > $(SIM_VLT_DIR)/$(VLT_COMMAND_FILE).generated \
408
                -e s!\$$BENCH_DIR!$(BENCH_VERILOG_DIR)!              \
409
                -e s!\$$RTL_DIR!$(RTL_VERILOG_DIR)!                  \
410
                -e s!\$$BACKEND_DIR!$(BACKEND_DIR)!                  \
411
                -e \\!^//.*\$$!d -e \\!^\$$!d;
412
 
413
.PHONY: vlt_model_links
414
vlt_model_links:
415
# Link all the required system C model files into the verilator work dir
416
        @echo; echo "\tLinking SystemC model source to verilator build path"; echo
417
        @if [ ! -d $(SIM_VLT_DIR) ]; then mkdir $(SIM_VLT_DIR); fi
418
        @cd $(SIM_VLT_DIR) && \
419
        for SYSCMODEL in $(SYSC_MODELS); do \
420
                if [ ! -e $$SYSCMODEL.cpp ]; then \
421
                        ln -s $(BENCH_SYSC_SRC_DIR)/$$SYSCMODEL.cpp .; \
422
                        ln -s $(BENCH_SYSC_INCLUDE_DIR)/$$SYSCMODEL.h .; \
423
                fi; \
424
        done
425
 
426 53 julius
 
427 52 julius
################################################################################
428 53 julius
# Verilator test loop
429
################################################################################
430
 
431
# Verilator defaults to internal memories
432
vlt-tests: prepare_sw_uart_printf prepare_rtl prepare_vlt
433 56 julius
        @if [ ! -d $(SIM_RESULTS_DIR) ]; then mkdir -p $(SIM_RESULTS_DIR); fi
434 53 julius
        @echo
435
        @echo "Beginning loop that will complete the following tests: $(TESTS)"
436
        @echo
437
        @for TEST in $(TESTS); do \
438
                echo "################################################################################"; \
439
                echo; \
440
                echo "\t#### Current test: $$TEST ####"; echo; \
441
                echo "\t#### Compiling software ####"; echo; \
442
                CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
443
                $(MAKE) -C $$CURRENT_TEST_SW_DIR $$TEST $(TEST_SW_MAKE_OPTS) UART_PRINTF=1; \
444
                rm -f $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
445
                ln -s $$CURRENT_TEST_SW_DIR/$$TEST.vmem $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
446
                echo "\t#### Beginning simulation ####"; \
447 55 julius
                time -p $(SIM_VLT_DIR)/Vorpsoc_top $$TEST; \
448 53 julius
                if [ $$? -gt 0 ]; then exit $$?; fi; \
449
                TEST_RESULT=1; \
450
                echo; echo "\t####"; \
451
                if [ $$TEST_RESULT -gt 0 ]; then \
452
                        echo "\t#### Test $$TEST PASSED ####";TESTS_PASSED=`expr $$TESTS_PASSED + 1`;\
453
                else    echo "\t#### Test $$TEST FAILED ####";\
454
                fi; \
455
                echo "\t####"; echo; \
456
                TESTS_PERFORMED=`expr $$TESTS_PERFORMED + 1`;\
457
        done; \
458
        echo "Test results: "$$TESTS_PASSED" out of "$$TESTS_PERFORMED" tests passed"; echo
459
 
460
 
461 56 julius
 
462 53 julius
################################################################################
463 56 julius
# Architectural simulator test loop
464
################################################################################
465
 
466
# Verilator defaults to internal memories
467
sim-tests: prepare_sw_uart_printf
468
        @if [ ! -d $(SIM_RESULTS_DIR) ]; then mkdir -p $(SIM_RESULTS_DIR); fi
469
        @echo
470
        @echo "Beginning loop that will complete the following tests: $(TESTS)"
471
        @echo
472
        @for TEST in $(TESTS); do \
473
                echo "################################################################################"; \
474
                echo; \
475
                echo "\t#### Current test: $$TEST ####"; echo; \
476
                echo "\t#### Compiling software ####"; echo; \
477
                CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
478
                $(MAKE) -C $$CURRENT_TEST_SW_DIR $$TEST $(TEST_SW_MAKE_OPTS) UART_PRINTF=1; \
479
                rm -f $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
480
                ln -s $$CURRENT_TEST_SW_DIR/$$TEST.or32 $(SIM_RUN_DIR)/.; \
481
                echo;echo "\t#### Launching architectural simulator ####"; \
482
                time -p $(ARCH_SIM_EXE) --nosrv -f $(SIM_BIN_DIR)/$(ARCH_SIM_CFG_FILE) $$TEST.or32 > $(SIM_RESULTS_DIR)/$$TEST-or1ksim.log 2>&1; \
483
                if [ $$? -gt 0 ]; then exit $$?; fi; \
484
                if [ `tail -n 10 $(SIM_RESULTS_DIR)/$$TEST-or1ksim.log | grep -c $(SIM_SUCCESS_MESSAGE)` -gt 0 ]; then \
485
                        TEST_RESULT=1; \
486
                fi; \
487
                echo; echo "\t####"; \
488
                if [ $$TEST_RESULT -gt 0 ]; then \
489
                        echo "\t#### Test $$TEST PASSED ####";TESTS_PASSED=`expr $$TESTS_PASSED + 1`;\
490
                else    echo "\t#### Test $$TEST FAILED ####";\
491
                fi; \
492
                echo "\t####"; echo; \
493
                TESTS_PERFORMED=`expr $$TESTS_PERFORMED + 1`;\
494
                unlink $(SIM_RUN_DIR)/$$TEST.or32; \
495
        done; \
496
        echo "Test results: "$$TESTS_PASSED" out of "$$TESTS_PERFORMED" tests passed"; echo
497
 
498
 
499
 
500
################################################################################
501 52 julius
# Cleaning rules
502
################################################################################
503
 
504 22 julius
clean-sw:
505
        @for TEST in $(TESTS); do \
506
                echo "Current test: $$TEST"; \
507
                CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
508
                echo "Current test sw directory: " $$CURRENT_TEST_SW_DIR; \
509
                $(MAKE) -C $$CURRENT_TEST_SW_DIR clean; \
510
        done
511 31 julius
        $(MAKE) -C $(SW_DIR)/support clean
512
        $(MAKE) -C $(SW_DIR)/utils clean
513
 
514
clean-sim:
515 52 julius
        rm -rf $(SIM_RESULTS_DIR) $(SIM_RUN_DIR)/*.* $(SIM_VLT_DIR)

powered by: WebSVN 2.1.0

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