| 1 |
# Copyright cocotb contributors |
| 2 |
# Copyright (c) 2013, 2018 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 |
# This file includes an appropriate makefile depending on the SIM variable. |
| 8 |
|
| 9 |
.PHONY: all |
| 10 |
all: sim |
| 11 |
|
| 12 |
# NOTE: keep this at 80 chars. |
| 13 |
define help_targets = |
| 14 |
Targets |
| 15 |
======= |
| 16 |
sim Unconditionally re-run the simulator (default) |
| 17 |
regression Run simulator when dependencies have changes |
| 18 |
clean Remove build and simulation artefacts |
| 19 |
help This help text |
| 20 |
|
| 21 |
endef |
| 22 |
|
| 23 |
# NOTE: keep this at 80 chars. |
| 24 |
define help_makevars = |
| 25 |
Variables |
| 26 |
========= |
| 27 |
|
| 28 |
The following variables are makefile variables: |
| 29 |
|
| 30 |
Makefile-based Test Scripts |
| 31 |
--------------------------- |
| 32 |
GUI Set this to 1 to enable the GUI mode in the simulator |
| 33 |
SIM Selects which simulator Makefile to use |
| 34 |
WAVES Enable wave traces dump for Riviera-PRO and Questa |
| 35 |
VERILOG_SOURCES A list of the Verilog source files to include |
| 36 |
VHDL_SOURCES A list of the VHDL source files to include |
| 37 |
VHDL_SOURCES_<lib> VHDL source files to include in *lib* (GHDL/NVC/ModelSim/Questa/Xcelium/Incisive/Riviera-PRO only) |
| 38 |
VHDL_LIB_ORDER Compilation order of VHDL libraries (needed for NVC/ModelSim/Questa/Xcelium/Incisive/Riviera-PRO) |
| 39 |
SIM_CMD_PREFIX Prefix for simulation command invocations |
| 40 |
COMPILE_ARGS Arguments to pass to compile (analysis) stage of simulation |
| 41 |
SIM_ARGS Arguments to pass to execution of compiled simulation |
| 42 |
EXTRA_ARGS Arguments for compile and execute phases |
| 43 |
COCOTB_PLUSARGS Plusargs to pass to the simulator |
| 44 |
COCOTB_HDL_TIMEUNIT Default time unit for simulation |
| 45 |
COCOTB_HDL_TIMEPRECISION Default time precision for simulation |
| 46 |
CUSTOM_COMPILE_DEPS Add additional dependencies to the compilation target |
| 47 |
CUSTOM_SIM_DEPS Add additional dependencies to the simulation target |
| 48 |
SIM_BUILD Define a scratch directory for use by the simulator |
| 49 |
SCRIPT_FILE Simulator script to run (for e.g. wave traces) |
| 50 |
|
| 51 |
endef |
| 52 |
|
| 53 |
|
| 54 |
# NOTE: keep *two* empty lines between "define" and "endef": |
| 55 |
define newline |
| 56 |
|
| 57 |
|
| 58 |
endef |
| 59 |
|
| 60 |
# this ensures we use the same python as the one cocotb was installed into |
| 61 |
# attempts to use cocotb_config entry script to get that info, falls back to "python" |
| 62 |
PYTHON_BIN_RES := $(shell cocotb-config --python-bin 2>>/dev/null; echo $$?) |
| 63 |
PYTHON_BIN_RC := $(lastword $(PYTHON_BIN_RES)) |
| 64 |
PYTHON_BIN := $(strip $(subst $(PYTHON_BIN_RC)QQQQ,,$(PYTHON_BIN_RES)QQQQ)) |
| 65 |
ifneq ($(PYTHON_BIN_RC),0) |
| 66 |
PYTHON_BIN := python3 |
| 67 |
endif |
| 68 |
|
| 69 |
# this cannot be a regular target because of the way Makefile.$(SIM) is included |
| 70 |
ifeq ($(MAKECMDGOALS),help) |
| 71 |
$(info $(help_targets)) |
| 72 |
$(info $(help_makevars)) |
| 73 |
# hack to get newlines in output, see https://stackoverflow.com/a/54539610 |
| 74 |
# NOTE: the output of the command must not include a '%' sign, otherwise the formatting will break |
| 75 |
help_envvars := $(subst %,${newline},$(shell $(PYTHON_BIN) -m cocotb.config --help-vars | tr \\n %)) |
| 76 |
$(info ${help_envvars}) |
| 77 |
# is there a cleaner way to exit here? |
| 78 |
$(error Stopping after printing help) |
| 79 |
endif |
| 80 |
|
| 81 |
include $(shell $(PYTHON_BIN) -m cocotb_tools.config --makefiles)/Makefile.inc |
| 82 |
|
| 83 |
# Default to Icarus if no simulator is defined |
| 84 |
SIM ?= icarus |
| 85 |
|
| 86 |
# Maintain backwards compatibility by supporting upper and lower case SIM variable |
| 87 |
SIM_LOWERCASE := $(shell echo $(SIM) | tr A-Z a-z) |
| 88 |
|
| 89 |
HAVE_SIMULATOR = $(shell if [ -f $(COCOTB_MAKEFILES_DIR)/simulators/Makefile.$(SIM_LOWERCASE) ]; then echo 1; else echo 0; fi;) |
| 90 |
AVAILABLE_SIMULATORS = $(patsubst .%,%,$(suffix $(wildcard $(COCOTB_MAKEFILES_DIR)/simulators/Makefile.*))) |
| 91 |
|
| 92 |
ifeq ($(HAVE_SIMULATOR),0) |
| 93 |
$(error Couldn't find makefile for simulator: "$(SIM_LOWERCASE)"! Available simulators: $(AVAILABLE_SIMULATORS)) |
| 94 |
endif |
| 95 |
|
| 96 |
include $(COCOTB_MAKEFILES_DIR)/simulators/Makefile.$(SIM_LOWERCASE) |