forked from OpenXiangShan/XiangShan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sc
255 lines (160 loc) · 6.45 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
/***************************************************************************************
* Copyright (c) 2024 Beijing Institute of Open Source Chip (BOSC)
* Copyright (c) 2020-2024 Institute of Computing Technology, Chinese Academy of Sciences
* Copyright (c) 2020-2021 Peng Cheng Laboratory
*
* XiangShan is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
*
* See the Mulan PSL v2 for more details.
***************************************************************************************/
import mill._
import scalalib._
import $file.`rocket-chip`.common
import $file.`rocket-chip`.cde.common
import $file.`rocket-chip`.hardfloat.build
import $file.huancun.common
import $file.coupledL2.common
import $file.openLLC.common
val defaultScalaVersion = "2.13.14"
def defaultVersions = Map(
"chisel" -> ivy"org.chipsalliance::chisel:6.5.0",
"chisel-plugin" -> ivy"org.chipsalliance:::chisel-plugin:6.5.0",
"chiseltest" -> ivy"edu.berkeley.cs::chiseltest:6.0.0"
)
trait HasChisel extends SbtModule {
def chiselModule: Option[ScalaModule] = None
def chiselPluginJar: T[Option[PathRef]] = None
def chiselIvy: Option[Dep] = Some(defaultVersions("chisel"))
def chiselPluginIvy: Option[Dep] = Some(defaultVersions("chisel-plugin"))
override def scalaVersion = defaultScalaVersion
override def scalacOptions = super.scalacOptions() ++
Agg("-language:reflectiveCalls", "-Ymacro-annotations", "-Ytasty-reader")
override def ivyDeps = super.ivyDeps() ++ Agg(chiselIvy.get)
override def scalacPluginIvyDeps = super.scalacPluginIvyDeps() ++ Agg(chiselPluginIvy.get)
}
object rocketchip
extends millbuild.`rocket-chip`.common.RocketChipModule
with HasChisel {
def scalaVersion: T[String] = T(defaultScalaVersion)
override def millSourcePath = os.pwd / "rocket-chip"
def macrosModule = macros
def hardfloatModule = hardfloat
def cdeModule = cde
def mainargsIvy = ivy"com.lihaoyi::mainargs:0.7.0"
def json4sJacksonIvy = ivy"org.json4s::json4s-jackson:4.0.7"
object macros extends Macros
trait Macros
extends millbuild.`rocket-chip`.common.MacrosModule
with SbtModule {
def scalaVersion: T[String] = T(defaultScalaVersion)
def scalaReflectIvy = ivy"org.scala-lang:scala-reflect:${defaultScalaVersion}"
}
object hardfloat
extends millbuild.`rocket-chip`.hardfloat.common.HardfloatModule with HasChisel {
def scalaVersion: T[String] = T(defaultScalaVersion)
override def millSourcePath = os.pwd / "rocket-chip" / "hardfloat" / "hardfloat"
}
object cde
extends millbuild.`rocket-chip`.cde.common.CDEModule with ScalaModule {
def scalaVersion: T[String] = T(defaultScalaVersion)
override def millSourcePath = os.pwd / "rocket-chip" / "cde" / "cde"
}
}
object utility extends HasChisel {
override def millSourcePath = os.pwd / "utility"
override def moduleDeps = super.moduleDeps ++ Seq(
rocketchip
)
}
object yunsuan extends HasChisel {
override def millSourcePath = os.pwd / "yunsuan"
}
object huancun extends millbuild.huancun.common.HuanCunModule with HasChisel {
override def millSourcePath = os.pwd / "huancun"
def rocketModule: ScalaModule = rocketchip
def utilityModule: ScalaModule = utility
}
object coupledL2 extends millbuild.coupledL2.common.CoupledL2Module with HasChisel {
override def millSourcePath = os.pwd / "coupledL2"
def rocketModule: ScalaModule = rocketchip
def utilityModule: ScalaModule = utility
def huancunModule: ScalaModule = huancun
}
object openLLC extends millbuild.openLLC.common.OpenLLCModule with HasChisel {
override def millSourcePath = os.pwd / "openLLC"
def coupledL2Module: ScalaModule = coupledL2
def rocketModule: ScalaModule = rocketchip
def utilityModule: ScalaModule = utility
}
object difftest extends HasChisel {
override def millSourcePath = os.pwd / "difftest"
}
object fudian extends HasChisel {
override def millSourcePath = os.pwd / "fudian"
}
object macros extends ScalaModule {
override def millSourcePath = os.pwd / "macros"
override def scalaVersion: T[String] = T(defaultScalaVersion)
override def ivyDeps = super.ivyDeps() ++ Agg(ivy"org.scala-lang:scala-reflect:${defaultScalaVersion}")
def scalaReflectIvy = ivy"org.scala-lang:scala-reflect:${defaultScalaVersion}"
}
// extends this trait to use XiangShan in other projects
trait XiangShanModule extends ScalaModule {
def rocketModule: ScalaModule
def difftestModule: ScalaModule
def huancunModule: ScalaModule
def coupledL2Module: ScalaModule
def openLLCModule: ScalaModule
def fudianModule: ScalaModule
def utilityModule: ScalaModule
def yunsuanModule: ScalaModule
def macrosModule: ScalaModule
override def moduleDeps = super.moduleDeps ++ Seq(
rocketModule,
difftestModule,
huancunModule,
coupledL2Module,
openLLCModule,
yunsuanModule,
fudianModule,
utilityModule,
macrosModule,
)
val resourcesPATH = os.pwd.toString() + "/src/main/resources"
val envPATH = sys.env("PATH") + ":" + resourcesPATH
override def forkEnv = Map("PATH" -> envPATH)
}
object xiangshan extends XiangShanModule with HasChisel {
override def millSourcePath = os.pwd
def rocketModule = rocketchip
def difftestModule = difftest
def huancunModule = huancun
def coupledL2Module = coupledL2
def openLLCModule = openLLC
def fudianModule = fudian
def utilityModule = utility
def yunsuanModule = yunsuan
def macrosModule = macros
override def forkArgs = Seq("-Xmx40G", "-Xss256m")
override def ivyDeps = super.ivyDeps() ++ Agg(
defaultVersions("chiseltest"),
)
override def scalacOptions = super.scalacOptions() ++ Agg("-deprecation", "-feature")
object test extends SbtModuleTests with TestModule.ScalaTest {
override def forkArgs = Seq("-Xmx40G", "-Xss256m")
override def ivyDeps = super.ivyDeps() ++ Agg(
defaultVersions("chiseltest")
)
override def scalacOptions = super.scalacOptions() ++ Agg("-deprecation", "-feature")
val resourcesPATH = os.pwd.toString() + "/src/main/resources"
val envPATH = sys.env("PATH") + ":" + resourcesPATH
override def forkEnv = Map("PATH" -> envPATH)
}
}