2016-06-08 10:39:40 +02:00
|
|
|
#--------------------------------------------------------------------
|
2017-03-29 20:27:33 +02:00
|
|
|
# Verilator Generation
|
2016-06-08 10:39:40 +02:00
|
|
|
#--------------------------------------------------------------------
|
2016-09-19 22:23:17 +02:00
|
|
|
firrtl = $(generated_dir)/$(long_name).fir
|
2017-08-08 05:36:22 +02:00
|
|
|
verilog = \
|
|
|
|
$(generated_dir)/$(long_name).v \
|
|
|
|
$(generated_dir)/$(long_name).behav_srams.v \
|
2016-06-08 10:39:40 +02:00
|
|
|
|
2017-08-04 10:01:15 +02:00
|
|
|
.SECONDARY: $(firrtl) $(verilog)
|
2016-06-08 10:39:40 +02:00
|
|
|
|
2017-02-03 04:24:55 +01:00
|
|
|
$(generated_dir)/%.fir $(generated_dir)/%.d: $(FIRRTL_JAR) $(chisel_srcs) $(bootrom_img)
|
2016-06-08 10:39:40 +02:00
|
|
|
mkdir -p $(dir $@)
|
2017-12-13 03:46:51 +01:00
|
|
|
cd $(base_dir) && $(SBT) "runMain $(PROJECT).Generator $(generated_dir) $(PROJECT) $(MODEL) $(CFG_PROJECT) $(CONFIG)"
|
2016-06-08 10:39:40 +02:00
|
|
|
|
2017-08-08 05:36:22 +02:00
|
|
|
%.v %.conf: %.fir $(FIRRTL_JAR)
|
2016-06-08 10:39:40 +02:00
|
|
|
mkdir -p $(dir $@)
|
2017-10-11 08:42:55 +02:00
|
|
|
$(FIRRTL) $(patsubst %,-i %,$(filter %.fir,$^)) -o $*.v -X verilog --infer-rw $(MODEL) --repl-seq-mem -c:$(MODEL):-o:$*.conf -faf $*.anno -ffaaf
|
2017-08-08 05:36:22 +02:00
|
|
|
|
|
|
|
$(generated_dir)/$(long_name).behav_srams.v : $(generated_dir)/$(long_name).conf $(VLSI_MEM_GEN)
|
|
|
|
cd $(generated_dir) && \
|
|
|
|
$(VLSI_MEM_GEN) $(generated_dir)/$(long_name).conf > $@.tmp && \
|
|
|
|
mv -f $@.tmp $@
|
2016-06-08 10:39:40 +02:00
|
|
|
|
2016-06-14 20:42:19 +02:00
|
|
|
# Build and install our own Verilator, to work around versionining issues.
|
2017-05-19 07:52:28 +02:00
|
|
|
VERILATOR_VERSION=3.904
|
2016-12-04 22:10:13 +01:00
|
|
|
VERILATOR_SRCDIR ?= verilator/src/verilator-$(VERILATOR_VERSION)
|
2016-12-12 07:02:46 +01:00
|
|
|
VERILATOR_TARGET := $(abspath verilator/install/bin/verilator)
|
|
|
|
INSTALLED_VERILATOR ?= $(VERILATOR_TARGET)
|
|
|
|
$(VERILATOR_TARGET): $(VERILATOR_SRCDIR)/bin/verilator
|
2016-06-16 19:13:21 +02:00
|
|
|
$(MAKE) -C $(VERILATOR_SRCDIR) installbin installdata
|
2016-06-14 20:42:19 +02:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
$(VERILATOR_SRCDIR)/bin/verilator: $(VERILATOR_SRCDIR)/Makefile
|
2016-06-16 19:13:21 +02:00
|
|
|
$(MAKE) -C $(VERILATOR_SRCDIR) verilator_bin
|
2016-06-14 20:42:19 +02:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
$(VERILATOR_SRCDIR)/Makefile: $(VERILATOR_SRCDIR)/configure
|
|
|
|
mkdir -p $(dir $@)
|
|
|
|
cd $(dir $@) && ./configure --prefix=$(abspath verilator/install)
|
|
|
|
|
|
|
|
$(VERILATOR_SRCDIR)/configure: verilator/verilator-$(VERILATOR_VERSION).tar.gz
|
|
|
|
rm -rf $(dir $@)
|
|
|
|
mkdir -p $(dir $@)
|
|
|
|
cat $^ | tar -xz --strip-components=1 -C $(dir $@)
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
verilator/verilator-$(VERILATOR_VERSION).tar.gz:
|
|
|
|
mkdir -p $(dir $@)
|
|
|
|
wget http://www.veripool.org/ftp/verilator-$(VERILATOR_VERSION).tgz -O $@
|
|
|
|
|
2016-11-22 02:37:14 +01:00
|
|
|
verilator: $(INSTALLED_VERILATOR)
|
|
|
|
|
2016-06-14 20:42:19 +02:00
|
|
|
# Run Verilator to produce a fast binary to emulate this circuit.
|
|
|
|
VERILATOR := $(INSTALLED_VERILATOR) --cc --exe
|
2016-09-09 19:57:10 +02:00
|
|
|
VERILATOR_FLAGS := --top-module $(MODEL) \
|
|
|
|
+define+PRINTF_COND=\$$c\(\"verbose\",\"\&\&\"\,\"done_reset\"\) \
|
2017-08-08 05:36:22 +02:00
|
|
|
+define+RANDOMIZE_GARBAGE_ASSIGN \
|
2016-09-09 19:57:10 +02:00
|
|
|
+define+STOP_COND=\$$c\(\"done_reset\"\) --assert \
|
2016-10-05 07:28:26 +02:00
|
|
|
--output-split 20000 \
|
2017-06-26 08:29:29 +02:00
|
|
|
--output-split-cfuncs 20000 \
|
2016-07-08 04:34:03 +02:00
|
|
|
-Wno-STMTDLY --x-assign unique \
|
2016-08-16 07:03:03 +02:00
|
|
|
-I$(base_dir)/vsrc \
|
2018-01-15 20:21:09 +01:00
|
|
|
-O3 -CFLAGS "$(CXXFLAGS) -DVERILATOR -DTEST_HARNESS=V$(MODEL) -include $(base_dir)/csrc/verilator.h -include $(generated_dir)/$(CONFIG).plusArgs"
|
2016-06-08 10:39:40 +02:00
|
|
|
cppfiles = $(addprefix $(base_dir)/csrc/, $(addsuffix .cc, $(CXXSRCS)))
|
2016-07-09 11:37:39 +02:00
|
|
|
headers = $(wildcard $(base_dir)/csrc/*.h)
|
2016-06-08 10:39:40 +02:00
|
|
|
|
2016-09-19 22:23:17 +02:00
|
|
|
model_header = $(generated_dir)/$(long_name)/V$(MODEL).h
|
|
|
|
model_header_debug = $(generated_dir_debug)/$(long_name)/V$(MODEL).h
|
2016-06-08 10:39:40 +02:00
|
|
|
|
2017-02-03 04:24:55 +01:00
|
|
|
$(emu): $(verilog) $(cppfiles) $(headers) $(INSTALLED_VERILATOR)
|
2016-09-19 22:23:17 +02:00
|
|
|
mkdir -p $(generated_dir)/$(long_name)
|
|
|
|
$(VERILATOR) $(VERILATOR_FLAGS) -Mdir $(generated_dir)/$(long_name) \
|
2017-08-08 05:36:22 +02:00
|
|
|
-o $(abspath $(sim_dir))/$@ $(verilog) $(cppfiles) -LDFLAGS "$(LDFLAGS)" \
|
2017-02-03 04:24:55 +01:00
|
|
|
-CFLAGS "-I$(generated_dir) -include $(model_header)"
|
2016-10-05 07:28:26 +02:00
|
|
|
$(MAKE) VM_PARALLEL_BUILDS=1 -C $(generated_dir)/$(long_name) -f V$(MODEL).mk
|
2016-06-08 10:39:40 +02:00
|
|
|
|
2017-08-04 10:01:15 +02:00
|
|
|
$(emu_debug): $(verilog) $(cppfiles) $(headers) $(generated_dir)/$(long_name).d $(INSTALLED_VERILATOR)
|
2016-09-19 22:23:17 +02:00
|
|
|
mkdir -p $(generated_dir_debug)/$(long_name)
|
|
|
|
$(VERILATOR) $(VERILATOR_FLAGS) -Mdir $(generated_dir_debug)/$(long_name) --trace \
|
2017-08-08 05:36:22 +02:00
|
|
|
-o $(abspath $(sim_dir))/$@ $(verilog) $(cppfiles) -LDFLAGS "$(LDFLAGS)" \
|
2017-02-03 04:24:55 +01:00
|
|
|
-CFLAGS "-I$(generated_dir_debug) -include $(model_header_debug)"
|
2016-10-05 07:28:26 +02:00
|
|
|
$(MAKE) VM_PARALLEL_BUILDS=1 -C $(generated_dir_debug)/$(long_name) -f V$(MODEL).mk
|