diff --git a/.gitmodules b/.gitmodules index 73e556a4..698c53b9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -28,3 +28,6 @@ [submodule "generators/sifive-blocks"] path = generators/sifive-blocks url = git@github.com:sifive/sifive-blocks.git +[submodule "generators/hwacha"] + path = generators/hwacha + url = git@github.com:ucb-bar/hwacha.git diff --git a/build.sbt b/build.sbt index 55a28adf..9fdc386a 100644 --- a/build.sbt +++ b/build.sbt @@ -46,7 +46,11 @@ def conditionalDependsOn(prj: Project): Project = { } lazy val example = conditionalDependsOn(project in file(".")) - .dependsOn(boom, sifive_blocks) + .dependsOn(boom, hwacha, sifive_blocks) + .settings(commonSettings) + +lazy val hwacha = (project in file ("generators/hwacha")) + .dependsOn(rebarrocketchip) .settings(commonSettings) lazy val boom = (project in file("generators/boom")) diff --git a/common.mk b/common.mk index d7703f7e..f93e44a6 100644 --- a/common.mk +++ b/common.mk @@ -8,7 +8,7 @@ SHELL=/bin/bash ######################################################################################### lookup_scala_srcs = $(shell find -L $(1)/ -iname "*.scala" 2> /dev/null) -PACKAGES=rocket-chip testchipip boom +PACKAGES=rocket-chip testchipip boom hwacha sifive-blocks SCALA_SOURCES=$(foreach pkg,$(PACKAGES),$(call lookup_scala_srcs,$(base_dir)/generators/$(pkg)/src/main/scala)) $(call lookup_scala_srcs,$(base_dir)/src/main/scala) ######################################################################################### @@ -41,7 +41,7 @@ CHISEL_ARGS ?= $(FIRRTL_FILE) $(ANNO_FILE): $(SCALA_SOURCES) $(sim_dotf) mkdir -p $(build_dir) - cd $(base_dir) && $(SBT) "project $(SBT_PROJECT)" "runMain $(PROJECT).Generator $(CHISEL_ARGS) $(build_dir) $(PROJECT) $(MODEL) $(CFG_PROJECT) $(CONFIG)" + cd $(base_dir) && $(SBT) "project $(SBT_PROJECT)" "runMain $(GENERATOR_PACKAGE).Generator $(CHISEL_ARGS) $(build_dir) $(MODEL_PACKAGE) $(MODEL) $(CONFIG_PACKAGE) $(CONFIG)" ######################################################################################### # create verilog files rules and variables @@ -78,7 +78,7 @@ $(output_dir)/%.run: $(output_dir)/% $(sim) $(sim) +max-cycles=$(timeout_cycles) $< && touch $@ $(output_dir)/%.out: $(output_dir)/% $(sim) - $(sim) +verbose +max-cycles=$(timeout_cycles) $< 3>&1 1>&2 2>&3 | spike-dasm > $@ + $(sim) +permissive +verbose +max-cycles=$(timeout_cycles) +permissive-off $< 3>&1 1>&2 2>&3 | spike-dasm > $@ ######################################################################################### # include build/project specific makefrags made from the generator diff --git a/generators/hwacha b/generators/hwacha new file mode 160000 index 00000000..bc89157b --- /dev/null +++ b/generators/hwacha @@ -0,0 +1 @@ +Subproject commit bc89157b28b22ba59af6ddad1130f61749d648c1 diff --git a/sims/verisim/Makefile b/sims/verisim/Makefile index 93f45d5a..485b2357 100644 --- a/sims/verisim/Makefile +++ b/sims/verisim/Makefile @@ -22,8 +22,8 @@ sim_name = verilator # vcs simulator types and rules ######################################################################################### sim_prefix = simulator -sim = $(sim_dir)/$(sim_prefix)-$(PROJECT)-$(CONFIG) -sim_debug = $(sim_dir)/$(sim_prefix)-$(PROJECT)-$(CONFIG)-debug +sim = $(sim_dir)/$(sim_prefix)-$(MODEL_PACKAGE)-$(CONFIG) +sim_debug = $(sim_dir)/$(sim_prefix)-$(MODEL_PACKAGE)-$(CONFIG)-debug .PHONY: default debug default: $(sim) @@ -78,7 +78,7 @@ $(sim_debug): $(model_mk_debug) $(MAKE) VM_PARALLEL_BUILDS=1 -C $(build_dir)/$(long_name).debug -f V$(VLOG_MODEL).mk ######################################################################################### -# create a vcs vpd rule +# create a verisim vpd rule ######################################################################################### $(output_dir)/%.vpd: $(output_dir)/% $(sim_debug) rm -f $@.vcd && mkfifo $@.vcd diff --git a/sims/vsim/Makefile b/sims/vsim/Makefile index be8fd716..374e2f89 100644 --- a/sims/vsim/Makefile +++ b/sims/vsim/Makefile @@ -22,8 +22,8 @@ sim_name = vcs # vcs simulator types and rules ######################################################################################### sim_prefix = simv -sim = $(sim_dir)/$(sim_prefix)-$(PROJECT)-$(CONFIG) -sim_debug = $(sim_dir)/$(sim_prefix)-$(PROJECT)-$(CONFIG)-debug +sim = $(sim_dir)/$(sim_prefix)-$(MODEL_PACKAGE)-$(CONFIG) +sim_debug = $(sim_dir)/$(sim_prefix)-$(MODEL_PACKAGE)-$(CONFIG)-debug .PHONY: default debug default: $(sim) diff --git a/src/main/scala/example/Configs.scala b/src/main/scala/example/Configs.scala index 52ee21de..57e4300f 100644 --- a/src/main/scala/example/Configs.scala +++ b/src/main/scala/example/Configs.scala @@ -17,6 +17,10 @@ class DefaultRocketConfig extends Config( new WithNormalRocketTop ++ new BaseRocketConfig) +class HwachaConfig extends Config( + new hwacha.DefaultHwachaConfig ++ + new DefaultRocketConfig) + class RoccRocketConfig extends Config( new WithRoccExample ++ new DefaultRocketConfig) @@ -64,6 +68,10 @@ class DefaultBoomConfig extends Config( new WithNormalBoomTop ++ new BaseBoomConfig) +class HwachaBoomConfig extends Config( + new hwacha.DefaultHwachaConfig ++ + new DefaultBoomConfig) + class RoccBoomConfig extends Config( new WithRoccExample ++ new DefaultBoomConfig) diff --git a/variables.mk b/variables.mk index 9b52c45c..43e1f0c5 100644 --- a/variables.mk +++ b/variables.mk @@ -3,53 +3,88 @@ ######################################################################################### ######################################################################################### -# default variables to invoke the generator for a example Rocket system +# variables to invoke the generator # descriptions: -# PROJECT = the scala package to find the MODEL/Generator in +# SBT_PROJECT = the SBT project that you should find the classes/packages in # MODEL = the top level module of the project in Chisel (normally the harness) # VLOG_MODEL = the top level module of the project in Firrtl/Verilog (normally the harness) +# MODEL_PACKAGE = the scala package to find the MODEL in # CONFIG = the configuration class to give the parameters for the project -# CFG_PROJECT = the scala package to find the CONFIG class -# SBT_PROJECT = the SBT project that you should find the Generator class in -# TB = wrapper over the TestHarness needed to simulate in VCS +# CONFIG_PACKAGE = the scala package to find the CONFIG class +# GENERATOR_PACKAGE = the scala package to find the Generator class in +# TB = wrapper over the TestHarness needed to simulate in a verilog simulator # TOP = top level module of the project (normally the module instantiated by the harness) # # project specific: # SUB_PROJECT = use the specific subproject default variables ######################################################################################### -PROJECT ?= example -MODEL ?= RocketTestHarness -VLOG_MODEL ?= TestHarness -CONFIG ?= DefaultRocketConfig -CFG_PROJECT ?= $(PROJECT) -SBT_PROJECT ?= $(PROJECT) -TB ?= TestDriver -TOP ?= RocketTop -# make it so that you only change 1 param to change most or all of them! +######################################################################################### +# subproject overrides +# description: +# - make it so that you only change 1 param to change most or all of them! +# - mainly intended for quick developer setup for common flags +######################################################################################### SUB_PROJECT ?= example + +ifeq ($(SUB_PROJECT),example) + SBT_PROJECT ?= example + MODEL ?= RocketTestHarness + VLOG_MODEL ?= TestHarness + MODEL_PACKAGE ?= $(SBT_PROJECT) + CONFIG ?= DefaultRocketConfig + CONFIG_PACKAGE ?= $(SBT_PROJECT) + GENERATOR_PACKAGE ?= $(SBT_PROJECT) + TB ?= TestDriver + TOP ?= RocketTop +endif +# for a BOOM based example system ifeq ($(SUB_PROJECT),boomexample) - # for a BOOM based system (provides all necessary params) - MODEL=BoomTestHarness - CONFIG=DefaultBoomConfig - TOP=BoomTop + SBT_PROJECT ?= example + MODEL ?= BoomTestHarness + VLOG_MODEL ?= TestHarness + MODEL_PACKAGE ?= $(SBT_PROJECT) + CONFIG ?= DefaultBoomConfig + CONFIG_PACKAGE ?= $(SBT_PROJECT) + GENERATOR_PACKAGE ?= $(SBT_PROJECT) + TB ?= TestDriver + TOP ?= BoomTop endif +# for BOOM developers ifeq ($(SUB_PROJECT),boom) - # for BOOM developers (only need to provide a CONFIG) - PROJECT=boom.system - MODEL=TestHarness - CFG_PROJECT=boom.system - SBT_PROJECT=boom - TOP=ExampleBoomSystem + SBT_PROJECT ?= boom + MODEL ?= TestHarness + VLOG_MODEL ?= TestHarness + MODEL_PACKAGE ?= boom.system + CONFIG ?= BoomConfig + CONFIG_PACKAGE ?= boom.system + GENERATOR_PACKAGE ?= boom.system + TB ?= TestDriver + TOP ?= ExampleBoomSystem endif +# for Rocket-chip developers ifeq ($(SUB_PROJECT),rocketchip) - # for Rocket-chip developers - PROJECT=freechips.rocketchip.system - MODEL=TestHarness - CONFIG=DefaultConfig - CFG_PROJECT=freechips.rocketchip.system - SBT_PROJECT=rebarrocketchip - TOP=ExampleRocketSystem + SBT_PROJECT ?= rebarrocketchip + MODEL ?= TestHarness + VLOG_MODEL ?= TestHarness + MODEL_PACKAGE ?= freechips.rocketchip.system + CONFIG ?= DefaultConfig + CONFIG_PACKAGE ?= freechips.rocketchip.system + GENERATOR_PACKAGE ?= freechips.rocketchip.system + TB ?= TestDriver + TOP ?= ExampleRocketSystem +endif +# for Hwacha developers +ifeq ($(SUB_PROJECT),hwacha) + SBT_PROJECT ?= hwacha + MODEL ?= TestHarness + VLOG_MODEL ?= TestHarness + MODEL_PACKAGE ?= freechips.rocketchip.system + CONFIG ?= HwachaConfig + CONFIG_PACKAGE ?= hwacha + GENERATOR_PACKAGE ?= hwacha + TB ?= TestDriver + TOP ?= ExampleRocketSystem endif ######################################################################################### @@ -62,11 +97,14 @@ REBAR_FIRRTL_DIR = $(base_dir)/tools/firrtl ######################################################################################### # names of various files needed to compile and run things ######################################################################################### -long_name = $(PROJECT).$(MODEL).$(CONFIG) +long_name = $(MODEL_PACKAGE).$(MODEL).$(CONFIG) -# if building from rocketchip, override the long_name to match what they expect -ifeq ($(SBT_PROJECT),rebarrocketchip) - long_name=$(PROJECT).$(CONFIG) +# match the long_name to what the specific generator will output +ifeq ($(GENERATOR_PACKAGE),freechips.rocketchip.system) + long_name=$(CONFIG_PACKAGE).$(CONFIG) +endif +ifeq ($(GENERATOR_PACKAGE),hwacha) + long_name=$(MODEL_PACKAGE).$(CONFIG) endif FIRRTL_FILE ?= $(build_dir)/$(long_name).fir @@ -100,7 +138,7 @@ output_dir=$(sim_dir)/output ######################################################################################### # build output directory for compilation ######################################################################################### -build_dir=$(sim_dir)/generated-src +build_dir=$(sim_dir)/generated-src/$(long_name) ######################################################################################### # vsrcs needed to run projects