diff --git a/deploy/buildtools/buildafi.py b/deploy/buildtools/buildafi.py index 7d44e261ad..aca2e8d9fc 100644 --- a/deploy/buildtools/buildafi.py +++ b/deploy/buildtools/buildafi.py @@ -70,12 +70,12 @@ def replace_rtl_local(conf, buildconfig): build_driver(conf, buildconfig) def gen_replace_rtl_script(conf, buildconfig): - """ Run SBT assembly to create FAT jar to send to build hosts along with config-specific shell-script - to execute the FAT jar + """ Generate config-specific replace-rtl.sh script and any prerequisites to send to build hosts + for running Chisel->Verilog generation and population of cl_firesim template in aws-fpga hdk THIS ALWAYS RUNS LOCALLY""" - rootLogger.info("Generating FAT jar and replace-rtl.sh for " + str(buildconfig.get_chisel_triplet())) + rootLogger.info("Generating replace-rtl.sh for " + str(buildconfig.get_chisel_triplet())) sim_local(buildconfig.make_recipe("--quiet gen-replace-rtl-script")) def build_driver(conf, buildconfig): @@ -124,14 +124,13 @@ def on_build_failure(): fpgabuilddir = "hdk/cl/developer_designs/cl_" + buildconfig.get_chisel_triplet() fpgatemplatedir = 'hdk/cl/developer_designs/cl_firesim' generated_dir = get_sim_makevar(buildconfig, 'GENERATED_DIR') - fat_jar = get_sim_makevar(buildconfig, 'FAT_JAR') + gen_classpath = get_sim_makevar(buildconfig, 'GEN_CLASSPATH') # first, copy aws-fpga to the build instance. it will live in # the same path on the build host as on the manager with StreamLogger('stdout'), StreamLogger('stderr'): run('mkdir -p ' + ddir) run('mkdir -p ' + generated_dir) - run('mkdir -p ' + dirname(fat_jar)) run('mkdir -p ' + aws_fpga_root) run('mkdir -p ' + pjoin(aws_fpga_root, fpgatemplatedir)) run('mkdir -p ' + pjoin(aws_fpga_root, fpgabuilddir)) @@ -164,18 +163,21 @@ def on_build_failure(): extra_opts="-l", capture=True) rootLogger.debug(rsync_cap) rootLogger.debug(rsync_cap.stderr) - # sync the fat jar - rsync_cap = rsync_project(local_dir=fat_jar, - remote_dir=fat_jar, - ssh_opts="-o StrictHostKeyChecking=no", - extra_opts="-l", capture=True) - rootLogger.debug(rsync_cap) - rootLogger.debug(rsync_cap.stderr) + # sync all components of the generator classpath + # classpath members are directories or archives + for e in gen_classpath.split(":"): + run('mkdir -p ' + dirname(e)) + rsync_cap = rsync_project(local_dir=e, + remote_dir=e, + ssh_opts="-o StrictHostKeyChecking=no", + extra_opts="-l", capture=True) + rootLogger.debug(rsync_cap) + rootLogger.debug(rsync_cap.stderr) with InfoStreamLogger('stdout'), InfoStreamLogger('stderr'): # install java and dtc on the build host sudo('yum install -y java dtc') # run the replace-rtl.sh script - rootLogger.info("Running process to build verilog from FAT jar.") + rootLogger.info("Running Verilog generation via: " + pjoin(generated_dir,'replace-rtl.sh')) run('bash -xe ' + pjoin(generated_dir,'replace-rtl.sh')) with StreamLogger('stdout'), StreamLogger('stderr'): # rsync generated_dir back to manager diff --git a/sim/Makefile b/sim/Makefile index edabb84f73..7ead53ef90 100644 --- a/sim/Makefile +++ b/sim/Makefile @@ -29,8 +29,7 @@ TARGET_PROJECT_MAKEFRAG ?= $(firesim_base_dir)/src/main/makefrag/$(TARGET_PROJEC PLATFORM ?= f1 # If TARGET_PROJECT_MAKEFRAG requires additional PROJECT-specific artifacts in GENERATED_DIR before -# Chisel->FIRRTL->Verilog is run, register them as prereqs of the pre-elaboration target. -# See src/main/makefrag/firesim/Makefrag's BOOTROM_TARGETS for an example +# Chisel->FIRRTL->Verilog is run, add them to PRE_ELABORATION_TARGETS to register them as prereqs PRE_ELABORATION_TARGETS = ifdef FIRESIM_STANDALONE @@ -99,8 +98,8 @@ ifdef ENABLE_SBT_THIN_CLIENT # continue to use SBT for main class invocations of the generator and goldengate run_main = run_scala_main else - # recipes for generator and gg using sbt are calls out to FAT_JAR instead of SBT - run_main = cd $(base_dir) && java $(JAVA_OPTS) -cp $(FAT_JAR) $(2) $(3) + # recipes for generator and gg are now java invocations using GEN_CLASSPATH instead of SBT + run_main = cd $(base_dir) && java $(JAVA_OPTS) -cp $(GEN_CLASSPATH) $(2) $(3) endif # Include target-specific sources and input generation recipes diff --git a/sim/src/main/makefrag/fasedtests/Makefrag b/sim/src/main/makefrag/fasedtests/Makefrag index 881ddf15b6..35d2af4812 100644 --- a/sim/src/main/makefrag/fasedtests/Makefrag +++ b/sim/src/main/makefrag/fasedtests/Makefrag @@ -15,9 +15,9 @@ TARGET_CONFIG ?= DefaultConfig PLATFORM_CONFIG_PACKAGE ?= firesim.fasedtests PLATFORM_CONFIG ?= DefaultF1Config -name_tuple := $(DESIGN)-$(TARGET_CONFIG)-$(PLATFORM_CONFIG) -GENERATED_DIR := $(firesim_base_dir)/generated-src/$(PLATFORM)/$(name_tuple) -OUTPUT_DIR := $(firesim_base_dir)/output/$(PLATFORM)/$(name_tuple) +name_tuple ?= $(DESIGN)-$(TARGET_CONFIG)-$(PLATFORM_CONFIG) +GENERATED_DIR ?= $(firesim_base_dir)/generated-src/$(PLATFORM)/$(name_tuple) +OUTPUT_DIR ?= $(firesim_base_dir)/output/$(PLATFORM)/$(name_tuple) ################## # RTL Generation # @@ -31,10 +31,6 @@ HEADER := $(GENERATED_DIR)/$(DESIGN)-const.h CONF_NAME ?= runtime.conf firesim_sbt_project := {file:${firesim_base_dir}/}firesim -FAT_JAR := $(firesim_base_dir)/generated-src/firesim.jar -PRE_ELABORATION_TARGETS += $(FAT_JAR) - - chisel_src_dirs = \ $(addprefix $(firesim_base_dir)/,. midas midas/targetutils firesim-lib) \ @@ -43,12 +39,40 @@ chisel_src_dirs = \ chisel_srcs = $(foreach submodule,$(chisel_src_dirs),\ $(shell find $(submodule)/ -iname "[!.]*.scala" -print 2> /dev/null | grep 'src/main/scala')) -# don't search for implicit rules to make the chisel_srcs (reduces useless output in --debug=i) +# don't search for implicit rules to make the chisel_srcs (reduces useless output in make --debug) $(chisel_srcs): ; -$(FAT_JAR): $(chisel_srcs) $(SCALA_BUILDTOOL_DEPS) +GEN_CLASSPATH_ORDERONLY_DEPS ?= + +ifndef GEN_CLASSPATH + GEN_CLASSPATH = $(firesim_base_dir)/generated-src/firesim.jar + jardir = $(dir $(GEN_CLASSPATH)) + GEN_CLASSPATH_ORDERONLY_DEPS += $(jardir) + + $(jardir): mkdir -p $(@D) - $(SBT) "project $(firesim_sbt_project)" 'set assemblyOutputPath in assembly := file("$(FAT_JAR)")' assembly + +endif +GEN_CLASSPATH_DEPS ?= $(chisel_srcs) $(SCALA_BUILDTOOL_DEPS) + +# if GEN_CLASSPATH is a true java classpath, it can be colon-delimited list of paths (on *nix) +GEN_CLASSPATH_TARGETS ?= $(subst :, ,$(GEN_CLASSPATH)) + +ifndef ENABLE_SBT_THIN_CLIENT + PRE_ELABORATION_TARGETS += $(GEN_CLASSPATH_TARGETS) +endif + +GEN_CLASSPATH_RECIPE ?= cd $(base_dir) && $(SBT) "project $(firesim_sbt_project); set assemblyOutputPath in assembly := file(\"$(GEN_CLASSPATH)\"); assembly" + + +# empty recipe to help make understand multiple targets come from single invocation +# without using the new (4.3) '&:' grouped targets +# see https://stackoverflow.com/a/41710495 +$(GEN_CLASSPATH_TARGETS): classpath.intermediate ; + +.SECONDARY: classpath.intermediate +classpath.intermediate: $(GEN_CLASSPATH_DEPS) | $(GEN_CLASSPATH_ORDERONLY_DEPS) + $(GEN_CLASSPATH_RECIPE) # empty recipe to help make understand multiple targets come from single invocation # without using the new (4.3) '&:' grouped targets diff --git a/sim/src/main/makefrag/firesim/Makefrag b/sim/src/main/makefrag/firesim/Makefrag index 30809bb7a6..e26f1cfeb5 100644 --- a/sim/src/main/makefrag/firesim/Makefrag +++ b/sim/src/main/makefrag/firesim/Makefrag @@ -54,6 +54,38 @@ PRE_ELABORATION_TARGETS += $(BOOTROM_TARGETS) # Don't search for implicit rules to build the scala sources or bootrom sources (reduces useless output in --debug) $(SCALA_SOURCES) $(addprefix $(CHIPYARD_ROMDIR)/, $(BOOTROM_FILES)): ; +GEN_CLASSPATH_ORDERONLY_DEPS ?= + +ifndef GEN_CLASSPATH + GEN_CLASSPATH = $(firesim_base_dir)/generated-src/firechip.jar + jardir = $(dir $(GEN_CLASSPATH)) + GEN_CLASSPATH_ORDERONLY_DEPS += $(jardir) + + $(jardir): + mkdir -p $(@D) + +endif +GEN_CLASSPATH_DEPS ?= $(chisel_srcs) $(SCALA_BUILDTOOL_DEPS) + +# if GEN_CLASSPATH is a true java classpath, it can be colon-delimited list of paths (on *nix) +GEN_CLASSPATH_TARGETS ?= $(subst :, ,$(GEN_CLASSPATH)) + +ifndef ENABLE_SBT_THIN_CLIENT + PRE_ELABORATION_TARGETS += $(GEN_CLASSPATH_TARGETS) +endif + +GEN_CLASSPATH_RECIPE ?= cd $(base_dir) && $(SBT) "project $(firesim_sbt_project); set assemblyOutputPath in assembly := file(\"$(GEN_CLASSPATH)\"); assembly" + + +# empty recipe to help make understand multiple targets come from single invocation +# without using the new (4.3) '&:' grouped targets +# see https://stackoverflow.com/a/41710495 +$(GEN_CLASSPATH_TARGETS): classpath.intermediate ; + +.SECONDARY: classpath.intermediate +classpath.intermediate: $(GEN_CLASSPATH_DEPS) | $(GEN_CLASSPATH_ORDERONLY_DEPS) + $(GEN_CLASSPATH_RECIPE) + GENERATOR_NAME ?= chipyard.Generator GENERATOR_ARGS ?= \ --target-dir $(GENERATED_DIR) \ @@ -61,18 +93,7 @@ GENERATOR_ARGS ?= \ --top-module $(DESIGN_PACKAGE).$(DESIGN) \ --legacy-configs $(TARGET_CONFIG_PACKAGE):$(TARGET_CONFIG) -FAT_JAR ?= $(firesim_base_dir)/generated-src/firechip.jar -FAT_JAR_DEPS ?= $(SCALA_SOURCES) $(SCALA_BUILDTOOL_DEPS) -FAT_JAR_RECIPE ?= cd $(base_dir) && $(SBT) "project $(firesim_sbt_project); set assemblyOutputPath in assembly := file(\"$(FAT_JAR)\"); assembly" - -fat_jar_dir := $(dir $(FAT_JAR)) -$(fat_jar_dir): - mkdir -p $@ -$(FAT_JAR): $(FAT_JAR_DEPS) | $(fat_jar_dir) - $(FAT_JAR_RECIPE) - -PRE_ELABORATION_TARGETS += $(FAT_JAR) # empty recipe to help make understand multiple targets come from single invocation # without using the new (4.3) '&:' grouped targets see https://stackoverflow.com/a/41710495 @@ -82,7 +103,6 @@ $(FIRRTL_FILE) $(ANNO_FILE): $(FIRRTL_FILE).intermediate ; $(FIRRTL_FILE).intermediate: $(SCALA_SOURCES) $(PRE_ELABORATION_TARGETS) | $(GENERATED_DIR) $(call run_main,$(firesim_sbt_project),$(GENERATOR_NAME),$(GENERATOR_ARGS)) - # DOC include start: Bridge Build System Changes ########################## # Driver Sources & Flags # diff --git a/sim/src/main/makefrag/midasexamples/Makefrag b/sim/src/main/makefrag/midasexamples/Makefrag index 3609505b8d..1885b552f7 100644 --- a/sim/src/main/makefrag/midasexamples/Makefrag +++ b/sim/src/main/makefrag/midasexamples/Makefrag @@ -10,9 +10,9 @@ TARGET_CONFIG ?= NoConfig PLATFORM_CONFIG_PACKAGE ?= firesim.midasexamples PLATFORM_CONFIG ?= DefaultF1Config -name_tuple := $(DESIGN)-$(TARGET_CONFIG)-$(PLATFORM_CONFIG) -GENERATED_DIR := $(firesim_base_dir)/generated-src/$(PLATFORM)/$(name_tuple) -OUTPUT_DIR := $(firesim_base_dir)/output/$(PLATFORM)/$(name_tuple) +name_tuple ?= $(DESIGN)-$(TARGET_CONFIG)-$(PLATFORM_CONFIG) +GENERATED_DIR ?= $(firesim_base_dir)/generated-src/$(PLATFORM)/$(name_tuple) +OUTPUT_DIR ?= $(firesim_base_dir)/output/$(PLATFORM)/$(name_tuple) ########################## # RTL Generation # @@ -30,10 +30,6 @@ else firesim_sbt_project := {file:${firesim_base_dir}/}firesim endif -# FAT_JAR is applicable across config tuples but is tied to the sbt project -FAT_JAR := $(firesim_base_dir)/generated-src/firesim.jar -PRE_ELABORATION_TARGETS += $(FAT_JAR) - chisel_src_dirs = \ $(addprefix $(firesim_base_dir)/,. midas midas/targetutils firesim-lib) \ $(addprefix $(chipyard_dir)/generators/, chipyard rocket-chip/src, rocket-chip/api-config-chipsalliance) @@ -44,9 +40,42 @@ chisel_srcs = $(foreach submodule,$(chisel_src_dirs),\ # don't search for implicit rules to make the chisel_srcs (reduces useless output in --debug=i) $(chisel_srcs): ; -$(FAT_JAR): $(chisel_srcs) $(SCALA_BUILDTOOL_DEPS) +GEN_CLASSPATH_ORDERONLY_DEPS ?= + +# GEN_CLASSPATH is applicable across config tuples but is tied to the sbt project +ifndef GEN_CLASSPATH + GEN_CLASSPATH = $(firesim_base_dir)/generated-src/firesim.jar + jardir = $(dir $(GEN_CLASSPATH)) + GEN_CLASSPATH_ORDERONLY_DEPS += $(jardir) + + $(jardir): + mkdir -p $(@D) + +endif +GEN_CLASSPATH_DEPS ?= $(chisel_srcs) $(SCALA_BUILDTOOL_DEPS) + +# if GEN_CLASSPATH is a true java classpath, it can be colon-delimited list of paths (on *nix) +GEN_CLASSPATH_TARGETS ?= $(subst :, ,$(GEN_CLASSPATH)) + +ifndef ENABLE_SBT_THIN_CLIENT + PRE_ELABORATION_TARGETS += $(GEN_CLASSPATH_TARGETS) +endif + +GEN_CLASSPATH_RECIPE ?= cd $(base_dir) && $(SBT) "project $(firesim_sbt_project); set assemblyOutputPath in assembly := file(\"$(GEN_CLASSPATH)\"); assembly" + + +# empty recipe to help make understand multiple targets come from single invocation +# without using the new (4.3) '&:' grouped targets +# see https://stackoverflow.com/a/41710495 +$(GEN_CLASSPATH_TARGETS): classpath.intermediate ; + +.SECONDARY: classpath.intermediate +classpath.intermediate: $(GEN_CLASSPATH_DEPS) | $(GEN_CLASSPATH_ORDERONLY_DEPS) + $(GEN_CLASSPATH_RECIPE) + +$(GEN_CLASSPATH): $(chisel_srcs) $(SCALA_BUILDTOOL_DEPS) mkdir -p $(@D) - $(SBT) "project $(firesim_sbt_project)" 'set assemblyOutputPath in assembly := file("$(FAT_JAR)")' assembly + $(SBT) "project $(firesim_sbt_project)" 'set assemblyOutputPath in assembly := file("$(GEN_CLASSPATH)")' assembly CONF_NAME ?= runtime.conf diff --git a/sim/target-agnostic.mk b/sim/target-agnostic.mk index 32b47a0652..fe577d6f03 100644 --- a/sim/target-agnostic.mk +++ b/sim/target-agnostic.mk @@ -1,8 +1,10 @@ # See LICENSE for license details. # FireSim MAKEFRAG interface - Compulsory variables follow -# The FAT JAR created using sbt assembly -FAT_JAR ?= +# The Generator CLASSPATH used in java invocation to run generator and goldengate. Can be: +# - FAT JAR created using sbt assembly +# - An actual Java classpath created some other way +GEN_CLASSPATH ?= # The directory into which generated verilog and headers will be dumped # RTL simulations will also be built here GENERATED_DIR ?= @@ -85,11 +87,9 @@ $(VERILOG).intermediate: $(FIRRTL_FILE) $(ANNO_FILE) $(PRE_ELABORATION_TARGETS) # to generate a runtime configuration that is compatible with the generated # hardware (BridgeModule). Useful for modelling a memory system that differs from the default. .PHONY: conf -conf: $(fame_annos) $(FAT_JAR) +conf: $(fame_annos) $(GEN_CLASSPATH) mkdir -p $(GENERATED_DIR) - # Runtime configuration generator must run under SBT currently; When - # launched via bloop some Console input and output is lost. - cd $(base_dir) && java $(JAVA_OPTS) -cp $(FAT_JAR) midas.stage.RuntimeConfigGeneratorMain \ + cd $(base_dir) && java $(JAVA_OPTS) -cp $(GEN_CLASSPATH) midas.stage.RuntimeConfigGeneratorMain \ -td $(GENERATED_DIR) \ -faf $(fame_annos) \ -ggcp $(PLATFORM_CONFIG_PACKAGE) \ @@ -234,13 +234,13 @@ fpga: $(fpga_v) $(base_dir)/scripts/checkpoints/$(name_tuple) # Generate a script that can be run remotely on a build host by manager assuming only the following # are copied (recursively with Fabric's rsync_project) to the build-host: -# - $(FAT_JAR) +# - $(GEN_CLASSPATH) # - $(GENERATED_DIR) # - $(board_dir)/cl_firesim # The script will be run with 'bash -xe' to approximate the behavior of make shell execution # --no-print-directory avoids some info print statements that aren't actual commands -# --assume-new=$(FAT_JAR) ensures that the script consistently generates the commands for -# $(FAT_JAR) -> replace-rtl, regardless of whether they need to be done. This is done so that +# --assume-new=$(PRE_ELABORATION_TARGETS) ensures that the script consistently generates the commands for +# $(PRE_ELABORATION_TARGETS) -> replace-rtl, regardless of whether they need to be done. This is done so that # replace-rtl.sh should always be legit commands and we don't have to handle shortcuts for output # that look like "make: Nothing to be done for `replace-rtl'." .PHONY: gen-replace-rtl-script