OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

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

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

powered by: WebSVN 2.1.0

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