1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
//| mvnDeps:
//| - com.typesafe:config:1.4.3
import mill._
import mill.scalalib._
trait SpinalModule extends ScalaModule {
def scalaVersion = "2.13.14"
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
|