aboutsummaryrefslogtreecommitdiff
path: root/build.mill
diff options
context:
space:
mode:
Diffstat (limited to 'build.mill')
-rw-r--r--build.mill61
1 files changed, 58 insertions, 3 deletions
diff --git a/build.mill b/build.mill
index 4b60b5f..5ccce1d 100644
--- a/build.mill
+++ b/build.mill
@@ -3,15 +3,70 @@
import mill._
import mill.scalalib._
-object top_simple extends ScalaModule {
+trait SpinalModule extends ScalaModule {
def scalaVersion = "2.13.14"
- //override def sources = Task.Sources(moduleDir / os.up / "src")
-
override def mvnDeps = Seq(
mvn"com.github.spinalhdl::spinalhdl-core:1.12.3",
mvn"com.github.spinalhdl::spinalhdl-lib:1.12.3"
)
override def scalacPluginMvnDeps = Seq(mvn"com.github.spinalhdl::spinalhdl-idsl-plugin:1.12.3")
+
+ def generateVhdl: T[PathRef] = Task {
+ val name = moduleDir.last
+ val cp = runClasspath().map(_.path).mkString(java.io.File.pathSeparator)
+ os.proc("java", s"-DspinalTargetDir=${Task.dest}", "-cp", cp, s"$name.genvhdl")
+ .call(cwd = moduleDir / os.up, stdout = os.Inherit, stderr = os.Inherit)
+ PathRef(Task.dest / s"$name.vhd")
+ }
+
+ def pinsFile: T[PathRef] = Task.Source(moduleDir / "pnr" / s"${moduleDir.last}_pins.tcl")
+ def sdcFile: T[PathRef] = Task.Source(moduleDir / "pnr" / s"${moduleDir.last}.sdc")
+ def qprojectScript: T[PathRef] = Task.Source(moduleDir / os.up / "scripts" / "create_quartus_project_settings.tcl")
+
+ def qproject: T[PathRef] = Task {
+ val name = moduleDir.last
+ val vhdl = generateVhdl()
+ val pins = pinsFile()
+ val sdc = sdcFile()
+ val script = qprojectScript()
+ assert(os.exists(sdc.path), s"SDC file not found: ${sdc.path}")
+ os.proc("quartus_sh",
+ "--64bit",
+ "-t", script.path,
+ "-projectname", name,
+ "-vhdlfile", vhdl.path,
+ "-pinfile", pins.path,
+ "-sdcfile", sdc.path)
+ .call(cwd = Task.dest, stdout = os.Inherit, stderr = os.Inherit)
+ PathRef(Task.dest)
+ }
+
+ def quartusgui() = Task.Command {
+ val name = moduleDir.last
+ val projectDir = qproject().path
+ os.proc("quartus", "--64bit", projectDir / s"$name.qpf")
+ .call(cwd = projectDir, stdout = os.Inherit, stderr = os.Inherit)
+ }
+
+ def prog() = Task.Command {
+ val sof = synthesis().path
+ os.proc("quartus_pgm",
+ "--64bit",
+ "-c", "USB-Blaster",
+ "--mode", "jtag",
+ s"--operation=p;$sof")
+ .call(stdout = os.Inherit, stderr = os.Inherit)
+ }
+
+ def synthesis: T[PathRef] = Task {
+ val name = moduleDir.last
+ val projectDir = qproject().path
+ os.proc("quartus_sh", "--64bit", "--flow", "compile", projectDir / s"$name.qpf")
+ .call(cwd = projectDir, stdout = os.Inherit, stderr = os.Inherit)
+ PathRef(projectDir / s"$name.sof")
+ }
}
+
+object top_simple extends SpinalModule