diff --git a/.gitignore b/.gitignore index 47cb4d87..35d9b2d8 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ tags *~ env-riscv-tools.sh env-esp-tools.sh +.bloop/ diff --git a/common.mk b/common.mk index 5b502cb1..ee888b3b 100644 --- a/common.mk +++ b/common.mk @@ -34,13 +34,8 @@ lookup_srcs = $(shell find -L $(1)/ -name target -prune -o -iname "*.$(2)" -prin SOURCE_DIRS = $(addprefix $(base_dir)/,generators sims/firesim/sim tools/barstools/iocell) SCALA_SOURCES = $(call lookup_srcs,$(SOURCE_DIRS),scala) VLOG_SOURCES = $(call lookup_srcs,$(SOURCE_DIRS),sv) $(call lookup_srcs,$(SOURCE_DIRS),v) - -######################################################################################### -# rocket and testchipip classes -######################################################################################### -# NB: target/ lives under source ----V , due to how we're handling midas dependency injection -ROCKET_CLASSES ?= "$(ROCKETCHIP_DIR)/src/target/scala-$(SCALA_VERSION_MAJOR)/classes:$(ROCKETCHIP_DIR)/chisel3/target/scala-$(SCALA_VERSION_MAJOR)/*" -TESTCHIPIP_CLASSES ?= "$(TESTCHIP_DIR)/target/scala-$(SCALA_VERSION_MAJOR)/classes" +# This assumes no SBT meta-build sources +SBT_SOURCES = $(call lookup_srcs,$(base_dir),sbt) ######################################################################################### # jar creation variables and rules @@ -60,11 +55,19 @@ $(FIRRTL_TEST_JAR): $(call lookup_srcs,$(CHIPYARD_FIRRTL_DIR),scala) cp -p $(CHIPYARD_FIRRTL_DIR)/utils/bin/firrtl-test.jar $@ touch $@ + +######################################################################################### +# Bloop Project Definitions +######################################################################################### +$(BLOOP_CONFIG_DIR)/TIMESTAMP: $(SBT_SOURCES) + cd $(base_dir) && $(SBT) "project chipyardRoot" "bloopInstall" + touch $@ + ######################################################################################### # create list of simulation file inputs ######################################################################################### -$(sim_files): $(call lookup_srcs,$(base_dir)/generators/utilities/src/main/scala,scala) $(FIRRTL_JAR) - cd $(base_dir) && $(SBT) "project utilities" "runMain utilities.GenerateSimFiles -td $(build_dir) -sim $(sim_name)" +$(sim_files): $(call lookup_srcs,$(base_dir)/generators/utilities/src/main/scala,scala) $(FIRRTL_JAR) $(SCALA_BUILDTOOL_DEPS) + $(call run_scala_main,utilities,utilities.GenerateSimFiles,-td $(build_dir) -sim $(sim_name)) ######################################################################################### # create firrtl file rule and variables @@ -76,11 +79,11 @@ $(FIRRTL_FILE) $(ANNO_FILE): generator_temp # AG: must re-elaborate if ariane sources have changed... otherwise just run firrtl compile generator_temp: $(SCALA_SOURCES) $(sim_files) $(EXTRA_GENERATOR_REQS) mkdir -p $(build_dir) - cd $(base_dir) && $(SBT) "project $(SBT_PROJECT)" "runMain $(GENERATOR_PACKAGE).Generator \ + $(call run_scala_main,$(SBT_PROJECT),$(GENERATOR_PACKAGE).Generator,\ --target-dir $(build_dir) \ --name $(long_name) \ --top-module $(MODEL_PACKAGE).$(MODEL) \ - --legacy-configs $(CONFIG_PACKAGE).$(CONFIG)" + --legacy-configs $(CONFIG_PACKAGE).$(CONFIG)) .PHONY: firrtl firrtl: $(FIRRTL_FILE) @@ -101,7 +104,7 @@ $(TOP_TARGETS) $(HARNESS_TARGETS): firrtl_temp @echo "" > /dev/null firrtl_temp: $(FIRRTL_FILE) $(ANNO_FILE) $(VLOG_SOURCES) - cd $(base_dir) && $(SBT) "project tapeout" "runMain barstools.tapeout.transforms.GenerateTopAndHarness -o $(TOP_FILE) -tho $(HARNESS_FILE) -i $(FIRRTL_FILE) --syn-top $(TOP) --harness-top $(VLOG_MODEL) -faf $(ANNO_FILE) -tsaof $(TOP_ANNO) -tdf $(sim_top_blackboxes) -tsf $(TOP_FIR) -thaof $(HARNESS_ANNO) -hdf $(sim_harness_blackboxes) -thf $(HARNESS_FIR) $(REPL_SEQ_MEM) $(HARNESS_CONF_FLAGS) -td $(build_dir)" && touch $(sim_top_blackboxes) $(sim_harness_blackboxes) + $(call run_scala_main,tapeout,barstools.tapeout.transforms.GenerateTopAndHarness,-o $(TOP_FILE) -tho $(HARNESS_FILE) -i $(FIRRTL_FILE) --syn-top $(TOP) --harness-top $(VLOG_MODEL) -faf $(ANNO_FILE) -tsaof $(TOP_ANNO) -tdf $(sim_top_blackboxes) -tsf $(TOP_FIR) -thaof $(HARNESS_ANNO) -hdf $(sim_harness_blackboxes) -thf $(HARNESS_FIR) $(REPL_SEQ_MEM) $(HARNESS_CONF_FLAGS) -td $(build_dir)) && touch $(sim_top_blackboxes) $(sim_harness_blackboxes) # DOC include end: FirrtlCompiler # This file is for simulation only. VLSI flows should replace this file with one containing hard SRAMs @@ -111,7 +114,7 @@ $(TOP_SMEMS_FILE) $(TOP_SMEMS_FIR): top_macro_temp @echo "" > /dev/null top_macro_temp: $(TOP_SMEMS_CONF) - cd $(base_dir) && $(SBT) "project barstoolsMacros" "runMain barstools.macros.MacroCompiler -n $(TOP_SMEMS_CONF) -v $(TOP_SMEMS_FILE) -f $(TOP_SMEMS_FIR) $(MACROCOMPILER_MODE)" + $(call run_scala_main,barstoolsMacros,barstools.macros.MacroCompiler,-n $(TOP_SMEMS_CONF) -v $(TOP_SMEMS_FILE) -f $(TOP_SMEMS_FIR) $(MACROCOMPILER_MODE)) HARNESS_MACROCOMPILER_MODE = --mode synflops .INTERMEDIATE: harness_macro_temp @@ -119,7 +122,7 @@ $(HARNESS_SMEMS_FILE) $(HARNESS_SMEMS_FIR): harness_macro_temp @echo "" > /dev/null harness_macro_temp: $(HARNESS_SMEMS_CONF) | top_macro_temp - cd $(base_dir) && $(SBT) "project barstoolsMacros" "runMain barstools.macros.MacroCompiler -n $(HARNESS_SMEMS_CONF) -v $(HARNESS_SMEMS_FILE) -f $(HARNESS_SMEMS_FIR) $(HARNESS_MACROCOMPILER_MODE)" + $(call run_scala_main,barstoolsMacros,barstools.macros.MacroCompiler, -n $(HARNESS_SMEMS_CONF) -v $(HARNESS_SMEMS_FILE) -f $(HARNESS_SMEMS_FIR) $(HARNESS_MACROCOMPILER_MODE)) ######################################################################################## # remove duplicate files and headers in list of simulation file inputs diff --git a/project/plugins.sbt b/project/plugins.sbt index 8de71081..3fe776fa 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -15,5 +15,6 @@ addSbtPlugin("com.simplytyped" % "sbt-antlr4" % "0.8.1") addSbtPlugin("com.github.gseitz" % "sbt-protobuf" % "0.6.3") addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.4") addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.6.1") +addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.4.1") libraryDependencies += "com.github.os72" % "protoc-jar" % "3.5.1.1" diff --git a/scripts/firesim-setup.sh b/scripts/firesim-setup.sh index bb14f39e..a110cb61 100755 --- a/scripts/firesim-setup.sh +++ b/scripts/firesim-setup.sh @@ -12,7 +12,6 @@ cd "${scripts_dir}/.." # Reenable the FireSim submodule git config --unset submodule.sims/firesim.update || true -git submodule update --init sims/firesim cd sims/firesim ./build-setup.sh "$@" --library cd "$RDIR" diff --git a/sims/firesim b/sims/firesim index 82ce80bc..8064d880 160000 --- a/sims/firesim +++ b/sims/firesim @@ -1 +1 @@ -Subproject commit 82ce80bc129905834426629279098fcd970a9ed3 +Subproject commit 8064d8808b9c936711361532a95affbfc2fcbdca diff --git a/variables.mk b/variables.mk index 1a3623a2..48da498e 100644 --- a/variables.mk +++ b/variables.mk @@ -125,9 +125,33 @@ JAVA_ARGS ?= -Xmx$(JAVA_HEAP_SIZE) -Xss8M -XX:MaxPermSize=256M ######################################################################################### SCALA_VERSION=2.12.10 SCALA_VERSION_MAJOR=$(basename $(SCALA_VERSION)) - SBT ?= java $(JAVA_ARGS) -jar $(ROCKETCHIP_DIR)/sbt-launch.jar +BLOOP ?= bloop +BLOOP_CONFIG_DIR ?= $(base_dir)/.bloop +# This mirrors the bloop default. Set to a system-unique port in a multi-user environment +BLOOP_NAILGUN_PORT ?= 8212 + +SCALA_BUILDTOOL_DEPS = $(SBT_SOURCES) + +ifdef ENABLE_BLOOP +override SCALA_BUILDTOOL_DEPS += $(BLOOP_CONFIG_DIR)/TIMESTAMP +# Two notes about the bloop invocation: +# 1) the sed removes a leading {file:} that sometimes needs to be +# provided to SBT when a project but not for bloop. +# 2) Generally, one could could pass '--' to indicate all remaining arguments are +# destined for the scala Main, however a bug in Bloop's argument parsing causes the +# --nailgun-port argument to be lost in this case. Workaround this by prefixing +# every main-destined argument with "--args" +define run_scala_main + cd $(base_dir) && bloop --nailgun-port $(BLOOP_NAILGUN_PORT) run $(shell echo $(1) | sed 's/{.*}//') --main $(2) $(addprefix --args ,$3) +endef +else +define run_scala_main + cd $(base_dir) && $(SBT) "project $(1)" "runMain $(2) $(3)" +endef +endif + ######################################################################################### # output directory for tests #########################################################################################