diff --git a/.ctags b/.ctags new file mode 100644 index 00000000..b7d31250 --- /dev/null +++ b/.ctags @@ -0,0 +1,13 @@ +--langdef=scala +--langmap=scala:.scala + +--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*(private[^ ]*|protected)?[ \t]*class[ \t]+([a-zA-Z0-9_]+)/\4/c,classes/ +--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*(private[^ ]*|protected)?[ \t]*object[ \t]+([a-zA-Z0-9_]+)/\4/o,objects/ +--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*(private[^ ]*|protected)?[ \t]*((abstract|final|sealed|implicit|lazy)[ \t ]*)*case class[ \t ]+([a-zA-Z0-9_]+)/\6/C,case classes/ +--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*(private[^ ]*|protected)?[ \t]*case object[ \t]+([a-zA-Z0-9_]+)/\4/O,case objects/ +--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*(private[^ ]*|protected)?[ \t]*trait[ \t]+([a-zA-Z0-9_]+)/\4/t,traits/ +--regex-scala=/^[ \t]*type[ \t]+([a-zA-Z0-9_]+)/\1/T,types/ +--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy|override|private[^ ]*(\[[a-z]*\])*|protected)[ \t]*)*def[ \t]+([a-zA-Z0-9_]+)/\4/m,methods/ +--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy|override|private[^ ]*|protected)[ \t]*)*val[ \t]+([a-zA-Z0-9_]+)/\3/V,values/ +--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy|override|private[^ ]*|protected)[ \t]*)*var[ \t]+([a-zA-Z0-9_]+)/\3/v,variables/ +--regex-scala=/^[ \t]*package[ \t]+([a-zA-Z0-9_.]+)/\1/p,packages/ diff --git a/.gitmodules b/.gitmodules index 72203f96..3d3a7a73 100644 --- a/.gitmodules +++ b/.gitmodules @@ -19,3 +19,9 @@ [submodule "esp-tools"] path = toolchains/esp-tools url = https://github.com/ucb-bar/esp-tools.git +[submodule "tools/torture"] + path = tools/torture + url = git@github.com:ucb-bar/riscv-torture.git +[submodule "generators/boom"] + path = generators/boom + url = git@github.com:riscv-boom/riscv-boom.git diff --git a/README.md b/README.md index 8f07c855..887dce08 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # RISC-V Project Template -**THIS BRANCH IS UNDER DEVELOPMENT** -**IT CURRENTLY HAS MANY SUBMODULES** -**PLEASE RUN ./build.sh TO UPDATE SUBMODULES, UNLESS YOU WANT TO SPEND A LONG TIME WAITING FOR SUBMODULE TO CLONE** +**This branch is under development** +**It currently has many submodules** +**Please run ./scripts/init-submodules-no-riscv-tools.sh to update submodules, unless you want to spend a long time waiting for submodule to clone** This is a starter template for your custom RISC-V project. It will allow you to leverage the Chisel HDL and RocketChip SoC generator to produce a @@ -62,6 +62,26 @@ follows. * bootrom - sources for the first-stage bootloader included in the Boot ROM * src/main/scala - scala source files for your project go here +## For submodule developers + +Depending on the submodule that you develop in, you might want to run things out of the submodule. +For example, `boom` has its own Generator, package, top module, and configurations separate from +the `example` package in `src/main/scala`. Thus, to build a `boom` project you do something like +the following: + + make SBT_PROJECT=boom PROJECT=boom.system CONFIG= TOP=ExampleBoomSystem + +However, that is very long to write everytime there is a compile. Thus, a shorthand way to build +the subproject is the following: + + make SUB_PROJECT=boom CONFIG= + +This sets the proper configuration flags for make to work correctly. + +Currently, the supported `SUB_PROJECT` flags are: + + * boom - to build and run `boom` subproject configurations + ## Using the block device The default example project just provides the Rocket coreplex, memory, and diff --git a/build.sbt b/build.sbt index 2d217ba4..41ccfc36 100644 --- a/build.sbt +++ b/build.sbt @@ -8,21 +8,25 @@ lazy val commonSettings = Seq( case PathList("META-INF", "MANIFEST.MF") => MergeStrategy.discard case _ => MergeStrategy.first}}, scalacOptions ++= Seq("-deprecation","-unchecked","-Xsource:2.11"), - libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test", - libraryDependencies += "org.json4s" %% "json4s-native" % "3.5.3", + libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % "test", + libraryDependencies += "org.json4s" %% "json4s-native" % "3.6.1", libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value, libraryDependencies += "edu.berkeley.cs" %% "firrtl-interpreter" % "1.2-SNAPSHOT", - libraryDependencies += "com.github.scopt" %% "scopt" % "3.7.1", + libraryDependencies += "com.github.scopt" %% "scopt" % "3.7.0", addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full), resolvers ++= Seq( Resolver.sonatypeRepo("snapshots"), Resolver.sonatypeRepo("releases"), Resolver.mavenLocal)) +lazy val rebarFirrtl = (project in file("tools/firrtl")) + .settings(commonSettings) + lazy val rocketchip = RootProject(file("generators/rocket-chip")) -lazy val testchipip = (project in file("generators/testchipip")).settings(commonSettings) +lazy val testchipip = (project in file("generators/testchipip")) .dependsOn(rocketchip) + .settings(commonSettings) // Checks for -DROCKET_USE_MAVEN. // If it's there, use a maven dependency. @@ -36,16 +40,22 @@ def conditionalDependsOn(prj: Project): Project = { prj.dependsOn(testchipip) } } + lazy val example = conditionalDependsOn(project in file(".")) .settings(commonSettings) +lazy val boom = (project in file("generators/boom")) + .dependsOn(rocketchip) + .settings(commonSettings) + lazy val tapeout = conditionalDependsOn(project in file("./tools/barstools/tapeout/")) + .dependsOn(rebarFirrtl) .settings(commonSettings) lazy val mdf = (project in file("./tools/barstools/mdf/scalalib/")) + .settings(commonSettings) -lazy val `barstools-macros` = conditionalDependsOn(project in file("./tools/barstools/macros/")) +lazy val `barstools-macros` = (project in file("./tools/barstools/macros/")) + .dependsOn(mdf, rocketchip, rebarFirrtl) .enablePlugins(sbtassembly.AssemblyPlugin) .settings(commonSettings) - .dependsOn(mdf) - diff --git a/common.mk b/common.mk index 0f9e176e..b090285d 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 +PACKAGES=rocket-chip testchipip boom 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) ######################################################################################### @@ -22,10 +22,10 @@ TESTCHIPIP_CLASSES ?= "$(TESTCHIP_DIR)/target/scala-$(SCALA_VERSION_MAJOR)/class ######################################################################################### FIRRTL_JAR ?= $(ROCKETCHIP_DIR)/lib/firrtl.jar -$(FIRRTL_JAR): $(call lookup_scala_srcs, $(ROCKETCHIP_DIR)/firrtl/src/main/scala) - $(MAKE) -C $(ROCKETCHIP_DIR)/firrtl SBT="$(SBT)" root_dir=$(ROCKETCHIP_DIR)/firrtl build-scala +$(FIRRTL_JAR): $(call lookup_scala_srcs, $(REBAR_FIRRTL_DIR)/src/main/scala) + $(MAKE) -C $(REBAR_FIRRTL_DIR) SBT="$(SBT)" root_dir=$(REBAR_FIRRTL_DIR) build-scala mkdir -p $(dir $@) - cp -p $(ROCKETCHIP_DIR)/firrtl/utils/bin/firrtl.jar $@ + cp -p $(REBAR_FIRRTL_DIR)/utils/bin/firrtl.jar $@ touch $@ ######################################################################################### @@ -41,7 +41,7 @@ CHISEL_ARGS ?= $(FIRRTL_FILE) $(ANNO_FILE): $(SCALA_SOURCES) $(sim_dotf) mkdir -p $(build_dir) - cd $(base_dir) && $(SBT) "runMain $(PROJECT).Generator $(CHISEL_ARGS) $(build_dir) $(PROJECT) $(MODEL) $(CFG_PROJECT) $(CONFIG)" + cd $(base_dir) && $(SBT) "project $(SBT_PROJECT)" "runMain $(PROJECT).Generator $(CHISEL_ARGS) $(build_dir) $(PROJECT) $(MODEL) $(CFG_PROJECT) $(CONFIG)" ######################################################################################### # create verilog files rules and variables diff --git a/generators/boom b/generators/boom new file mode 160000 index 00000000..4cd347ed --- /dev/null +++ b/generators/boom @@ -0,0 +1 @@ +Subproject commit 4cd347ed51f8bdf98d2d1868cf1530d845539613 diff --git a/project/plugins.sbt b/project/plugins.sbt index df29eabe..9d35b376 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,17 @@ -addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.5") -addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.2") +resolvers += Resolver.url("scalasbt", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases")) (Resolver.ivyStylePatterns) +resolvers += Classpaths.sbtPluginReleases +resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven" +addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.2") +addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.2") +addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.3.1") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0") +addSbtPlugin("org.xerial.sbt" % "sbt-pack" % "0.9.3") +addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.1") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1") +addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0") +addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6") +addSbtPlugin("com.simplytyped" % "sbt-antlr4" % "0.8.1") +addSbtPlugin("com.github.gseitz" % "sbt-protobuf" % "0.6.3") + +libraryDependencies += "com.github.os72" % "protoc-jar" % "3.5.1.1" diff --git a/build.sh b/scripts/init-submodules-no-riscv-tools.sh old mode 100644 new mode 100755 similarity index 100% rename from build.sh rename to scripts/init-submodules-no-riscv-tools.sh diff --git a/src/main/scala/example/Simulator.scala b/src/main/scala/example/Simulator.scala index 240f930f..09c2cd77 100644 --- a/src/main/scala/example/Simulator.scala +++ b/src/main/scala/example/Simulator.scala @@ -101,6 +101,7 @@ object GenerateSimFiles extends App with HasGenerateSimConfig { def writeBootrom(): Unit = { firrtl.FileUtils.makeDirectory("./bootrom/") writeResource("/testchipip/bootrom/bootrom.rv64.img", "./bootrom/") + writeResource("/testchipip/bootrom/bootrom.rv32.img", "./bootrom/") } def writeFiles(cfg: GenerateSimConfig): Unit = { diff --git a/tools/firrtl b/tools/firrtl index 2272044c..bf66997b 160000 --- a/tools/firrtl +++ b/tools/firrtl @@ -1 +1 @@ -Subproject commit 2272044c6ab46b5148c39c124e66e1a8e9073a24 +Subproject commit bf66997b1a2438a322cd619ca2b6aeb0f0ac0ba0 diff --git a/tools/torture b/tools/torture new file mode 160000 index 00000000..59b0f0f2 --- /dev/null +++ b/tools/torture @@ -0,0 +1 @@ +Subproject commit 59b0f0f224ff4f1eb6ebb1b4dd7eaf1ab3fac2e5 diff --git a/variables.mk b/variables.mk index 29a48c6c..5aea54a5 100644 --- a/variables.mk +++ b/variables.mk @@ -5,25 +5,38 @@ ######################################################################################### # default variables to invoke the generator # descriptions: -# PROJECT = the scala package to find the MODEL in +# PROJECT = the scala package to find the MODEL/Generator in # MODEL = the top level module of the project (normally the harness) # 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 # 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 ?= TestHarness CONFIG ?= DefaultExampleConfig CFG_PROJECT ?= $(PROJECT) +SBT_PROJECT ?= $(PROJECT) TB ?= TestDriver TOP ?= ExampleTop +SUB_PROJECT ?= example +ifeq ($(SUB_PROJECT),boom) # make it so that you only change 1 param to change them all! + SBT_PROJECT=boom + PROJECT=boom.system + TOP=ExampleBoomSystem +endif + ######################################################################################### # path to rocket-chip and testchipip ######################################################################################### -ROCKETCHIP_DIR = $(base_dir)/generators/rocket-chip -TESTCHIP_DIR = $(base_dir)/generators/testchipip +ROCKETCHIP_DIR = $(base_dir)/generators/rocket-chip +TESTCHIP_DIR = $(base_dir)/generators/testchipip +REBAR_FIRRTL_DIR = $(base_dir)/tools/firrtl ######################################################################################### # names of various files needed to compile and run things