############################################################################### # Copyright (c) 2013, 2018 Potential Ventures Ltd # Copyright (c) 2013 SolarFlare Communications Inc # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of Potential Ventures Ltd, # SolarFlare Communications Inc nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL POTENTIAL VENTURES LTD BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ############################################################################### # This file includes an appropriate makefile depending on the SIM variable. .PHONY: all all: sim # NOTE: keep this at 80 chars. define help_targets = Targets ======= sim Unconditionally re-run the simulator (default) regression Run simulator when dependencies have changes clean Remove build and simulation artefacts help This help text endef # NOTE: keep this at 80 chars. define help_makevars = Variables ========= The following variables are makefile variables: Makefile-based Test Scripts --------------------------- GUI Set this to 1 to enable the GUI mode in the simulator SIM Selects which simulator Makefile to use WAVES Enable wave traces dump for Riviera-PRO and Questa VERILOG_SOURCES A list of the Verilog source files to include VHDL_SOURCES A list of the VHDL source files to include VHDL_SOURCES_ VHDL source files to include in *lib* (GHDL/NVC/ModelSim/Questa/Xcelium/Incisive only) VHDL_LIB_ORDER Compilation order of VHDL libraries (needed for NVC/ModelSim/Questa/Xcelium/Incisive) SIM_CMD_PREFIX Prefix for simulation command invocations COMPILE_ARGS Arguments to pass to compile (analysis) stage of simulation SIM_ARGS Arguments to pass to execution of compiled simulation EXTRA_ARGS Arguments for compile and execute phases PLUSARGS Plusargs to pass to the simulator COCOTB_HDL_TIMEUNIT Default time unit for simulation COCOTB_HDL_TIMEPRECISION Default time precision for simulation CUSTOM_COMPILE_DEPS Add additional dependencies to the compilation target CUSTOM_SIM_DEPS Add additional dependencies to the simulation target SIM_BUILD Define a scratch directory for use by the simulator SCRIPT_FILE Simulator script to run (for e.g. wave traces) endef # NOTE: keep *two* empty lines between "define" and "endef": define newline endef # this cannot be a regular target because of the way Makefile.$(SIM) is included ifeq ($(MAKECMDGOALS),help) $(info $(help_targets)) $(info $(help_makevars)) # hack to get newlines in output, see https://stackoverflow.com/a/54539610 # NOTE: the output of the command must not include a '%' sign, otherwise the formatting will break help_envvars := $(subst %,${newline},$(shell cocotb-config --help-vars | tr \\n %)) $(info ${help_envvars}) # is there a cleaner way to exit here? $(error Stopping after printing help) endif # Default to Icarus if no simulator is defined SIM ?= icarus # Maintain backwards compatibility by supporting upper and lower case SIM variable SIM_LOWERCASE := $(shell echo $(SIM) | tr A-Z a-z) # Directory containing the cocotb Makfiles COCOTB_MAKEFILES_DIR := $(shell cocotb-config --makefiles) include $(COCOTB_MAKEFILES_DIR)/Makefile.deprecations HAVE_SIMULATOR = $(shell if [ -f $(COCOTB_MAKEFILES_DIR)/simulators/Makefile.$(SIM_LOWERCASE) ]; then echo 1; else echo 0; fi;) AVAILABLE_SIMULATORS = $(patsubst .%,%,$(suffix $(wildcard $(COCOTB_MAKEFILES_DIR)/simulators/Makefile.*))) ifeq ($(HAVE_SIMULATOR),0) $(error Couldn't find makefile for simulator: "$(SIM_LOWERCASE)"! Available simulators: $(AVAILABLE_SIMULATORS)) endif include $(COCOTB_MAKEFILES_DIR)/simulators/Makefile.$(SIM_LOWERCASE)