forked from chipsalliance/rocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.sc
69 lines (66 loc) · 2.93 KB
/
common.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
import mill._
import mill.scalalib._
// Basically we are migrating RocketCore which depends on RocketChip to bare chisel3.
// We put original codes inside DiplomaticModule, and extracting them file by file to RocketModule
// The RocketModule should only depend on chisel3Module and tilelinkModule, currently in submodule.
trait RocketModule extends ScalaModule {
// TODO: add option to depend on Chisel Maven
def chisel3Module: Option[ScalaModule]
def chisel3PluginJar: T[Option[PathRef]]
def tilelinkModule: Option[ScalaModule]
def riscvopcodesModule: RiscvOpcodesModule
def hardfloatModule: Option[ScalaModule]
override def generatedSources: T[Seq[PathRef]] = T {
Seq(
riscvopcodesModule.rvInstruction(),
riscvopcodesModule.rv32Instruction(),
riscvopcodesModule.rv64Instruction(),
riscvopcodesModule.csrs(),
riscvopcodesModule.causes()
)
}
override def moduleDeps = Seq() ++ chisel3Module ++ tilelinkModule ++ hardfloatModule
override def scalacPluginClasspath = T(super.scalacPluginClasspath() ++ chisel3PluginJar())
override def scalacOptions = T(super.scalacOptions() ++ chisel3PluginJar().map(p => s"-Xplugin:${p.path}"))
}
// Test should depend on DiplomaticModule for now
trait DiplomaticModule extends ScalaModule {
// The bare RocketModule
def rocketModule: RocketModule
// upstream RocketChip in dev branch
def rocketchipModule: ScalaModule
override def moduleDeps = super.moduleDeps :+ rocketModule :+ rocketchipModule
override def scalacPluginClasspath = T(super.scalacPluginClasspath() ++ rocketModule.chisel3PluginJar())
override def scalacOptions = T(super.scalacOptions() ++ rocketModule.chisel3PluginJar().map(p => s"-Xplugin:${p.path}"))
}
// Build targets to codegen instructions
// millSourcePath should be set to riscv/riscv-opcodes to generate required Scala file
trait RiscvOpcodesModule extends Module {
// path to script calling python library in riscv/riscv-opcodes.git
def script: T[PathRef]
def rv64Instruction = T {
val f = T.ctx.dest / "Instructions64.scala"
os.proc("python", script().path, "rv64*").call(stdout = f, env = Map("PYTHONPATH"->millSourcePath.toString))
PathRef(f)
}
def rv32Instruction = T {
val f = T.ctx.dest / "Instructions32.scala"
os.proc("python", script().path, "rv32*").call(stdout = f, env = Map("PYTHONPATH"->millSourcePath.toString))
PathRef(f)
}
def rvInstruction = T {
val f = T.ctx.dest / "Instructions.scala"
os.proc("python", script().path, "rv_*").call(stdout = f, env = Map("PYTHONPATH"->millSourcePath.toString))
PathRef(f)
}
def causes = T {
val f = T.ctx.dest / "Causes.scala"
os.proc("python", script().path, "causes").call(stdout = f, env = Map("PYTHONPATH"->millSourcePath.toString))
PathRef(f)
}
def csrs = T {
val f = T.ctx.dest / "CSRs.scala"
os.proc("python", script().path, "csrs").call(stdout = f, env = Map("PYTHONPATH"->millSourcePath.toString))
PathRef(f)
}
}