* [ariane/make] integrate ariane | have verilator be installed on path not in makefile * [misc] warn on verilator not found | search for v files | cleanup build.sbt + .gitignore * [firesim] bump * [ci] add midas ariane tests * [docker/ci] use new docker-image with verilator | re-elab on v changes for ariane | address comments * [ci] remove references to local verilator install * [verilator] update flags * [verilator] minimal set of flags for ariane * [ariane] bump ariane to master * [ci] revert to 4.016 verilator * [ci] install verilator to ci server | misc compile fixes * [ci/make] add longer ci timeout | update when assert is added in verilator sim * [firesim] bump for misc. updates * [make/ci] cleanup makefile and remove firesim tests of it * [docs/firesim] bump and clean docs * [firesim] bump * [ci] use remote verilator for midas tests * [misc] cleanup built.sbt more * [firesim] bump * [misc] bump build.sbt patch for tutorials * [firesim/ci] cleanup and bump firesim
143 lines
5.8 KiB
Makefile
143 lines
5.8 KiB
Makefile
#########################################################################################
|
|
# verilator makefile
|
|
#########################################################################################
|
|
ifeq ($(shell which verilator),)
|
|
$(error Did not find Verilator in PATH. Make sure all requirements are installed)
|
|
endif
|
|
|
|
#########################################################################################
|
|
# general path variables
|
|
#########################################################################################
|
|
base_dir=$(abspath ../..)
|
|
sim_dir=$(abspath .)
|
|
|
|
#########################################################################################
|
|
# include shared variables
|
|
#########################################################################################
|
|
include $(base_dir)/variables.mk
|
|
|
|
#########################################################################################
|
|
# name of simulator (used to generate *.f arguments file)
|
|
#########################################################################################
|
|
sim_name = verilator
|
|
|
|
#########################################################################################
|
|
# vcs simulator types and rules
|
|
#########################################################################################
|
|
sim_prefix = simulator
|
|
sim = $(sim_dir)/$(sim_prefix)-$(MODEL_PACKAGE)-$(CONFIG)
|
|
sim_debug = $(sim_dir)/$(sim_prefix)-$(MODEL_PACKAGE)-$(CONFIG)-debug
|
|
|
|
PERMISSIVE_ON=
|
|
PERMISSIVE_OFF=
|
|
|
|
WAVEFORM_FLAG=-v$(sim_out_name).vcd
|
|
|
|
.PHONY: default debug
|
|
default: $(sim)
|
|
debug: $(sim_debug)
|
|
|
|
#########################################################################################
|
|
# import other necessary rules and variables
|
|
#########################################################################################
|
|
include $(base_dir)/common.mk
|
|
|
|
#########################################################################################
|
|
# verilator binary and flags
|
|
#########################################################################################
|
|
VERILATOR := verilator --cc --exe
|
|
|
|
CXXFLAGS := $(CXXFLAGS) -O1 -std=c++11 -I$(RISCV)/include -I$(dramsim_dir) -D__STDC_FORMAT_MACROS
|
|
LDFLAGS := $(LDFLAGS) -L$(RISCV)/lib -Wl,-rpath,$(RISCV)/lib -L$(dramsim_dir) -Wl,-rpath,$(dramsim_dir) -L$(sim_dir) -lfesvr -lpthread -ldramsim
|
|
|
|
VERILATOR_CC_OPTS = \
|
|
-O3 \
|
|
-CFLAGS "$(CXXFLAGS) -DTEST_HARNESS=V$(VLOG_MODEL) -DVERILATOR" \
|
|
-CFLAGS "-I$(build_dir) -include $(build_dir)/$(long_name).plusArgs -include $(build_dir)/verilator.h" \
|
|
-LDFLAGS "$(LDFLAGS)"
|
|
|
|
# default flags added for ariane
|
|
ARIANE_VERILATOR_FLAGS = \
|
|
--unroll-count 256 \
|
|
-Werror-PINMISSING \
|
|
-Werror-IMPLICIT \
|
|
-Wno-fatal \
|
|
-Wno-PINCONNECTEMPTY \
|
|
-Wno-ASSIGNDLY \
|
|
-Wno-DECLFILENAME \
|
|
-Wno-UNUSED \
|
|
-Wno-UNOPTFLAT \
|
|
-Wno-BLKANDNBLK \
|
|
-Wno-style \
|
|
-Wall
|
|
|
|
# normal flags used for chipyard builds (that are incompatible with ariane)
|
|
CHIPYARD_VERILATOR_FLAGS = \
|
|
--assert
|
|
|
|
VERILATOR_NONCC_OPTS = \
|
|
--top-module $(VLOG_MODEL) \
|
|
$(shell if ! grep -iq "module.*ariane" $(build_dir)/*.*v; then echo "$(CHIPYARD_VERILATOR_FLAGS)"; else echo "$(ARIANE_VERILATOR_FLAGS)"; fi) \
|
|
--output-split 10000 \
|
|
--output-split-cfuncs 100 \
|
|
-f $(sim_common_files) \
|
|
$(sim_vsrcs)
|
|
|
|
VERILATOR_DEFINES = \
|
|
+define+PRINTF_COND=\$$c\(\"verbose\",\"\&\&\"\,\"done_reset\"\) \
|
|
+define+STOP_COND=\$$c\(\"done_reset\"\)
|
|
|
|
VERILATOR_OPTS = $(VERILATOR_CC_OPTS) $(VERILATOR_NONCC_OPTS) $(VERILATOR_DEFINES)
|
|
|
|
#########################################################################################
|
|
# verilator build paths and file names
|
|
#########################################################################################
|
|
model_dir = $(build_dir)/$(long_name)
|
|
model_dir_debug = $(build_dir)/$(long_name).debug
|
|
|
|
model_header = $(model_dir)/V$(VLOG_MODEL).h
|
|
model_header_debug = $(model_dir_debug)/V$(VLOG_MODEL).h
|
|
|
|
model_mk = $(model_dir)/V$(VLOG_MODEL).mk
|
|
model_mk_debug = $(model_dir_debug)/V$(VLOG_MODEL).mk
|
|
|
|
#########################################################################################
|
|
# build makefile fragment that builds the verilator sim rules
|
|
#########################################################################################
|
|
$(model_mk): $(sim_vsrcs) $(sim_common_files)
|
|
rm -rf $(build_dir)/$(long_name)
|
|
mkdir -p $(build_dir)/$(long_name)
|
|
$(VERILATOR) $(VERILATOR_OPTS) -o $(sim) -Mdir $(model_dir) -CFLAGS "-include $(model_header)"
|
|
touch $@
|
|
|
|
$(model_mk_debug): $(sim_vsrcs) $(sim_common_files)
|
|
rm -rf $(build_dir)/$(long_name)
|
|
mkdir -p $(build_dir)/$(long_name).debug
|
|
$(VERILATOR) $(VERILATOR_OPTS) -o $(sim_debug) --trace -Mdir $(model_dir_debug) -CFLAGS "-include $(model_header_debug)"
|
|
touch $@
|
|
|
|
#########################################################################################
|
|
# invoke make to make verilator sim rules
|
|
#########################################################################################
|
|
$(sim): $(model_mk) $(dramsim_lib)
|
|
$(MAKE) VM_PARALLEL_BUILDS=1 -C $(model_dir) -f V$(VLOG_MODEL).mk
|
|
|
|
$(sim_debug): $(model_mk_debug) $(dramsim_lib)
|
|
$(MAKE) VM_PARALLEL_BUILDS=1 -C $(model_dir_debug) -f V$(VLOG_MODEL).mk
|
|
|
|
#########################################################################################
|
|
# create a verilator vpd rule
|
|
#########################################################################################
|
|
.PRECIOUS: $(output_dir)/%.vpd %.vcd
|
|
$(output_dir)/%.vpd: $(output_dir)/% $(sim_debug)
|
|
rm -f $@.vcd && mkfifo $@.vcd
|
|
vcd2vpd $@.vcd $@ > /dev/null &
|
|
(set -o pipefail && $(sim_debug) $(PERMISSIVE_ON) +max-cycles=$(timeout_cycles) $(SIM_FLAGS) $(VERBOSE_FLAGS) -v$@.vcd $(PERMISSIVE_OFF) $< </dev/null 2> >(spike-dasm > $<.out) | tee $<.log)
|
|
|
|
#########################################################################################
|
|
# general cleanup rule
|
|
#########################################################################################
|
|
.PHONY: clean
|
|
clean:
|
|
rm -rf $(gen_dir) $(sim_prefix)-*
|