diff --git a/build.mill b/build.mill new file mode 100644 index 000000000..90bda0469 --- /dev/null +++ b/build.mill @@ -0,0 +1,190 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2022 Jiuyang Liu + +package build + +import mill._ +import mill.scalalib._ +import mill.define.{Command, TaskModule} +import mill.scalalib.publish._ +import mill.scalalib.scalafmt._ +import mill.scalalib.TestModule.Utest +import mill.util.Jvm +import coursier.maven.MavenRepository + +object v { + val scala = "2.13.15" + val mainargs = ivy"com.lihaoyi::mainargs:0.5.0" + val oslib = ivy"com.lihaoyi::os-lib:0.9.1" + val upickle = ivy"com.lihaoyi::upickle:3.3.1" + val spire = ivy"org.typelevel::spire:latest.integration" + val evilplot = ivy"io.github.cibotech::evilplot:latest.integration" + val chisel = ivy"org.chipsalliance::chisel:0.0.0+0-no-vcs-SNAPSHOT" + val panamaconverter = ivy"org.chipsalliance::panamaconverter-cross:0.0.0+0-no-vcs-SNAPSHOT" + val chiselPlugin = ivy"org.chipsalliance:::chisel-plugin:0.0.0+0-no-vcs-SNAPSHOT" + val axi4 = ivy"org.chipsalliance::axi4-snapshot:0.0.0+0-no-vcs-SNAPSHOT" + val dwbb = ivy"org.chipsalliance::dwbb-snapshot:0.0.0+0-no-vcs-SNAPSHOT" + val jtag = ivy"org.chipsalliance::jtag-snapshot:0.0.0+0-no-vcs-SNAPSHOT" + val arithmetic = ivy"me.jiuyang::arithmetic-snapshot:0.0.0+0-no-vcs-SNAPSHOT" + val rvdecoderdb = ivy"me.jiuyang::rvdecoderdb-jvm:0.0.0+0-no-vcs-SNAPSHOT" + val hardfloat = ivy"edu.berkeley.cs::hardfloat-snapshot:0.0.0-SNAPSHOT" +} + +object stdlib extends Stdlib + +trait Stdlib extends common.StdlibModule with ScalafmtModule { + def scalaVersion = v.scala + + def mainargsIvy = v.mainargs + + def dwbbIvy: Dep = v.dwbb + + def chiselModule = None + def chiselPluginJar = None + def chiselIvy = Some(v.chisel) + def chiselPluginIvy = Some(v.chiselPlugin) +} + +object t1 extends T1 + +trait T1 extends common.T1Module with ScalafmtModule { + def scalaVersion = T(v.scala) + + def arithmeticIvy = v.arithmetic + def axi4Ivy = v.axi4 + def hardfloatIvy = v.hardfloat + def rvdecoderdbIvy = v.rvdecoderdb + def stdlibModule = stdlib + def riscvOpcodesPath = T.input(PathRef(millSourcePath / os.up / "dependencies" / "riscv-opcodes")) + + def chiselModule = None + def chiselPluginJar = None + def chiselIvy = Some(v.chisel) + def chiselPluginIvy = Some(v.chiselPlugin) +} + +object configgen extends ConfigGen + +trait ConfigGen extends common.ConfigGenModule with ScalafmtModule { + def scalaVersion = T(v.scala) + + def t1Module = t1 + + def mainargsIvy = v.mainargs +} + +object rocketv extends RocketV + +trait RocketV extends common.RocketVModule with ScalafmtModule { + def scalaVersion = T(v.scala) + def rvdecoderdbIvy = v.rvdecoderdb + def riscvOpcodesPath = T.input(PathRef(millSourcePath / os.up / "dependencies" / "riscv-opcodes")) + def hardfloatIvy = v.hardfloat + def axi4Ivy = v.axi4 + def stdlibModule = stdlib + + def chiselModule = None + def chiselPluginJar = None + def chiselIvy = Some(v.chisel) + def chiselPluginIvy = Some(v.chiselPlugin) +} + +object t1rocket extends T1Rocket + +trait T1Rocket extends common.T1RocketModule with ScalafmtModule { + def scalaVersion = T(v.scala) + def rocketModule = rocketv + def t1Module = t1 + + def chiselModule = None + def chiselPluginJar = None + def chiselIvy = Some(v.chisel) + def chiselPluginIvy = Some(v.chiselPlugin) +} + +object t1emu extends T1Emulator + +trait T1Emulator extends common.T1EmulatorModule with ScalafmtModule { + def scalaVersion = T(v.scala) + + def t1Module = t1 + + def chiselModule = None + def chiselPluginJar = None + def chiselIvy = Some(v.chisel) + def chiselPluginIvy = Some(v.chiselPlugin) +} + +object t1rocketemu extends T1RocketEmulator + +trait T1RocketEmulator extends common.T1RocketEmulatorModule with ScalafmtModule { + def scalaVersion = T(v.scala) + + def t1rocketModule = t1rocket + + def chiselModule = None + def chiselPluginJar = None + def chiselIvy = Some(v.chisel) + def chiselPluginIvy = Some(v.chiselPlugin) +} + +// Module to generate RTL from json config +object elaborator extends Elaborator + +trait Elaborator extends common.ElaboratorModule with ScalafmtModule { + def scalaVersion = T(v.scala) + + def panamaconverterIvy = v.panamaconverter + + def circtInstallPath = T.input(PathRef(os.Path(T.ctx().env("CIRCT_INSTALL_PATH")))) + + def generators = Seq( + t1, + t1emu, + rocketv, + t1rocket, + t1rocketemu + ) + + def mainargsIvy = v.mainargs + + def chiselModule = None + def chiselPluginJar = None + def chiselIvy = Some(v.chisel) + def chiselPluginIvy = Some(v.chiselPlugin) +} + +object omreaderlib extends OMReaderLib + +trait OMReaderLib extends common.OMReaderLibModule with ScalafmtModule { + def scalaVersion = T(v.scala) + + def panamaconverterIvy = v.panamaconverter + + def circtInstallPath = T.input(PathRef(os.Path(T.ctx().env("CIRCT_INSTALL_PATH")))) + + def mainargsIvy = v.mainargs + + def chiselModule = None + def chiselPluginJar = None + def chiselIvy = Some(v.chisel) + def chiselPluginIvy = Some(v.chiselPlugin) +} + +object omreader extends OMReader + +trait OMReader extends common.OMReaderModule with ScalafmtModule { + def scalaVersion = T(v.scala) + + def panamaconverterIvy = v.panamaconverter + def omreaderlibModule = omreaderlib + + def circtInstallPath = T.input(PathRef(os.Path(T.ctx().env("CIRCT_INSTALL_PATH")))) + + def mainargsIvy = v.mainargs + + def chiselModule = None + def chiselPluginJar = None + def chiselIvy = Some(v.chisel) + def chiselPluginIvy = Some(v.chiselPlugin) +} diff --git a/build.sc b/build.sc deleted file mode 100644 index 022c7ef8a..000000000 --- a/build.sc +++ /dev/null @@ -1,293 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2022 Jiuyang Liu - -import mill._ -import mill.scalalib._ -import mill.define.{Command, TaskModule} -import mill.scalalib.publish._ -import mill.scalalib.scalafmt._ -import mill.scalalib.TestModule.Utest -import mill.util.Jvm -import coursier.maven.MavenRepository -import $file.dependencies.chisel.build -import $file.dependencies.arithmetic.common -import $file.dependencies.`chisel-interface`.common -import $file.dependencies.`berkeley-hardfloat`.common -import $file.dependencies.rvdecoderdb.common -import $file.common - -object v { - val scala = "2.13.15" - val mainargs = ivy"com.lihaoyi::mainargs:0.5.0" - val oslib = ivy"com.lihaoyi::os-lib:0.9.1" - val upickle = ivy"com.lihaoyi::upickle:3.3.1" - val spire = ivy"org.typelevel::spire:latest.integration" - val evilplot = ivy"io.github.cibotech::evilplot:latest.integration" -} - -object chisel extends Chisel - -trait Chisel extends millbuild.dependencies.chisel.build.Chisel { - def crossValue = v.scala - override def millSourcePath = os.pwd / "dependencies" / "chisel" -} - -object arithmetic extends Arithmetic - -trait Arithmetic extends millbuild.dependencies.arithmetic.common.ArithmeticModule { - override def millSourcePath = os.pwd / "dependencies" / "arithmetic" / "arithmetic" - def scalaVersion = T(v.scala) - - def chiselModule = Some(chisel) - def chiselPluginJar = T(Some(chisel.pluginModule.jar())) - def chiselIvy = None - def chiselPluginIvy = None - - def spireIvy: T[Dep] = v.spire - def evilplotIvy: T[Dep] = v.evilplot -} - -object axi4 extends AXI4 - -trait AXI4 extends millbuild.dependencies.`chisel-interface`.common.AXI4Module { - override def millSourcePath = os.pwd / "dependencies" / "chisel-interface" / "axi4" - def scalaVersion = v.scala - - def mainargsIvy = v.mainargs - - def chiselModule = Some(chisel) - def chiselPluginJar = T(Some(chisel.pluginModule.jar())) - def chiselIvy = None - def chiselPluginIvy = None -} - -object hardfloat extends Hardfloat - -trait Hardfloat extends millbuild.dependencies.`berkeley-hardfloat`.common.HardfloatModule { - override def millSourcePath = os.pwd / "dependencies" / "berkeley-hardfloat" / "hardfloat" - def scalaVersion = T(v.scala) - - def chiselModule = Some(chisel) - def chiselPluginJar = T(Some(chisel.pluginModule.jar())) - def chiselIvy = None - def chiselPluginIvy = None -} - -object rvdecoderdb extends RVDecoderDB - -trait RVDecoderDB extends millbuild.dependencies.rvdecoderdb.common.RVDecoderDBJVMModule with ScalaModule { - def scalaVersion = T(v.scala) - def osLibIvy = v.oslib - def upickleIvy = v.upickle - override def millSourcePath = os.pwd / "dependencies" / "rvdecoderdb" / "rvdecoderdb" -} - -object dwbb extends DWBB - -trait DWBB extends millbuild.dependencies.`chisel-interface`.common.DWBBModule { - override def millSourcePath = os.pwd / "dependencies" / "chisel-interface" / "dwbb" - def scalaVersion = v.scala - - def mainargsIvy = v.mainargs - - def chiselModule = Some(chisel) - def chiselPluginJar = T(Some(chisel.pluginModule.jar())) - def chiselIvy = None - def chiselPluginIvy = None -} - -object stdlib extends Stdlib - -trait Stdlib extends millbuild.common.StdlibModule with ScalafmtModule { - def scalaVersion = v.scala - - def mainargsIvy = v.mainargs - - def dwbbModule: ScalaModule = dwbb - - def chiselModule = Some(chisel) - def chiselPluginJar = T(Some(chisel.pluginModule.jar())) - def chiselIvy = None - def chiselPluginIvy = None -} - -object t1 extends T1 - -trait T1 extends millbuild.common.T1Module with ScalafmtModule { - def scalaVersion = T(v.scala) - - def arithmeticModule = arithmetic - def axi4Module = axi4 - def hardfloatModule = hardfloat - def rvdecoderdbModule = rvdecoderdb - def stdlibModule = stdlib - def riscvOpcodesPath = T.input(PathRef(os.pwd / "dependencies" / "riscv-opcodes")) - - def chiselModule = Some(chisel) - def chiselPluginJar = T(Some(chisel.pluginModule.jar())) - def chiselIvy = None - def chiselPluginIvy = None -} - -object configgen extends ConfigGen - -trait ConfigGen extends millbuild.common.ConfigGenModule with ScalafmtModule { - def scalaVersion = T(v.scala) - - def t1Module = t1 - - def mainargsIvy = v.mainargs -} - -object rocketv extends RocketV - -trait RocketV extends millbuild.common.RocketVModule with ScalafmtModule { - def scalaVersion = T(v.scala) - def rvdecoderdbModule = rvdecoderdb - def riscvOpcodesPath = T.input(PathRef(os.pwd / "dependencies" / "riscv-opcodes")) - def hardfloatModule = hardfloat - def axi4Module = axi4 - def stdlibModule = stdlib - - def chiselModule = Some(chisel) - def chiselPluginJar = T(Some(chisel.pluginModule.jar())) - def chiselPluginIvy = None - def chiselIvy = None -} - -object t1rocket extends T1Rocket - -trait T1Rocket extends millbuild.common.T1RocketModule with ScalafmtModule { - def scalaVersion = T(v.scala) - def rocketModule = rocketv - def t1Module = t1 - - def chiselModule = Some(chisel) - def chiselPluginJar = T(Some(chisel.pluginModule.jar())) - def chiselPluginIvy = None - def chiselIvy = None -} - -object t1emu extends T1Emulator - -trait T1Emulator extends millbuild.common.T1EmulatorModule with ScalafmtModule { - def scalaVersion = T(v.scala) - - def t1Module = t1 - - def chiselModule = Some(chisel) - def chiselPluginJar = T(Some(chisel.pluginModule.jar())) - def chiselPluginIvy = None - def chiselIvy = None -} - -object t1rocketemu extends T1RocketEmulator - -trait T1RocketEmulator extends millbuild.common.T1RocketEmulatorModule with ScalafmtModule { - def scalaVersion = T(v.scala) - - def t1rocketModule = t1rocket - - def chiselModule = Some(chisel) - def chiselPluginJar = T(Some(chisel.pluginModule.jar())) - def chiselPluginIvy = None - def chiselIvy = None -} - -object panamaconverter extends PanamaConverter - -trait PanamaConverter extends millbuild.dependencies.chisel.build.PanamaConverter { - def crossValue = v.scala - - override def millSourcePath = os.pwd / "dependencies" / "chisel" / "panamaconverter" - - def scalaVersion = T(v.scala) -} - -// Module to generate RTL from json config -object elaborator extends Elaborator - -trait Elaborator extends millbuild.common.ElaboratorModule with ScalafmtModule { - def scalaVersion = T(v.scala) - - def panamaconverterModule = panamaconverter - - def circtInstallPath = T.input(PathRef(os.Path(T.ctx().env("CIRCT_INSTALL_PATH")))) - - def generators = Seq( - t1, - t1emu, - rocketv, - t1rocket, - t1rocketemu - ) - - def mainargsIvy = v.mainargs - - def chiselModule = Some(chisel) - def chiselPluginJar = T(Some(chisel.pluginModule.jar())) - def chiselPluginIvy = None - def chiselIvy = None -} - -object omreaderlib extends OMReaderLib - -trait OMReaderLib extends millbuild.common.OMReaderLibModule with ScalafmtModule { - def scalaVersion = T(v.scala) - - def panamaconverterModule = panamaconverter - - def circtInstallPath = T.input(PathRef(os.Path(T.ctx().env("CIRCT_INSTALL_PATH")))) - - def mainargsIvy = v.mainargs - - def chiselModule = Some(chisel) - def chiselPluginJar = T(Some(chisel.pluginModule.jar())) - def chiselPluginIvy = None - def chiselIvy = None -} - -object omreader extends OMReader - -trait OMReader extends millbuild.common.OMReaderModule with ScalafmtModule { - def scalaVersion = T(v.scala) - - def panamaconverterModule = panamaconverter - def omreaderlibModule = omreaderlib - - def circtInstallPath = T.input(PathRef(os.Path(T.ctx().env("CIRCT_INSTALL_PATH")))) - - def mainargsIvy = v.mainargs - - def chiselModule = Some(chisel) - def chiselPluginJar = T(Some(chisel.pluginModule.jar())) - def chiselPluginIvy = None - def chiselIvy = None -} - -/** A simple release flow for T1 generator: package required dependency to flat jar. usage: mill - * t1package.{sourceJar,jar} out/t1package/sourceJar.dest/out.jar -> t1package-sources.jar - * out/t1package/jar.dest/out.jar -> t1package.jar out/t1package/chiselPluginJar.dest/out.jar -> chiselPlugin.jar these - * two jar is enough for this usages: object somepackagethatdependsont1 extends ScalaModule { def unmanagedClasspath = - * T(Seq(PathRef(os.pwd / "t1package.jar"), PathRef(os.pwd / "t1package-sources.jar"))) } For Jiuyang's Team, this is - * used for link T1 to NDA Blackboxes that cannot be open-sourced - */ -object t1package extends ScalaModule { - def scalaVersion = T(v.scala) - def moduleDeps = super.moduleDeps ++ Seq(t1, t1emu, panamaconverter, omreaderlib) - override def sourceJar: T[PathRef] = T( - Jvm.createJar( - T.traverse(transitiveModuleDeps)(dep => T.sequence(Seq(dep.allSources, dep.resources, dep.compileResources)))() - .flatten - .flatten - .map(_.path) - .filter(os.exists), - manifest() - ) - ) - def chiselPluginJar = T { - val jar = T.dest / "out.jar" - os.copy(chisel.pluginModule.jar().path, jar) - PathRef(jar) - } -} diff --git a/common.sc b/common.mill similarity index 82% rename from common.sc rename to common.mill index fc3054ea2..e46f1914a 100644 --- a/common.sc +++ b/common.mill @@ -1,6 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 Jiuyang Liu +package build + import mill._ import mill.scalalib._ @@ -31,9 +33,9 @@ trait HasChisel extends ScalaModule { } trait HasRVDecoderDB extends ScalaModule { - def rvdecoderdbModule: ScalaModule + def rvdecoderdbIvy: Dep def riscvOpcodesPath: T[PathRef] - def moduleDeps = super.moduleDeps ++ Seq(rvdecoderdbModule) + def ivyDeps = T(super.ivyDeps() ++ Seq(rvdecoderdbIvy)) def riscvOpcodesTar: T[PathRef] = T { val tmpDir = os.temp.dir() os.makeDir(tmpDir / "unratified") @@ -58,11 +60,12 @@ trait HasRVDecoderDB extends ScalaModule { // Local definitions trait T1Module extends ScalaModule with HasChisel with HasRVDecoderDB { - def arithmeticModule: ScalaModule - def hardfloatModule: ScalaModule - def axi4Module: ScalaModule + def arithmeticIvy: Dep + def hardfloatIvy: Dep + def axi4Ivy: Dep def stdlibModule: ScalaModule - def moduleDeps = super.moduleDeps ++ Seq(arithmeticModule, hardfloatModule, axi4Module, stdlibModule) + def moduleDeps = super.moduleDeps ++ Seq(stdlibModule) + override def ivyDeps = T(super.ivyDeps() ++ Seq(arithmeticIvy, hardfloatIvy, axi4Ivy)) } trait ConfigGenModule extends ScalaModule { @@ -80,11 +83,12 @@ trait RocketModule extends ScalaModule with HasChisel with HasRVDecoderDB { // The next generation of purely standalone Rocket Core w/ AXI/CHI. trait RocketVModule extends ScalaModule with HasChisel with HasRVDecoderDB { - def axi4Module: ScalaModule - def hardfloatModule: ScalaModule + def axi4Ivy: Dep + def hardfloatIvy: Dep def stdlibModule: ScalaModule - def moduleDeps = super.moduleDeps ++ Seq(axi4Module, hardfloatModule, stdlibModule) + def moduleDeps = super.moduleDeps ++ Seq(stdlibModule) + override def ivyDeps = T(super.ivyDeps() ++ Seq(hardfloatIvy, axi4Ivy)) } // Link T1 example: RocketV+T1 @@ -109,11 +113,11 @@ trait T1RocketEmulatorModule extends ScalaModule with HasChisel { trait ElaboratorModule extends ScalaModule with HasChisel { def generators: Seq[ScalaModule] - def panamaconverterModule: ScalaModule + def panamaconverterIvy: Dep def circtInstallPath: T[PathRef] - override def moduleDeps = super.moduleDeps ++ Seq(panamaconverterModule) ++ generators + override def moduleDeps = super.moduleDeps ++ generators def mainargsIvy: Dep - override def ivyDeps = T(super.ivyDeps() ++ Seq(mainargsIvy)) + override def ivyDeps = T(super.ivyDeps() ++ Seq(panamaconverterIvy) ++ Seq(mainargsIvy)) override def javacOptions = T(super.javacOptions() ++ Seq("--enable-preview", "--release", "21")) override def forkArgs: T[Seq[String]] = T( super.forkArgs() ++ Seq( @@ -125,11 +129,10 @@ trait ElaboratorModule extends ScalaModule with HasChisel { } trait OMReaderLibModule extends ScalaModule with HasChisel { - def panamaconverterModule: ScalaModule + def panamaconverterIvy: Dep def circtInstallPath: T[PathRef] - override def moduleDeps = super.moduleDeps ++ Seq(panamaconverterModule) def mainargsIvy: Dep - override def ivyDeps = T(super.ivyDeps() ++ Seq(mainargsIvy)) + override def ivyDeps = T(super.ivyDeps() ++ Seq(mainargsIvy, panamaconverterIvy)) override def javacOptions = T(super.javacOptions() ++ Seq("--enable-preview", "--release", "21")) override def forkArgs: T[Seq[String]] = T( super.forkArgs() ++ Seq( @@ -141,12 +144,12 @@ trait OMReaderLibModule extends ScalaModule with HasChisel { } trait OMReaderModule extends ScalaModule with HasChisel { - def panamaconverterModule: ScalaModule + def panamaconverterIvy: Dep def omreaderlibModule: ScalaModule def circtInstallPath: T[PathRef] - override def moduleDeps = super.moduleDeps ++ Seq(panamaconverterModule, omreaderlibModule) + override def moduleDeps = super.moduleDeps ++ Seq(omreaderlibModule) def mainargsIvy: Dep - override def ivyDeps = T(super.ivyDeps() ++ Seq(mainargsIvy)) + override def ivyDeps = T(super.ivyDeps() ++ Seq(mainargsIvy, panamaconverterIvy)) override def javacOptions = T(super.javacOptions() ++ Seq("--enable-preview", "--release", "21")) override def forkArgs: T[Seq[String]] = T( super.forkArgs() ++ Seq( @@ -158,7 +161,7 @@ trait OMReaderModule extends ScalaModule with HasChisel { } trait StdlibModule extends ScalaModule with HasChisel { - def dwbbModule: ScalaModule + def dwbbIvy: Dep - def moduleDeps = super.moduleDeps ++ Seq(dwbbModule) + override def ivyDeps = T(super.ivyDeps() ++ Seq(dwbbIvy)) } diff --git a/nix/t1/dependencies/_sources/generated.json b/nix/t1/dependencies/_sources/generated.json index 961059d45..e8160dc42 100644 --- a/nix/t1/dependencies/_sources/generated.json +++ b/nix/t1/dependencies/_sources/generated.json @@ -1,7 +1,7 @@ { "arithmetic": { "cargoLocks": null, - "date": "2024-01-23", + "date": "2025-02-07", "extract": null, "name": "arithmetic", "passthru": null, @@ -13,35 +13,15 @@ "name": null, "owner": "sequencer", "repo": "arithmetic", - "rev": "4a81e23e1794844b36c53385d343475d4d7eca49", - "sha256": "sha256-tQwzECNOXhuKzpwRD+iKSEJYl1/wlhMQTJULJSCdTrY=", + "rev": "7f167dd90874afa5717fcfb1b8bbfb15ba6317a7", + "sha256": "sha256-gCduOy1xKPH3sP6pU4IegF0270h+UNoP1cErgBQzuCs=", "type": "github" }, - "version": "4a81e23e1794844b36c53385d343475d4d7eca49" - }, - "berkeley-hardfloat": { - "cargoLocks": null, - "date": "2024-06-05", - "extract": null, - "name": "berkeley-hardfloat", - "passthru": null, - "pinned": false, - "src": { - "deepClone": false, - "fetchSubmodules": false, - "leaveDotGit": false, - "name": null, - "owner": "ucb-bar", - "repo": "berkeley-hardfloat", - "rev": "26f00d00c3f3f57480065e02bfcfde3d3b41ec51", - "sha256": "sha256-gA1Ol7xnzC+10lGwK9+ftfJcMhKsC0KhjENQvUg3u88=", - "type": "github" - }, - "version": "26f00d00c3f3f57480065e02bfcfde3d3b41ec51" + "version": "7f167dd90874afa5717fcfb1b8bbfb15ba6317a7" }, "chisel": { "cargoLocks": null, - "date": "2025-01-15", + "date": "2025-02-09", "extract": null, "name": "chisel", "passthru": null, @@ -51,17 +31,17 @@ "fetchSubmodules": false, "leaveDotGit": false, "name": null, - "owner": "chipsalliance", + "owner": "unlsycn", "repo": "chisel", - "rev": "751971afee8196cbc7018ec448b48fd5ccf86652", - "sha256": "sha256-D0BWvxoGdI4AR/j6OcDwRdOQ0tHmV9AVxcT0podkh1I=", + "rev": "6cde7ce50d36994d293f6dcd1717e41c3dcf3126", + "sha256": "sha256-YWmqj7YxqyiLjijFVZ28PrAuaOac9j/XRhF01zGQKBk=", "type": "github" }, - "version": "751971afee8196cbc7018ec448b48fd5ccf86652" + "version": "6cde7ce50d36994d293f6dcd1717e41c3dcf3126" }, "chisel-interface": { "cargoLocks": null, - "date": "2024-10-12", + "date": "2025-01-30", "extract": null, "name": "chisel-interface", "passthru": null, @@ -73,15 +53,15 @@ "name": null, "owner": "chipsalliance", "repo": "chisel-interface", - "rev": "57081e3e080d09bf811cce7b3936ea9e5dc187f9", - "sha256": "sha256-Pmeu5dtjPp9WMzmJY2ULWB20DFq5Vh7Y4G0/Hbjyogc=", + "rev": "e228636d406a948e5e56d841e877591485bfcb22", + "sha256": "sha256-CTi9AaVEIagN8HahvihAEtFzc76deKRzBZqX/4V9u8Y=", "type": "github" }, - "version": "57081e3e080d09bf811cce7b3936ea9e5dc187f9" + "version": "e228636d406a948e5e56d841e877591485bfcb22" }, "riscv-opcodes": { "cargoLocks": null, - "date": "2024-07-24", + "date": "2025-02-07", "extract": null, "name": "riscv-opcodes", "passthru": null, @@ -93,15 +73,15 @@ "name": null, "owner": "riscv", "repo": "riscv-opcodes", - "rev": "07b21cc5143a15959eda12e30aa40cea0971efe0", - "sha256": "sha256-B9njfBxZfm7xkSKBD8JOUWIKEzL8ra/X9FKC3CJ2gK8=", + "rev": "21dab92c834bf782e67034deab87b6bd1952c8ef", + "sha256": "sha256-8jkSaSnKKYVLhbautY7IC1SqWXDjd+mvgzkH7Yp6vYg=", "type": "github" }, - "version": "07b21cc5143a15959eda12e30aa40cea0971efe0" + "version": "21dab92c834bf782e67034deab87b6bd1952c8ef" }, "rvdecoderdb": { "cargoLocks": null, - "date": "2024-07-25", + "date": "2025-02-06", "extract": null, "name": "rvdecoderdb", "passthru": null, @@ -113,10 +93,10 @@ "name": null, "owner": "sequencer", "repo": "rvdecoderdb", - "rev": "6f22826d2c8facb6bf0b41f4bea26a2225751220", - "sha256": "sha256-4Hwa2Z4mmALy4ZElWzxFgqC+7EsyBhahVYlVUzyYKF4=", + "rev": "4572bb92fa458f27228ec0ad1aada2a9b7ea92d1", + "sha256": "sha256-h6lUBQFeLfWY4cjyp/YImISUMcUvg15V/EJxc1RJoIQ=", "type": "github" }, - "version": "6f22826d2c8facb6bf0b41f4bea26a2225751220" + "version": "4572bb92fa458f27228ec0ad1aada2a9b7ea92d1" } } \ No newline at end of file diff --git a/nix/t1/dependencies/_sources/generated.nix b/nix/t1/dependencies/_sources/generated.nix index b522e6927..b4d7d2e5c 100644 --- a/nix/t1/dependencies/_sources/generated.nix +++ b/nix/t1/dependencies/_sources/generated.nix @@ -3,74 +3,62 @@ { arithmetic = { pname = "arithmetic"; - version = "4a81e23e1794844b36c53385d343475d4d7eca49"; + version = "7f167dd90874afa5717fcfb1b8bbfb15ba6317a7"; src = fetchFromGitHub { owner = "sequencer"; repo = "arithmetic"; - rev = "4a81e23e1794844b36c53385d343475d4d7eca49"; + rev = "7f167dd90874afa5717fcfb1b8bbfb15ba6317a7"; fetchSubmodules = false; - sha256 = "sha256-tQwzECNOXhuKzpwRD+iKSEJYl1/wlhMQTJULJSCdTrY="; + sha256 = "sha256-gCduOy1xKPH3sP6pU4IegF0270h+UNoP1cErgBQzuCs="; }; - date = "2024-01-23"; - }; - berkeley-hardfloat = { - pname = "berkeley-hardfloat"; - version = "26f00d00c3f3f57480065e02bfcfde3d3b41ec51"; - src = fetchFromGitHub { - owner = "ucb-bar"; - repo = "berkeley-hardfloat"; - rev = "26f00d00c3f3f57480065e02bfcfde3d3b41ec51"; - fetchSubmodules = false; - sha256 = "sha256-gA1Ol7xnzC+10lGwK9+ftfJcMhKsC0KhjENQvUg3u88="; - }; - date = "2024-06-05"; + date = "2025-02-07"; }; chisel = { pname = "chisel"; - version = "751971afee8196cbc7018ec448b48fd5ccf86652"; + version = "6cde7ce50d36994d293f6dcd1717e41c3dcf3126"; src = fetchFromGitHub { - owner = "chipsalliance"; + owner = "unlsycn"; repo = "chisel"; - rev = "751971afee8196cbc7018ec448b48fd5ccf86652"; + rev = "6cde7ce50d36994d293f6dcd1717e41c3dcf3126"; fetchSubmodules = false; - sha256 = "sha256-D0BWvxoGdI4AR/j6OcDwRdOQ0tHmV9AVxcT0podkh1I="; + sha256 = "sha256-YWmqj7YxqyiLjijFVZ28PrAuaOac9j/XRhF01zGQKBk="; }; - date = "2025-01-15"; + date = "2025-02-09"; }; chisel-interface = { pname = "chisel-interface"; - version = "57081e3e080d09bf811cce7b3936ea9e5dc187f9"; + version = "e228636d406a948e5e56d841e877591485bfcb22"; src = fetchFromGitHub { owner = "chipsalliance"; repo = "chisel-interface"; - rev = "57081e3e080d09bf811cce7b3936ea9e5dc187f9"; + rev = "e228636d406a948e5e56d841e877591485bfcb22"; fetchSubmodules = false; - sha256 = "sha256-Pmeu5dtjPp9WMzmJY2ULWB20DFq5Vh7Y4G0/Hbjyogc="; + sha256 = "sha256-CTi9AaVEIagN8HahvihAEtFzc76deKRzBZqX/4V9u8Y="; }; - date = "2024-10-12"; + date = "2025-01-30"; }; riscv-opcodes = { pname = "riscv-opcodes"; - version = "07b21cc5143a15959eda12e30aa40cea0971efe0"; + version = "21dab92c834bf782e67034deab87b6bd1952c8ef"; src = fetchFromGitHub { owner = "riscv"; repo = "riscv-opcodes"; - rev = "07b21cc5143a15959eda12e30aa40cea0971efe0"; + rev = "21dab92c834bf782e67034deab87b6bd1952c8ef"; fetchSubmodules = false; - sha256 = "sha256-B9njfBxZfm7xkSKBD8JOUWIKEzL8ra/X9FKC3CJ2gK8="; + sha256 = "sha256-8jkSaSnKKYVLhbautY7IC1SqWXDjd+mvgzkH7Yp6vYg="; }; - date = "2024-07-24"; + date = "2025-02-07"; }; rvdecoderdb = { pname = "rvdecoderdb"; - version = "6f22826d2c8facb6bf0b41f4bea26a2225751220"; + version = "4572bb92fa458f27228ec0ad1aada2a9b7ea92d1"; src = fetchFromGitHub { owner = "sequencer"; repo = "rvdecoderdb"; - rev = "6f22826d2c8facb6bf0b41f4bea26a2225751220"; + rev = "4572bb92fa458f27228ec0ad1aada2a9b7ea92d1"; fetchSubmodules = false; - sha256 = "sha256-4Hwa2Z4mmALy4ZElWzxFgqC+7EsyBhahVYlVUzyYKF4="; + sha256 = "sha256-h6lUBQFeLfWY4cjyp/YImISUMcUvg15V/EJxc1RJoIQ="; }; - date = "2024-07-25"; + date = "2025-02-06"; }; } diff --git a/nix/t1/dependencies/default.nix b/nix/t1/dependencies/default.nix index 6c4aec5ca..a5cac83a8 100644 --- a/nix/t1/dependencies/default.nix +++ b/nix/t1/dependencies/default.nix @@ -1,51 +1,215 @@ -{ pkgs, makeSetupHook, writeText, lib }: +{ pkgs +, fetchMillDeps +, publishMillJar +, git +, makeSetupHook +, writeText +, lib +, newScope +, circt-full +, jextract-21 +}: + let submodules = lib.filterAttrs (_: v: v ? src) (pkgs.callPackage ./_sources/generated.nix { }); - makeRemote = module: "git@github.com:${module.src.owner}/${module.src.repo}.git"; in -{ - setupHook = makeSetupHook { name = "submodules-setup.sh"; } (writeText "submodules-setup.sh" ('' - _setupOneSubmodule() { - src="$1" - name="$2" - - echo "[nix-shell] linking '$src' to 'dependencies/$name'" - ln -sfT "$src" "dependencies/$name" - } +lib.makeScope newScope (scope: { + sources = submodules; - _setupOneSubmoduleEditable() { - name="$1"; shift - remote="$1"; shift - rev="$1"; shift - depDir="dependencies/$name" - - if [ -d "$depDir" -a ! -L "$depDir" ]; then - echo "[nix-shell] ignored existing submodule directory '$depDir', remove them if you want a update" - else - if [ -L "$depDir" ]; then - echo "[nix-shell] replacing symlink '$depDir' with full git worktree" - rm "$depDir" - else - echo "[nix-shell] fetching submodule $name" - fi - - git clone $remote $depDir - git -C $depDir -c advice.detachedHead=false checkout $rev - fi - } + ivy-chisel = + let + chiselDeps = fetchMillDeps { + name = "chisel-snapshot"; + src = submodules.chisel.src; + fetchTargets = [ + "unipublish" + ]; + nativeBuildInputs = [ + git + ]; + millDepsHash = "sha256-i5v3V/3X+EuyWy2Czhd8KYTgVQi45Ynl/dDKl3IhThI="; + }; + in + publishMillJar { + name = "chisel-snapshot"; + src = submodules.chisel.src; - setupSubmodules() { - mkdir -p dependencies - '' + lib.concatLines (lib.mapAttrsToList (k: v: "_setupOneSubmodule '${v.src}' '${k}'") submodules) + '' - } + publishTargets = [ + "unipublish" + ]; + + buildInputs = [ + chiselDeps.setupHook + ]; + + nativeBuildInputs = [ + # chisel requires git to generate version + git + ]; + + passthru = { + inherit chiselDeps; + }; + }; + + ivy-chisel-panama = + publishMillJar { + name = "chisel-panama-snapshot"; + src = submodules.chisel.src; + + publishTargets = [ + "panamaconverter.cross[2.13.15]" + "panamaom.cross[2.13.15]" + "panamalib.cross[2.13.15]" + "circtpanamabinding" + ]; + + buildInputs = [ + scope.ivy-chisel.chiselDeps.setupHook + scope.ivy-chisel.setupHook + ]; + + env = { + CIRCT_INSTALL_PATH = circt-full; + JEXTRACT_INSTALL_PATH = jextract-21; + }; + + nativeBuildInputs = [ + # chisel requires git to generate version + git + + circt-full + jextract-21 + ]; + }; + + ivy-arithmetic = + let + arithmeticDeps = fetchMillDeps { + name = "arithmetic-snapshot"; + src = submodules.arithmetic.src; + buildInputs = [ scope.ivy-chisel.setupHook ]; + millDepsHash = "sha256-WNfY4zlLk+/sUoRXQsL0PBHZ5Fz8bFnpAFueJjNiSYI="; + }; + in + publishMillJar { + name = "arithmetic-snapshot"; + src = submodules.arithmetic.src; + + publishTargets = [ + "arithmetic[snapshot]" + ]; + + buildInputs = [ + arithmeticDeps.setupHook + scope.ivy-chisel.setupHook + ]; - # for use of shellHook - setupSubmodulesEditable() { + passthru = { + inherit arithmeticDeps; + }; + }; + + ivy-chisel-interface = + let + chiselInterfaceDeps = fetchMillDeps { + name = "chisel-interface-snapshot"; + src = submodules.chisel-interface.src; + buildInputs = [ scope.ivy-chisel.setupHook ]; + millDepsHash = "sha256-Ktow0COOz+HDHOU2AIVaqsidHCPGjT7J+pdgpSGH0DM="; + }; + in + publishMillJar { + name = "chiselInterface-snapshot"; + src = submodules.chisel-interface.src; + + publishTargets = [ + "jtag[snapshot]" + "axi4[snapshot]" + "dwbb[snapshot]" + ]; + + nativeBuildInputs = [ git ]; + + buildInputs = [ + chiselInterfaceDeps.setupHook + scope.ivy-chisel.setupHook + ]; + + passthru = { + inherit chiselInterfaceDeps; + }; + }; + + ivy-rvdecoderdb = + let + rvdecoderdbDeps = fetchMillDeps { + name = "rvdecoderdb-snapshot"; + src = submodules.rvdecoderdb.src; + millDepsHash = "sha256-j6ixFkxLsm8ihDLFkkJDePVuS2yVFmX3B1gOUVguCHQ="; + }; + in + publishMillJar { + name = "rvdecoderdb-snapshot"; + src = submodules.rvdecoderdb.src; + + publishTargets = [ + "rvdecoderdb.jvm" + ]; + + buildInputs = [ + rvdecoderdbDeps.setupHook + ]; + + nativeBuildInputs = [ + # rvdecoderdb requires git to generate version + git + ]; + + passthru = { + inherit rvdecoderdbDeps; + }; + }; + + ivy-hardfloat = + let + hardfloatSrc = ../../../dependencies/berkeley-hardfloat; + hardfloatDeps = fetchMillDeps { + name = "hardfloat-snapshot"; + src = hardfloatSrc; + buildInputs = [ scope.ivy-chisel.setupHook ]; + millDepsHash = "sha256-lYV/BHKXpX1ssI3pZIBlzfsBclgwxVCE/TQJq/eeOcY="; + }; + in + publishMillJar { + name = "hardfloat-snapshot"; + src = hardfloatSrc; + + publishTargets = [ + "hardfloat[snapshot]" + ]; + + buildInputs = [ + hardfloatDeps.setupHook + scope.ivy-chisel.setupHook + ]; + + nativeBuildInputs = [ + # hardfloat requires git to generate version + git + ]; + + passthru = { + inherit hardfloatDeps; + }; + }; + + riscv-opcodes = makeSetupHook { name = "setup-riscv-opcodes-src"; } (writeText "setup-riscv-opcodes-src.sh" '' + setupRiscvOpcodes() { mkdir -p dependencies - '' + lib.concatLines (lib.mapAttrsToList (k: v: "_setupOneSubmoduleEditable '${k}' '${makeRemote v}' '${v.src.rev}'") submodules) + '' + ln -sfT "${submodules.riscv-opcodes.src}" "dependencies/riscv-opcodes" } - prePatchHooks+=(setupSubmodules) - '')); - sources = submodules; -} + prePatchHooks+=(setupRiscvOpcodes) + ''); +}) diff --git a/nix/t1/dependencies/nvfetcher.toml b/nix/t1/dependencies/nvfetcher.toml index ab22554db..14f343981 100644 --- a/nix/t1/dependencies/nvfetcher.toml +++ b/nix/t1/dependencies/nvfetcher.toml @@ -3,15 +3,10 @@ src.git = "https://github.com/sequencer/arithmetic" src.branch = "master" fetch.github = "sequencer/arithmetic" -[berkeley-hardfloat] -src.git = "https://github.com/ucb-bar/berkeley-hardfloat" -src.branch = "master" -fetch.github = "ucb-bar/berkeley-hardfloat" - [chisel] -src.git = "https://github.com/chipsalliance/chisel" -src.branch = "main" -fetch.github = "chipsalliance/chisel" +src.git = "https://github.com/unlsycn/chisel" +src.branch = "fix-mill-version" +fetch.github = "unlsycn/chisel" [chisel-interface] src.git = "https://github.com/chipsalliance/chisel-interface" diff --git a/nix/t1/mill-modules.nix b/nix/t1/mill-modules.nix index ca7db5024..ef4eaa05e 100644 --- a/nix/t1/mill-modules.nix +++ b/nix/t1/mill-modules.nix @@ -12,6 +12,7 @@ , jextract-21 , add-determinism , writeShellApplication +, glibcLocales , dependencies }: @@ -23,8 +24,8 @@ let src = with lib.fileset; toSource { root = ./../..; fileset = unions [ - ./../../build.sc - ./../../common.sc + ./../../build.mill + ./../../common.mill ./../../t1 ./../../omreader ./../../omreaderlib @@ -42,12 +43,19 @@ let src = with lib.fileset; toSource { root = ./../..; fileset = unions [ - ./../../build.sc - ./../../common.sc + ./../../build.mill + ./../../common.mill ]; }; - millDepsHash = "sha256-XvGLNLOC7OEwfC7SB5zBdB64VjROBkwgIcHx+9FHmSs="; - nativeBuildInputs = [ dependencies.setupHook ]; + millDepsHash = "sha256-TU6o7ldRVwcDv7cY02Av8QI9yFH8npV/a30baJtfT/U="; + buildInputs = with dependencies; [ + ivy-arithmetic.setupHook + ivy-chisel.setupHook + ivy-chisel-panama.setupHook + ivy-chisel-interface.setupHook + ivy-rvdecoderdb.setupHook + ivy-hardfloat.setupHook + ]; }; passthru.editable = self.overrideAttrs (_: { @@ -61,7 +69,7 @@ let setupSubmodules ''; - nativeBuildInputs = [ + nativeBuildInputs = with dependencies; [ mill circt-full jextract-21 @@ -72,25 +80,32 @@ let makeWrapper passthru.millDeps.setupHook - dependencies.setupHook + ivy-arithmetic.setupHook + ivy-chisel.setupHook + ivy-chisel-panama.setupHook + ivy-chisel-interface.setupHook + ivy-rvdecoderdb.setupHook + ivy-hardfloat.setupHook + riscv-opcodes ]; env = { CIRCT_INSTALL_PATH = circt-full; JEXTRACT_INSTALL_PATH = jextract-21; - JAVA_TOOL_OPTIONS = "--enable-preview"; }; - - outputs = [ "out" "omreader" "elaborator" "t1package" ]; + outputs = [ "out" "omreader" "elaborator" ]; buildPhase = '' runHook preBuild - mill -i '__.assembly' + # Mill assume path string is always encoded in UTF-8. However in Nix + # build environment, locale type is set to "C", and breaks the assembly + # JAR class path. Here is the workaround for the Scala build environment. + export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive" + export LANG="en_US.UTF-8"; - mill -i t1package.sourceJar - mill -i t1package.chiselPluginJar + mill -i '__.assembly' runHook postBuild ''; @@ -103,18 +118,10 @@ let } add-determinism-q out/elaborator/assembly.dest/out.jar add-determinism-q out/omreader/assembly.dest/out.jar - add-determinism-q out/t1package/assembly.dest/out.jar - add-determinism-q out/t1package/sourceJar.dest/out.jar - add-determinism-q out/t1package/chiselPluginJar.dest/out.jar mv out/elaborator/assembly.dest/out.jar $out/share/java/elaborator.jar mv out/omreader/assembly.dest/out.jar "$out"/share/java/omreader.jar - mkdir -p $t1package/share/java - mv out/t1package/sourceJar.dest/out.jar $t1package/share/java/t1package-sources.jar - mv out/t1package/assembly.dest/out.jar $t1package/share/java/t1package.jar - mv out/t1package/chiselPluginJar.dest/out.jar $t1package/share/java/chiselPluginJar.jar - mkdir -p $elaborator/bin makeWrapper ${jdk21}/bin/java $elaborator/bin/elaborator \ --add-flags "--enable-preview -Djava.library.path=${circt-full}/lib" \ @@ -132,10 +139,6 @@ let name = "mill-format-for-t1"; runtimeInputs = [ mill ]; text = '' - # shellcheck disable=SC1091 - source ${dependencies.setupHook}/nix-support/setup-hook - setupSubmodules - subcmd="''${1:-}" [[ -z "$subcmd" ]] && \ echo "no subcmd specify, available: (check, run)" >&2 && exit 1 diff --git a/script/default.nix b/script/default.nix index a6a098999..aaafbe6fd 100644 --- a/script/default.nix +++ b/script/default.nix @@ -31,7 +31,7 @@ let ./build.sc ]; }; - millDepsHash = "sha256-DAEgWFDUX22IfQ0N7j3icPjjrND3612leUT0qqXp+Zc="; + millDepsHash = "sha256-sEOrIm7kTlpM9K6t0zma71FHFQgTHVhj5WmFwJ8UQmo="; }; passthru.withLsp = self.overrideAttrs (old: {