Debian Codegraph @

src/cocotb_tools/makefiles/simulators/Makefile.questa-qisqrun

raw
1 # Copyright cocotb contributors
2 # Licensed under the Revised BSD License, see LICENSE for details.
3 # SPDX-License-Identifier: BSD-3-Clause
4
5 # Questa QIS/Qrun flow using the Questa Information System (QIS) for design
6 # access and qrun to build and run the simulation.
7
8 QRUN_BIN := qrun
9 VIS_BIN := vis
10
11 ifdef MODELSIM_BIN_DIR
12 QRUN_CMD := $(shell :; command -v $(MODELSIM_BIN_DIR)/$(QRUN_BIN) 2>/dev/null)
13 VIS_CMD := $(shell :; command -v $(MODELSIM_BIN_DIR)/$(VIS_BIN) 2>/dev/null)
14 else
15 # auto-detect bin dir from system path
16 QRUN_CMD := $(shell :; command -v $(QRUN_BIN) 2>/dev/null)
17 VIS_CMD := $(shell :; command -v $(VIS_BIN) 2>/dev/null)
18 endif
19
20 ifeq (,$(QRUN_CMD))
21 $(error Unable to locate command >$(QRUN_BIN)<)
22 endif
23 ifeq (,$(VIS_CMD))
24 $(error Unable to locate command >$(VIS_BIN)<)
25 endif
26
27 DESIGNFILE ?= design.bin
28 WAVEFILE ?= qwave.db
29 TOPLEVEL_LIBRARY ?= work
30 COCOTB_TOPLEVEL := "$(TOPLEVEL_LIBRARY).$(COCOTB_TOPLEVEL)"
31
32
33 ifndef VLOG_ARGS
34 VLOG_ARGS = -timescale $(COCOTB_HDL_TIMEUNIT)/$(COCOTB_HDL_TIMEPRECISION) -mfcu
35 endif
36
37 ifdef VERILOG_INCLUDE_DIRS
38 VLOG_ARGS += $(addprefix +incdir+, $(VERILOG_INCLUDE_DIRS))
39 endif
40
41 # below allows for maintaining legacy syntax as well as enables using cross-simulator vars COMPILE_ARGS/SIM_ARGS
42 VLOG_ARGS += $(COMPILE_ARGS)
43 VCOM_ARGS +=
44 VOPT_ARGS += -access=rw+/.
45 VSIM_ARGS += $(SIM_ARGS)
46
47 ifdef GUI
48 # Run in GUI mode.
49
50 # Two modes are supported:
51 # - GUI=livesim: Open the Visualizer GUI before running the simulation.
52 # GUI=1 is a backwards-compatible alias for livesim.
53 # - GUI=postsim: Open the Visualizer GUI after the simulation has finished.
54
55 ifeq ($(filter livesim postsim 1,$(GUI)),)
56 $(error A valid value (livesim, postsim, or 1) was not provided for GUI=$(GUI))
57 endif
58
59 # Map GUI=1 to GUI=livesim.
60 ifeq ($(GUI),1)
61 GUI := livesim
62 endif
63
64 VOPT_ARGS += -designfile $(DESIGNFILE)
65 VSIM_ARGS += -onfinish stop -qwavedb=+signal+memory=all+class+assertion+uvm_schematic+msg+wavefile=$(WAVEFILE)
66
67 ifeq ($(GUI),livesim)
68 QRUN_CMD += -gui -visualizer
69 VOPT_ARGS += -debug,livesim
70 endif
71
72 # For GUI=postsim Visualizer is called in the $(COCOTB_RESULTS_FILE) target.
73 else
74 # Run in batch mode (no GUI).
75 QRUN_CMD += -c
76 VSIM_ARGS += -onfinish exit
77 endif # ifdef GUI
78
79 FLI_LIB := $(shell $(PYTHON_BIN) -m cocotb_tools.config --lib-name-path fli questa)
80 VHPI_LIB := $(shell $(PYTHON_BIN) -m cocotb_tools.config --lib-name-path vhpi questa)
81 GPI_EXTRA :=
82
83 VHDL_GPI_INTERFACE ?= fli
84
85 ifeq ($(filter vhpi fli,$(VHDL_GPI_INTERFACE)),)
86 $(error A valid value (fli or vhpi) was not provided for VHDL_GPI_INTERFACE=$(VHDL_GPI_INTERFACE))
87 endif
88
89 ifeq ($(TOPLEVEL_LANG),vhdl)
90 VSIM_ARGS += -t $(COCOTB_HDL_TIMEPRECISION)
91 ifeq ($(VHDL_GPI_INTERFACE),fli)
92 CUSTOM_COMPILE_DEPS += $(FLI_LIB)
93 VSIM_ARGS += -foreign "cocotb_init $(FLI_LIB)"
94 else
95 VSIM_ARGS += -foreign "vhpi_startup_routines_bootstrap $(call to_tcl_path,$(VHPI_LIB))"
96 endif
97 ifneq ($(VERILOG_SOURCES),)
98 GPI_EXTRA := $(shell $(PYTHON_BIN) -m cocotb_tools.config --lib-name-path vpi questa):cocotbvpi_entry_point
99 endif
100
101 else ifeq ($(TOPLEVEL_LANG),verilog)
102 VSIM_ARGS += -pli $(shell $(PYTHON_BIN) -m cocotb_tools.config --lib-name-path vpi questa)
103 ifneq ($(VHDL_SOURCES),)
104 GPI_EXTRA := $(shell $(PYTHON_BIN) -m cocotb_tools.config --lib-name-path $(VHDL_GPI_INTERFACE) questa):cocotb$(VHDL_GPI_INTERFACE)_entry_point
105 endif
106
107 else
108 $(error A valid value (verilog or vhdl) was not provided for TOPLEVEL_LANG=$(TOPLEVEL_LANG))
109 endif
110
111 ifdef SCRIPT_FILE
112 VSIM_ARGS += -do $(SCRIPT_FILE)
113 endif
114
115 ifeq ($(PYTHON_ARCH),64bit)
116 QRUN_CMD += -64
117 endif
118
119 define make_lib
120 -makelib $(LIB) $(VHDL_SOURCES_$(LIB)) -end
121 endef
122
123 $(COCOTB_RESULTS_FILE):
124 # Make sure all libs in SOURCES_VHDL_* are mentioned in VHDL_LIB_ORDER and vice versa
125 $(foreach LIB, $(VHDL_LIB_ORDER), $(check_vhdl_sources))
126 $(foreach SOURCES_VAR, $(filter VHDL_SOURCES_%, $(.VARIABLES)), $(check_lib_order))
127
128 $(RM) $(COCOTB_RESULTS_FILE)
129 mkdir -p $(SIM_BUILD)
130
131 set -o pipefail; \
132 COCOTB_TEST_MODULES=$(COCOTB_TEST_MODULES) \
133 COCOTB_TESTCASE=$(COCOTB_TESTCASE) \
134 COCOTB_TEST_FILTER=$(COCOTB_TEST_FILTER) \
135 COCOTB_TOPLEVEL=$(COCOTB_TOPLEVEL) \
136 GPI_EXTRA=$(GPI_EXTRA) TOPLEVEL_LANG=$(TOPLEVEL_LANG) \
137 VHDL_GPI_INTERFACE=$(VHDL_GPI_INTERFACE) \
138 COCOTB__QUESTA_MODE=qisqrun \
139 $(SIM_CMD_PREFIX) $(QRUN_CMD) $(RUN_ARGS) -outdir $(SIM_BUILD) \
140 $(foreach LIB, $(VHDL_LIB_ORDER), $(make_lib)) \
141 -makelib $(TOPLEVEL_LIBRARY) $(VERILOG_SOURCES) $(VHDL_SOURCES) $(VLOG_ARGS) $(VCOM_ARGS) -end \
142 $(VOPT_ARGS) $(VSIM_ARGS) $(EXTRA_ARGS) $(COCOTB_PLUSARGS) -sv \
143 -top $(COCOTB_TOPLEVEL) 2>&1 | tee $(SIM_BUILD)/sim.log
144
145 ifeq ($(GUI),postsim)
146 $(VIS_CMD) -designfile $(DESIGNFILE) -wavefile $(WAVEFILE)
147 endif
148
149 $(call check_results)