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 425

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 412 julius
# Export BOARD_PATH for the software makefiles
58
BOARD_PATH=$(BOARD_DIR)
59
export BOARD_PATH
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
bootrom: $(BOOTROM_VERILOG)
166
 
167
$(BOOTROM_VERILOG): $(BOOTROM_SRC)
168
        $(Q)echo; echo "\t### Generating bootup ROM ###"; echo
169 415 julius
        $(Q)$(MAKE) -C $(BOARD_BOOTROM_SW_DIR) $(BOOTROM_FILE)
170 412 julius
 
171
# Suffix of file to check after each test for the string
172
TEST_OUT_FILE_SUFFIX=-general.log
173
TEST_OK_STRING=8000000d
174
 
175
# Dynamically generated verilog file defining configuration for various things
176
# Rule actually generating this is found in definesgen.inc file.
177
TEST_DEFINES_VLG=test-defines.v
178 415 julius
.PHONY: $(TEST_DEFINES_VLG)
179 412 julius
# Set V=1 when calling make to enable verbose output
180
# mainly for debugging purposes.
181
ifeq ($(V), 1)
182
Q=
183
QUIET=
184
else
185
Q ?=@
186
QUIET=-quiet
187
endif
188
 
189
# Modelsim variables
190
MGC_VSIM=vsim
191
MGC_VLOG_COMP=vlog
192
MGC_VHDL_COMP=vcom
193
MODELSIM=modelsim
194
 
195
# Default simulator is Modelsim here as we're using the ProASIC3
196
# libraries which are not compilable with Icarus.
197
# Set SIMULATOR=modelsim to use Modelsim (Default)
198
# Set SIMULATOR=ncverilog to use Cadence's NC-Verilog - TODO
199
# Set SIMULATOR=icarus to use Icarus Verilog (Not supported for this board)
200
 
201
SIMULATOR ?= $(MODELSIM)
202
 
203
#
204
# Modelsim-specific settings
205
#
206
VOPT_ARGS=$(QUIET) -suppress 2241
207
# If VCD dump is desired, tell Modelsim not to optimise
208
# away everything.
209 67 julius
ifeq ($(VCD), 1)
210 412 julius
#VOPT_ARGS=-voptargs="+acc=rnp"
211
VOPT_ARGS=+acc=rnpqv
212 67 julius
endif
213 412 julius
# VSIM commands
214
# Suppressed warnings - 3009: Failed to open $readmemh() file
215
# Suppressed warnings - 3009: Module 'blah' does not have a `timescale directive in effect, but previous modules do.
216
# Suppressed warnings - 8598: Non-positive replication multiplier inside concat. Replication will be ignored
217
VSIM_ARGS=  -suppress 7 -suppress 3009 -suppress 8598 -c $(QUIET) -do "set StdArithNoWarnings 1; run -all; exit"
218
# Modelsim VPI settings
219
ifeq ($(VPI), 1)
220
VPI_LIBS=$(VPI_SRC_C_DIR)/$(MODELTECH_VPILIB)
221
VSIM_ARGS += -pli $(VPI_SRC_C_DIR)/$(MODELTECH_VPILIB)
222
endif
223
# Rule to make the VPI library for modelsim
224
$(VPI_SRC_C_DIR)/$(MODELTECH_VPILIB): $(VPI_SRCS)
225
        $(MAKE) -C $(VPI_SRC_C_DIR) $(MODELTECH_VPILIB)
226 67 julius
 
227 412 julius
#
228
# Verilog DUT source variables
229
#
230 67 julius
 
231 412 julius
# First consider any modules we'll use gatelevel descriptions of.
232
# These will have to be set on the command line
233
GATELEVEL_MODULES ?=
234 67 julius
 
235 412 julius
# First we get a list of modules in the RTL path of the board's path.
236
# Next we check which modules not in the board's RTL path are in the root RTL
237
# path (modules which can be commonly instantiated, but over which board
238
# build-specific versions take precedence.)
239 67 julius
 
240 412 julius
# Paths under board/***/rtl/verilog we wish to exclude when getting modules
241
BOARD_VERILOG_MODULES_EXCLUDE= include $(GATELEVEL_MODULES)
242
BOARD_VERILOG_MODULES_DIR_LIST=$(shell ls $(BOARD_RTL_VERILOG_DIR))
243
# Apply exclude to list of modules
244
BOARD_RTL_VERILOG_MODULES=$(filter-out $(BOARD_VERILOG_MODULES_EXCLUDE),$(BOARD_VERILOG_MODULES_DIR_LIST))
245 67 julius
 
246 412 julius
# Rule for debugging this script
247
print-board-modules:
248
        @echo echo; echo "\t### Board verilog modules ###"; echo
249
        @echo $(BOARD_RTL_VERILOG_MODULES)
250 67 julius
 
251 412 julius
# Now get list of modules that we don't have a version of in the board path
252
COMMON_VERILOG_MODULES_EXCLUDE= include
253
COMMON_VERILOG_MODULES_EXCLUDE += $(BOARD_RTL_VERILOG_MODULES)
254
COMMON_VERILOG_MODULES_EXCLUDE += $(GATELEVEL_MODULES)
255
 
256
COMMON_RTL_VERILOG_MODULES_DIR_LIST=$(shell ls $(COMMON_RTL_VERILOG_DIR))
257
COMMON_RTL_VERILOG_MODULES=$(filter-out $(COMMON_VERILOG_MODULES_EXCLUDE), $(COMMON_RTL_VERILOG_MODULES_DIR_LIST))
258
 
259
 
260
# Add these to exclude their RTL directories from being included in scripts
261
 
262
 
263
 
264
# Rule for debugging this script
265
print-common-modules-exclude:
266
        @echo echo; echo "\t### Common verilog modules being excluded due to board versions ###"; echo
267
        @echo "$(COMMON_VERILOG_MODULES_EXCLUDE)"
268
 
269
print-common-modules:
270
        @echo echo; echo "\t###  Verilog modules from common RTL dir ###"; echo
271
        @echo $(COMMON_RTL_VERILOG_MODULES)
272
 
273
# List of verilog source files (only .v files!)
274
# Board RTL modules first
275
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)
276
# Common RTL module source
277
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)
278
 
279
# List of verilog includes from board RTL path - only for rule sensitivity
280
RTL_VERILOG_INCLUDES=$(shell ls $(BOARD_RTL_VERILOG_INCLUDE_DIR)/*.*)
281
 
282
print-verilog-src:
283
        @echo echo; echo "\t### Verilog source ###"; echo
284
        @echo $(RTL_VERILOG_SRC)
285
 
286
# Rules to make RTL we might need
287
# Expects modules, if they need making, to have their top verilog file to
288
# correspond to their module name, and the directory should have a make file
289
# and rule which works for this command.
290
# Add name of module to this list, currently only does verilog ones.
291
# Rule 'rtl' is called just before generating DUT modelsim compilation script
292
RTL_TO_CHECK=
293
rtl:
294
        $(Q)for module in $(RTL_TO_CHECK); do \
295
                $(MAKE) -C $(RTL_VERILOG_DIR)/$$module $$module.v; \
296
        done
297
 
298
#
299
# VHDL DUT source variables
300
#
301
# VHDL modules
302
#RTL_VHDL_MODULES=$(shell ls $(RTL_VHDL_DIR))
303
# VHDL sources
304
#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)
305
#print-vhdl-src:
306
#       @echo echo; echo "\t### VHDL modules and source ###"; echo
307
#       @echo "modules: "; echo $(RTL_VHDL_MODULES); echo
308
#       @echo "source: "$(RTL_VHDL_SRC)
309
 
310
#
311
# Testbench source
312
#
313
BOARD_BENCH_VERILOG_SRC=$(shell ls $(BOARD_BENCH_VERILOG_DIR)/*.v | grep -v $(DESIGN_NAME)_testbench )
314
BOARD_BENCH_VERILOG_SRC_FILES=$(notdir $(BOARD_BENCH_VERILOG_SRC))
315
 
316
# Now only take the source from the common path that we don't already have in
317
# our board's
318
COMMON_BENCH_VERILOG_DIR_LS=$(shell ls $(COMMON_BENCH_VERILOG_DIR)/*.v)
319
COMMON_BENCH_VERILOG_SRC_FILES=$(notdir $(COMMON_BENCH_VERILOG_DIR_LS))
320
COMMON_BENCH_VERILOG_SRC_FILTERED=$(filter-out $(BOARD_BENCH_VERILOG_SRC_FILES) $(DESIGN_NAME)_testbench.v,$(COMMON_BENCH_VERILOG_SRC_FILES))
321
COMMON_BENCH_VERILOG_SRC=$(addprefix $(COMMON_BENCH_VERILOG_DIR)/, $(COMMON_BENCH_VERILOG_SRC_FILTERED))
322
 
323
print-board-bench-src:
324
        $(Q)echo "\tBoard bench verilog source"; \
325
        echo $(BOARD_BENCH_VERILOG_SRC)
326
 
327
print-common-bench-src:
328
        $(Q)echo "\Common bench verilog source"; \
329
        echo $(COMMON_BENCH_VERILOG_SRC)
330
 
331
# Testbench source subdirectory detection (exclude include, we always use
332
# board bench include directory!)
333
BOARD_BENCH_VERILOG_SUBDIRS=$(shell cd $(BOARD_BENCH_VERILOG_DIR) && ls -d */ | grep -v include)
334
COMMON_BENCH_VERILOG_SUBDIRS=$(shell cd $(COMMON_BENCH_VERILOG_DIR) && ls -d */ | grep -v include)
335
 
336
# Get rid of ones we have a copy of locally
337
COMMON_BENCH_VERILOG_SUBDIRS_EXCLUDE_BOARDS=$(filter-out $(BOARD_BENCH_VERILOG_SUBDIRS),$(COMMON_BENCH_VERILOG_SUBDIRS))
338
 
339
# Construct list of paths we will want to include
340
BENCH_VERILOG_SUBDIRS=$(addprefix $(COMMON_BENCH_VERILOG_DIR)/,$(COMMON_BENCH_VERILOG_SUBDIRS_EXCLUDE_BOARDS))
341
BENCH_VERILOG_SUBDIRS += $(addprefix $(BOARD_BENCH_VERILOG_DIR)/,$(BOARD_BENCH_VERILOG_SUBDIRS))
342
 
343
# Finally, add include path from local bench path
344
BENCH_VERILOG_SUBDIRS += $(BOARD_BENCH_VERILOG_DIR)/include
345
 
346
print-board-bench-subdirs:
347
        $(Q)echo "\tBoard bench subdirectories"; \
348
        echo $(BOARD_BENCH_VERILOG_SUBDIRS)
349
 
350
print-common-bench-subdirs:
351
        $(Q)echo "\tCommon bench subdirectories"; \
352
        echo $(COMMON_BENCH_VERILOG_SUBDIRS)
353
 
354
print-bench-subdirs:
355
        $(Q)echo "\tBench subdirectories"; \
356
        echo $(BENCH_VERILOG_SUBDIRS)
357
 
358
 
359
# Backend technology library files
360
# We don't do this for the board backend stuff - that should all be properly
361
# named, and so we only need to pass the "-y" option for that path.
362
BOARD_BACKEND_VERILOG_SRC=$(shell ls $(BOARD_BACKEND_VERILOG_DIR)/*.v )
363
 
364
#
365
# Compile script generation rules:
366
#
367
 
368
# Modelsim library compilation rules
369
#       $(Q)echo "-y " $(BOARD_BACKEND_VERILOG_DIR) >> $@;
370
# DUT compile script
371
modelsim_dut.scr: rtl $(RTL_VERILOG_SRC) $(RTL_VERILOG_INCLUDES) $(BOOTROM_VERILOG)
372
        $(Q)echo "+incdir+"$(BOARD_RTL_VERILOG_INCLUDE_DIR) > $@;
373 415 julius
        $(Q)echo "+incdir+"$(BOARD_BOOTROM_SW_DIR) >> $@;
374 412 julius
        $(Q)echo "+incdir+"$(BOARD_BENCH_VERILOG_INCLUDE_DIR) >> $@;
375
        $(Q)echo "+libext+.v" >> $@;
376
        $(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
377
        $(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
378
        $(Q)echo "-y "$(TECHNOLOGY_BACKEND_VERILOG_DIR)"/src/unisims" >> $@;
379
        $(Q)echo "-y "$(TECHNOLOGY_BACKEND_VERILOG_DIR)"/src/XilinxCoreLib" >> $@;
380
        $(Q)if [ ! -z "$$GATELEVEL_MODULES" ]; \
381
                then echo "-y " $(BOARD_SYN_OUT_DIR) >> $@; \
382
                echo "+libext+.vm" >> $@; \
383 67 julius
        fi
384 412 julius
        $(Q)echo >> $@
385 67 julius
 
386 412 julius
modelsim_bench.scr: $(BOARD_BENCH_VERILOG_SRC) $(COMMON_BENCH_VERILOG_SRC)
387
        $(Q)echo "+incdir+"$(BOARD_BENCH_VERILOG_INCLUDE_DIR) > $@;
388
        $(Q)echo "+incdir+"$(COMMON_BENCH_VERILOG_INCLUDE_DIR) >> $@;
389
        $(Q)for path in $(BENCH_VERILOG_SUBDIRS); do echo "+incdir+"$$path >> $@; done
390
        $(Q)for path in $(BENCH_VERILOG_SUBDIRS); do echo "-y "$$path >> $@; done
391
        $(Q)echo "+incdir+"$(BOARD_RTL_VERILOG_INCLUDE_DIR) >> $@;
392
        $(Q)echo "+libext+.v" >> $@;
393
        $(Q)echo "+incdir+"$(TECHNOLOGY_BACKEND_VERILOG_DIR)"/src" >> $@;
394
        $(Q)for vsrc in $(BOARD_BENCH_VERILOG_SRC); do echo $$vsrc >> $@; done
395
        $(Q)for vsrc in $(COMMON_BENCH_VERILOG_SRC); do echo $$vsrc >> $@; done
396
        $(Q)echo >> $@
397 67 julius
 
398 412 julius
# Modelsim library compilation rules
399 67 julius
 
400 412 julius
# Compile DUT into "work" library
401
work: modelsim_dut.scr
402
        $(Q)if [ ! -e $@ ]; then vlib $@; fi
403
        $(Q)echo; echo "\t### Compiling Verilog design library ###"; echo
404
        $(Q)vlog $(QUIET) -f $< $(DUT_TOP)
405
#       $(Q)echo; echo "\t### Compiling VHDL design library ###"; echo
406
#       $(Q)vcom -93 $(QUIET) $(RTL_VHDL_SRC)
407 67 julius
 
408 412 julius
# Single compile rule
409
.PHONY : $(MODELSIM)
410
$(MODELSIM): modelsim_bench.scr $(TEST_DEFINES_VLG) $(VPI_LIBS) work
411
        $(Q)echo; echo "\t### Compiling Xilinx support libs, user design & testbench ###"; echo
412
        $(Q)vlog $(QUIET) -nologo -incr $(BENCH_TOP) -f $<
413
        $(Q)vopt $(QUIET) glbl $(RTL_TESTBENCH_TOP) $(VOPT_ARGS) -o tb
414
        $(Q)echo; echo "\t### Launching simulation ###"; echo
415
        $(Q)vsim $(VSIM_ARGS) tb
416 67 julius
 
417
 
418 412 julius
.PHONY: rtl-test
419
rtl-test: clean-sim-test-sw sw clean-test-defines $(TEST_DEFINES_VLG) \
420
        $(SIMULATOR)
421 67 julius
 
422 412 julius
# Run an RTL test followed by checking of generated results
423
rtl-test-with-check: rtl-test
424
        $(Q)$(MAKE) check-test-log; \
425
        if [ $$? -ne 0 ]; then \
426
                echo; echo "\t### "$(TEST)" test FAIL ###"; echo; \
427
        else \
428
                echo; echo "\t### "$(TEST)" test OK ###"; echo; \
429
        fi
430
 
431
# Do check, don't print anything out
432
rtl-test-with-check-no-print: rtl-test check-test-log
433
 
434
# Main RTL test loop
435
rtl-tests:
436
        $(Q)for test in $(TESTS); do \
437
                export TEST=$$test; \
438
                $(MAKE) rtl-test-with-check-no-print; \
439
                if [ $$? -ne 0 ]; then break; fi; \
440
                echo; echo "\t### $$test test OK ###"; echo; \
441
        done
442
 
443
 
444
.PHONY: check-test-log
445
check-test-log:
446
        $(Q)echo "#!/bin/bash" > $@
447
        $(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; }" >> $@
448
        $(Q)echo "check-test-log" >> $@
449
        $(Q)chmod +x $@
450
        $(Q) echo; echo "\t### Checking simulation results for "$(TEST)" test ###"; echo;
451
        $(Q)./$@
452
 
453
# Include the test-defines.v generation rule
454
include $(PROJECT_ROOT)/sim/bin/definesgen.inc
455
 
456
#
457
# Software make rules (called recursively)
458
#
459
 
460
# Path for the current test
461
# First check for a local copy of the test. If it doesn't exist then we
462
# default to the software tests in the root directory
463
TEST_MODULE=$(shell echo $(TEST) | cut -d "-" -f 1)
464
BOARD_SW_TEST_DIR=$(BOARD_SW_DIR)/tests/$(TEST_MODULE)/sim
465
COMMON_SW_TEST_DIR=$(COMMON_SW_DIR)/tests/$(TEST_MODULE)/sim
466
# Do this by testing for the file's existence
467
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)
468
 
469
print-test-sw-dir:
470
        @echo; echo "\tTest software is in the following path"; echo;
471
        @echo $(BOARD_SW_DIR); echo;
472
        @echo $(BOARD_SW_TEST_DIR); echo;
473
        @echo $(SW_TEST_DIR); echo;
474
 
475
print-sw-tests:
476
        $(Q) $(MAKE) -C $(COMMON_SW_DIR)/lib print-sw-tests
477
        $(Q) $(MAKE) -C $(COMMON_SW_DIR)/lib print-sw-tests-subdirs
478
 
479
 
480
# Name of the image the RAM model will attempt to load via Verilog $readmemh
481
# system function.
482
 
483
# Set PRELOAD_RAM=1 to preload the system memory - be sure the bootROM program
484
# chosen in board.h is the one booting from the reset vector.
485
ifeq ($(PRELOAD_RAM), 1)
486
SIM_SW_IMAGE ?=sram.vmem
487
else
488
SIM_SW_IMAGE ?=flash.in
489
endif
490
 
491 415 julius
# Amount to pad the image we'll load into the SPI flash
492
HEX_IMAGE_PADDING ?=0x1c0000
493
 
494 412 julius
.PHONY : sw
495
sw: $(SIM_SW_IMAGE)
496
 
497
 
498
flash.in: $(SW_TEST_DIR)/$(TEST).flashin
499
        $(Q)if [ -L $@ ]; then unlink $@; fi
500
        $(Q)ln -s $< $@
501
 
502
sram.vmem: $(SW_TEST_DIR)/$(TEST).vmem
503
        $(Q)if [ -L $@ ]; then unlink $@; fi
504
        $(Q)ln -s $< $@
505
 
506
.PHONY: $(SW_TEST_DIR)/$(TEST).flashin
507
$(SW_TEST_DIR)/$(TEST).flashin:
508
        $(Q) echo; echo "\t### Compiling software ###"; echo;
509 415 julius
        $(Q)$(MAKE) -C $(SW_TEST_DIR) $(TEST).flashin \
510
                HEX_IMAGE_PADDING=$(HEX_IMAGE_PADDING)
511 412 julius
 
512
.PHONY: $(SW_TEST_DIR)/$(TEST).vmem
513
$(SW_TEST_DIR)/$(TEST).vmem:
514
        $(Q) echo; echo "\t### Compiling software ###"; echo;
515
        $(Q)$(MAKE) -C $(SW_TEST_DIR) $(TEST).vmem
516
 
517
# Create test software disassembly
518
 
519
sw-dis: $(SW_TEST_DIR)/$(TEST).dis
520
        $(Q)cp -v $< .
521
 
522
$(SW_TEST_DIR)/$(TEST).dis:
523
        $(Q)$(MAKE) -C $(SW_TEST_DIR) $(TEST).dis
524
 
525
#
526
# Cleaning rules
527
#
528
clean: clean-sim clean-sim-test-sw clean-bootrom clean-out clean-sw
529
 
530
clean-sim:
531
        $(Q) echo; echo "\t### Cleaning simulation run directory ###"; echo;
532
        $(Q)rm -rf *.* lib_* work transcript check-test-log
533
# No VPI support for now.       $(Q) if [ -e $(VPI_SRC_C_DIR) ]; then $(MAKE) -C $(VPI_SRC_C_DIR) clean; fi
534
 
535
clean-bootrom:
536 415 julius
        $(MAKE) -C $(BOARD_BOOTROM_SW_DIR) clean
537 412 julius
 
538
clean-out:
539
        $(Q)rm -rf $(RTL_SIM_RESULTS_DIR)/*.*
540
 
541
clean-test-defines:
542
        $(Q)rm -f $(TEST_DEFINES_VLG)
543
 
544
clean-sim-test-sw:
545
        $(Q)if [ -e $(SIM_SW_IMAGE) ]; then unlink $(SIM_SW_IMAGE); fi
546
 
547
clean-sw:
548
        $(Q) echo; echo "\t### Cleaning simulation sw directories ###"; echo;
549
        $(Q) $(MAKE) -C $(COMMON_SW_DIR)/lib clean-all
550
 
551
clean-rtl:
552
        $(Q) echo; echo "\t### Cleaning generated verilog RTL ###"; echo;
553
        for module in $(RTL_TO_CHECK); do \
554
                $(MAKE) -C $(RTL_VERILOG_DIR)/$$module clean; \
555
        done
556
 
557
# Removes any checked out RTL
558
distclean: clean
559
        $(Q) echo; echo "\t### Cleaning generated verilog RTL ###"; echo;
560
        $(Q)for module in $(RTL_TO_CHECK); do \
561
                $(MAKE) -C $(RTL_VERILOG_DIR)/$$module distclean; \
562
        done

powered by: WebSVN 2.1.0

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