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