ISP/Makefile

135 lines
3.9 KiB
Makefile
Raw Permalink Normal View History

2024-05-10 21:41:47 +08:00
######################################################################
#
# DESCRIPTION: Verilator Example: Small Makefile
#
# This calls the object directory makefile. That allows the objects to
# be placed in the "current directory" which simplifies the Makefile.
#
# This file ONLY is placed under the Creative Commons Public Domain, for
# any use, without warranty, 2020 by Wilson Snyder.
# SPDX-License-Identifier: CC0-1.0
#
######################################################################
# Check for sanity to avoid later confusion
ifneq ($(words $(CURDIR)),1)
$(error Unsupported: GNU Make cannot build in directories containing spaces, build elsewhere: '$(CURDIR)')
endif
######################################################################
# Set up variables
# If $VERILATOR_ROOT isn't in the environment, we assume it is part of a
# package install, and verilator is in your path. Otherwise find the
# binary relative to $VERILATOR_ROOT (such as when inside the git sources).
ifeq ($(VERILATOR_ROOT),)
VERILATOR = verilator
VERILATOR_COVERAGE = verilator_coverage
else
export VERILATOR_ROOT
VERILATOR = $(VERILATOR_ROOT)/bin/verilator
VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage
endif
VERILATOR_FLAGS =
# Generate SystemC in executable form
VERILATOR_FLAGS += -sc --exe
# Generate makefile dependencies (not shown as complicates the Makefile)
#VERILATOR_FLAGS += -MMD
# Optimize
VERILATOR_FLAGS += -x-assign fast
2024-05-10 21:41:47 +08:00
# Warn abount lint issues; may not want this on less solid designs
VERILATOR_FLAGS += -Wall
# Make waveforms
VERILATOR_FLAGS += --trace
# Check SystemVerilog assertions
VERILATOR_FLAGS += --assert
2024-05-16 21:39:15 +08:00
# Enable multithreading
VERILATOR_FLAGS += --threads 14
2024-05-10 21:41:47 +08:00
# Generate coverage analysis
# VERILATOR_FLAGS += --coverage
# Run Verilator in debug mode
#VERILATOR_FLAGS += --debug
# Add this trace to get a backtrace in gdb
#VERILATOR_FLAGS += --gdbbt
# Ignore Some Warnings
VERILATOR_FLAGS += -Wno-WIDTHEXPAND -Wno-UNUSEDSIGNAL -Wno-UNUSEDPARAM
2024-05-10 21:41:47 +08:00
# Specify top module
TOP_MODULE = isp
VERILATOR_FLAGS += --top-module $(TOP_MODULE)
2024-07-03 21:50:29 +08:00
# Input files for Verilator
# Verilog/SystemVerilog files
SOURCES := $(wildcard ./rtl/isp.sv ./rtl/Windows.sv ./rtl/Demosaic/*.sv ./rtl/Crop/*.sv ./rtl/Color/*.sv)
# C/C++ files
SOURCES += $(wildcard ./src/*.cpp ./src/transform/*.cpp)
# Exclude files
EXCLUDES := $(wildcard )
2024-07-03 21:50:29 +08:00
VERILATOR_INPUT := $(filter-out $(EXCLUDES), $(SOURCES))
2024-05-10 21:41:47 +08:00
# Check if SC exists via a verilator call (empty if not)
SYSTEMC_EXISTS := $(shell $(VERILATOR) --get-supported SYSTEMC)
######################################################################
ifneq ($(SYSTEMC_EXISTS),)
default: build run
2024-05-10 21:41:47 +08:00
else
default: nosc
endif
lint:
@echo "-- Verilator lint check ----"
$(VERILATOR) -sc --lint-only $(VERILATOR_INPUT)
2024-05-10 21:41:47 +08:00
build:
2024-05-10 21:41:47 +08:00
@echo
@echo "-- VERILATE ----------------"
$(VERILATOR) $(VERILATOR_FLAGS) $(VERILATOR_INPUT)
@echo
@echo "-- COMPILE -----------------"
# To compile, we can either
# 1. Pass --build to Verilator by editing VERILATOR_FLAGS above.
# 2. Or, run the make rules Verilator does:
# $(MAKE) -j -C obj_dir -f Vtop.mk
# 3. Or, call a submakefile where we can override the rules ourselves:
2024-05-13 11:29:03 +08:00
$(MAKE) -j -C obj_dir -f V$(TOP_MODULE).mk
2024-05-10 21:41:47 +08:00
run:
2024-05-10 21:41:47 +08:00
@echo
@echo "-- RUN ---------------------"
2024-05-18 18:56:32 +08:00
obj_dir/V$(TOP_MODULE)
2024-05-10 21:41:47 +08:00
# @echo
# @echo "-- COVERAGE ----------------"
# @rm -rf logs/annotated
# $(VERILATOR_COVERAGE) --annotate logs/annotated logs/coverage.dat
@echo "-- FINISH ------------------"
trace:
@rm -rf logs
@mkdir -p logs
obj_dir/V$(TOP_MODULE) +trace
2024-05-10 21:41:47 +08:00
@echo
@echo "-- DONE --------------------"
@echo "To see waveforms, open vlt_dump.vcd in a waveform viewer"
@echo
######################################################################
# Other targets
nosc:
@echo
@echo "%Skip: SYSTEMC_INCLUDE not in environment"
@echo "(If you have SystemC see the README, and rebuild Verilator)"
@echo
show-config:
$(VERILATOR) -V
maintainer-copy::
clean mostlyclean distclean maintainer-clean::
-rm -rf obj_dir logs *.log *.dmp *.vpd coverage.dat core