-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathcommon.mill
167 lines (140 loc) · 5.56 KB
/
common.mill
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2022 Jiuyang Liu <liu@jiuyang.me>
package build
import mill._
import mill.scalalib._
trait HasChisel extends ScalaModule {
// Define these for building chisel from source
def chiselModule: Option[ScalaModule]
override def moduleDeps = super.moduleDeps ++ chiselModule
def chiselPluginJar: T[Option[PathRef]]
override def scalacOptions = T(
super.scalacOptions() ++ chiselPluginJar().map(path => s"-Xplugin:${path.path}") ++ Seq("-Ymacro-annotations")
)
override def scalacPluginClasspath: T[Agg[PathRef]] = T(super.scalacPluginClasspath() ++ chiselPluginJar())
// Define these for building chisel from ivy
def chiselIvy: Option[Dep]
override def ivyDeps = T(super.ivyDeps() ++ chiselIvy)
def chiselPluginIvy: Option[Dep]
override def scalacPluginIvyDeps: T[Agg[Dep]] = T(
super.scalacPluginIvyDeps() ++ chiselPluginIvy.map(Agg(_)).getOrElse(Agg.empty[Dep])
)
}
trait HasRVDecoderDB extends ScalaModule {
def rvdecoderdbIvy: Dep
def riscvOpcodesPath: T[PathRef]
def ivyDeps = T(super.ivyDeps() ++ Seq(rvdecoderdbIvy))
def riscvOpcodesTar: T[PathRef] = T {
val tmpDir = os.temp.dir()
os.makeDir(tmpDir / "unratified")
os.walk(riscvOpcodesPath().path)
.filter(f =>
f.baseName.startsWith("rv128_") ||
f.baseName.startsWith("rv64_") ||
f.baseName.startsWith("rv32_") ||
f.baseName.startsWith("rv_") ||
f.ext == "csv"
)
.groupBy(_.segments.contains("unratified"))
.map {
case (true, fs) => fs.map(os.copy.into(_, tmpDir / "unratified"))
case (false, fs) => fs.map(os.copy.into(_, tmpDir))
}
os.proc("tar", "cf", T.dest / "riscv-opcodes.tar", ".").call(tmpDir)
PathRef(T.dest)
}
override def resources: T[Seq[PathRef]] = super.resources() ++ Some(riscvOpcodesTar())
}
// Local definitions
trait T1Module extends ScalaModule with HasChisel with HasRVDecoderDB {
def arithmeticIvy: Dep
def hardfloatIvy: Dep
def axi4Ivy: Dep
def stdlibModule: ScalaModule
def moduleDeps = super.moduleDeps ++ Seq(stdlibModule)
override def ivyDeps = T(super.ivyDeps() ++ Seq(arithmeticIvy, hardfloatIvy, axi4Ivy))
}
trait ConfigGenModule extends ScalaModule {
def t1Module: ScalaModule
def moduleDeps = super.moduleDeps ++ Seq(t1Module)
def mainargsIvy: Dep
override def ivyDeps = T(super.ivyDeps() ++ Seq(mainargsIvy))
}
// T1 forked version of RocketCore
trait RocketModule extends ScalaModule with HasChisel with HasRVDecoderDB {
def rocketchipModule: ScalaModule
def moduleDeps = super.moduleDeps ++ Seq(rocketchipModule)
}
// The next generation of purely standalone Rocket Core w/ AXI/CHI.
trait RocketVModule extends ScalaModule with HasChisel with HasRVDecoderDB {
def axi4Ivy: Dep
def hardfloatIvy: Dep
def stdlibModule: ScalaModule
def moduleDeps = super.moduleDeps ++ Seq(stdlibModule)
override def ivyDeps = T(super.ivyDeps() ++ Seq(hardfloatIvy, axi4Ivy))
}
// Link T1 example: RocketV+T1
trait T1RocketModule extends ScalaModule with HasChisel {
def rocketModule: ScalaModule
def t1Module: ScalaModule
def moduleDeps = super.moduleDeps ++ Seq(rocketModule, t1Module)
}
trait EmuHelperModule extends ScalaModule with HasChisel
trait T1EmulatorModule extends ScalaModule with HasChisel {
def t1Module: ScalaModule
def moduleDeps = super.moduleDeps ++ Seq(t1Module)
}
trait T1RocketEmulatorModule extends ScalaModule with HasChisel {
def t1rocketModule: ScalaModule
def moduleDeps = super.moduleDeps ++ Seq(t1rocketModule)
}
trait ElaboratorModule extends ScalaModule with HasChisel {
def generators: Seq[ScalaModule]
def panamaconverterIvy: Dep
def circtInstallPath: T[PathRef]
override def moduleDeps = super.moduleDeps ++ generators
def mainargsIvy: Dep
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(
"--enable-native-access=ALL-UNNAMED",
"--enable-preview",
s"-Djava.library.path=${circtInstallPath().path / "lib"}"
)
)
}
trait OMReaderLibModule extends ScalaModule with HasChisel {
def panamaconverterIvy: Dep
def circtInstallPath: T[PathRef]
def mainargsIvy: Dep
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(
"--enable-native-access=ALL-UNNAMED",
"--enable-preview",
s"-Djava.library.path=${circtInstallPath().path / "lib"}"
)
)
}
trait OMReaderModule extends ScalaModule with HasChisel {
def panamaconverterIvy: Dep
def omreaderlibModule: ScalaModule
def circtInstallPath: T[PathRef]
override def moduleDeps = super.moduleDeps ++ Seq(omreaderlibModule)
def mainargsIvy: Dep
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(
"--enable-native-access=ALL-UNNAMED",
"--enable-preview",
s"-Djava.library.path=${circtInstallPath().path / "lib"}"
)
)
}
trait StdlibModule extends ScalaModule with HasChisel {
def dwbbIvy: Dep
override def ivyDeps = T(super.ivyDeps() ++ Seq(dwbbIvy))
}