1/*************************************************************************************** 2* Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences 3* Copyright (c) 2020-2021 Peng Cheng Laboratory 4* 5* XiangShan is licensed under Mulan PSL v2. 6* You can use this software according to the terms and conditions of the Mulan PSL v2. 7* You may obtain a copy of Mulan PSL v2 at: 8* http://license.coscl.org.cn/MulanPSL2 9* 10* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 11* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 12* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 13* 14* See the Mulan PSL v2 for more details. 15***************************************************************************************/ 16 17import os.Path 18import mill._ 19import scalalib._ 20import publish._ 21import coursier.maven.MavenRepository 22import $file.`rocket-chip`.common 23import $file.`rocket-chip`.`api-config-chipsalliance`.`build-rules`.mill.build 24import $file.`rocket-chip`.hardfloat.build 25 26object ivys { 27 val sv = "2.12.13" 28 val chisel3 = ivy"edu.berkeley.cs::chisel3:3.5.0-RC1" 29 val chisel3Plugin = ivy"edu.berkeley.cs:::chisel3-plugin:3.5.0-RC1" 30 val chiseltest = ivy"edu.berkeley.cs::chiseltest:0.3.2" 31 val scalatest = ivy"org.scalatest::scalatest:3.2.2" 32 val macroParadise = ivy"org.scalamacros:::paradise:2.1.1" 33} 34 35trait XSModule extends ScalaModule with PublishModule { 36 37 // override this to use chisel from source 38 def chiselOpt: Option[PublishModule] = None 39 40 override def scalaVersion = ivys.sv 41 42 override def compileIvyDeps = Agg(ivys.macroParadise) 43 44 override def scalacPluginIvyDeps = Agg(ivys.macroParadise, ivys.chisel3Plugin) 45 46 override def scalacOptions = Seq("-Xsource:2.11") 47 48 override def ivyDeps = if(chiselOpt.isEmpty) Agg(ivys.chisel3) else Agg.empty[Dep] 49 50 override def moduleDeps = Seq() ++ chiselOpt 51 52 def publishVersion = "0.0.1" 53 54 // TODO: fix this 55 def pomSettings = PomSettings( 56 description = "XiangShan", 57 organization = "", 58 url = "https://github.com/OpenXiangShan/XiangShan", 59 licenses = Seq(License.`Apache-2.0`), 60 versionControl = VersionControl.github("OpenXiangShan", "XiangShan"), 61 developers = Seq.empty 62 ) 63} 64 65object rocketchip extends `rocket-chip`.common.CommonRocketChip { 66 67 val rcPath = os.pwd / "rocket-chip" 68 69 override def scalaVersion = ivys.sv 70 71 override def scalacOptions = Seq("-Xsource:2.11") 72 73 override def millSourcePath = rcPath 74 75 object configRocket extends `rocket-chip`.`api-config-chipsalliance`.`build-rules`.mill.build.config with PublishModule { 76 override def millSourcePath = rcPath / "api-config-chipsalliance" / "design" / "craft" 77 78 override def scalaVersion = T { 79 rocketchip.scalaVersion() 80 } 81 82 override def pomSettings = T { 83 rocketchip.pomSettings() 84 } 85 86 override def publishVersion = T { 87 rocketchip.publishVersion() 88 } 89 } 90 91 object hardfloatRocket extends `rocket-chip`.hardfloat.build.hardfloat { 92 override def millSourcePath = rcPath / "hardfloat" 93 94 override def scalaVersion = T { 95 rocketchip.scalaVersion() 96 } 97 98 def chisel3IvyDeps = if(chisel3Module.isEmpty) Agg( 99 common.getVersion("chisel3") 100 ) else Agg.empty[Dep] 101 } 102 103 def hardfloatModule = hardfloatRocket 104 105 def configModule = configRocket 106 107} 108 109object huancun extends XSModule with SbtModule { 110 111 override def millSourcePath = os.pwd / "huancun" 112 113 override def moduleDeps = super.moduleDeps ++ Seq( 114 rocketchip 115 ) 116} 117 118object difftest extends XSModule with SbtModule { 119 override def millSourcePath = os.pwd / "difftest" 120} 121 122object fudian extends XSModule with SbtModule 123 124// extends this trait to use XiangShan in other projects 125trait CommonXiangShan extends XSModule with SbtModule { m => 126 127 // module deps 128 def rocketModule: PublishModule 129 def difftestModule: PublishModule 130 def huancunModule: PublishModule 131 def fudianModule: PublishModule 132 133 override def millSourcePath = os.pwd 134 135 override def forkArgs = Seq("-Xmx64G", "-Xss256m") 136 137 override def ivyDeps = super.ivyDeps() ++ Seq(ivys.chiseltest) 138 139 override def moduleDeps = super.moduleDeps ++ Seq( 140 rocketModule, 141 difftestModule, 142 huancunModule, 143 fudianModule 144 ) 145 146 object test extends Tests with TestModule.ScalaTest { 147 148 override def forkArgs = m.forkArgs 149 150 override def ivyDeps = super.ivyDeps() ++ Agg( 151 ivys.scalatest 152 ) 153 154 } 155 156} 157 158object XiangShan extends CommonXiangShan { 159 override def rocketModule = rocketchip 160 override def difftestModule = difftest 161 override def huancunModule = huancun 162 override def fudianModule = fudian 163} 164