From e0d1ba285d27367deed7f1cdec45834e7f0ecef9 Mon Sep 17 00:00:00 2001 From: Jerry Zhao Date: Tue, 23 Apr 2019 16:20:23 -0700 Subject: [PATCH 1/7] Add Hwacha config to example project --- .gitmodules | 3 +++ build.sbt | 6 +++++- generators/hwacha | 1 + src/main/scala/example/Configs.scala | 8 ++++++++ variables.mk | 16 +++++++++++++--- 5 files changed, 30 insertions(+), 4 deletions(-) create mode 160000 generators/hwacha 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/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/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..606bf47f 100644 --- a/variables.mk +++ b/variables.mk @@ -28,22 +28,22 @@ TOP ?= RocketTop # make it so that you only change 1 param to change most or all of them! SUB_PROJECT ?= example +# for a BOOM based system (provides all necessary params) ifeq ($(SUB_PROJECT),boomexample) - # for a BOOM based system (provides all necessary params) MODEL=BoomTestHarness CONFIG=DefaultBoomConfig TOP=BoomTop endif +# for BOOM developers (only need to provide a CONFIG) 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 endif +# for Rocket-chip developers ifeq ($(SUB_PROJECT),rocketchip) - # for Rocket-chip developers PROJECT=freechips.rocketchip.system MODEL=TestHarness CONFIG=DefaultConfig @@ -51,6 +51,16 @@ ifeq ($(SUB_PROJECT),rocketchip) SBT_PROJECT=rebarrocketchip TOP=ExampleRocketSystem endif +# for Hwacha developers (only need to provide a CONFIG) +ifeq ($(SUB_PROJECT),hwacha) + PROJECT=freechips.rocketchip.system + MODEL=TestHarness + CFG_PROJECT=hwacha + SBT_PROJECT=hwacha + TOP=ExampleRocketSystem + TB=TestDriver + CONFIG=HwachaConfig +endif ######################################################################################### # path to rocket-chip and testchipip From 017a3c23507f922fdbdc894dd3233d7e20ec4a9a Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Tue, 23 Apr 2019 18:34:42 -0700 Subject: [PATCH 2/7] support rocketchip longname from generator | extra comments | subprojects specify configs --- variables.mk | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/variables.mk b/variables.mk index 606bf47f..8e4947a7 100644 --- a/variables.mk +++ b/variables.mk @@ -26,15 +26,21 @@ 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 +# - for each you only need to specify a CONFIG +######################################################################################### SUB_PROJECT ?= example -# for a BOOM based system (provides all necessary params) + +# for a BOOM based example system ifeq ($(SUB_PROJECT),boomexample) MODEL=BoomTestHarness - CONFIG=DefaultBoomConfig TOP=BoomTop endif -# for BOOM developers (only need to provide a CONFIG) +# for BOOM developers ifeq ($(SUB_PROJECT),boom) PROJECT=boom.system MODEL=TestHarness @@ -46,12 +52,11 @@ endif ifeq ($(SUB_PROJECT),rocketchip) PROJECT=freechips.rocketchip.system MODEL=TestHarness - CONFIG=DefaultConfig CFG_PROJECT=freechips.rocketchip.system SBT_PROJECT=rebarrocketchip TOP=ExampleRocketSystem endif -# for Hwacha developers (only need to provide a CONFIG) +# for Hwacha developers ifeq ($(SUB_PROJECT),hwacha) PROJECT=freechips.rocketchip.system MODEL=TestHarness @@ -59,7 +64,6 @@ ifeq ($(SUB_PROJECT),hwacha) SBT_PROJECT=hwacha TOP=ExampleRocketSystem TB=TestDriver - CONFIG=HwachaConfig endif ######################################################################################### @@ -75,8 +79,8 @@ REBAR_FIRRTL_DIR = $(base_dir)/tools/firrtl long_name = $(PROJECT).$(MODEL).$(CONFIG) # if building from rocketchip, override the long_name to match what they expect -ifeq ($(SBT_PROJECT),rebarrocketchip) - long_name=$(PROJECT).$(CONFIG) +ifeq ($(PROJECT),freechips.rocketchip.system) + long_name=$(CFG_PROJECT).$(CONFIG) endif FIRRTL_FILE ?= $(build_dir)/$(long_name).fir From 4c3dc0889ce5fc9391def2a4af912cdc335ebaed Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Wed, 24 Apr 2019 00:43:44 -0700 Subject: [PATCH 3/7] update make variable names | change hwacha to use its own generator --- common.mk | 2 +- sims/verisim/Makefile | 4 +-- sims/vsim/Makefile | 4 +-- variables.mk | 57 ++++++++++++++++++++++++------------------- 4 files changed, 37 insertions(+), 30 deletions(-) diff --git a/common.mk b/common.mk index d7703f7e..f5aea9b8 100644 --- a/common.mk +++ b/common.mk @@ -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 diff --git a/sims/verisim/Makefile b/sims/verisim/Makefile index 93f45d5a..7de100d8 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) 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/variables.mk b/variables.mk index 8e4947a7..6917f763 100644 --- a/variables.mk +++ b/variables.mk @@ -5,26 +5,28 @@ ######################################################################################### # default variables to invoke the generator for a example Rocket system # 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 +# 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 VCS # 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 +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 ######################################################################################### # subproject overrides @@ -42,28 +44,30 @@ ifeq ($(SUB_PROJECT),boomexample) endif # for BOOM developers ifeq ($(SUB_PROJECT),boom) - PROJECT=boom.system - MODEL=TestHarness - CFG_PROJECT=boom.system SBT_PROJECT=boom + MODEL_PACKAGE=boom.system + MODEL=TestHarness + CONFIG_PACKAGE=boom.system + GENERATOR_PACKAGE=boom.system TOP=ExampleBoomSystem endif # for Rocket-chip developers ifeq ($(SUB_PROJECT),rocketchip) - PROJECT=freechips.rocketchip.system - MODEL=TestHarness - CFG_PROJECT=freechips.rocketchip.system SBT_PROJECT=rebarrocketchip + MODEL_PACKAGE=freechips.rocketchip.system + MODEL=TestHarness + CONFIG_PACKAGE=freechips.rocketchip.system + GENERATOR_PACKAGE=freechips.rocketchip.system TOP=ExampleRocketSystem endif # for Hwacha developers ifeq ($(SUB_PROJECT),hwacha) - PROJECT=freechips.rocketchip.system - MODEL=TestHarness - CFG_PROJECT=hwacha SBT_PROJECT=hwacha + MODEL_PACKAGE=freechips.rocketchip.system + MODEL=TestHarness + CONFIG_PACKAGE=hwacha + GENERATOR_PACKAGE=hwacha TOP=ExampleRocketSystem - TB=TestDriver endif ######################################################################################### @@ -76,11 +80,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 ($(PROJECT),freechips.rocketchip.system) - long_name=$(CFG_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 From 575980e337e48446884c14f674f6f3592fd80356 Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Wed, 24 Apr 2019 11:18:12 -0700 Subject: [PATCH 4/7] track src changes correctly in make --- common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.mk b/common.mk index f5aea9b8..16afa6f6 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) ######################################################################################### From b88937b8a0cb664baea7d57f09360c07cb37c129 Mon Sep 17 00:00:00 2001 From: Jerry Zhao Date: Wed, 24 Apr 2019 18:23:26 -0700 Subject: [PATCH 5/7] Fix vcs tests for rocketchip and hwacha --- common.mk | 2 +- sims/verisim/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common.mk b/common.mk index 16afa6f6..f93e44a6 100644 --- a/common.mk +++ b/common.mk @@ -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/sims/verisim/Makefile b/sims/verisim/Makefile index 7de100d8..485b2357 100644 --- a/sims/verisim/Makefile +++ b/sims/verisim/Makefile @@ -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 From 2e53de6f2220886f561b7f7bf1b39995a5fd309f Mon Sep 17 00:00:00 2001 From: Jerry Zhao Date: Thu, 25 Apr 2019 13:33:08 -0700 Subject: [PATCH 6/7] Allow default configs for sub projects | have separate build_dir based on long_name --- variables.mk | 81 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 32 deletions(-) diff --git a/variables.mk b/variables.mk index 6917f763..bc1f78c1 100644 --- a/variables.mk +++ b/variables.mk @@ -3,7 +3,7 @@ ######################################################################################### ######################################################################################### -# default variables to invoke the generator for a example Rocket system +# variables to invoke the generator # descriptions: # 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) @@ -18,56 +18,73 @@ # project specific: # SUB_PROJECT = use the specific subproject default variables ######################################################################################### -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 ######################################################################################### # 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 -# - for each you only need to specify a CONFIG ######################################################################################### 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) - MODEL=BoomTestHarness - 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) - SBT_PROJECT=boom - MODEL_PACKAGE=boom.system - MODEL=TestHarness - CONFIG_PACKAGE=boom.system - GENERATOR_PACKAGE=boom.system - 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) - SBT_PROJECT=rebarrocketchip - MODEL_PACKAGE=freechips.rocketchip.system - MODEL=TestHarness - CONFIG_PACKAGE=freechips.rocketchip.system - GENERATOR_PACKAGE=freechips.rocketchip.system - 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_PACKAGE=freechips.rocketchip.system - MODEL=TestHarness - CONFIG_PACKAGE=hwacha - GENERATOR_PACKAGE=hwacha - TOP=ExampleRocketSystem + 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 ######################################################################################### @@ -121,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 From fa0cc26737437d56e12d1d051ce81fd7203f34d1 Mon Sep 17 00:00:00 2001 From: Jerry Zhao Date: Mon, 29 Apr 2019 15:11:23 -0700 Subject: [PATCH 7/7] Remove references to VCS in variables.mk --- variables.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variables.mk b/variables.mk index bc1f78c1..43e1f0c5 100644 --- a/variables.mk +++ b/variables.mk @@ -12,7 +12,7 @@ # CONFIG = the configuration class to give the parameters for the project # 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 VCS +# 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: