From 0e94154d57144a3e5c7943c9f638f522b2361396 Mon Sep 17 00:00:00 2001 From: RuigeLee Date: Mon, 3 Jul 2023 16:25:19 +0800 Subject: [PATCH] add rocketchip --- build.sbt | 97 ++++++++++++++++++++++++++++++++++++++++++++- project/plugins.sbt | 32 +++++++++++++++ 2 files changed, 128 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 9e91ec3..0ae02a0 100644 --- a/build.sbt +++ b/build.sbt @@ -1,12 +1,107 @@ // See README.md for license details. -ThisBuild / scalaVersion := "2.13.8" +ThisBuild / scalaVersion := "2.13.10" ThisBuild / version := "0.1.0" ThisBuild / organization := "%ORGANIZATION%" val chiselVersion = "3.5.6" +lazy val commonSettings = Seq( + // organization := "edu.berkeley.cs", + // version := "1.6", + assembly / assemblyMergeStrategy := { _ match { + case PathList("META-INF", "MANIFEST.MF") => MergeStrategy.discard + case _ => MergeStrategy.first}}, + scalacOptions ++= Seq( + "-deprecation", + "-unchecked", + "-Ymacro-annotations"), // fix hierarchy API +) + +lazy val chiselSettings = Seq( + libraryDependencies ++= Seq("edu.berkeley.cs" %% "chisel3" % chiselVersion, + "org.apache.commons" % "commons-lang3" % "3.12.0", + "org.apache.commons" % "commons-text" % "1.9"), + addCompilerPlugin("edu.berkeley.cs" % "chisel3-plugin" % chiselVersion cross CrossVersion.full)) + +/** + * It has been a struggle for us to override settings in subprojects. + * An example would be adding a dependency to rocketchip on midas's targetutils library, + * or replacing dsptools's maven dependency on chisel with the local chisel project. + * + * This function works around this by specifying the project's root at src/ and overriding + * scalaSource and resourceDirectory. + */ +def freshProject(name: String, dir: File): Project = { + Project(id = name, base = dir / "src") + .settings( + Compile / scalaSource := baseDirectory.value / "main" / "scala", + Compile / resourceDirectory := baseDirectory.value / "main" / "resources" + ) +} + +// Rocket-chip dependencies (subsumes making RC a RootProject) +lazy val hardfloat = (project in file("./rocket-chip/hardfloat")) + .settings(chiselSettings) + .settings(commonSettings) + .settings(name := "hardfloat", organization := "edu.berkeley.cs") + .settings( + libraryDependencies ++= Seq( + "org.scala-lang" % "scala-reflect" % scalaVersion.value, + "org.json4s" %% "json4s-jackson" % "3.6.6", + "org.scalatest" %% "scalatest" % "3.2.0" % "test" + ) + ) + +lazy val rocketMacros = (project in file("./rocket-chip/macros")) + .settings(chiselSettings) + .settings(commonSettings) + .settings(name := "rocketMacros", organization := "org.chipsalliance") + .settings( + libraryDependencies ++= Seq( + "org.scala-lang" % "scala-reflect" % scalaVersion.value, + "org.json4s" %% "json4s-jackson" % "3.6.6", + "org.scalatest" %% "scalatest" % "3.2.0" % "test" + ) + ) + +lazy val rocketConfig = (project in file("./rocket-chip/cde/cde/src/chipsalliance/rocketchip")) + .settings(chiselSettings) + .settings(commonSettings) + .settings(name := "rocketConfig", organization := "org.chipsalliance") + .settings(commonSettings) + .settings( + libraryDependencies ++= Seq( + "org.scala-lang" % "scala-reflect" % scalaVersion.value, + "org.json4s" %% "json4s-jackson" % "3.6.6", + "org.scalatest" %% "scalatest" % "3.2.0" % "test" + ) + ) + +lazy val rocketchip = freshProject("rocketchip", file("./rocket-chip")) + .dependsOn(hardfloat, rocketMacros, rocketConfig) + .settings(commonSettings) + .settings(chiselSettings) + .settings(name := "rocketchip", organization := "org.chipsalliance", version := "1.6") + .settings( + libraryDependencies ++= Seq( + "org.scala-lang" % "scala-reflect" % scalaVersion.value, + "org.json4s" %% "json4s-jackson" % "3.6.6", + "org.scalatest" %% "scalatest" % "3.2.0" % "test" + ) + ) + .settings( // Settings for scalafix + semanticdbEnabled := true, + semanticdbVersion := "4.7.6", + scalacOptions += "-Ywarn-unused" + ) +lazy val rocketLibDeps = (rocketchip / Keys.libraryDependencies) + + + + lazy val root = (project in file(".")) + .dependsOn(rocketchip) .settings( name := "%NAME%", libraryDependencies ++= Seq( diff --git a/project/plugins.sbt b/project/plugins.sbt index 5708f81..2727923 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1 +1,33 @@ logLevel := Level.Warn + +addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0") +addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.5" ) +addSbtPlugin("org.xerial.sbt" % "sbt-pack" % "0.17") + + +// addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.2") + +// addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.3.1") + +// addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") + + + +// addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.1") + +// addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0") + +// addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1") + +// addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.6.1") + + + +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.21") + +// addSbtPlugin("com.eed3si9n" % "sbt-sriracha" % "0.1.0") + + + +// addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1") +// addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.9")