[make] split up specific make vars/targets into frags (#499)
* [make] split up specific make vars/targets into frags * [make] move dramsim and max-cycles into SIM_FLAGS * [misc] move ariane configs to configs/ folder
This commit is contained in:
45
common.mk
45
common.mk
@@ -3,6 +3,18 @@
|
|||||||
#########################################################################################
|
#########################################################################################
|
||||||
SHELL=/bin/bash
|
SHELL=/bin/bash
|
||||||
|
|
||||||
|
#########################################################################################
|
||||||
|
# extra make variables/rules from subprojects
|
||||||
|
#
|
||||||
|
# EXTRA_GENERATOR_REQS - requirements needed for the main generator
|
||||||
|
# EXTRA_SIM_FLAGS - runtime simulation flags
|
||||||
|
# EXTRA_SIM_CC_FLAGS - cc flags for simulators
|
||||||
|
# EXTRA_SIM_SOURCES - simulation sources needed for simulator
|
||||||
|
# EXTRA_SIM_REQS - requirements to build the simulator
|
||||||
|
#########################################################################################
|
||||||
|
include $(base_dir)/generators/ariane/ariane.mk
|
||||||
|
include $(base_dir)/generators/tracegen/tracegen.mk
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
# variables to get all *.scala files
|
# variables to get all *.scala files
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
@@ -11,7 +23,6 @@ lookup_srcs = $(shell find -L $(1)/ -name target -prune -o -iname "*.$(2)" -prin
|
|||||||
SOURCE_DIRS = $(addprefix $(base_dir)/,generators sims/firesim/sim)
|
SOURCE_DIRS = $(addprefix $(base_dir)/,generators sims/firesim/sim)
|
||||||
SCALA_SOURCES = $(call lookup_srcs,$(SOURCE_DIRS),scala)
|
SCALA_SOURCES = $(call lookup_srcs,$(SOURCE_DIRS),scala)
|
||||||
VLOG_SOURCES = $(call lookup_srcs,$(SOURCE_DIRS),sv) $(call lookup_srcs,$(SOURCE_DIRS),v)
|
VLOG_SOURCES = $(call lookup_srcs,$(SOURCE_DIRS),sv) $(call lookup_srcs,$(SOURCE_DIRS),v)
|
||||||
ARIANE_VLOG_SOURCES = $(call lookup_srcs,$(base_dir)/generators/ariane,sv) $(call lookup_srcs,$(base_dir)/generators/ariane,v)
|
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
# rocket and testchipip classes
|
# rocket and testchipip classes
|
||||||
@@ -45,7 +56,7 @@ $(FIRRTL_FILE) $(ANNO_FILE): generator_temp
|
|||||||
@echo "" > /dev/null
|
@echo "" > /dev/null
|
||||||
|
|
||||||
# AG: must re-elaborate if ariane sources have changed... otherwise just run firrtl compile
|
# AG: must re-elaborate if ariane sources have changed... otherwise just run firrtl compile
|
||||||
generator_temp: $(SCALA_SOURCES) $(ARIANE_VLOG_SOURCES) $(sim_files)
|
generator_temp: $(SCALA_SOURCES) $(sim_files) $(EXTRA_GENERATOR_REQS)
|
||||||
mkdir -p $(build_dir)
|
mkdir -p $(build_dir)
|
||||||
cd $(base_dir) && $(SBT) "project $(SBT_PROJECT)" "runMain $(GENERATOR_PACKAGE).Generator $(build_dir) $(MODEL_PACKAGE) $(MODEL) $(CONFIG_PACKAGE) $(CONFIG)"
|
cd $(base_dir) && $(SBT) "project $(SBT_PROJECT)" "runMain $(GENERATOR_PACKAGE).Generator $(build_dir) $(MODEL_PACKAGE) $(MODEL) $(CONFIG_PACKAGE) $(CONFIG)"
|
||||||
|
|
||||||
@@ -105,19 +116,19 @@ verilog: $(sim_vsrcs)
|
|||||||
#########################################################################################
|
#########################################################################################
|
||||||
.PHONY: run-binary run-binary-fast run-binary-debug run-fast
|
.PHONY: run-binary run-binary-fast run-binary-debug run-fast
|
||||||
run-binary: $(sim)
|
run-binary: $(sim)
|
||||||
(set -o pipefail && $(sim) $(PERMISSIVE_ON) +max-cycles=$(timeout_cycles) $(SIM_FLAGS) $(VERBOSE_FLAGS) $(PERMISSIVE_OFF) $(BINARY) </dev/null 2> >(spike-dasm > $(sim_out_name).out) | tee $(sim_out_name).log)
|
(set -o pipefail && $(sim) $(PERMISSIVE_ON) $(SIM_FLAGS) $(EXTRA_SIM_FLAGS) $(VERBOSE_FLAGS) $(PERMISSIVE_OFF) $(BINARY) </dev/null 2> >(spike-dasm > $(sim_out_name).out) | tee $(sim_out_name).log)
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
# helper rules to run simulator as fast as possible
|
# helper rules to run simulator as fast as possible
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
run-binary-fast: $(sim)
|
run-binary-fast: $(sim)
|
||||||
(set -o pipefail && $(sim) $(PERMISSIVE_ON) +max-cycles=$(timeout_cycles) $(SIM_FLAGS) $(PERMISSIVE_OFF) $(BINARY) </dev/null | tee $(sim_out_name).log)
|
(set -o pipefail && $(sim) $(PERMISSIVE_ON) $(SIM_FLAGS) $(EXTRA_SIM_FLAGS) $(PERMISSIVE_OFF) $(BINARY) </dev/null | tee $(sim_out_name).log)
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
# helper rules to run simulator with as much debug info as possible
|
# helper rules to run simulator with as much debug info as possible
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
run-binary-debug: $(sim_debug)
|
run-binary-debug: $(sim_debug)
|
||||||
(set -o pipefail && $(sim_debug) $(PERMISSIVE_ON) +max-cycles=$(timeout_cycles) $(SIM_FLAGS) $(VERBOSE_FLAGS) $(WAVEFORM_FLAG) $(PERMISSIVE_OFF) $(BINARY) </dev/null 2> >(spike-dasm > $(sim_out_name).out) | tee $(sim_out_name).log)
|
(set -o pipefail && $(sim_debug) $(PERMISSIVE_ON) $(SIM_FLAGS) $(EXTRA_SIM_FLAGS) $(VERBOSE_FLAGS) $(WAVEFORM_FLAG) $(PERMISSIVE_OFF) $(BINARY) </dev/null 2> >(spike-dasm > $(sim_out_name).out) | tee $(sim_out_name).log)
|
||||||
|
|
||||||
run-fast: run-asm-tests-fast run-bmark-tests-fast
|
run-fast: run-asm-tests-fast run-bmark-tests-fast
|
||||||
|
|
||||||
@@ -129,10 +140,10 @@ $(output_dir)/%: $(RISCV)/riscv64-unknown-elf/share/riscv-tests/isa/%
|
|||||||
ln -sf $< $@
|
ln -sf $< $@
|
||||||
|
|
||||||
$(output_dir)/%.run: $(output_dir)/% $(sim)
|
$(output_dir)/%.run: $(output_dir)/% $(sim)
|
||||||
(set -o pipefail && $(sim) $(PERMISSIVE_ON) +max-cycles=$(timeout_cycles) $(SIM_FLAGS) $(PERMISSIVE_OFF) $< </dev/null | tee $<.log) && touch $@
|
(set -o pipefail && $(sim) $(PERMISSIVE_ON) $(SIM_FLAGS) $(EXTRA_SIM_FLAGS) $(PERMISSIVE_OFF) $< </dev/null | tee $<.log) && touch $@
|
||||||
|
|
||||||
$(output_dir)/%.out: $(output_dir)/% $(sim)
|
$(output_dir)/%.out: $(output_dir)/% $(sim)
|
||||||
(set -o pipefail && $(sim) $(PERMISSIVE_ON) +dramsim +max-cycles=$(timeout_cycles) $(VERBOSE_FLAGS) $(PERMISSIVE_OFF) $< </dev/null 2> >(spike-dasm > $@) | tee $<.log)
|
(set -o pipefail && $(sim) $(PERMISSIVE_ON) $(SIM_FLAGS) $(EXTRA_SIM_FLAGS) $(VERBOSE_FLAGS) $(PERMISSIVE_OFF) $< </dev/null 2> >(spike-dasm > $@) | tee $<.log)
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
# include build/project specific makefrags made from the generator
|
# include build/project specific makefrags made from the generator
|
||||||
@@ -141,26 +152,6 @@ ifneq ($(filter run% %.run %.out %.vpd %.vcd,$(MAKECMDGOALS)),)
|
|||||||
-include $(build_dir)/$(long_name).d
|
-include $(build_dir)/$(long_name).d
|
||||||
endif
|
endif
|
||||||
|
|
||||||
#################################################
|
|
||||||
# Rules for running and checking tracegen tests #
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
AXE_DIR=$(base_dir)/tools/axe/src
|
|
||||||
AXE=$(AXE_DIR)/axe
|
|
||||||
|
|
||||||
$(AXE): $(wildcard $(AXE_DIR)/*.[ch]) $(AXE_DIR)/make.sh
|
|
||||||
cd $(AXE_DIR) && ./make.sh
|
|
||||||
|
|
||||||
$(output_dir)/tracegen.out: $(sim)
|
|
||||||
mkdir -p $(output_dir) && $(sim) $(PERMISSIVE_ON) +max-cycles=$(timeout_cycles) $(VERBOSE_FLAGS) $(PERMISSIVE_OFF) none </dev/null 2> $@
|
|
||||||
|
|
||||||
$(output_dir)/tracegen.result: $(output_dir)/tracegen.out $(AXE)
|
|
||||||
$(base_dir)/scripts/check-tracegen.sh $< > $@
|
|
||||||
|
|
||||||
tracegen: $(output_dir)/tracegen.result
|
|
||||||
|
|
||||||
.PHONY: tracegen
|
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Rules for building DRAMSim2 library #
|
# Rules for building DRAMSim2 library #
|
||||||
#######################################
|
#######################################
|
||||||
|
|||||||
Submodule generators/ariane updated: 145b5ed106...e02436d2aa
18
generators/tracegen/tracegen.mk
Normal file
18
generators/tracegen/tracegen.mk
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
##############################################################
|
||||||
|
# extra variables/targets ingested by the chipyard make system
|
||||||
|
##############################################################
|
||||||
|
|
||||||
|
AXE_DIR=$(base_dir)/tools/axe/src
|
||||||
|
AXE=$(AXE_DIR)/axe
|
||||||
|
|
||||||
|
$(AXE): $(wildcard $(AXE_DIR)/*.[ch]) $(AXE_DIR)/make.sh
|
||||||
|
cd $(AXE_DIR) && ./make.sh
|
||||||
|
|
||||||
|
$(output_dir)/tracegen.out: $(sim)
|
||||||
|
mkdir -p $(output_dir) && $(sim) $(PERMISSIVE_ON) $(SIM_FLAGS) $(EXTRA_SIM_FLAGS) $(VERBOSE_FLAGS) $(PERMISSIVE_OFF) none </dev/null 2> $@
|
||||||
|
|
||||||
|
$(output_dir)/tracegen.result: $(output_dir)/tracegen.out $(AXE)
|
||||||
|
$(base_dir)/scripts/check-tracegen.sh $< > $@
|
||||||
|
|
||||||
|
.PHONY: tracegen
|
||||||
|
tracegen: $(output_dir)/tracegen.result
|
||||||
@@ -50,7 +50,8 @@ VCS_CC_OPTS = \
|
|||||||
-CC "-I$(dramsim_dir)" \
|
-CC "-I$(dramsim_dir)" \
|
||||||
-CC "-std=c++11" \
|
-CC "-std=c++11" \
|
||||||
$(dramsim_lib) \
|
$(dramsim_lib) \
|
||||||
$(RISCV)/lib/libfesvr.a
|
$(RISCV)/lib/libfesvr.a \
|
||||||
|
-CC "$(EXTRA_SIM_CC_FLAGS)"
|
||||||
|
|
||||||
VCS_NONCC_OPTS = \
|
VCS_NONCC_OPTS = \
|
||||||
+lint=all,noVCDE,noONGS,noUI \
|
+lint=all,noVCDE,noONGS,noUI \
|
||||||
@@ -80,16 +81,16 @@ VCS_DEFINES = \
|
|||||||
+define+RANDOMIZE_GARBAGE_ASSIGN \
|
+define+RANDOMIZE_GARBAGE_ASSIGN \
|
||||||
+define+RANDOMIZE_INVALID_ASSIGN
|
+define+RANDOMIZE_INVALID_ASSIGN
|
||||||
|
|
||||||
VCS_OPTS = -notice -line $(VCS_CC_OPTS) $(VCS_NONCC_OPTS) $(VCS_DEFINES)
|
VCS_OPTS = -notice -line $(VCS_CC_OPTS) $(VCS_NONCC_OPTS) $(VCS_DEFINES) $(EXTRA_SIM_SOURCES)
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
# vcs simulator rules
|
# vcs simulator rules
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
$(sim): $(sim_vsrcs) $(sim_common_files) $(dramsim_lib)
|
$(sim): $(sim_vsrcs) $(sim_common_files) $(dramsim_lib) $(EXTRA_SIM_REQS)
|
||||||
rm -rf csrc && $(VCS) $(VCS_OPTS) -o $@ \
|
rm -rf csrc && $(VCS) $(VCS_OPTS) -o $@ \
|
||||||
-debug_pp
|
-debug_pp
|
||||||
|
|
||||||
$(sim_debug): $(sim_vsrcs) $(sim_common_files) $(dramsim_lib)
|
$(sim_debug): $(sim_vsrcs) $(sim_common_files) $(dramsim_lib) $(EXTRA_SIM_REQS)
|
||||||
rm -rf csrc && $(VCS) $(VCS_OPTS) -o $@ \
|
rm -rf csrc && $(VCS) $(VCS_OPTS) -o $@ \
|
||||||
+define+DEBUG \
|
+define+DEBUG \
|
||||||
-debug_pp
|
-debug_pp
|
||||||
@@ -99,7 +100,7 @@ $(sim_debug): $(sim_vsrcs) $(sim_common_files) $(dramsim_lib)
|
|||||||
#########################################################################################
|
#########################################################################################
|
||||||
.PRECIOUS: $(output_dir)/%.vpd %.vpd
|
.PRECIOUS: $(output_dir)/%.vpd %.vpd
|
||||||
$(output_dir)/%.vpd: $(output_dir)/% $(sim_debug)
|
$(output_dir)/%.vpd: $(output_dir)/% $(sim_debug)
|
||||||
(set -o pipefail && $(sim_debug) $(PERMISSIVE_ON) +max-cycles=$(timeout_cycles) $(SIM_FLAGS) $(VERBOSE_FLAGS) +vcdplusfile=$@ $(PERMISSIVE_OFF) $< </dev/null 2> >(spike-dasm > $<.out) | tee $<.log)
|
(set -o pipefail && $(sim_debug) $(PERMISSIVE_ON) $(SIM_FLAGS) $(EXTRA_SIM_FLAGS) $(VERBOSE_FLAGS) +vcdplusfile=$@ $(PERMISSIVE_OFF) $< </dev/null 2> >(spike-dasm > $<.out) | tee $<.log)
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
# general cleanup rule
|
# general cleanup rule
|
||||||
|
|||||||
@@ -47,14 +47,25 @@ include $(base_dir)/common.mk
|
|||||||
#########################################################################################
|
#########################################################################################
|
||||||
VERILATOR := verilator --cc --exe
|
VERILATOR := verilator --cc --exe
|
||||||
|
|
||||||
CXXFLAGS := $(CXXFLAGS) -O1 -std=c++11 -I$(RISCV)/include -I$(dramsim_dir) -D__STDC_FORMAT_MACROS
|
CXXFLAGS := \
|
||||||
LDFLAGS := $(LDFLAGS) -L$(RISCV)/lib -Wl,-rpath,$(RISCV)/lib -L$(dramsim_dir) -Wl,-rpath,$(dramsim_dir) -L$(sim_dir) -lfesvr -lpthread -ldramsim
|
$(CXXFLAGS) -O1 -std=c++11 \
|
||||||
|
-I$(RISCV)/include \
|
||||||
|
-I$(dramsim_dir) \
|
||||||
|
-D__STDC_FORMAT_MACROS \
|
||||||
|
$(EXTRA_SIM_CC_FLAGS)
|
||||||
|
|
||||||
|
LDFLAGS := \
|
||||||
|
$(LDFLAGS) \
|
||||||
|
-L$(sim_dir) \
|
||||||
|
-lpthread
|
||||||
|
|
||||||
VERILATOR_CC_OPTS = \
|
VERILATOR_CC_OPTS = \
|
||||||
-O3 \
|
-O3 \
|
||||||
-CFLAGS "$(CXXFLAGS) -DTEST_HARNESS=V$(VLOG_MODEL) -DVERILATOR" \
|
-CFLAGS "$(CXXFLAGS) -DTEST_HARNESS=V$(VLOG_MODEL) -DVERILATOR" \
|
||||||
-CFLAGS "-I$(build_dir) -include $(build_dir)/$(long_name).plusArgs -include $(build_dir)/verilator.h" \
|
-CFLAGS "-I$(build_dir) -include $(build_dir)/$(long_name).plusArgs -include $(build_dir)/verilator.h" \
|
||||||
-LDFLAGS "$(LDFLAGS)"
|
-LDFLAGS "$(LDFLAGS)" \
|
||||||
|
$(RISCV)/lib/libfesvr.a \
|
||||||
|
$(dramsim_lib)
|
||||||
|
|
||||||
# default flags added for ariane
|
# default flags added for ariane
|
||||||
ARIANE_VERILATOR_FLAGS = \
|
ARIANE_VERILATOR_FLAGS = \
|
||||||
@@ -87,7 +98,7 @@ VERILATOR_DEFINES = \
|
|||||||
+define+PRINTF_COND=\$$c\(\"verbose\",\"\&\&\"\,\"done_reset\"\) \
|
+define+PRINTF_COND=\$$c\(\"verbose\",\"\&\&\"\,\"done_reset\"\) \
|
||||||
+define+STOP_COND=\$$c\(\"done_reset\"\)
|
+define+STOP_COND=\$$c\(\"done_reset\"\)
|
||||||
|
|
||||||
VERILATOR_OPTS = $(VERILATOR_CC_OPTS) $(VERILATOR_NONCC_OPTS) $(VERILATOR_DEFINES)
|
VERILATOR_OPTS = $(VERILATOR_CC_OPTS) $(VERILATOR_NONCC_OPTS) $(VERILATOR_DEFINES) $(EXTRA_SIM_SOURCES)
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
# verilator build paths and file names
|
# verilator build paths and file names
|
||||||
@@ -104,13 +115,13 @@ model_mk_debug = $(model_dir_debug)/V$(VLOG_MODEL).mk
|
|||||||
#########################################################################################
|
#########################################################################################
|
||||||
# build makefile fragment that builds the verilator sim rules
|
# build makefile fragment that builds the verilator sim rules
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
$(model_mk): $(sim_vsrcs) $(sim_common_files)
|
$(model_mk): $(sim_vsrcs) $(sim_common_files) $(EXTRA_SIM_REQS)
|
||||||
rm -rf $(build_dir)/$(long_name)
|
rm -rf $(build_dir)/$(long_name)
|
||||||
mkdir -p $(build_dir)/$(long_name)
|
mkdir -p $(build_dir)/$(long_name)
|
||||||
$(VERILATOR) $(VERILATOR_OPTS) -o $(sim) -Mdir $(model_dir) -CFLAGS "-include $(model_header)"
|
$(VERILATOR) $(VERILATOR_OPTS) -o $(sim) -Mdir $(model_dir) -CFLAGS "-include $(model_header)"
|
||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
$(model_mk_debug): $(sim_vsrcs) $(sim_common_files)
|
$(model_mk_debug): $(sim_vsrcs) $(sim_common_files) $(EXTRA_SIM_REQS)
|
||||||
rm -rf $(build_dir)/$(long_name)
|
rm -rf $(build_dir)/$(long_name)
|
||||||
mkdir -p $(build_dir)/$(long_name).debug
|
mkdir -p $(build_dir)/$(long_name).debug
|
||||||
$(VERILATOR) $(VERILATOR_OPTS) -o $(sim_debug) --trace -Mdir $(model_dir_debug) -CFLAGS "-include $(model_header_debug)"
|
$(VERILATOR) $(VERILATOR_OPTS) -o $(sim_debug) --trace -Mdir $(model_dir_debug) -CFLAGS "-include $(model_header_debug)"
|
||||||
@@ -132,7 +143,7 @@ $(sim_debug): $(model_mk_debug) $(dramsim_lib)
|
|||||||
$(output_dir)/%.vpd: $(output_dir)/% $(sim_debug)
|
$(output_dir)/%.vpd: $(output_dir)/% $(sim_debug)
|
||||||
rm -f $@.vcd && mkfifo $@.vcd
|
rm -f $@.vcd && mkfifo $@.vcd
|
||||||
vcd2vpd $@.vcd $@ > /dev/null &
|
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)
|
(set -o pipefail && $(sim_debug) $(PERMISSIVE_ON) $(SIM_FLAGS) $(EXTRA_SIM_FLAGS) $(VERBOSE_FLAGS) -v$@.vcd $(PERMISSIVE_OFF) $< </dev/null 2> >(spike-dasm > $<.out) | tee $<.log)
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
# general cleanup rule
|
# general cleanup rule
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ output_dir=$(sim_dir)/output/$(long_name)
|
|||||||
# helper variables to run binaries
|
# helper variables to run binaries
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
BINARY ?=
|
BINARY ?=
|
||||||
SIM_FLAGS ?=
|
override SIM_FLAGS += +dramsim +max-cycles=$(timeout_cycles)
|
||||||
VERBOSE_FLAGS ?= +verbose
|
VERBOSE_FLAGS ?= +verbose
|
||||||
sim_out_name = $(subst $() $(),_,$(notdir $(basename $(BINARY))).$(long_name))
|
sim_out_name = $(subst $() $(),_,$(notdir $(basename $(BINARY))).$(long_name))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user