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 60

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 57 julius
####  ORPSoC(v2) design.                                          ####
9 39 julius
####                                                              ####
10 58 julius
####  To do:                                                      ####
11 57 julius
####    * 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 58 julius
####      before it's run in whatever model we're using           ####
16 57 julius
####    * Expand software test-suite (uClibc, ecos tests, LTP?)   ####
17 39 julius
####                                                              ####
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 22 julius
 
49 55 julius
# 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 57 julius
#       make sim-tests
64
#
65
#       Run all the software tests in the architectural simulator
66
#
67 39 julius
 
68 55 julius
# 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 39 julius
 
73 55 julius
# Specific tests:
74
#
75 39 julius
# To run an individual test, specify it in the variable TESTS when
76 55 julius
# calling make, eg:
77
#
78
#        make rtl-tests TESTS="mmu-nocache mul-idcd-O2"
79 39 julius
 
80 55 julius
# 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 57 julius
# 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 55 julius
 
90
# VCDs:
91
#
92 39 julius
# 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 55 julius
# 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 39 julius
 
103 57 julius
# 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 39 julius
 
112 57 julius
# 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 39 julius
 
124 57 julius
# Note:
125
#
126
# The way each of the test loops is written is probably a bit overly complex
127 58 julius
# but this is to save maintaining, and calling, multiple files.
128 57 julius
#
129 39 julius
 
130 58 julius
# 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 22 julius
CUR_DIR=$(shell pwd)
221 39 julius
 
222
# The root path of the whole project
223 22 julius
PROJECT_ROOT=$(CUR_DIR)/../..
224
 
225 39 julius
# 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 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
228 22 julius
 
229 39 julius
# Paths to other important parts of this test suite
230 22 julius
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 44 julius
SIM_VLT_DIR=$(SIM_DIR)/vlt
235 22 julius
BENCH_DIR=$(PROJECT_ROOT)/bench
236
BACKEND_DIR=$(PROJECT_ROOT)/backend
237
BENCH_VERILOG_DIR=$(BENCH_DIR)/verilog
238 44 julius
BENCH_SYSC_DIR=$(BENCH_DIR)/sysc
239 47 julius
BENCH_SYSC_SRC_DIR=$(BENCH_SYSC_DIR)/src
240
BENCH_SYSC_INCLUDE_DIR=$(BENCH_SYSC_DIR)/include
241 22 julius
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 41 julius
VLT_COMMAND_FILE=verilator.scr
248 32 julius
SIM_SUCCESS_MESSAGE=deaddead
249 22 julius
 
250 56 julius
ARCH_SIM_EXE=or32-elf-sim
251
ARCH_SIM_CFG_FILE=or1ksim-orpsocv2.cfg
252
 
253 45 julius
# 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 58 julius
EVENT_SIM_FLAGS += "-D USE_SDRAM=$(USE_SDRAM)"
258 45 julius
endif
259
SIM_FLASH_MEM_FILE="flash.in"
260
FLASH_MEM_FILE_SUFFIX="-twobyte-sizefirst.hex"
261
SIM_SRAM_MEM_FILE="sram.vmem"
262
 
263 52 julius
TESTS_PASSED=0
264
TESTS_PERFORMED=0;
265
 
266
################################################################################
267
# Event-driven simulator build rules (Icarus, NCSim)
268
################################################################################
269
 
270 22 julius
.PHONY: prepare_rtl
271
prepare_rtl:
272 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
273 43 julius
        @cd $(RTL_VERILOG_DIR) && sed '/defparam/!s/\([a-zA-Z0-9_]\)\.//g' intercon.vm > intercon.v
274 22 julius
 
275 52 julius
 
276
ifdef UART_PRINTF
277
TEST_SW_MAKE_OPTS=UART_PRINTF=1
278
endif
279
 
280 26 julius
.PHONY: prepare_sw
281
prepare_sw:
282 52 julius
        @$(MAKE) -C $(SW_DIR)/support all $(TEST_SW_MAKE_OPTS)
283
        @$(MAKE) -C $(SW_DIR)/utils all
284 26 julius
 
285 54 julius
# A rule with UART_PRINTF hard defined ... used by verilator make sw
286 53 julius
prepare_sw_uart_printf:
287
        @$(MAKE) -C $(SW_DIR)/support all UART_PRINTF=1 $(TEST_SW_MAKE_OPTS)
288
        @$(MAKE) -C $(SW_DIR)/utils all
289 52 julius
 
290 53 julius
 
291 39 julius
# Rough guide to how these tests work:
292
# First, the couple of custom, required, software tools under sw/utils are
293
# compiled, and then the software library files.
294
# Next the few verilog files that need preperation are taken care of.
295
# The test begins by starting a loop in bash using on the strings defined in
296
# TESTS. Each one corresponds to a certain module of software for the OpenRISC
297
# that is included in this test suite. Under the sw/ path is a set of paths,
298 45 julius
# and all except the support/ and utils/ paths contain code which is run to
299
# test the OR1k used in this test suite. For each of these software modules,
300
# it is possible that different tests are done using the same module. These
301
# tests can vary by either using different levels of optimisation during
302
# compilation, and/or by having the OR1k's caches enabled or disabled.
303 39 julius
# Each test has a unique name, and under the $(SIM_RESULTS_DIR), which is
304
# usually just ../results, log files, and optionally VCD files, are created for
305
# inspection later and are named according to the test. Inspect the file
306 45 julius
# bench/verilog/or1200_monitor.v to find out in detail what each log consists
307
# of.
308 39 julius
# For each test, a few things occur. First the software that will run inside
309 45 julius
# the simulated OR1k system is compiled, converted to a format which can be
310
# read
311 39 julius
# into the flash memory model via $readmemh() and linked to the sim/run
312 45 julius
# directory as $(SIM_FLASH_MEM_FILE), which currently is flash.in. Next a
313
# compilation script for icarus is generated, containing a list of all the
314
# RTL files and include directories. Next, an include file for the verilog
315
# testbench is generated, containing a string of the name of the current
316
# test, path to the results directory (for VCD generation) and any other
317
# things which might vary from test to test. This is not done by +define
318
# lines in the icarus script because of string handling incosistencies
319
# between different simulators and shells.
320
# Once all the files are generated, icarus is called to compile the rtl
321
# design, and then run it. Each of the tested software modules have code which
322
# will trigger the simulation to be stopped by use of the l.nop instruction
323
# with an immediate value of 1. When the simulation finishes, the simulation
324
# executable exits and the log of the simulation is inspected for the expected
325
# output. Currently, the string "deaddead" indicates that the software
326
# completed successfully. This is counted as the ORPSoC "passing" the test. In
327
# fact, whether the system did the right thing or not requires more
328
# inspection, but roughly this is a good indicator that nothing major went
329
# wrong.
330 39 julius
# Once the current test is finished, the next begins with the compilation of its
331
# software and linking of the resulting hex file to the run path, etc.
332 45 julius
# Main RAM setup - (RTL simulation with Icarus/NCSim only!):
333
# Define USE_SDRAM to enable the external SDRAM, otherwise the simulation
334
# defaults to an internal SRAM. Eg. $ make rtl-tests USE_SDRAM=1 VCD=1
335
# Verilator defaults to internal memories
336 39 julius
rtl-tests: prepare_sw prepare_rtl
337 22 julius
        @if [ ! -d $(SIM_RESULTS_DIR) ]; then mkdir -p $(SIM_RESULTS_DIR); fi
338 33 julius
        @echo
339
        @echo "Beginning loop that will complete the following tests: $(TESTS)"
340
        @echo
341 31 julius
        @for TEST in $(TESTS); do \
342 33 julius
                echo "################################################################################"; \
343
                echo; \
344
                echo "\t#### Current test: $$TEST ####"; echo; \
345 32 julius
                echo "\t#### Compiling software ####"; echo; \
346 22 julius
                CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
347 52 julius
                $(MAKE) -C $$CURRENT_TEST_SW_DIR $$TEST $(TEST_SW_MAKE_OPTS); \
348 45 julius
                rm -f $(SIM_RUN_DIR)/$(SIM_FLASH_MEM_FILE); \
349
                rm -f $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
350
                ln -s $$CURRENT_TEST_SW_DIR/$$TEST$(FLASH_MEM_FILE_SUFFIX) $(SIM_RUN_DIR)/$(SIM_FLASH_MEM_FILE); \
351
                ln -s $$CURRENT_TEST_SW_DIR/$$TEST.vmem $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
352 22 julius
                sed < $(SIM_BIN_DIR)/$(ICARUS_COMMAND_FILE) > $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated \
353
                        -e s!\$$BENCH_DIR!$(BENCH_VERILOG_DIR)!              \
354
                        -e s!\$$RTL_DIR!$(RTL_VERILOG_DIR)!                  \
355
                        -e s!\$$BACKEND_DIR!$(BACKEND_DIR)!                  \
356
                        -e \\!^//.*\$$!d -e \\!^\$$!d ; \
357 34 julius
                echo "+define+TEST_DEFINE_FILE=\"test_define.v\"" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
358 26 julius
                if [ ! -z $$VCD ]; \
359
                        then echo "+define+VCD" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
360
                fi; \
361 54 julius
                if [ ! -z $$UART_PRINTF ]; \
362
                        then echo "+define+UART_PRINTF" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
363
                fi; \
364 34 julius
                echo "\`define TEST_NAME_STRING \"$$TEST\"" > $(SIM_RUN_DIR)/test_define.v; \
365
                echo "\`define TEST_RESULTS_DIR \"$(SIM_RESULTS_DIR)/\" " >> $(SIM_RUN_DIR)/test_define.v; \
366 39 julius
                if [ -z $$NO_SIM_LOGGING ]; then \
367
                        echo "\`define OR1200_DISPLAY_ARCH_STATE" >> $(SIM_RUN_DIR)/test_define.v; \
368
                fi; \
369 22 julius
                echo ; \
370 32 julius
                echo "\t#### Compiling RTL ####"; \
371 22 julius
                rm -f $(SIM_RUN_DIR)/a.out; \
372 58 julius
                $(ICARUS) -sorpsoc_testbench -c $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated $(EVENT_SIM_FLAGS); \
373 22 julius
                echo; \
374 32 julius
                echo "\t#### Beginning simulation ####"; \
375 33 julius
                time -p $(ICARUS_VVP) -l $(SIM_RESULTS_DIR)/$$TEST-vvp-out.log a.out ; \
376 36 julius
                if [ $$? -gt 0 ]; then exit $$?; fi; \
377
                TEST_RESULT=`cat $(SIM_RESULTS_DIR)/$$TEST-general.log | grep report | grep $(SIM_SUCCESS_MESSAGE) -c`; \
378 33 julius
                echo; echo "\t####"; \
379 34 julius
                if [ $$TEST_RESULT -gt 0 ]; then \
380 52 julius
                        echo "\t#### Test $$TEST PASSED ####";TESTS_PASSED=`expr $$TESTS_PASSED + 1`;\
381 32 julius
                else    echo "\t#### Test $$TEST FAILED ####";\
382
                fi; \
383 33 julius
                echo "\t####"; echo; \
384 52 julius
                TESTS_PERFORMED=`expr $$TESTS_PERFORMED + 1`;\
385
        done; \
386
        echo "Test results: "$$TESTS_PASSED" out of "$$TESTS_PERFORMED" tests passed"; echo
387 33 julius
 
388
 
389 52 julius
 
390 39 julius
# Use NCSIM instead of icarus
391
rtl-nc-tests: prepare_sw prepare_rtl
392 35 julius
        @if [ ! -d $(SIM_RESULTS_DIR) ]; then mkdir -p $(SIM_RESULTS_DIR); fi
393
        @echo
394
        @echo "Beginning loop that will complete the following tests: $(TESTS)"
395
        @echo
396
        @for TEST in $(TESTS); do \
397
                echo "################################################################################"; \
398
                echo; \
399
                echo "\t#### Current test: $$TEST ####"; echo; \
400
                echo "\t#### Compiling software ####"; echo; \
401
                CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
402
                $(MAKE) -C $$CURRENT_TEST_SW_DIR $$TEST; \
403 45 julius
                rm -f $(SIM_RUN_DIR)/$(SIM_FLASH_MEM_FILE); \
404
                rm -f $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
405
                ln -s $$CURRENT_TEST_SW_DIR/$$TEST_twobyte_sizefirst.hex $(SIM_RUN_DIR)/$(SIM_FLASH_MEM_FILE); \
406
                ln -s $$CURRENT_TEST_SW_DIR/$$TEST_fourbyte.hex $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
407 35 julius
                sed < $(SIM_BIN_DIR)/$(ICARUS_COMMAND_FILE) > $(SIM_RUN_DIR)/$(ICARUS_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
                echo "+define+TEST_DEFINE_FILE=\"test_define.v\"" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
413
                if [ ! -z $$VCD ]; \
414
                        then echo "+define+VCD" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
415
                        echo "+access+r" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
416
                fi; \
417 54 julius
                if [ ! -z $$UART_PRINTF ]; \
418
                        then echo "+define+UART_PRINTF" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
419
                fi; \
420 45 julius
                if [ ! -z $$USE_SDRAM ]; then \
421
                        echo "\`define USE_SDRAM" >> $(SIM_RUN_DIR)/test_define.v; \
422
                fi; \
423 36 julius
                echo "+nocopyright" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
424
                echo "+nowarn+MACRDF" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
425 35 julius
                echo "\`define TEST_NAME_STRING \"$$TEST\"" > $(SIM_RUN_DIR)/test_define.v; \
426
                echo "\`define TEST_RESULTS_DIR \"$(SIM_RESULTS_DIR)/\" " >> $(SIM_RUN_DIR)/test_define.v; \
427 39 julius
                if [ -z $$NO_SIM_LOGGING ]; then \
428
                        echo "\`define OR1200_DISPLAY_ARCH_STATE" >> $(SIM_RUN_DIR)/test_define.v; \
429
                fi; \
430 35 julius
                echo ; \
431
                echo "\t#### Beginning simulation ####"; \
432 58 julius
                time -p ncverilog -f $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated -Q -l $(SIM_RESULTS_DIR)/$$TEST-ius-out.log $(EVENT_SIM_FLAGS); \
433 36 julius
                if [ $$? -gt 0 ]; then exit $$?; fi; \
434
                TEST_RESULT=`cat $(SIM_RESULTS_DIR)/$$TEST-general.log | grep report | grep $(SIM_SUCCESS_MESSAGE) -c`; \
435 35 julius
                echo; echo "\t####"; \
436
                if [ $$TEST_RESULT -gt 0 ]; then \
437 54 julius
                        echo "\t#### Test $$TEST PASSED ####";TESTS_PASSED=`expr $$TESTS_PASSED + 1`;\
438 35 julius
                else    echo "\t#### Test $$TEST FAILED ####";\
439
                fi; \
440
                echo "\t####"; echo; \
441 54 julius
                TESTS_PERFORMED=`expr $$TESTS_PERFORMED + 1`;\
442
        done; \
443
        echo "Test results: "$$TESTS_PASSED" out of "$$TESTS_PERFORMED" tests passed"; echo
444 33 julius
 
445 52 julius
################################################################################
446
# Verilator model build rules
447
################################################################################
448 48 julius
 
449 52 julius
 
450 60 julius
SYSC_LIB_ARCH_DIR=$(shell ls $$SYSTEMC | grep "lib-")
451 52 julius
 
452
 
453
# List of System C models - use this list to link the sources into the Verilator
454 50 julius
# build directory
455 48 julius
SYSC_MODELS=OrpsocAccess TraceSC
456
 
457 55 julius
ifdef VCD
458
VLT_FLAGS +=-trace
459
endif
460
 
461 52 julius
# Only need the trace target if we are tracing
462
ifneq (,$(findstring -trace, $(VLT_FLAGS)))
463
VLT_TRACEOBJ = SpTraceVcdC
464
endif
465
 
466 50 julius
# This is the list of extra models we'll issue make commands for
467
# Included is the SystemPerl trace model
468 52 julius
SYSC_MODELS_BUILD=$(SYSC_MODELS) $(VLT_TRACEOBJ)
469 50 julius
 
470 52 julius
prepare_vlt: prepare_rtl vlt_model_links $(SIM_VLT_DIR)/Vorpsoc_top
471
 
472
$(SIM_VLT_DIR)/Vorpsoc_top: $(SIM_VLT_DIR)/libVorpsoc_top.a $(SIM_VLT_DIR)/OrpsocMain.o
473
# Final linking of the simulation executable. Order of libraries here is important!
474
        @echo; echo "\tGenerating simulation executable"; echo
475 60 julius
        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
476 52 julius
 
477
$(SIM_VLT_DIR)/OrpsocMain.o:
478
# Now compile the top level systemC "testbench" module
479
        @echo; echo "\tCompiling top level SystemC testbench"; echo
480 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
481 52 julius
 
482
$(SIM_VLT_DIR)/libVorpsoc_top.a: $(SIM_VLT_DIR)/Vorpsoc_top__ALL.a vlt_modules_compile $(SIM_VLT_DIR)/verilated.o
483 48 julius
# Now archive all of the libraries from verilator witht he other modules we might have
484 52 julius
        @echo; echo "\tArchiving libraries into libVorpsoc_top.a"; echo
485
        @cd $(SIM_VLT_DIR) && \
486 48 julius
        cp Vorpsoc_top__ALL.a libVorpsoc_top.a && \
487
        ar rcs libVorpsoc_top.a verilated.o; \
488 50 julius
        for SYSCMODEL in $(SYSC_MODELS_BUILD); do \
489 48 julius
                ar rcs libVorpsoc_top.a $$SYSCMODEL.o; \
490
        done
491 41 julius
 
492 52 julius
$(SIM_VLT_DIR)/verilated.o:
493
        @echo; echo "\tCompiling verilated.o"; echo
494
        @cd $(SIM_VLT_DIR) && \
495
        $(MAKE) -f Vorpsoc_top.mk verilated.o
496 41 julius
 
497 52 julius
.PHONY: vlt_modules_compile
498
vlt_modules_compile:
499
# Compile the module files
500
        @echo; echo "\tCompiling SystemC models"
501
        @cd $(SIM_VLT_DIR) && \
502
        for SYSCMODEL in $(SYSC_MODELS_BUILD); do \
503
                echo;echo "\t$$SYSCMODEL"; echo; \
504
                $(MAKE) -f Vorpsoc_top.mk $$SYSCMODEL.o; \
505
        done
506
 
507
$(SIM_VLT_DIR)/Vorpsoc_top__ALL.a: $(SIM_VLT_DIR)/Vorpsoc_top.mk
508
        @echo; echo "\tCompiling main design"; echo
509
        @cd $(SIM_VLT_DIR) && \
510
        $(MAKE) -f Vorpsoc_top.mk Vorpsoc_top__ALL.a
511
 
512
$(SIM_VLT_DIR)/Vorpsoc_top.mk: $(SIM_VLT_DIR)/$(VLT_COMMAND_FILE).generated $(SIM_VLT_DIR)/libmodules.a
513
# Now call verilator to generate the .mk files
514 53 julius
        @echo; echo "\tGenerating makefiles with Verilator"; echo
515 52 julius
        cd $(SIM_VLT_DIR) && \
516
        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
517
 
518 47 julius
# SystemC modules library
519
$(SIM_VLT_DIR)/libmodules.a:
520 52 julius
        @echo; echo "\tCompiling SystemC modules"; echo
521
        @$(MAKE) -C $(BENCH_SYSC_SRC_DIR) -f $(BENCH_SYSC_SRC_DIR)/Modules.make
522 47 julius
 
523 52 julius
 
524
# Verilator command script
525
# Generate the compile script to give Verilator
526
$(SIM_VLT_DIR)/$(VLT_COMMAND_FILE).generated:
527
        @echo; echo "\tGenerating verilator compile script"; echo
528
        @sed < $(SIM_BIN_DIR)/$(VLT_COMMAND_FILE) > $(SIM_VLT_DIR)/$(VLT_COMMAND_FILE).generated \
529
                -e s!\$$BENCH_DIR!$(BENCH_VERILOG_DIR)!              \
530
                -e s!\$$RTL_DIR!$(RTL_VERILOG_DIR)!                  \
531
                -e s!\$$BACKEND_DIR!$(BACKEND_DIR)!                  \
532
                -e \\!^//.*\$$!d -e \\!^\$$!d;
533
 
534
.PHONY: vlt_model_links
535
vlt_model_links:
536
# Link all the required system C model files into the verilator work dir
537
        @echo; echo "\tLinking SystemC model source to verilator build path"; echo
538
        @if [ ! -d $(SIM_VLT_DIR) ]; then mkdir $(SIM_VLT_DIR); fi
539
        @cd $(SIM_VLT_DIR) && \
540
        for SYSCMODEL in $(SYSC_MODELS); do \
541
                if [ ! -e $$SYSCMODEL.cpp ]; then \
542
                        ln -s $(BENCH_SYSC_SRC_DIR)/$$SYSCMODEL.cpp .; \
543
                        ln -s $(BENCH_SYSC_INCLUDE_DIR)/$$SYSCMODEL.h .; \
544
                fi; \
545
        done
546
 
547 53 julius
 
548 52 julius
################################################################################
549 53 julius
# Verilator test loop
550
################################################################################
551
 
552
# Verilator defaults to internal memories
553
vlt-tests: prepare_sw_uart_printf prepare_rtl prepare_vlt
554 56 julius
        @if [ ! -d $(SIM_RESULTS_DIR) ]; then mkdir -p $(SIM_RESULTS_DIR); fi
555 53 julius
        @echo
556
        @echo "Beginning loop that will complete the following tests: $(TESTS)"
557
        @echo
558
        @for TEST in $(TESTS); do \
559
                echo "################################################################################"; \
560
                echo; \
561
                echo "\t#### Current test: $$TEST ####"; echo; \
562
                echo "\t#### Compiling software ####"; echo; \
563
                CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
564
                $(MAKE) -C $$CURRENT_TEST_SW_DIR $$TEST $(TEST_SW_MAKE_OPTS) UART_PRINTF=1; \
565
                rm -f $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
566
                ln -s $$CURRENT_TEST_SW_DIR/$$TEST.vmem $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
567
                echo "\t#### Beginning simulation ####"; \
568 55 julius
                time -p $(SIM_VLT_DIR)/Vorpsoc_top $$TEST; \
569 53 julius
                if [ $$? -gt 0 ]; then exit $$?; fi; \
570
                TEST_RESULT=1; \
571
                echo; echo "\t####"; \
572
                if [ $$TEST_RESULT -gt 0 ]; then \
573
                        echo "\t#### Test $$TEST PASSED ####";TESTS_PASSED=`expr $$TESTS_PASSED + 1`;\
574
                else    echo "\t#### Test $$TEST FAILED ####";\
575
                fi; \
576
                echo "\t####"; echo; \
577
                TESTS_PERFORMED=`expr $$TESTS_PERFORMED + 1`;\
578
        done; \
579
        echo "Test results: "$$TESTS_PASSED" out of "$$TESTS_PERFORMED" tests passed"; echo
580
 
581
 
582 56 julius
 
583 53 julius
################################################################################
584 56 julius
# Architectural simulator test loop
585
################################################################################
586
 
587
# Verilator defaults to internal memories
588
sim-tests: prepare_sw_uart_printf
589
        @if [ ! -d $(SIM_RESULTS_DIR) ]; then mkdir -p $(SIM_RESULTS_DIR); fi
590
        @echo
591
        @echo "Beginning loop that will complete the following tests: $(TESTS)"
592
        @echo
593
        @for TEST in $(TESTS); do \
594
                echo "################################################################################"; \
595
                echo; \
596
                echo "\t#### Current test: $$TEST ####"; echo; \
597
                echo "\t#### Compiling software ####"; echo; \
598
                CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
599
                $(MAKE) -C $$CURRENT_TEST_SW_DIR $$TEST $(TEST_SW_MAKE_OPTS) UART_PRINTF=1; \
600
                rm -f $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
601
                ln -s $$CURRENT_TEST_SW_DIR/$$TEST.or32 $(SIM_RUN_DIR)/.; \
602
                echo;echo "\t#### Launching architectural simulator ####"; \
603
                time -p $(ARCH_SIM_EXE) --nosrv -f $(SIM_BIN_DIR)/$(ARCH_SIM_CFG_FILE) $$TEST.or32 > $(SIM_RESULTS_DIR)/$$TEST-or1ksim.log 2>&1; \
604
                if [ $$? -gt 0 ]; then exit $$?; fi; \
605
                if [ `tail -n 10 $(SIM_RESULTS_DIR)/$$TEST-or1ksim.log | grep -c $(SIM_SUCCESS_MESSAGE)` -gt 0 ]; then \
606
                        TEST_RESULT=1; \
607
                fi; \
608
                echo; echo "\t####"; \
609
                if [ $$TEST_RESULT -gt 0 ]; then \
610
                        echo "\t#### Test $$TEST PASSED ####";TESTS_PASSED=`expr $$TESTS_PASSED + 1`;\
611
                else    echo "\t#### Test $$TEST FAILED ####";\
612
                fi; \
613
                echo "\t####"; echo; \
614
                TESTS_PERFORMED=`expr $$TESTS_PERFORMED + 1`;\
615
                unlink $(SIM_RUN_DIR)/$$TEST.or32; \
616
        done; \
617
        echo "Test results: "$$TESTS_PASSED" out of "$$TESTS_PERFORMED" tests passed"; echo
618
 
619
 
620
 
621
################################################################################
622 52 julius
# Cleaning rules
623
################################################################################
624
 
625 57 julius
clean: clean-sw clean-sim
626
 
627 22 julius
clean-sw:
628
        @for TEST in $(TESTS); do \
629
                echo "Current test: $$TEST"; \
630
                CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
631
                echo "Current test sw directory: " $$CURRENT_TEST_SW_DIR; \
632
                $(MAKE) -C $$CURRENT_TEST_SW_DIR clean; \
633
        done
634 31 julius
        $(MAKE) -C $(SW_DIR)/support clean
635
        $(MAKE) -C $(SW_DIR)/utils clean
636
 
637
clean-sim:
638 52 julius
        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.