1 |
542 |
julius |
# Modelsim script generation, compile and run rules for board simulations
|
2 |
|
|
|
3 |
|
|
#
|
4 |
|
|
# Modelsim-specific settings
|
5 |
|
|
#
|
6 |
560 |
julius |
VOPT_ARGS+=$(QUIET) -suppress 2241
|
7 |
542 |
julius |
|
8 |
|
|
# If VCD dump is desired, tell Modelsim not to optimise
|
9 |
|
|
# away everything.
|
10 |
|
|
ifeq ($(VCD), 1)
|
11 |
|
|
#VOPT_ARGS=-voptargs="+acc=rnp"
|
12 |
560 |
julius |
VOPT_ARGS+=+acc=rnpqv
|
13 |
542 |
julius |
endif
|
14 |
|
|
|
15 |
|
|
# VSIM commands
|
16 |
|
|
# Suppressed warnings - 3009: Failed to open $readmemh() file
|
17 |
|
|
# Suppressed warnings - 3009: Module 'blah' does not have a `timescale directive in effect, but previous modules do.
|
18 |
|
|
# Suppressed warnings - 8598: Non-positive replication multiplier inside concat. Replication will be ignored
|
19 |
560 |
julius |
VSIM_ARGS+= -suppress 7 -suppress 3009 -suppress 8598 -c $(QUIET) -do "set StdArithNoWarnings 1; run -all; exit"
|
20 |
542 |
julius |
|
21 |
|
|
# VPI debugging interface set up
|
22 |
|
|
VPI_SRC_C_DIR=$(COMMON_BENCH_VERILOG_DIR)/vpi/c
|
23 |
|
|
VPI_SRCS=$(shell ls $(VPI_SRC_C_DIR)/*.[ch])
|
24 |
|
|
|
25 |
|
|
# Modelsim VPI compile variables
|
26 |
|
|
MODELTECH_VPILIB=msim_jp_vpi.sl
|
27 |
|
|
|
28 |
|
|
# Modelsim VPI settings
|
29 |
|
|
ifeq ($(VPI), 1)
|
30 |
|
|
VPI_LIBS=$(VPI_SRC_C_DIR)/$(MODELTECH_VPILIB)
|
31 |
|
|
VSIM_ARGS += -pli $(VPI_SRC_C_DIR)/$(MODELTECH_VPILIB)
|
32 |
|
|
endif
|
33 |
|
|
|
34 |
|
|
# Rule to make the VPI library for modelsim
|
35 |
|
|
$(VPI_SRC_C_DIR)/$(MODELTECH_VPILIB): $(VPI_SRCS)
|
36 |
|
|
$(MAKE) -C $(VPI_SRC_C_DIR) $(MODELTECH_VPILIB)
|
37 |
|
|
|
38 |
|
|
#
|
39 |
|
|
# Script generation rules
|
40 |
|
|
#
|
41 |
|
|
|
42 |
|
|
# Backend script generation - make these rules sensitive to source and includes
|
43 |
|
|
modelsim_backend.scr: $(BOARD_BACKEND_VERILOG_SRC)
|
44 |
|
|
$(Q)echo "+incdir+"$(TECHNOLOGY_BACKEND_VERILOG_DIR) > $@;
|
45 |
|
|
$(Q)echo "-y " $(BOARD_BACKEND_VERILOG_DIR) >> $@;
|
46 |
|
|
$(Q)for vsrc in $(BACKEND_TECHNOLOGY_VERILOG_SRC); do echo $$vsrc >> $@; done
|
47 |
|
|
$(Q)echo "-y " $(TECHNOLOGY_LIBRARY_VERILOG_DIR) >> $@;
|
48 |
|
|
$(Q)echo "+libext+.v" >> $@;
|
49 |
|
|
$(Q)echo >> $@;
|
50 |
|
|
|
51 |
|
|
# DUT compile script
|
52 |
|
|
modelsim_dut.scr: $(RTL_VERILOG_SRC) $(RTL_VERILOG_INCLUDES) $(BOOTROM_VERILOG)
|
53 |
|
|
$(Q)echo "+incdir+"$(BOARD_RTL_VERILOG_INCLUDE_DIR) > $@;
|
54 |
|
|
$(Q)echo "+incdir+"$(BOOTROM_SW_DIR) >> $@;
|
55 |
|
|
$(Q)echo "+incdir+"$(BOARD_BENCH_VERILOG_INCLUDE_DIR) >> $@;
|
56 |
|
|
$(Q)echo "+libext+.v" >> $@;
|
57 |
|
|
$(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
|
58 |
|
|
$(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
|
59 |
|
|
$(Q)echo "-y " $(BOARD_BACKEND_VERILOG_DIR) >> $@;
|
60 |
|
|
$(Q)if [ ! -z "$$GATELEVEL_MODULES" ]; \
|
61 |
|
|
then echo "-y " $(BOARD_SYN_OUT_DIR) >> $@; \
|
62 |
|
|
echo "+libext+.vm" >> $@; \
|
63 |
|
|
fi
|
64 |
|
|
ifeq ($(FPGA_VENDOR), xilinx)
|
65 |
560 |
julius |
$(Q)echo "-y "$(TECHNOLOGY_LIBRARY_VERILOG_DIR)"/src/unisims" >> $@;
|
66 |
|
|
$(Q)echo "-y "$(TECHNOLOGY_LIBRARY_VERILOG_DIR)"/src/XilinxCoreLib" >> $@;
|
67 |
542 |
julius |
endif
|
68 |
|
|
$(Q)echo >> $@
|
69 |
|
|
|
70 |
|
|
modelsim_bench.scr: $(BOARD_BENCH_VERILOG_SRC) $(COMMON_BENCH_VERILOG_SRC)
|
71 |
|
|
$(Q)echo "+incdir+"$(BOARD_BENCH_VERILOG_INCLUDE_DIR) > $@;
|
72 |
|
|
$(Q)echo "+incdir+"$(COMMON_BENCH_VERILOG_INCLUDE_DIR) >> $@;
|
73 |
|
|
$(Q)for path in $(BENCH_VERILOG_SUBDIRS); do echo "+incdir+"$$path >> $@; done
|
74 |
|
|
$(Q)for path in $(BENCH_VERILOG_SUBDIRS); do echo "-y "$$path >> $@; done
|
75 |
|
|
$(Q)echo "+incdir+"$(BOARD_RTL_VERILOG_INCLUDE_DIR) >> $@;
|
76 |
|
|
$(Q)echo "+libext+.v" >> $@;
|
77 |
|
|
$(Q)for vsrc in $(BOARD_BENCH_VERILOG_SRC); do echo $$vsrc >> $@; done
|
78 |
|
|
$(Q)for vsrc in $(COMMON_BENCH_VERILOG_SRC); do echo $$vsrc >> $@; done
|
79 |
|
|
ifeq ($(FPGA_VENDOR), xilinx)
|
80 |
560 |
julius |
$(Q)echo "+incdir+"$(TECHNOLOGY_LIBRARY_VERILOG_DIR)"/src" >> $@;
|
81 |
542 |
julius |
endif
|
82 |
|
|
$(Q)echo >> $@
|
83 |
|
|
|
84 |
|
|
#
|
85 |
|
|
# Build rules
|
86 |
|
|
#
|
87 |
|
|
|
88 |
|
|
# Modelsim backend library compilation rules
|
89 |
|
|
BACKEND_LIB=lib_backend
|
90 |
|
|
$(BACKEND_LIB): modelsim_backend.scr
|
91 |
|
|
$(Q)if [ ! -e $@ ]; then vlib $@; fi
|
92 |
|
|
$(Q)echo; echo "\t### Compiling backend library ###"; echo
|
93 |
|
|
$(Q)vlog -nologo $(QUIET) -work $@ -f $<
|
94 |
|
|
|
95 |
|
|
# Compile DUT into "work" library
|
96 |
|
|
work: modelsim_dut.scr
|
97 |
|
|
$(Q)if [ ! -e $@ ]; then vlib $@; fi
|
98 |
|
|
$(Q)echo; echo "\t### Compiling Verilog design library ###"; echo
|
99 |
558 |
julius |
$(Q)vlog $(QUIET) -f $< $(DUT_TOP_FILE)
|
100 |
|
|
$(Q)if [ "$(RTL_VHDL_SRC)" != "" ]; then \
|
101 |
|
|
echo; echo "\t### Compiling VHDL design library ###"; \
|
102 |
|
|
echo; \
|
103 |
|
|
vcom -93 $(QUIET) $(RTL_VHDL_SRC); \
|
104 |
|
|
fi
|
105 |
542 |
julius |
|
106 |
|
|
#
|
107 |
558 |
julius |
# Run rule, one for each vendor
|
108 |
542 |
julius |
#
|
109 |
|
|
|
110 |
|
|
.PHONY : $(MODELSIM)
|
111 |
|
|
ifeq ($(FPGA_VENDOR), actel)
|
112 |
|
|
$(MODELSIM): modelsim_bench.scr $(TEST_DEFINES_VLG) $(BACKEND_LIB) $(VPI_LIBS) work
|
113 |
|
|
$(Q)echo; echo "\t### Compiling testbench ###"; echo
|
114 |
558 |
julius |
$(Q)vlog $(QUIET) -nologo -incr $(BENCH_TOP_FILE) -f $<
|
115 |
|
|
$(Q)vopt $(QUIET) $(RTL_TESTBENCH_TOP_NAME) $(VOPT_ARGS) \
|
116 |
|
|
-L $(BACKEND_LIB) -o tb
|
117 |
542 |
julius |
$(Q)echo; echo "\t### Launching simulation ###"; echo
|
118 |
|
|
$(Q)vsim $(VSIM_ARGS) tb
|
119 |
|
|
endif
|
120 |
|
|
|
121 |
|
|
ifeq ($(FPGA_VENDOR), xilinx)
|
122 |
|
|
$(MODELSIM): modelsim_bench.scr $(TEST_DEFINES_VLG) $(VPI_LIBS) work
|
123 |
|
|
$(Q)echo; echo "\t### Compiling Xilinx support libs, user design & testbench ###"; echo
|
124 |
560 |
julius |
ifeq ($(DO_XILINX_COMPXLIB), 1)
|
125 |
562 |
julius |
$(Q)$(TECHNOLOGY_BACKEND_BIN_DIR)/compxlib $(XLIB_ARGS)
|
126 |
560 |
julius |
endif
|
127 |
558 |
julius |
$(Q)vlog $(QUIET) -nologo -incr $(BENCH_TOP_FILE) -f $<
|
128 |
|
|
$(Q)vopt $(QUIET) glbl $(RTL_TESTBENCH_TOP_NAME) $(VOPT_ARGS) -o tb
|
129 |
542 |
julius |
$(Q)echo; echo "\t### Launching simulation ###"; echo
|
130 |
|
|
$(Q)vsim $(VSIM_ARGS) tb
|
131 |
|
|
endif
|
132 |
|
|
|
133 |
558 |
julius |
ifeq ($(FPGA_VENDOR), altera)
|
134 |
|
|
$(MODELSIM): modelsim_bench.scr $(TEST_DEFINES_VLG) $(BACKEND_LIB) $(VPI_LIBS) work
|
135 |
|
|
$(Q)echo; echo "\t### Compiling testbench ###"; echo
|
136 |
|
|
$(Q)vlog $(QUIET) -nologo -incr $(BENCH_TOP_FILE) -f $<
|
137 |
|
|
$(Q)vopt $(QUIET) $(RTL_TESTBENCH_TOP_NAME) $(VOPT_ARGS) \
|
138 |
|
|
-L $(BACKEND_LIB) -o tb
|
139 |
|
|
$(Q)echo; echo "\t### Launching simulation ###"; echo
|
140 |
|
|
$(Q)vsim $(VSIM_ARGS) tb
|
141 |
|
|
endif
|