-
Notifications
You must be signed in to change notification settings - Fork 23
/
build.sc
307 lines (231 loc) · 9.13 KB
/
build.sc
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2022 Jiuyang Liu <[email protected]>
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 rocketemu extends RocketEmulator
trait RocketEmulator extends millbuild.common.RocketEmulatorModule with ScalafmtModule {
def scalaVersion = T(v.scala)
def rocketVModule = rocketv
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,
rocketemu,
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)
}
}