hardware: Add additional comments to Makefile and clean up
[ci skip]
@@ -21,24 +21,28 @@ VERILATOR_OPTIONS=--unroll-count 512 --assert \
-Wall -Wno-unused -Wno-pinconnectempty -Wno-undriven -Wno-declfilename \
-Icore -y testbench -y fpga/common -DSIMULATION=1 -Mdir obj
+# If you set DUMP_WAVEFORM in the environment when running make, the resulting
+# simulator executable will generating a .vcd file that can be read by a
+# waveform viewer like gtkwave.
ifeq (${DUMP_WAVEFORM},1)
VERILATOR_OPTIONS+=--trace --trace-structs
endif
all: $(BINDIR) $(TARGET)
-$(TARGET): $(BINDIR) FORCE test_verilator_version
+$(TARGET): $(BINDIR) test_verilator_version
verilator $(VERILATOR_OPTIONS) --cc testbench/verilator_tb.sv --exe testbench/verilator_main.cpp
make CXXFLAGS=-Wno-parentheses-equality OPT_FAST="-Os" -C obj/ -f Vverilator_tb.mk Vverilator_tb
cp obj/Vverilator_tb $(TARGET)
+# Verilator usually doesn't compile the FPGA project files, but this
+# will run it in lint-only mode to catch syntax errors or mismatches
+# introduced by changes in the core.
fpgalint:
verilator $(VERILATOR_OPTIONS) --lint-only fpga/de2-115/de2_115_top.sv
-core/srams.inc: $(TARGET)
- $(TARGET) +dumpmems | ../tools/misc/extract_mems.py > core/srams.inc
-
-# Expands AUTOWIRE/AUTOINST/etc. Requires emacs and verilog-mode module installed.
+# Expands AUTOWIRE/AUTOINST/etc. Requires emacs and verilog-mode module
+# installed.
autos:
emacs --eval '(setq-default indent-tabs-mode nil)' \
--eval '(setq-default verilog-typedef-regexp "_t$$")' \
@@ -48,6 +52,7 @@ autos:
--batch core/*.sv testbench/*.sv fpga/common/*.sv fpga/de2-115/*.sv \
-f verilog-batch-auto -f save-buffer
+# Bail if verilator is too old.
test_verilator_version:
@if [ $$(verilator --version | cut -f2 -d ' ' | cut -f2 -d .) -lt $(MIN_VERILATOR_VERSION) ]; \
then \
@@ -55,11 +60,14 @@ test_verilator_version:
false; \
fi
+# This is not used by the verilator simulator or FPGA projects, but is
+# theoretically useful for environments that use a separate memory compiler.
+core/srams.inc: $(TARGET)
+ $(TARGET) +dumpmems | ../tools/misc/extract_mems.py > core/srams.inc
+
$(BINDIR):
mkdir -p $(BINDIR)
-clean: FORCE
+clean:
rm -rf obj/*
rm -f $(TARGET)
-
-FORCE:
