From 5ab7540596679b2ca630f2f414e45c0f348a66b7 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 27 Jan 2026 23:57:32 +0800 Subject: [PATCH] Add alternative Rocket Chip setup using local source checkout --- emulator/build.sc | 78 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 71 insertions(+), 7 deletions(-) diff --git a/emulator/build.sc b/emulator/build.sc index 9a3883a..d8ea637 100644 --- a/emulator/build.sc +++ b/emulator/build.sc @@ -7,10 +7,12 @@ import scalalib._ // support BSP import mill.bsp._ -object emulator extends ScalaModule { - def millSourcePath = os.pwd - def scalaVersion = "2.13.12" +/** Local rocket-chip checkout path */ +def rocketRoot = os.Path("/workspace/rocket-chip") +/** Common settings */ +trait CommonScala extends ScalaModule { + def scalaVersion = "2.13.12" def scalacOptions = Seq( "-language:reflectiveCalls", "-deprecation", @@ -18,21 +20,83 @@ object emulator extends ScalaModule { "-Xcheckinit", "-Ymacro-annotations", ) + + + override def ivyDeps = Agg( + ivy"org.chipsalliance::chisel:6.0.0" + ) + + override def scalacPluginIvyDeps = Agg( + ivy"org.chipsalliance:::chisel-plugin:6.0.0" + ) +} +// /** ---- Local rocket-chip submodules (from rocket-chip/dependencies/*) ---- +// * These folders exist in your local clone. We compile them as source modules +// * so we don't rely on remote SNAPSHOT artifacts. +// * +// * Path assumptions (based on typical rocket-chip layout): +// * rocket-chip/dependencies/cde/cde/src/... +// * rocket-chip/dependencies/diplomacy/diplomacy/src/... +// * rocket-chip/dependencies/hardfloat/hardfloat/src/... +// * +// * If your folder names differ slightly, adjust millSourcePath accordingly. +// */ +object cde extends CommonScala { + def millSourcePath = rocketRoot / "dependencies" / "cde" / "cde" +} + +object diplomacy extends CommonScala { + def millSourcePath = rocketRoot / "dependencies" / "diplomacy" / "diplomacy" + override def moduleDeps = Seq(cde) +} + +object hardfloat extends CommonScala { + def millSourcePath = rocketRoot / "dependencies" / "hardfloat" / "hardfloat" +} + +/** ---- Local rocket-chip main module ---- */ +object rocketchip extends CommonScala { + def millSourcePath = rocketRoot + + // Ensure rocket-chip sees its local submodules + override def moduleDeps = Seq(cde, diplomacy, hardfloat) + + // rocket-chip needs extra libs: mainargs + json4s-jackson + override def ivyDeps = super.ivyDeps() ++ Agg( + ivy"com.lihaoyi::mainargs:0.7.6", + ivy"org.json4s::json4s-jackson:4.0.7" + ) +} + + +/** ---- Your emulator module ---- */ +object emulator extends CommonScala { + def millSourcePath = os.pwd + + // Make emulator depend on the local rocket-chip build outputs + override def moduleDeps = Seq(rocketchip) + override def ivyDeps = Agg( ivy"org.chipsalliance::chisel:6.0.0", - ivy"edu.berkeley.cs::rocketchip-6.0.0:1.6-6.0.0-1b9f43352-SNAPSHOT", ivy"com.lihaoyi::pprint:0.9.0" ) + override def scalacPluginIvyDeps = Agg( ivy"org.chipsalliance:::chisel-plugin:6.0.0", ) - // https://mill-build.org/mill/0.11.12/Scala_Module_Config.html + // Keep these repos (harmless), but no longer required for rocketchip SNAPSHOT val sonatypeReleases = Seq( coursier.maven.MavenRepository("https://oss.sonatype.org/content/repositories/snapshots/"), coursier.maven.MavenRepository("https://oss.sonatype.org/content/repositories/releases/"), ) + val extraRepos = Seq( + coursier.maven.MavenRepository("https://repo.maven.apache.org/maven2"), + coursier.maven.MavenRepository("https://maven.aliyun.com/repository/central"), + coursier.maven.MavenRepository("https://mirrors.cloud.tencent.com/nexus/repository/maven-public/") + ) + def repositoriesTask = T.task { - super.repositoriesTask() ++ sonatypeReleases + super.repositoriesTask() ++ extraRepos ++ sonatypeReleases } -} +} \ No newline at end of file