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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sim/] [bin/] [Makefile] - Blame information for rev 6

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

Line No. Rev Author Line
1 6 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(v2) design.                                          ####
9
####                                                              ####
10
####  To do:                                                      ####
11
####    * Arrange verilator make rules so that the whole thing    ####
12
####      isn't recompiled when a single SystemC module is        ####
13
####      updated.                                                ####
14
####    * Test if each software test file gets made properly      ####
15
####      before it's run in whatever model we're using           ####
16
####    * Expand software test-suite (uClibc, ecos tests, LTP?)   ####
17
####                                                              ####
18
####  Author(s):                                                  ####
19
####      - jb, jb@orsoc.se                                       ####
20
####                                                              ####
21
####                                                              ####
22
######################################################################
23
####                                                              ####
24
#### Copyright (C) 2009 Authors and OPENCORES.ORG                 ####
25
####                                                              ####
26
#### This source file may be used and distributed without         ####
27
#### restriction provided that this copyright statement is not    ####
28
#### removed from the file and that any derivative work contains  ####
29
#### the original copyright notice and the associated disclaimer. ####
30
####                                                              ####
31
#### This source file is free software; you can redistribute it   ####
32
#### and/or modify it under the terms of the GNU Lesser General   ####
33
#### Public License as published by the Free Software Foundation; ####
34
#### either version 2.1 of the License, or (at your option) any   ####
35
#### later version.                                               ####
36
####                                                              ####
37
#### This source is distributed in the hope that it will be       ####
38
#### useful, but WITHOUT ANY WARRANTY; without even the implied   ####
39
#### warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ####
40
#### PURPOSE.  See the GNU Lesser General Public License for more ####
41
#### details.                                                     ####
42
####                                                              ####
43
#### You should have received a copy of the GNU Lesser General    ####
44
#### Public License along with this source; if not, download it   ####
45
#### from http://www.opencores.org/lgpl.shtml                     ####
46
####                                                              ####
47
######################################################################
48
 
49
# Usage:
50
#
51
#       make rtl-tests
52
#
53
#       Run the software tests in the RTL model of the ORPSoC being
54
#       simulated with an event-driven simulator like Icarus. Also
55
#       possible to use Cadence's Verilog simulators with the
56
#       "rtl-nc-tests" target.
57
#
58
#       make vlt-tests
59
#
60
#       Run all the software tests in the RTL model which has been
61
#       converted into a cycle-accurate SystemC model with Verilator.
62
#
63
#       make sim-tests
64
#
65
#       Run all the software tests in the architectural simulator
66
#
67
 
68
# Simulation results:
69
#
70
# The results and output of the event-driven simulations are in the
71
# results path, in parallel to the simulation run and bin paths.
72
 
73
# Specific tests:
74
#
75
# To run an individual test, specify it in the variable TESTS when
76
# calling make, eg:
77
#
78
#        make rtl-tests TESTS="mmu-nocache mul-idcd-O2"
79
 
80
# UART printf:
81
#
82
# It is possible to enable printf to the console via the UART when
83
# running the event-driven simulators. To do this define UART_PRINTF=1
84
# when calling make. The SystemC cycle-acccurate model uses this by
85
# default.
86
# Also note when switching between runs with and without UART printf
87
# enabled, run a clean-sw so the library files are recompiled when
88
# the tests are run - this is not done automatically.
89
 
90
# VCDs:
91
#
92
# VCD (value change dumps, usable in a waveform viewer, such as gtkwave
93
# to inspect the internals of the system graphically) files can be
94
# generated by defining a variable VCD, eg.
95
#
96
#       make rtl-tests VCD=1
97
#
98
# and a dump file will be created in the simulation results directory,
99
# and named according to the test run which generated it. This is
100
# possible for both event-driven and cycle-accurate simulations.
101
# However the cycle-accurate
102
 
103
# NO_SIM_LOGGING:
104
#
105
# It is possible to speed up the event-driven simulation slightly by
106
# disabling log output of the processor's state to files by defining
107
# NO_SIM_LOGGING, eg:
108
#
109
#       make rtl-tests TESTS=except-icdc NO_SIM_LOGGING=1
110
#
111
 
112
# Cleaning:
113
# A simple "make clean" cleans everything - software and all temporary
114
# simulation files and directories. To clean just the software run:
115
#
116
#       make clean-sw
117
#
118
# and to clean just the temporary simulation files (including VCDs,
119
# results logs - everything under, and including, sim/results/, run
120
#
121
#       make clean-sim
122
#
123
 
124
# Note:
125
#
126
# The way each of the test loops is written is probably a bit overly complex
127
# but this is to save maintaining, and calling, multiple files.
128
#
129
 
130
# Model configuration:
131
#
132
# Currently, the ORPSoCv2, by default, contains an internal SRAM (configurable
133
# size - check the defparam in rtl/verilog/orpsoc_top.v), standard OR1200 (check
134
# the config in rtl/verilog/or1200_defines.v) and UART.
135
# Switches can be passed to enable certain parts of the design if testing with
136
# these is desired.
137
#
138
# SDRAM and controller
139
#
140
# To enable the use of SDRAM, define USE_SDRAM when calling the sim -this
141
# only has an effect in the event-driven simulators as the external SDRAM model
142
# is not availble in SystemC format. eg:
143
#
144
#       make rtl-tests USE_SDRAM=1
145
#
146
# This not only enables SDRAM but also enables the booting from external SPI
147
# interfaced flash memory. This causes significant increase in the time taken
148
# for simulation as the program to test is first loaded out of SPI flash memory
149
# and into SDRAM before it is executed. Although this more closely mimics the
150
# behaviour of the hardware, for simulation purposes it is purely time-consuming
151
# however it may be useful to track down any problems with this boot-loading
152
# process. Therefore, becuase it enables SDRAM memory, ir also enables the flash
153
# memory model and SPI controller inside ORPSoC.
154
#
155
# Ethernet
156
#
157
# Ethernet is disabled by default. This is due to the fact that it is not
158
# supported in the verilator/systemC model. Also, there is currently no software
159
# which tests it in any meaningful way.
160
#
161
 
162
#
163
# Event-driven simulation compilation
164
#
165
# The way the event-driven simulations are compiled is simply using the
166
# configuration script file in this directory, currently called icarus.scr -
167
# however it is first processesed to replace the variables, beginning with $'s,
168
# with the appropriate paths. Instead of naming each file to be compiled, the
169
# paths to be searched for each module are instead defined ( -y paths), and
170
# only the toplevel testbench and library source files are explicitly named.
171
# This simplifies the script, and also requires that the name of each verilog
172
# source file is the same as the module it contains (a good convention
173
# regardless.) In addition to the script/command file, defines are passed to
174
# the compiler via the command line in the EVENT_SIM_FLAGS variable.
175
# Additionally, a source file, test_define.v, is created with  some defines
176
# that cannot be passed to the compiled reliably (there are differences between
177
# the way, for instance, icarus and ncverilog parse strings +define+'d on the
178
# command line). This file is then included at the appropriate places.
179
# It is probably not ideal that the entire design be re-compiled for each test,
180
# but currently the design is small enough so that this doesn't cause a
181
# significant overhead, unlike the cycle-accurate model compile time.
182
#
183
 
184
#
185
# SystemC cycle-accurate model compilation
186
#
187
# A new addition to ORPSoC v2 is the cycle-accurate model. The primary enabler
188
# behind this is verilator, which processes the RTL sources and generates a c++
189
# description of the system. This c++ description is then compiled with a
190
# SystemC wrapper. Finally a top-level SystemC testbench instantiates the
191
# model, as well as any other modules - in this case a reset generation, UART
192
# decoder, and monitor module are included at the top level. These additional
193
# modules and models are written in SystemC and compiled all together with the
194
# cycle-accurate ORPSoC model to create the simulation executable. Finally this
195
# executable is run and should be a cycle-representation of the system. VCDs
196
# can be generated if enabled. The compiled mentioned above is all done with
197
# the GNU c++ compiler, g++.
198
# The compilation process is a little more tricky than a typical even-driven
199
# simulator. It proceeds basically by generating the makefiles for compiling
200
# the design with verilator, running these makes which produces a library
201
# containing the cycle-accurate ORPSoC design, compiling the additional
202
# top-level, and testbench, systemC models into a library, and then linking it
203
# all together into the simulation executable.
204
# The major advantage of the cycle-accurate model is that it is quicker, in
205
# terms of simulated cycles/second, when compared with event-driven simulators.
206
# It is, of course, less accurate in that it cannot model propegation delays.
207
# However this is usually not an issue for simulating a design which is known
208
# to synthesize and run OK. It is very useful for running complex software,
209
# such as the linux kernel and real-time OS applications, which generally
210
# require long simulation times.
211
# Currently the cycle-accurate model being used doesn't contain much more than
212
# the processor and a UART, however it's exepected in future this will be
213
# expanded on and more complex software test suites will be implemented to put
214
# the system through its paces.
215
#
216
 
217
 
218
# Name of
219
# the directory we're currently in
220
CUR_DIR=$(shell pwd)
221
 
222
# The root path of the whole project
223
PROJECT_ROOT=$(CUR_DIR)/../..
224
 
225
# Tests is only defined if it wasn't already defined when make was called
226
# This is the default list of every test that is currently possible
227
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
228
 
229
# Paths to other important parts of this test suite
230
SIM_DIR=$(PROJECT_ROOT)/sim
231
SIM_RUN_DIR=$(SIM_DIR)/run
232
SIM_BIN_DIR=$(SIM_DIR)/bin
233
SIM_RESULTS_DIR=$(SIM_DIR)/results
234
SIM_VLT_DIR=$(SIM_DIR)/vlt
235
BENCH_DIR=$(PROJECT_ROOT)/bench
236
BACKEND_DIR=$(PROJECT_ROOT)/backend
237
BENCH_VERILOG_DIR=$(BENCH_DIR)/verilog
238
BENCH_SYSC_DIR=$(BENCH_DIR)/sysc
239
BENCH_SYSC_SRC_DIR=$(BENCH_SYSC_DIR)/src
240
BENCH_SYSC_INCLUDE_DIR=$(BENCH_SYSC_DIR)/include
241
RTL_VERILOG_DIR=$(PROJECT_ROOT)/rtl/verilog
242
SW_DIR=$(PROJECT_ROOT)/sw
243
 
244
ICARUS=iverilog
245
ICARUS_VVP=vvp
246
ICARUS_COMMAND_FILE=icarus.scr
247
VLT_COMMAND_FILE=verilator.scr
248
SIM_SUCCESS_MESSAGE=deaddead
249
 
250
ARCH_SIM_EXE=or32-elf-sim
251
ARCH_SIM_CFG_FILE=or1ksim-orpsocv2.cfg
252
 
253
# If USE_SDRAM is defined we'll add it to the simulator's defines on the
254
# command line becuase it's used by many different modules and it's easier
255
# to do it this way than make them all include a file.
256
ifdef USE_SDRAM
257
EVENT_SIM_FLAGS += "-D USE_SDRAM=$(USE_SDRAM)"
258
endif
259
 
260
# Enable ethernet if defined on the command line
261
ifdef USE_ETHERNET
262
EVENT_SIM_FLAGS += "-D USE_ETHERNET=$(USE_ETHERNET)"
263
endif
264
 
265
SIM_FLASH_MEM_FILE="flash.in"
266
FLASH_MEM_FILE_SUFFIX="-twobyte-sizefirst.hex"
267
SIM_SRAM_MEM_FILE="sram.vmem"
268
 
269
TESTS_PASSED=0
270
TESTS_PERFORMED=0;
271
 
272
################################################################################
273
# Event-driven simulator build rules (Icarus, NCSim)
274
################################################################################
275
 
276
.PHONY: prepare_rtl
277
prepare_rtl:
278
        @cd $(RTL_VERILOG_DIR)/components/wb_sdram_ctrl && perl fizzim.pl -encoding onehot -terse < wb_sdram_ctrl_fsm.fzm > wb_sdram_ctrl_fsm.v
279
        @cd $(RTL_VERILOG_DIR) && sed '/defparam/!s/\([a-zA-Z0-9_]\)\.//g' intercon.vm > intercon.v
280
 
281
 
282
ifdef UART_PRINTF
283
TEST_SW_MAKE_OPTS=UART_PRINTF=1
284
endif
285
 
286
.PHONY: prepare_sw
287
prepare_sw:
288
        @$(MAKE) -C $(SW_DIR)/support all $(TEST_SW_MAKE_OPTS)
289
        @$(MAKE) -C $(SW_DIR)/utils all
290
 
291
# A rule with UART_PRINTF hard defined ... used by verilator make sw
292
prepare_sw_uart_printf:
293
        @$(MAKE) -C $(SW_DIR)/support all UART_PRINTF=1 $(TEST_SW_MAKE_OPTS)
294
        @$(MAKE) -C $(SW_DIR)/utils all
295
 
296
 
297
# Rough guide to how these tests work:
298
# First, the couple of custom, required, software tools under sw/utils are
299
# compiled, and then the software library files.
300
# Next the few verilog files that need preperation are taken care of.
301
# The test begins by starting a loop in bash using on the strings defined in
302
# TESTS. Each one corresponds to a certain module of software for the OpenRISC
303
# that is included in this test suite. Under the sw/ path is a set of paths,
304
# and all except the support/ and utils/ paths contain code which is run to
305
# test the OR1k used in this test suite. For each of these software modules,
306
# it is possible that different tests are done using the same module. These
307
# tests can vary by either using different levels of optimisation during
308
# compilation, and/or by having the OR1k's caches enabled or disabled.
309
# Each test has a unique name, and under the $(SIM_RESULTS_DIR), which is
310
# usually just ../results, log files, and optionally VCD files, are created for
311
# inspection later and are named according to the test. Inspect the file
312
# bench/verilog/or1200_monitor.v to find out in detail what each log consists
313
# of.
314
# For each test, a few things occur. First the software that will run inside
315
# the simulated OR1k system is compiled, converted to a format which can be
316
# read
317
# into the flash memory model via $readmemh() and linked to the sim/run
318
# directory as $(SIM_FLASH_MEM_FILE), which currently is flash.in. Next a
319
# compilation script for icarus is generated, containing a list of all the
320
# RTL files and include directories. Next, an include file for the verilog
321
# testbench is generated, containing a string of the name of the current
322
# test, path to the results directory (for VCD generation) and any other
323
# things which might vary from test to test. This is not done by +define
324
# lines in the icarus script because of string handling incosistencies
325
# between different simulators and shells.
326
# Once all the files are generated, icarus is called to compile the rtl
327
# design, and then run it. Each of the tested software modules have code which
328
# will trigger the simulation to be stopped by use of the l.nop instruction
329
# with an immediate value of 1. When the simulation finishes, the simulation
330
# executable exits and the log of the simulation is inspected for the expected
331
# output. Currently, the string "deaddead" indicates that the software
332
# completed successfully. This is counted as the ORPSoC "passing" the test. In
333
# fact, whether the system did the right thing or not requires more
334
# inspection, but roughly this is a good indicator that nothing major went
335
# wrong.
336
# Once the current test is finished, the next begins with the compilation of its
337
# software and linking of the resulting hex file to the run path, etc.
338
# Main RAM setup - (RTL simulation with Icarus/NCSim only!):
339
# Define USE_SDRAM to enable the external SDRAM, otherwise the simulation
340
# defaults to an internal SRAM. Eg. $ make rtl-tests USE_SDRAM=1 VCD=1
341
# Verilator defaults to internal memories
342
rtl-tests: prepare_sw prepare_rtl
343
        @if [ ! -d $(SIM_RESULTS_DIR) ]; then mkdir -p $(SIM_RESULTS_DIR); fi
344
        @echo
345
        @echo "Beginning loop that will complete the following tests: $(TESTS)"
346
        @echo
347
        @for TEST in $(TESTS); do \
348
                echo "################################################################################"; \
349
                echo; \
350
                echo "\t#### Current test: $$TEST ####"; echo; \
351
                echo "\t#### Compiling software ####"; echo; \
352
                CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
353
                $(MAKE) -C $$CURRENT_TEST_SW_DIR $$TEST $(TEST_SW_MAKE_OPTS); \
354
                rm -f $(SIM_RUN_DIR)/$(SIM_FLASH_MEM_FILE); \
355
                rm -f $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
356
                ln -s $$CURRENT_TEST_SW_DIR/$$TEST$(FLASH_MEM_FILE_SUFFIX) $(SIM_RUN_DIR)/$(SIM_FLASH_MEM_FILE); \
357
                ln -s $$CURRENT_TEST_SW_DIR/$$TEST.vmem $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
358
                sed < $(SIM_BIN_DIR)/$(ICARUS_COMMAND_FILE) > $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated \
359
                        -e s!\$$BENCH_DIR!$(BENCH_VERILOG_DIR)!              \
360
                        -e s!\$$RTL_DIR!$(RTL_VERILOG_DIR)!                  \
361
                        -e s!\$$BACKEND_DIR!$(BACKEND_DIR)!                  \
362
                        -e \\!^//.*\$$!d -e \\!^\$$!d ; \
363
                echo "+define+TEST_DEFINE_FILE=\"test_define.v\"" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
364
                if [ ! -z $$VCD ]; \
365
                        then echo "+define+VCD" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
366
                fi; \
367
                if [ ! -z $$UART_PRINTF ]; \
368
                        then echo "+define+UART_PRINTF" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
369
                fi; \
370
                echo "\`define TEST_NAME_STRING \"$$TEST\"" > $(SIM_RUN_DIR)/test_define.v; \
371
                echo "\`define TEST_RESULTS_DIR \"$(SIM_RESULTS_DIR)/\" " >> $(SIM_RUN_DIR)/test_define.v; \
372
                if [ -z $$NO_SIM_LOGGING ]; then \
373
                        echo "\`define OR1200_DISPLAY_ARCH_STATE" >> $(SIM_RUN_DIR)/test_define.v; \
374
                fi; \
375
                echo ; \
376
                echo "\t#### Compiling RTL ####"; \
377
                rm -f $(SIM_RUN_DIR)/a.out; \
378
                $(ICARUS) -sorpsoc_testbench -c $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated $(EVENT_SIM_FLAGS); \
379
                echo; \
380
                echo "\t#### Beginning simulation ####"; \
381
                time -p $(ICARUS_VVP) -l $(SIM_RESULTS_DIR)/$$TEST-vvp-out.log a.out ; \
382
                if [ $$? -gt 0 ]; then exit $$?; fi; \
383
                TEST_RESULT=`cat $(SIM_RESULTS_DIR)/$$TEST-general.log | grep report | grep $(SIM_SUCCESS_MESSAGE) -c`; \
384
                echo; echo "\t####"; \
385
                if [ $$TEST_RESULT -gt 0 ]; then \
386
                        echo "\t#### Test $$TEST PASSED ####";TESTS_PASSED=`expr $$TESTS_PASSED + 1`;\
387
                else    echo "\t#### Test $$TEST FAILED ####";\
388
                fi; \
389
                echo "\t####"; echo; \
390
                TESTS_PERFORMED=`expr $$TESTS_PERFORMED + 1`;\
391
        done; \
392
        echo "Test results: "$$TESTS_PASSED" out of "$$TESTS_PERFORMED" tests passed"; echo
393
 
394
 
395
 
396
# Use NCSIM instead of icarus
397
rtl-nc-tests: prepare_sw prepare_rtl
398
        @if [ ! -d $(SIM_RESULTS_DIR) ]; then mkdir -p $(SIM_RESULTS_DIR); fi
399
        @echo
400
        @echo "Beginning loop that will complete the following tests: $(TESTS)"
401
        @echo
402
        @for TEST in $(TESTS); do \
403
                echo "################################################################################"; \
404
                echo; \
405
                echo "\t#### Current test: $$TEST ####"; echo; \
406
                echo "\t#### Compiling software ####"; echo; \
407
                CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
408
                $(MAKE) -C $$CURRENT_TEST_SW_DIR $$TEST; \
409
                rm -f $(SIM_RUN_DIR)/$(SIM_FLASH_MEM_FILE); \
410
                rm -f $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
411
                ln -s $$CURRENT_TEST_SW_DIR/$$TEST_twobyte_sizefirst.hex $(SIM_RUN_DIR)/$(SIM_FLASH_MEM_FILE); \
412
                ln -s $$CURRENT_TEST_SW_DIR/$$TEST_fourbyte.hex $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
413
                sed < $(SIM_BIN_DIR)/$(ICARUS_COMMAND_FILE) > $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated \
414
                        -e s!\$$BENCH_DIR!$(BENCH_VERILOG_DIR)!              \
415
                        -e s!\$$RTL_DIR!$(RTL_VERILOG_DIR)!                  \
416
                        -e s!\$$BACKEND_DIR!$(BACKEND_DIR)!                  \
417
                        -e \\!^//.*\$$!d -e \\!^\$$!d ; \
418
                echo "+define+TEST_DEFINE_FILE=\"test_define.v\"" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
419
                if [ ! -z $$VCD ]; \
420
                        then echo "+define+VCD" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
421
                        echo "+access+r" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
422
                fi; \
423
                if [ ! -z $$UART_PRINTF ]; \
424
                        then echo "+define+UART_PRINTF" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
425
                fi; \
426
                if [ ! -z $$USE_SDRAM ]; then \
427
                        echo "\`define USE_SDRAM" >> $(SIM_RUN_DIR)/test_define.v; \
428
                fi; \
429
                echo "+nocopyright" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
430
                echo "+nowarn+MACRDF" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
431
                echo "\`define TEST_NAME_STRING \"$$TEST\"" > $(SIM_RUN_DIR)/test_define.v; \
432
                echo "\`define TEST_RESULTS_DIR \"$(SIM_RESULTS_DIR)/\" " >> $(SIM_RUN_DIR)/test_define.v; \
433
                if [ -z $$NO_SIM_LOGGING ]; then \
434
                        echo "\`define OR1200_DISPLAY_ARCH_STATE" >> $(SIM_RUN_DIR)/test_define.v; \
435
                fi; \
436
                echo ; \
437
                echo "\t#### Beginning simulation ####"; \
438
                time -p ncverilog -f $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated -Q -l $(SIM_RESULTS_DIR)/$$TEST-ius-out.log $(EVENT_SIM_FLAGS); \
439
                if [ $$? -gt 0 ]; then exit $$?; fi; \
440
                TEST_RESULT=`cat $(SIM_RESULTS_DIR)/$$TEST-general.log | grep report | grep $(SIM_SUCCESS_MESSAGE) -c`; \
441
                echo; echo "\t####"; \
442
                if [ $$TEST_RESULT -gt 0 ]; then \
443
                        echo "\t#### Test $$TEST PASSED ####";TESTS_PASSED=`expr $$TESTS_PASSED + 1`;\
444
                else    echo "\t#### Test $$TEST FAILED ####";\
445
                fi; \
446
                echo "\t####"; echo; \
447
                TESTS_PERFORMED=`expr $$TESTS_PERFORMED + 1`;\
448
        done; \
449
        echo "Test results: "$$TESTS_PASSED" out of "$$TESTS_PERFORMED" tests passed"; echo
450
 
451
################################################################################
452
# Verilator model build rules
453
################################################################################
454
 
455
 
456
SYSC_LIB_ARCH_DIR=$(shell ls $$SYSTEMC | grep "lib-")
457
 
458
 
459
# List of System C models - use this list to link the sources into the Verilator
460
# build directory
461
SYSC_MODELS=OrpsocAccess TraceSC
462
 
463
ifdef VCD
464
VLT_FLAGS +=-trace
465
endif
466
 
467
# Only need the trace target if we are tracing
468
ifneq (,$(findstring -trace, $(VLT_FLAGS)))
469
VLT_TRACEOBJ = SpTraceVcdC
470
endif
471
 
472
# This is the list of extra models we'll issue make commands for
473
# Included is the SystemPerl trace model
474
SYSC_MODELS_BUILD=$(SYSC_MODELS) $(VLT_TRACEOBJ)
475
 
476
prepare_vlt: prepare_rtl vlt_model_links $(SIM_VLT_DIR)/Vorpsoc_top
477
 
478
$(SIM_VLT_DIR)/Vorpsoc_top: $(SIM_VLT_DIR)/libVorpsoc_top.a $(SIM_VLT_DIR)/OrpsocMain.o
479
# Final linking of the simulation executable. Order of libraries here is important!
480
        @echo; echo "\tGenerating simulation executable"; echo
481
        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)/$(SYSC_LIB_ARCH_DIR) OrpsocMain.o -lVorpsoc_top -lmodules -lsystemc
482
 
483
$(SIM_VLT_DIR)/OrpsocMain.o:
484
# Now compile the top level systemC "testbench" module
485
        @echo; echo "\tCompiling top level SystemC testbench"; echo
486
        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
487
 
488
$(SIM_VLT_DIR)/libVorpsoc_top.a: $(SIM_VLT_DIR)/Vorpsoc_top__ALL.a vlt_modules_compile $(SIM_VLT_DIR)/verilated.o
489
# Now archive all of the libraries from verilator witht he other modules we might have
490
        @echo; echo "\tArchiving libraries into libVorpsoc_top.a"; echo
491
        @cd $(SIM_VLT_DIR) && \
492
        cp Vorpsoc_top__ALL.a libVorpsoc_top.a && \
493
        ar rcs libVorpsoc_top.a verilated.o; \
494
        for SYSCMODEL in $(SYSC_MODELS_BUILD); do \
495
                ar rcs libVorpsoc_top.a $$SYSCMODEL.o; \
496
        done
497
 
498
$(SIM_VLT_DIR)/verilated.o:
499
        @echo; echo "\tCompiling verilated.o"; echo
500
        @cd $(SIM_VLT_DIR) && \
501
        $(MAKE) -f Vorpsoc_top.mk verilated.o
502
 
503
.PHONY: vlt_modules_compile
504
vlt_modules_compile:
505
# Compile the module files
506
        @echo; echo "\tCompiling SystemC models"
507
        @cd $(SIM_VLT_DIR) && \
508
        for SYSCMODEL in $(SYSC_MODELS_BUILD); do \
509
                echo;echo "\t$$SYSCMODEL"; echo; \
510
                $(MAKE) -f Vorpsoc_top.mk $$SYSCMODEL.o; \
511
        done
512
 
513
$(SIM_VLT_DIR)/Vorpsoc_top__ALL.a: $(SIM_VLT_DIR)/Vorpsoc_top.mk
514
        @echo; echo "\tCompiling main design"; echo
515
        @cd $(SIM_VLT_DIR) && \
516
        $(MAKE) -f Vorpsoc_top.mk Vorpsoc_top__ALL.a
517
 
518
$(SIM_VLT_DIR)/Vorpsoc_top.mk: $(SIM_VLT_DIR)/$(VLT_COMMAND_FILE).generated $(SIM_VLT_DIR)/libmodules.a
519
# Now call verilator to generate the .mk files
520
        @echo; echo "\tGenerating makefiles with Verilator"; echo
521
        cd $(SIM_VLT_DIR) && \
522
        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
523
 
524
# SystemC modules library
525
$(SIM_VLT_DIR)/libmodules.a:
526
        @echo; echo "\tCompiling SystemC modules"; echo
527
        @$(MAKE) -C $(BENCH_SYSC_SRC_DIR) -f $(BENCH_SYSC_SRC_DIR)/Modules.make
528
 
529
 
530
# Verilator command script
531
# Generate the compile script to give Verilator
532
$(SIM_VLT_DIR)/$(VLT_COMMAND_FILE).generated:
533
        @echo; echo "\tGenerating verilator compile script"; echo
534
        @sed < $(SIM_BIN_DIR)/$(VLT_COMMAND_FILE) > $(SIM_VLT_DIR)/$(VLT_COMMAND_FILE).generated \
535
                -e s!\$$BENCH_DIR!$(BENCH_VERILOG_DIR)!              \
536
                -e s!\$$RTL_DIR!$(RTL_VERILOG_DIR)!                  \
537
                -e s!\$$BACKEND_DIR!$(BACKEND_DIR)!                  \
538
                -e \\!^//.*\$$!d -e \\!^\$$!d;
539
 
540
.PHONY: vlt_model_links
541
vlt_model_links:
542
# Link all the required system C model files into the verilator work dir
543
        @echo; echo "\tLinking SystemC model source to verilator build path"; echo
544
        @if [ ! -d $(SIM_VLT_DIR) ]; then mkdir $(SIM_VLT_DIR); fi
545
        @cd $(SIM_VLT_DIR) && \
546
        for SYSCMODEL in $(SYSC_MODELS); do \
547
                if [ ! -e $$SYSCMODEL.cpp ]; then \
548
                        ln -s $(BENCH_SYSC_SRC_DIR)/$$SYSCMODEL.cpp .; \
549
                        ln -s $(BENCH_SYSC_INCLUDE_DIR)/$$SYSCMODEL.h .; \
550
                fi; \
551
        done
552
 
553
 
554
################################################################################
555
# Verilator test loop
556
################################################################################
557
 
558
# Verilator defaults to internal memories
559
vlt-tests: prepare_sw_uart_printf prepare_rtl prepare_vlt
560
        @if [ ! -d $(SIM_RESULTS_DIR) ]; then mkdir -p $(SIM_RESULTS_DIR); fi
561
        @echo
562
        @echo "Beginning loop that will complete the following tests: $(TESTS)"
563
        @echo
564
        @for TEST in $(TESTS); do \
565
                echo "################################################################################"; \
566
                echo; \
567
                echo "\t#### Current test: $$TEST ####"; echo; \
568
                echo "\t#### Compiling software ####"; echo; \
569
                CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
570
                $(MAKE) -C $$CURRENT_TEST_SW_DIR $$TEST $(TEST_SW_MAKE_OPTS) UART_PRINTF=1; \
571
                rm -f $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
572
                ln -s $$CURRENT_TEST_SW_DIR/$$TEST.vmem $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
573
                echo "\t#### Beginning simulation ####"; \
574
                time -p $(SIM_VLT_DIR)/Vorpsoc_top $$TEST; \
575
                if [ $$? -gt 0 ]; then exit $$?; fi; \
576
                TEST_RESULT=1; \
577
                echo; echo "\t####"; \
578
                if [ $$TEST_RESULT -gt 0 ]; then \
579
                        echo "\t#### Test $$TEST PASSED ####";TESTS_PASSED=`expr $$TESTS_PASSED + 1`;\
580
                else    echo "\t#### Test $$TEST FAILED ####";\
581
                fi; \
582
                echo "\t####"; echo; \
583
                TESTS_PERFORMED=`expr $$TESTS_PERFORMED + 1`;\
584
        done; \
585
        echo "Test results: "$$TESTS_PASSED" out of "$$TESTS_PERFORMED" tests passed"; echo
586
 
587
 
588
 
589
################################################################################
590
# Architectural simulator test loop
591
################################################################################
592
 
593
# Verilator defaults to internal memories
594
sim-tests: prepare_sw_uart_printf
595
        @if [ ! -d $(SIM_RESULTS_DIR) ]; then mkdir -p $(SIM_RESULTS_DIR); fi
596
        @echo
597
        @echo "Beginning loop that will complete the following tests: $(TESTS)"
598
        @echo
599
        @for TEST in $(TESTS); do \
600
                echo "################################################################################"; \
601
                echo; \
602
                echo "\t#### Current test: $$TEST ####"; echo; \
603
                echo "\t#### Compiling software ####"; echo; \
604
                CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
605
                $(MAKE) -C $$CURRENT_TEST_SW_DIR $$TEST $(TEST_SW_MAKE_OPTS) UART_PRINTF=1; \
606
                rm -f $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
607
                ln -s $$CURRENT_TEST_SW_DIR/$$TEST.or32 $(SIM_RUN_DIR)/.; \
608
                echo;echo "\t#### Launching architectural simulator ####"; \
609
                time -p $(ARCH_SIM_EXE) --nosrv -f $(SIM_BIN_DIR)/$(ARCH_SIM_CFG_FILE) $$TEST.or32 > $(SIM_RESULTS_DIR)/$$TEST-or1ksim.log 2>&1; \
610
                if [ $$? -gt 0 ]; then exit $$?; fi; \
611
                if [ `tail -n 10 $(SIM_RESULTS_DIR)/$$TEST-or1ksim.log | grep -c $(SIM_SUCCESS_MESSAGE)` -gt 0 ]; then \
612
                        TEST_RESULT=1; \
613
                fi; \
614
                echo; echo "\t####"; \
615
                if [ $$TEST_RESULT -gt 0 ]; then \
616
                        echo "\t#### Test $$TEST PASSED ####";TESTS_PASSED=`expr $$TESTS_PASSED + 1`;\
617
                else    echo "\t#### Test $$TEST FAILED ####";\
618
                fi; \
619
                echo "\t####"; echo; \
620
                TESTS_PERFORMED=`expr $$TESTS_PERFORMED + 1`;\
621
                unlink $(SIM_RUN_DIR)/$$TEST.or32; \
622
        done; \
623
        echo "Test results: "$$TESTS_PASSED" out of "$$TESTS_PERFORMED" tests passed"; echo
624
 
625
 
626
 
627
################################################################################
628
# Cleaning rules
629
################################################################################
630
 
631
clean: clean-sw clean-sim
632
 
633
clean-sw:
634
        @for TEST in $(TESTS); do \
635
                echo "Current test: $$TEST"; \
636
                CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
637
                echo "Current test sw directory: " $$CURRENT_TEST_SW_DIR; \
638
                $(MAKE) -C $$CURRENT_TEST_SW_DIR clean; \
639
        done
640
        $(MAKE) -C $(SW_DIR)/support clean
641
        $(MAKE) -C $(SW_DIR)/utils clean
642
 
643
clean-sim:
644
        rm -rf $(SIM_RESULTS_DIR) $(SIM_RUN_DIR)/*.* $(SIM_VLT_DIR)

powered by: WebSVN 2.1.0

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