1 |
542 |
julius |
# Modelsim script generation, compile and run rules for board simulations
|
2 |
|
|
|
3 |
|
|
#
|
4 |
|
|
# Modelsim-specific settings
|
5 |
|
|
#
|
6 |
|
|
VOPT_ARGS=$(QUIET) -suppress 2241
|
7 |
|
|
|
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 |
|
|
VOPT_ARGS=+acc=rnpqv
|
13 |
|
|
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 |
|
|
VSIM_ARGS= -suppress 7 -suppress 3009 -suppress 8598 -c $(QUIET) -do "set StdArithNoWarnings 1; run -all; exit"
|
20 |
|
|
|
21 |
|
|
# VPI debugging interface set up
|
22 |
|
|
VPI_SRC_C_DIR=$(COMMON_BENCH_VERILOG_DIR)/vpi/c
|
23 |
|
|
VPI_SRC_VERILOG_DIR=vpi/verilog
|
24 |
|
|
VPI_SRCS=$(shell ls $(VPI_SRC_C_DIR)/*.[ch])
|
25 |
|
|
|
26 |
|
|
# Modelsim VPI compile variables
|
27 |
|
|
MODELTECH_VPILIB=msim_jp_vpi.sl
|
28 |
|
|
|
29 |
|
|
# Modelsim VPI settings
|
30 |
|
|
ifeq ($(VPI), 1)
|
31 |
|
|
VPI_LIBS=$(VPI_SRC_C_DIR)/$(MODELTECH_VPILIB)
|
32 |
|
|
VSIM_ARGS += -pli $(VPI_SRC_C_DIR)/$(MODELTECH_VPILIB)
|
33 |
|
|
endif
|
34 |
|
|
|
35 |
|
|
# Rule to make the VPI library for modelsim
|
36 |
|
|
$(VPI_SRC_C_DIR)/$(MODELTECH_VPILIB): $(VPI_SRCS)
|
37 |
|
|
$(MAKE) -C $(VPI_SRC_C_DIR) $(MODELTECH_VPILIB)
|
38 |
|
|
|
39 |
|
|
#
|
40 |
|
|
# Script generation rules
|
41 |
|
|
#
|
42 |
|
|
|
43 |
|
|
# Backend script generation - make these rules sensitive to source and includes
|
44 |
|
|
modelsim_backend.scr: $(BOARD_BACKEND_VERILOG_SRC)
|
45 |
|
|
$(Q)echo "+incdir+"$(TECHNOLOGY_BACKEND_VERILOG_DIR) > $@;
|
46 |
|
|
$(Q)echo "-y " $(BOARD_BACKEND_VERILOG_DIR) >> $@;
|
47 |
|
|
$(Q)for vsrc in $(BACKEND_TECHNOLOGY_VERILOG_SRC); do echo $$vsrc >> $@; done
|
48 |
|
|
$(Q)echo "-y " $(TECHNOLOGY_LIBRARY_VERILOG_DIR) >> $@;
|
49 |
|
|
$(Q)echo "+libext+.v" >> $@;
|
50 |
|
|
$(Q)echo >> $@;
|
51 |
|
|
|
52 |
|
|
# DUT compile script
|
53 |
|
|
modelsim_dut.scr: $(RTL_VERILOG_SRC) $(RTL_VERILOG_INCLUDES) $(BOOTROM_VERILOG)
|
54 |
|
|
$(Q)echo "+incdir+"$(BOARD_RTL_VERILOG_INCLUDE_DIR) > $@;
|
55 |
|
|
$(Q)echo "+incdir+"$(BOOTROM_SW_DIR) >> $@;
|
56 |
|
|
$(Q)echo "+incdir+"$(BOARD_BENCH_VERILOG_INCLUDE_DIR) >> $@;
|
57 |
|
|
$(Q)echo "+libext+.v" >> $@;
|
58 |
|
|
$(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
|
59 |
|
|
$(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
|
60 |
|
|
$(Q)echo "-y " $(BOARD_BACKEND_VERILOG_DIR) >> $@;
|
61 |
|
|
$(Q)if [ ! -z "$$GATELEVEL_MODULES" ]; \
|
62 |
|
|
then echo "-y " $(BOARD_SYN_OUT_DIR) >> $@; \
|
63 |
|
|
echo "+libext+.vm" >> $@; \
|
64 |
|
|
fi
|
65 |
|
|
ifeq ($(FPGA_VENDOR), xilinx)
|
66 |
|
|
$(Q)echo "-y "$(XILINX_PATH)"/verilog/src/unisims" >> $@;
|
67 |
|
|
$(Q)echo "-y "$(XILINX_PATH)"/verilog/src/XilinxCoreLib" >> $@;
|
68 |
|
|
endif
|
69 |
|
|
$(Q)echo >> $@
|
70 |
|
|
|
71 |
|
|
modelsim_bench.scr: $(BOARD_BENCH_VERILOG_SRC) $(COMMON_BENCH_VERILOG_SRC)
|
72 |
|
|
$(Q)echo "+incdir+"$(BOARD_BENCH_VERILOG_INCLUDE_DIR) > $@;
|
73 |
|
|
$(Q)echo "+incdir+"$(COMMON_BENCH_VERILOG_INCLUDE_DIR) >> $@;
|
74 |
|
|
$(Q)for path in $(BENCH_VERILOG_SUBDIRS); do echo "+incdir+"$$path >> $@; done
|
75 |
|
|
$(Q)for path in $(BENCH_VERILOG_SUBDIRS); do echo "-y "$$path >> $@; done
|
76 |
|
|
$(Q)echo "+incdir+"$(BOARD_RTL_VERILOG_INCLUDE_DIR) >> $@;
|
77 |
|
|
$(Q)echo "+libext+.v" >> $@;
|
78 |
|
|
$(Q)for vsrc in $(BOARD_BENCH_VERILOG_SRC); do echo $$vsrc >> $@; done
|
79 |
|
|
$(Q)for vsrc in $(COMMON_BENCH_VERILOG_SRC); do echo $$vsrc >> $@; done
|
80 |
|
|
ifeq ($(FPGA_VENDOR), xilinx)
|
81 |
|
|
$(Q)echo "+incdir+"$(XILINX_PATH)"/verilog/src" >> $@;
|
82 |
|
|
endif
|
83 |
|
|
$(Q)echo >> $@
|
84 |
|
|
|
85 |
|
|
#
|
86 |
|
|
# Build rules
|
87 |
|
|
#
|
88 |
|
|
|
89 |
|
|
# Modelsim backend library compilation rules
|
90 |
|
|
BACKEND_LIB=lib_backend
|
91 |
|
|
$(BACKEND_LIB): modelsim_backend.scr
|
92 |
|
|
$(Q)if [ ! -e $@ ]; then vlib $@; fi
|
93 |
|
|
$(Q)echo; echo "\t### Compiling backend library ###"; echo
|
94 |
|
|
$(Q)vlog -nologo $(QUIET) -work $@ -f $<
|
95 |
|
|
|
96 |
|
|
# Compile DUT into "work" library
|
97 |
|
|
work: modelsim_dut.scr
|
98 |
|
|
$(Q)if [ ! -e $@ ]; then vlib $@; fi
|
99 |
|
|
$(Q)echo; echo "\t### Compiling Verilog design library ###"; echo
|
100 |
|
|
$(Q)vlog $(QUIET) -f $< $(DUT_TOP)
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
#
|
104 |
|
|
# Run rule
|
105 |
|
|
#
|
106 |
|
|
|
107 |
|
|
.PHONY : $(MODELSIM)
|
108 |
|
|
ifeq ($(FPGA_VENDOR), actel)
|
109 |
|
|
$(MODELSIM): modelsim_bench.scr $(TEST_DEFINES_VLG) $(BACKEND_LIB) $(VPI_LIBS) work
|
110 |
|
|
$(Q)echo; echo "\t### Compiling testbench ###"; echo
|
111 |
|
|
$(Q)vlog $(QUIET) -nologo -incr $(BENCH_TOP) -f $<
|
112 |
|
|
$(Q)vopt $(QUIET) $(RTL_TESTBENCH_TOP) $(VOPT_ARGS) -L $(BACKEND_LIB) \
|
113 |
|
|
-o tb
|
114 |
|
|
$(Q)echo; echo "\t### Launching simulation ###"; echo
|
115 |
|
|
$(Q)vsim $(VSIM_ARGS) tb
|
116 |
|
|
endif
|
117 |
|
|
|
118 |
|
|
ifeq ($(FPGA_VENDOR), xilinx)
|
119 |
|
|
$(MODELSIM): modelsim_bench.scr $(TEST_DEFINES_VLG) $(VPI_LIBS) work
|
120 |
|
|
$(Q)echo; echo "\t### Compiling Xilinx support libs, user design & testbench ###"; echo
|
121 |
|
|
$(Q)vlog $(QUIET) -nologo -incr $(BENCH_TOP) -f $<
|
122 |
|
|
$(Q)vopt $(QUIET) glbl $(RTL_TESTBENCH_TOP) $(VOPT_ARGS) -o tb
|
123 |
|
|
$(Q)echo; echo "\t### Launching simulation ###"; echo
|
124 |
|
|
$(Q)vsim $(VSIM_ARGS) tb
|
125 |
|
|
endif
|
126 |
|
|
|