xref: /XiangShan/src/main/scala/top/XiangShanStage.scala (revision 908040848abb525b50722ff953b8e73a9be20899)
1/***************************************************************************************
2* Copyright (c) 2024 Beijing Institute of Open Source Chip (BOSC)
3* Copyright (c) 2020-2024 Institute of Computing Technology, Chinese Academy of Sciences
4* Copyright (c) 2020-2021 Peng Cheng Laboratory
5*
6* XiangShan is licensed under Mulan PSL v2.
7* You can use this software according to the terms and conditions of the Mulan PSL v2.
8* You may obtain a copy of Mulan PSL v2 at:
9*          http://license.coscl.org.cn/MulanPSL2
10*
11* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
12* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
13* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
14*
15* See the Mulan PSL v2 for more details.
16***************************************************************************************/
17
18package top
19
20import chisel3.stage._
21import xiangshan.transforms._
22import circt.stage.CLI
23import circt.stage.ChiselStage
24
25
26class XiangShanStage extends ChiselStage {
27
28  override val shell = new firrtl.options.Shell("xiangshan") with CLI with XiangShanCli {
29    // These are added by firrtl.options.Shell (which we must extend because we are a Stage)
30    override protected def includeLoggerOptions = false
31  }
32
33  trait XiangShanCli { this: firrtl.options.Shell =>
34    parser.note("XiangShan Options")
35    DisablePrintfAnnotation.addOptions(parser)
36    EnablePrintfAnnotation.addOptions(parser)
37    DisableAllPrintAnnotation.addOptions(parser)
38    RemoveAssertAnnotation.addOptions(parser)
39  }
40
41  override def run(annotations: firrtl.AnnotationSeq): firrtl.AnnotationSeq = {
42
43    val pm = new firrtl.options.PhaseManager(
44      targets = Seq(
45        firrtl.options.Dependency[chisel3.stage.phases.AddImplicitOutputFile],
46        firrtl.options.Dependency[chisel3.stage.phases.AddImplicitOutputAnnotationFile],
47        firrtl.options.Dependency[chisel3.stage.phases.AddSerializationAnnotations],
48        firrtl.options.Dependency[chisel3.stage.phases.Convert],
49        firrtl.options.Dependency[xiangshan.transforms.PrintModuleName],
50        firrtl.options.Dependency[xiangshan.transforms.PrintControl],
51        firrtl.options.Dependency[chisel3.stage.phases.AddDedupGroupAnnotations],
52        firrtl.options.Dependency[circt.stage.phases.AddImplicitOutputFile],
53        firrtl.options.Dependency[circt.stage.phases.CIRCT]
54      ),
55      currentState = Seq(
56        firrtl.options.Dependency[firrtl.stage.phases.AddDefaults],
57        firrtl.options.Dependency[firrtl.stage.phases.Checks]
58      )
59    )
60    pm.transform(annotations)
61  }
62
63}
64