| 1 |
# Copyright cocotb contributors |
| 2 |
# Copyright (c) 2013 Potential Ventures Ltd |
| 3 |
# Copyright (c) 2013 SolarFlare Communications Inc |
| 4 |
# Licensed under the Revised BSD License, see LICENSE for details. |
| 5 |
# SPDX-License-Identifier: BSD-3-Clause |
| 6 |
|
| 7 |
ifneq ($(VHDL_SOURCES),) |
| 8 |
|
| 9 |
$(COCOTB_RESULTS_FILE): |
| 10 |
@echo "Skipping simulation as VHDL is not supported on simulator=$(SIM)" |
| 11 |
|
| 12 |
else |
| 13 |
|
| 14 |
CMD_BIN := vcs |
| 15 |
|
| 16 |
ifdef VCS_BIN_DIR |
| 17 |
CMD := $(shell :; command -v $(VCS_BIN_DIR)/$(CMD_BIN) 2>/dev/null) |
| 18 |
else |
| 19 |
# auto-detect bin dir from system path |
| 20 |
CMD := $(shell :; command -v $(CMD_BIN) 2>/dev/null) |
| 21 |
VCS_BIN_DIR := $(shell dirname $(CMD)) |
| 22 |
endif |
| 23 |
|
| 24 |
ifdef VERILOG_INCLUDE_DIRS |
| 25 |
COMPILE_ARGS += $(addprefix +incdir+, $(VERILOG_INCLUDE_DIRS)) |
| 26 |
endif |
| 27 |
|
| 28 |
ifeq ($(PYTHON_ARCH),64bit) |
| 29 |
COMPILE_ARGS += -full64 |
| 30 |
endif |
| 31 |
|
| 32 |
ifeq ($(GUI),1) |
| 33 |
EXTRA_ARGS += -gui -kdb |
| 34 |
endif |
| 35 |
|
| 36 |
# Avoid linker "undefined reference to" error |
| 37 |
COMPILE_ARGS += -LDFLAGS -Wl,--no-as-needed |
| 38 |
|
| 39 |
# Enables globally access for read, write, and callback capabilities. |
| 40 |
COMPILE_ARGS += +acc+3 |
| 41 |
|
| 42 |
# Enables globally debug capabilities. |
| 43 |
COMPILE_ARGS += -debug_access+all |
| 44 |
|
| 45 |
# TODO: |
| 46 |
# investigate +vpi+1 option which reduces memory requirements |
| 47 |
|
| 48 |
# Compilation phase |
| 49 |
$(SIM_BUILD)/simv: $(VERILOG_SOURCES) $(CUSTOM_COMPILE_DEPS) | $(SIM_BUILD) |
| 50 |
cd $(SIM_BUILD) && \ |
| 51 |
COCOTB_TOPLEVEL=$(call deprecate,TOPLEVEL,COCOTB_TOPLEVEL) \ |
| 52 |
$(CMD) -top $(COCOTB_TOPLEVEL) $(call deprecate,PLUSARGS,COCOTB_PLUSARGS) -sverilog \ |
| 53 |
-timescale=$(COCOTB_HDL_TIMEUNIT)/$(COCOTB_HDL_TIMEPRECISION) \ |
| 54 |
$(EXTRA_ARGS) -load $(shell $(PYTHON_BIN) -m cocotb_tools.config --lib-name-path vpi vcs) $(COMPILE_ARGS) $(VERILOG_SOURCES) |
| 55 |
|
| 56 |
# Execution phase |
| 57 |
$(COCOTB_RESULTS_FILE): $(SIM_BUILD)/simv $(CUSTOM_SIM_DEPS) |
| 58 |
$(RM) $(COCOTB_RESULTS_FILE) |
| 59 |
|
| 60 |
COCOTB_TEST_MODULES=$(call deprecate,MODULE,COCOTB_TEST_MODULES) COCOTB_TESTCASE=$(call deprecate,TESTCASE,COCOTB_TESTCASE) COCOTB_TEST_FILTER=$(COCOTB_TEST_FILTER) COCOTB_TOPLEVEL=$(call deprecate,TOPLEVEL,COCOTB_TOPLEVEL) TOPLEVEL_LANG=$(TOPLEVEL_LANG) \ |
| 61 |
$(SIM_CMD_PREFIX) $(SIM_BUILD)/simv $(SIM_ARGS) $(EXTRA_ARGS) $(call deprecate,PLUSARGS,COCOTB_PLUSARGS) $(SIM_CMD_SUFFIX) |
| 62 |
|
| 63 |
$(call check_results) |
| 64 |
|
| 65 |
endif |