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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [boards/] [xilinx/] [ml501/] [sim/] [bin/] [Makefile] - Blame information for rev 479

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

Line No. Rev Author Line
1 412 julius
######################################################################
2
####                                                              ####
3 425 julius
####  ORPSoCv2 Xilinx simulation Makefile                         ####
4 412 julius
####                                                              ####
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
####                                                              ####
12
####  Author(s):                                                  ####
13
####      - Julius Baxter, julius@opencores.org                   ####
14
####                                                              ####
15
####                                                              ####
16
######################################################################
17
####                                                              ####
18
#### Copyright (C) 2009,2010 Authors and OPENCORES.ORG            ####
19
####                                                              ####
20
#### This source file may be used and distributed without         ####
21
#### restriction provided that this copyright statement is not    ####
22
#### removed from the file and that any derivative work contains  ####
23
#### the original copyright notice and the associated disclaimer. ####
24
####                                                              ####
25
#### This source file is free software; you can redistribute it   ####
26
#### and/or modify it under the terms of the GNU Lesser General   ####
27
#### Public License as published by the Free Software Foundation; ####
28
#### either version 2.1 of the License, or (at your option) any   ####
29
#### later version.                                               ####
30
####                                                              ####
31
#### This source is distributed in the hope that it will be       ####
32
#### useful, but WITHOUT ANY WARRANTY; without even the implied   ####
33
#### warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ####
34
#### PURPOSE.  See the GNU Lesser General Public License for more ####
35
#### details.                                                     ####
36
####                                                              ####
37
#### You should have received a copy of the GNU Lesser General    ####
38
#### Public License along with this source; if not, download it   ####
39
#### from http://www.opencores.org/lgpl.shtml                     ####
40
####                                                              ####
41
######################################################################
42 67 julius
 
43 412 julius
# Name of the directory we're currently in
44
CUR_DIR=$(shell pwd)
45 67 julius
 
46
# The root path of the whole project
47 412 julius
PROJECT_ROOT ?=$(CUR_DIR)/../../../../..
48 67 julius
 
49 412 julius
DESIGN_NAME=orpsoc
50
RTL_TESTBENCH_TOP=$(DESIGN_NAME)_testbench
51 67 julius
 
52 412 julius
# Hardset the board name, even though we could probably determine it
53
FPGA_VENDOR=xilinx
54
BOARD_NAME=ml501
55
BOARD_DIR=$(PROJECT_ROOT)/boards/$(FPGA_VENDOR)/$(BOARD_NAME)
56 67 julius
 
57 468 julius
# Export BOARD for the software makefiles
58
BOARD=$(FPGA_VENDOR)/$(BOARD_NAME)
59
export BOARD
60 67 julius
 
61 412 julius
# Paths to other important parts of this test suite
62
COMMON_RTL_DIR = $(PROJECT_ROOT)/rtl
63
COMMON_RTL_VERILOG_DIR = $(COMMON_RTL_DIR)/verilog
64
#COMMON_RTL_VHDL_DIR = $(COMMON_RTL_DIR)/vhdl
65 67 julius
 
66 412 julius
BOARD_RTL_DIR=$(BOARD_DIR)/rtl
67
BOARD_RTL_VERILOG_DIR=$(BOARD_RTL_DIR)/verilog
68
# Only 1 include path for board builds - their own!
69
BOARD_RTL_VERILOG_INCLUDE_DIR=$(BOARD_RTL_VERILOG_DIR)/include
70 67 julius
 
71 412 julius
BOARD_BENCH_DIR=$(BOARD_DIR)/bench
72
BOARD_BENCH_VERILOG_DIR=$(BOARD_BENCH_DIR)/verilog
73
BOARD_BENCH_VERILOG_INCLUDE_DIR=$(BOARD_BENCH_VERILOG_DIR)/include
74 67 julius
 
75 412 julius
COMMON_BENCH_DIR=$(PROJECT_ROOT)
76
COMMON_BENCH_VERILOG_DIR=$(COMMON_BENCH_DIR)/verilog
77
COMMON_BENCH_VERILOG_INCLUDE_DIR=$(COMMON_BENCH_VERILOG_DIR)/include
78 67 julius
 
79 412 julius
# Top level files for DUT and testbench
80
DUT_TOP=$(BOARD_RTL_VERILOG_DIR)/$(DESIGN_NAME)_top/$(DESIGN_NAME)_top.v
81
BENCH_TOP=$(BOARD_BENCH_VERILOG_DIR)/$(DESIGN_NAME)_testbench.v
82 67 julius
 
83 412 julius
# Software tests we'll run
84 67 julius
 
85 412 julius
# Need this for individual test variables to not break
86
TEST ?= or1200-simple
87 67 julius
 
88 412 julius
TESTS ?= or1200-simple or1200-cbasic or1200-dctest or1200-float or1200-mmu or1200-basic or1200-except or1200-tick or1200-ticksyscall uart-simple
89 67 julius
 
90 412 julius
# Gets turned into verilog `define
91
SIM_TYPE=RTL
92
 
93
# Main defines file is from board include path
94
PROJECT_VERILOG_DEFINES=$(BOARD_RTL_VERILOG_INCLUDE_DIR)/$(DESIGN_NAME)-defines.v
95
 
96
# Detect technology to use for the simulation
97
DESIGN_DEFINES=$(shell cat $(PROJECT_VERILOG_DEFINES) | sed s://.*::g | sed s:\`:\#:g | sed 's:^[ ]*::' | awk '{print};/^\#define/{printf "_%s=%s\n",$$2,$$2}' | grep -v PERIOD | cpp -P | sed s:^_::g | sed s:=$$::g )
98
 
99
# Rule to look at what defines are being extracted from main file
100
print-defines:
101
        @echo echo; echo "\t### Design defines ###"; echo;
102
        @echo "\tParsing "$(PROJECT_VERILOG_DEFINES)" and exporting:"
103
        @echo $(DESIGN_DEFINES)
104
 
105
print-tests:
106
        @echo; echo; echo "\t### Software tests to be run ###"; echo;
107
        @echo $(TESTS)
108
        @echo
109
 
110 425 julius
# Backend tool path
111
# Check that the XILINX_PATH variable is set
112
ifeq ($(XILINX_PATH),)
113
$(error XILINX_PATH environment variable not set. Set it and rerun)
114
endif
115
XILINX_SETTINGS_SCRIPT=$(XILINX_PATH)/settings32.sh
116
XILINX_SETTINGS_SCRIPT_EXISTS=$(shell if [ -e $(XILINX_SETTINGS_SCRIPT) ]; then echo 1; else echo 0; fi)
117
ifeq ($(XILINX_SETTINGS_SCRIPT_EXISTS),0)
118
$(error XILINX_PATH variable not set correctly. Cannot find $$XILINX_PATH/settings32.sh)
119
endif
120
 
121
 
122 412 julius
# Simulation directories
123
SIM_DIR ?=$(BOARD_DIR)/sim
124
RTL_SIM_DIR=$(SIM_DIR)
125
RTL_SIM_RUN_DIR=$(RTL_SIM_DIR)/run
126
RTL_SIM_BIN_DIR=$(RTL_SIM_DIR)/bin
127
RTL_SIM_RESULTS_DIR=$(RTL_SIM_DIR)/out
128
 
129
# Testbench paths
130
BOARD_BENCH_DIR=$(BOARD_DIR)/bench
131
BOARD_BENCH_VERILOG_DIR=$(BOARD_BENCH_DIR)/verilog
132
COMMON_BENCH_DIR=$(PROJECT_ROOT)/bench
133
COMMON_BENCH_VERILOG_DIR=$(COMMON_BENCH_DIR)/verilog
134
 
135
#BENCH_VHDL_DIR=$(BENCH_DIR)/vhdl
136
# No SystemC or Verilator support for this build
137
#BENCH_SYSC_DIR=$(BENCH_DIR)/sysc
138
#BENCH_SYSC_SRC_DIR=$(BENCH_SYSC_DIR)/src
139
#BENCH_SYSC_INCLUDE_DIR=$(BENCH_SYSC_DIR)/include
140
 
141
# Backend directories
142
# This one is the board build's backend dir.
143
BOARD_BACKEND_DIR=$(BOARD_DIR)/backend
144
BOARD_BACKEND_VERILOG_DIR=$(BOARD_BACKEND_DIR)/rtl/verilog
145
TECHNOLOGY_BACKEND_DIR=$(BOARD_DIR)/../backend
146
# This path is for the technology library
147 425 julius
#TECHNOLOGY_BACKEND_VERILOG_DIR=$(TECHNOLOGY_BACKEND_DIR)/rtl/verilog
148
# Depends on the XILINX_PATH variable - we check above if it's set properly.
149
TECHNOLOGY_BACKEND_VERILOG_DIR=$(XILINX_PATH)/verilog
150 412 julius
 
151
# Synthesis directory for board
152
BOARD_SYN_DIR=$(BOARD_DIR)/syn/synplify
153
BOARD_SYN_OUT_DIR=$(BOARD_SYN_DIR)/out
154
 
155
# System software dir
156
COMMON_SW_DIR=$(PROJECT_ROOT)/sw
157
BOARD_SW_DIR=$(BOARD_DIR)/sw
158
 
159
# BootROM code, which generates a verilog array select values
160
BOOTROM_FILE=bootrom.v
161 415 julius
BOARD_BOOTROM_SW_DIR=$(BOARD_SW_DIR)/bootrom
162
BOOTROM_SRC=$(shell ls $(BOARD_BOOTROM_SW_DIR)/* | grep -v $(BOOTROM_FILE))
163
BOOTROM_VERILOG=$(BOARD_BOOTROM_SW_DIR)/$(BOOTROM_FILE)
164 412 julius
 
165 479 julius
.phony: $(BOOTROM_VERILOG)
166 412 julius
bootrom: $(BOOTROM_VERILOG)
167
 
168
$(BOOTROM_VERILOG): $(BOOTROM_SRC)
169
        $(Q)echo; echo "\t### Generating bootup ROM ###"; echo
170 415 julius
        $(Q)$(MAKE) -C $(BOARD_BOOTROM_SW_DIR) $(BOOTROM_FILE)
171 412 julius
 
172
# Suffix of file to check after each test for the string
173
TEST_OUT_FILE_SUFFIX=-general.log
174
TEST_OK_STRING=8000000d
175
 
176
# Dynamically generated verilog file defining configuration for various things
177
# Rule actually generating this is found in definesgen.inc file.
178
TEST_DEFINES_VLG=test-defines.v
179 415 julius
.PHONY: $(TEST_DEFINES_VLG)
180 412 julius
# Set V=1 when calling make to enable verbose output
181
# mainly for debugging purposes.
182
ifeq ($(V), 1)
183
Q=
184
QUIET=
185
else
186
Q ?=@
187
QUIET=-quiet
188
endif
189
 
190
# Modelsim variables
191
MGC_VSIM=vsim
192
MGC_VLOG_COMP=vlog
193
MGC_VHDL_COMP=vcom
194
MODELSIM=modelsim
195
 
196
# Default simulator is Modelsim here as we're using the ProASIC3
197
# libraries which are not compilable with Icarus.
198
# Set SIMULATOR=modelsim to use Modelsim (Default)
199
# Set SIMULATOR=ncverilog to use Cadence's NC-Verilog - TODO
200
# Set SIMULATOR=icarus to use Icarus Verilog (Not supported for this board)
201
 
202
SIMULATOR ?= $(MODELSIM)
203
 
204
#
205
# Modelsim-specific settings
206
#
207
VOPT_ARGS=$(QUIET) -suppress 2241
208
# If VCD dump is desired, tell Modelsim not to optimise
209
# away everything.
210 67 julius
ifeq ($(VCD), 1)
211 412 julius
#VOPT_ARGS=-voptargs="+acc=rnp"
212
VOPT_ARGS=+acc=rnpqv
213 67 julius
endif
214 412 julius
# VSIM commands
215
# Suppressed warnings - 3009: Failed to open $readmemh() file
216
# Suppressed warnings - 3009: Module 'blah' does not have a `timescale directive in effect, but previous modules do.
217
# Suppressed warnings - 8598: Non-positive replication multiplier inside concat. Replication will be ignored
218
VSIM_ARGS=  -suppress 7 -suppress 3009 -suppress 8598 -c $(QUIET) -do "set StdArithNoWarnings 1; run -all; exit"
219
# Modelsim VPI settings
220
ifeq ($(VPI), 1)
221
VPI_LIBS=$(VPI_SRC_C_DIR)/$(MODELTECH_VPILIB)
222
VSIM_ARGS += -pli $(VPI_SRC_C_DIR)/$(MODELTECH_VPILIB)
223
endif
224
# Rule to make the VPI library for modelsim
225
$(VPI_SRC_C_DIR)/$(MODELTECH_VPILIB): $(VPI_SRCS)
226
        $(MAKE) -C $(VPI_SRC_C_DIR) $(MODELTECH_VPILIB)
227 67 julius
 
228 412 julius
#
229
# Verilog DUT source variables
230
#
231 67 julius
 
232 412 julius
# First consider any modules we'll use gatelevel descriptions of.
233
# These will have to be set on the command line
234
GATELEVEL_MODULES ?=
235 67 julius
 
236 412 julius
# First we get a list of modules in the RTL path of the board's path.
237
# Next we check which modules not in the board's RTL path are in the root RTL
238
# path (modules which can be commonly instantiated, but over which board
239
# build-specific versions take precedence.)
240 67 julius
 
241 412 julius
# Paths under board/***/rtl/verilog we wish to exclude when getting modules
242
BOARD_VERILOG_MODULES_EXCLUDE= include $(GATELEVEL_MODULES)
243
BOARD_VERILOG_MODULES_DIR_LIST=$(shell ls $(BOARD_RTL_VERILOG_DIR))
244
# Apply exclude to list of modules
245
BOARD_RTL_VERILOG_MODULES=$(filter-out $(BOARD_VERILOG_MODULES_EXCLUDE),$(BOARD_VERILOG_MODULES_DIR_LIST))
246 67 julius
 
247 412 julius
# Rule for debugging this script
248
print-board-modules:
249
        @echo echo; echo "\t### Board verilog modules ###"; echo
250
        @echo $(BOARD_RTL_VERILOG_MODULES)
251 67 julius
 
252 412 julius
# Now get list of modules that we don't have a version of in the board path
253
COMMON_VERILOG_MODULES_EXCLUDE= include
254
COMMON_VERILOG_MODULES_EXCLUDE += $(BOARD_RTL_VERILOG_MODULES)
255
COMMON_VERILOG_MODULES_EXCLUDE += $(GATELEVEL_MODULES)
256
 
257
COMMON_RTL_VERILOG_MODULES_DIR_LIST=$(shell ls $(COMMON_RTL_VERILOG_DIR))
258
COMMON_RTL_VERILOG_MODULES=$(filter-out $(COMMON_VERILOG_MODULES_EXCLUDE), $(COMMON_RTL_VERILOG_MODULES_DIR_LIST))
259
 
260
 
261
# Add these to exclude their RTL directories from being included in scripts
262
 
263
 
264
 
265
# Rule for debugging this script
266
print-common-modules-exclude:
267
        @echo echo; echo "\t### Common verilog modules being excluded due to board versions ###"; echo
268
        @echo "$(COMMON_VERILOG_MODULES_EXCLUDE)"
269
 
270
print-common-modules:
271
        @echo echo; echo "\t###  Verilog modules from common RTL dir ###"; echo
272
        @echo $(COMMON_RTL_VERILOG_MODULES)
273
 
274
# List of verilog source files (only .v files!)
275
# Board RTL modules first
276
RTL_VERILOG_SRC=$(shell for module in $(BOARD_RTL_VERILOG_MODULES); do if [ -d $(BOARD_RTL_VERILOG_DIR)/$$module ]; then ls $(BOARD_RTL_VERILOG_DIR)/$$module/*.v; fi; done)
277
# Common RTL module source
278
RTL_VERILOG_SRC +=$(shell for module in $(COMMON_RTL_VERILOG_MODULES); do if [ -d $(COMMON_RTL_VERILOG_DIR)/$$module ]; then ls $(COMMON_RTL_VERILOG_DIR)/$$module/*.v; fi; done)
279
 
280
# List of verilog includes from board RTL path - only for rule sensitivity
281
RTL_VERILOG_INCLUDES=$(shell ls $(BOARD_RTL_VERILOG_INCLUDE_DIR)/*.*)
282
 
283
print-verilog-src:
284
        @echo echo; echo "\t### Verilog source ###"; echo
285
        @echo $(RTL_VERILOG_SRC)
286
 
287
# Rules to make RTL we might need
288
# Expects modules, if they need making, to have their top verilog file to
289
# correspond to their module name, and the directory should have a make file
290
# and rule which works for this command.
291
# Add name of module to this list, currently only does verilog ones.
292
# Rule 'rtl' is called just before generating DUT modelsim compilation script
293
RTL_TO_CHECK=
294
rtl:
295
        $(Q)for module in $(RTL_TO_CHECK); do \
296
                $(MAKE) -C $(RTL_VERILOG_DIR)/$$module $$module.v; \
297
        done
298
 
299
#
300
# VHDL DUT source variables
301
#
302
# VHDL modules
303
#RTL_VHDL_MODULES=$(shell ls $(RTL_VHDL_DIR))
304
# VHDL sources
305
#RTL_VHDL_SRC=$(shell for module in $(RTL_VHDL_MODULES); do if [ -d $(RTL_VHDL_DIR)/$$module ]; then ls $(RTL_VHDL_DIR)/$$module/*.vhd; fi; done)
306
#print-vhdl-src:
307
#       @echo echo; echo "\t### VHDL modules and source ###"; echo
308
#       @echo "modules: "; echo $(RTL_VHDL_MODULES); echo
309
#       @echo "source: "$(RTL_VHDL_SRC)
310
 
311
#
312
# Testbench source
313
#
314
BOARD_BENCH_VERILOG_SRC=$(shell ls $(BOARD_BENCH_VERILOG_DIR)/*.v | grep -v $(DESIGN_NAME)_testbench )
315
BOARD_BENCH_VERILOG_SRC_FILES=$(notdir $(BOARD_BENCH_VERILOG_SRC))
316
 
317
# Now only take the source from the common path that we don't already have in
318
# our board's
319
COMMON_BENCH_VERILOG_DIR_LS=$(shell ls $(COMMON_BENCH_VERILOG_DIR)/*.v)
320
COMMON_BENCH_VERILOG_SRC_FILES=$(notdir $(COMMON_BENCH_VERILOG_DIR_LS))
321
COMMON_BENCH_VERILOG_SRC_FILTERED=$(filter-out $(BOARD_BENCH_VERILOG_SRC_FILES) $(DESIGN_NAME)_testbench.v,$(COMMON_BENCH_VERILOG_SRC_FILES))
322
COMMON_BENCH_VERILOG_SRC=$(addprefix $(COMMON_BENCH_VERILOG_DIR)/, $(COMMON_BENCH_VERILOG_SRC_FILTERED))
323
 
324
print-board-bench-src:
325
        $(Q)echo "\tBoard bench verilog source"; \
326
        echo $(BOARD_BENCH_VERILOG_SRC)
327
 
328
print-common-bench-src:
329
        $(Q)echo "\Common bench verilog source"; \
330
        echo $(COMMON_BENCH_VERILOG_SRC)
331
 
332
# Testbench source subdirectory detection (exclude include, we always use
333
# board bench include directory!)
334
BOARD_BENCH_VERILOG_SUBDIRS=$(shell cd $(BOARD_BENCH_VERILOG_DIR) && ls -d */ | grep -v include)
335
COMMON_BENCH_VERILOG_SUBDIRS=$(shell cd $(COMMON_BENCH_VERILOG_DIR) && ls -d */ | grep -v include)
336
 
337
# Get rid of ones we have a copy of locally
338
COMMON_BENCH_VERILOG_SUBDIRS_EXCLUDE_BOARDS=$(filter-out $(BOARD_BENCH_VERILOG_SUBDIRS),$(COMMON_BENCH_VERILOG_SUBDIRS))
339
 
340
# Construct list of paths we will want to include
341
BENCH_VERILOG_SUBDIRS=$(addprefix $(COMMON_BENCH_VERILOG_DIR)/,$(COMMON_BENCH_VERILOG_SUBDIRS_EXCLUDE_BOARDS))
342
BENCH_VERILOG_SUBDIRS += $(addprefix $(BOARD_BENCH_VERILOG_DIR)/,$(BOARD_BENCH_VERILOG_SUBDIRS))
343
 
344
# Finally, add include path from local bench path
345
BENCH_VERILOG_SUBDIRS += $(BOARD_BENCH_VERILOG_DIR)/include
346
 
347
print-board-bench-subdirs:
348
        $(Q)echo "\tBoard bench subdirectories"; \
349
        echo $(BOARD_BENCH_VERILOG_SUBDIRS)
350
 
351
print-common-bench-subdirs:
352
        $(Q)echo "\tCommon bench subdirectories"; \
353
        echo $(COMMON_BENCH_VERILOG_SUBDIRS)
354
 
355
print-bench-subdirs:
356
        $(Q)echo "\tBench subdirectories"; \
357
        echo $(BENCH_VERILOG_SUBDIRS)
358
 
359
 
360
# Backend technology library files
361
# We don't do this for the board backend stuff - that should all be properly
362
# named, and so we only need to pass the "-y" option for that path.
363
BOARD_BACKEND_VERILOG_SRC=$(shell ls $(BOARD_BACKEND_VERILOG_DIR)/*.v )
364
 
365
#
366
# Compile script generation rules:
367
#
368
 
369
# Modelsim library compilation rules
370
#       $(Q)echo "-y " $(BOARD_BACKEND_VERILOG_DIR) >> $@;
371
# DUT compile script
372
modelsim_dut.scr: rtl $(RTL_VERILOG_SRC) $(RTL_VERILOG_INCLUDES) $(BOOTROM_VERILOG)
373
        $(Q)echo "+incdir+"$(BOARD_RTL_VERILOG_INCLUDE_DIR) > $@;
374 415 julius
        $(Q)echo "+incdir+"$(BOARD_BOOTROM_SW_DIR) >> $@;
375 412 julius
        $(Q)echo "+incdir+"$(BOARD_BENCH_VERILOG_INCLUDE_DIR) >> $@;
376
        $(Q)echo "+libext+.v" >> $@;
377
        $(Q)for module in $(BOARD_RTL_VERILOG_MODULES); do if [ -d $(BOARD_RTL_VERILOG_DIR)/$$module ]; then echo "-y " $(BOARD_RTL_VERILOG_DIR)/$$module >> $@; fi; done
378
        $(Q)for module in $(COMMON_RTL_VERILOG_MODULES); do if [ -d $(COMMON_RTL_VERILOG_DIR)/$$module ]; then echo "-y " $(COMMON_RTL_VERILOG_DIR)/$$module >> $@; fi; done
379
        $(Q)echo "-y "$(TECHNOLOGY_BACKEND_VERILOG_DIR)"/src/unisims" >> $@;
380
        $(Q)echo "-y "$(TECHNOLOGY_BACKEND_VERILOG_DIR)"/src/XilinxCoreLib" >> $@;
381
        $(Q)if [ ! -z "$$GATELEVEL_MODULES" ]; \
382
                then echo "-y " $(BOARD_SYN_OUT_DIR) >> $@; \
383
                echo "+libext+.vm" >> $@; \
384 67 julius
        fi
385 412 julius
        $(Q)echo >> $@
386 67 julius
 
387 412 julius
modelsim_bench.scr: $(BOARD_BENCH_VERILOG_SRC) $(COMMON_BENCH_VERILOG_SRC)
388
        $(Q)echo "+incdir+"$(BOARD_BENCH_VERILOG_INCLUDE_DIR) > $@;
389
        $(Q)echo "+incdir+"$(COMMON_BENCH_VERILOG_INCLUDE_DIR) >> $@;
390
        $(Q)for path in $(BENCH_VERILOG_SUBDIRS); do echo "+incdir+"$$path >> $@; done
391
        $(Q)for path in $(BENCH_VERILOG_SUBDIRS); do echo "-y "$$path >> $@; done
392
        $(Q)echo "+incdir+"$(BOARD_RTL_VERILOG_INCLUDE_DIR) >> $@;
393
        $(Q)echo "+libext+.v" >> $@;
394
        $(Q)echo "+incdir+"$(TECHNOLOGY_BACKEND_VERILOG_DIR)"/src" >> $@;
395
        $(Q)for vsrc in $(BOARD_BENCH_VERILOG_SRC); do echo $$vsrc >> $@; done
396
        $(Q)for vsrc in $(COMMON_BENCH_VERILOG_SRC); do echo $$vsrc >> $@; done
397
        $(Q)echo >> $@
398 67 julius
 
399 412 julius
# Modelsim library compilation rules
400 67 julius
 
401 412 julius
# Compile DUT into "work" library
402
work: modelsim_dut.scr
403
        $(Q)if [ ! -e $@ ]; then vlib $@; fi
404
        $(Q)echo; echo "\t### Compiling Verilog design library ###"; echo
405
        $(Q)vlog $(QUIET) -f $< $(DUT_TOP)
406
#       $(Q)echo; echo "\t### Compiling VHDL design library ###"; echo
407
#       $(Q)vcom -93 $(QUIET) $(RTL_VHDL_SRC)
408 67 julius
 
409 412 julius
# Single compile rule
410
.PHONY : $(MODELSIM)
411
$(MODELSIM): modelsim_bench.scr $(TEST_DEFINES_VLG) $(VPI_LIBS) work
412
        $(Q)echo; echo "\t### Compiling Xilinx support libs, user design & testbench ###"; echo
413
        $(Q)vlog $(QUIET) -nologo -incr $(BENCH_TOP) -f $<
414
        $(Q)vopt $(QUIET) glbl $(RTL_TESTBENCH_TOP) $(VOPT_ARGS) -o tb
415
        $(Q)echo; echo "\t### Launching simulation ###"; echo
416
        $(Q)vsim $(VSIM_ARGS) tb
417 67 julius
 
418
 
419 412 julius
.PHONY: rtl-test
420
rtl-test: clean-sim-test-sw sw clean-test-defines $(TEST_DEFINES_VLG) \
421
        $(SIMULATOR)
422 67 julius
 
423 412 julius
# Run an RTL test followed by checking of generated results
424
rtl-test-with-check: rtl-test
425
        $(Q)$(MAKE) check-test-log; \
426
        if [ $$? -ne 0 ]; then \
427
                echo; echo "\t### "$(TEST)" test FAIL ###"; echo; \
428
        else \
429
                echo; echo "\t### "$(TEST)" test OK ###"; echo; \
430
        fi
431
 
432
# Do check, don't print anything out
433
rtl-test-with-check-no-print: rtl-test check-test-log
434
 
435
# Main RTL test loop
436
rtl-tests:
437
        $(Q)for test in $(TESTS); do \
438
                export TEST=$$test; \
439
                $(MAKE) rtl-test-with-check-no-print; \
440
                if [ $$? -ne 0 ]; then break; fi; \
441
                echo; echo "\t### $$test test OK ###"; echo; \
442
        done
443
 
444
 
445
.PHONY: check-test-log
446
check-test-log:
447
        $(Q)echo "#!/bin/bash" > $@
448
        $(Q)echo "function check-test-log { if [ \`grep -c -i "$(TEST_OK_STRING)" "$(RTL_SIM_RESULTS_DIR)"/"$(TEST)$(TEST_OUT_FILE_SUFFIX)"\` -gt 0 ]; then return 0; else return 1; fi; }" >> $@
449
        $(Q)echo "check-test-log" >> $@
450
        $(Q)chmod +x $@
451
        $(Q) echo; echo "\t### Checking simulation results for "$(TEST)" test ###"; echo;
452
        $(Q)./$@
453
 
454
# Include the test-defines.v generation rule
455
include $(PROJECT_ROOT)/sim/bin/definesgen.inc
456
 
457
#
458
# Software make rules (called recursively)
459
#
460
 
461
# Path for the current test
462
# First check for a local copy of the test. If it doesn't exist then we
463
# default to the software tests in the root directory
464
TEST_MODULE=$(shell echo $(TEST) | cut -d "-" -f 1)
465
BOARD_SW_TEST_DIR=$(BOARD_SW_DIR)/tests/$(TEST_MODULE)/sim
466
COMMON_SW_TEST_DIR=$(COMMON_SW_DIR)/tests/$(TEST_MODULE)/sim
467
# Do this by testing for the file's existence
468
SW_TEST_DIR=$(shell if [ -e $(BOARD_SW_TEST_DIR)/$(TEST).[cS] ]; then echo $(BOARD_SW_TEST_DIR); else echo $(COMMON_SW_TEST_DIR); fi)
469
 
470
print-test-sw-dir:
471
        @echo; echo "\tTest software is in the following path"; echo;
472
        @echo $(BOARD_SW_DIR); echo;
473
        @echo $(BOARD_SW_TEST_DIR); echo;
474
        @echo $(SW_TEST_DIR); echo;
475
 
476
print-sw-tests:
477
        $(Q) $(MAKE) -C $(COMMON_SW_DIR)/lib print-sw-tests
478
        $(Q) $(MAKE) -C $(COMMON_SW_DIR)/lib print-sw-tests-subdirs
479
 
480
 
481
# Name of the image the RAM model will attempt to load via Verilog $readmemh
482
# system function.
483
 
484
# Set PRELOAD_RAM=1 to preload the system memory - be sure the bootROM program
485
# chosen in board.h is the one booting from the reset vector.
486
ifeq ($(PRELOAD_RAM), 1)
487
SIM_SW_IMAGE ?=sram.vmem
488
else
489
SIM_SW_IMAGE ?=flash.in
490
endif
491
 
492 415 julius
# Amount to pad the image we'll load into the SPI flash
493
HEX_IMAGE_PADDING ?=0x1c0000
494
 
495 412 julius
.PHONY : sw
496
sw: $(SIM_SW_IMAGE)
497
 
498
 
499
flash.in: $(SW_TEST_DIR)/$(TEST).flashin
500
        $(Q)if [ -L $@ ]; then unlink $@; fi
501
        $(Q)ln -s $< $@
502
 
503
sram.vmem: $(SW_TEST_DIR)/$(TEST).vmem
504
        $(Q)if [ -L $@ ]; then unlink $@; fi
505
        $(Q)ln -s $< $@
506
 
507
.PHONY: $(SW_TEST_DIR)/$(TEST).flashin
508
$(SW_TEST_DIR)/$(TEST).flashin:
509
        $(Q) echo; echo "\t### Compiling software ###"; echo;
510 415 julius
        $(Q)$(MAKE) -C $(SW_TEST_DIR) $(TEST).flashin \
511
                HEX_IMAGE_PADDING=$(HEX_IMAGE_PADDING)
512 412 julius
 
513
.PHONY: $(SW_TEST_DIR)/$(TEST).vmem
514
$(SW_TEST_DIR)/$(TEST).vmem:
515
        $(Q) echo; echo "\t### Compiling software ###"; echo;
516
        $(Q)$(MAKE) -C $(SW_TEST_DIR) $(TEST).vmem
517
 
518
# Create test software disassembly
519
 
520
sw-dis: $(SW_TEST_DIR)/$(TEST).dis
521
        $(Q)cp -v $< .
522
 
523
$(SW_TEST_DIR)/$(TEST).dis:
524
        $(Q)$(MAKE) -C $(SW_TEST_DIR) $(TEST).dis
525
 
526
#
527
# Cleaning rules
528
#
529
clean: clean-sim clean-sim-test-sw clean-bootrom clean-out clean-sw
530
 
531
clean-sim:
532
        $(Q) echo; echo "\t### Cleaning simulation run directory ###"; echo;
533
        $(Q)rm -rf *.* lib_* work transcript check-test-log
534
# No VPI support for now.       $(Q) if [ -e $(VPI_SRC_C_DIR) ]; then $(MAKE) -C $(VPI_SRC_C_DIR) clean; fi
535
 
536
clean-bootrom:
537 415 julius
        $(MAKE) -C $(BOARD_BOOTROM_SW_DIR) clean
538 412 julius
 
539
clean-out:
540
        $(Q)rm -rf $(RTL_SIM_RESULTS_DIR)/*.*
541
 
542
clean-test-defines:
543
        $(Q)rm -f $(TEST_DEFINES_VLG)
544
 
545
clean-sim-test-sw:
546
        $(Q)if [ -e $(SIM_SW_IMAGE) ]; then unlink $(SIM_SW_IMAGE); fi
547
 
548
clean-sw:
549
        $(Q) echo; echo "\t### Cleaning simulation sw directories ###"; echo;
550 449 julius
        $(Q) $(MAKE) -C $(COMMON_SW_DIR)/lib distclean
551 412 julius
 
552
clean-rtl:
553
        $(Q) echo; echo "\t### Cleaning generated verilog RTL ###"; echo;
554
        for module in $(RTL_TO_CHECK); do \
555
                $(MAKE) -C $(RTL_VERILOG_DIR)/$$module clean; \
556
        done
557
 
558
# Removes any checked out RTL
559
distclean: clean
560
        $(Q) echo; echo "\t### Cleaning generated verilog RTL ###"; echo;
561
        $(Q)for module in $(RTL_TO_CHECK); do \
562
                $(MAKE) -C $(RTL_VERILOG_DIR)/$$module distclean; \
563
        done

powered by: WebSVN 2.1.0

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