XiangShanStage.scala 2.3 KB
Newer Older
1 2 3 4 5 6 7
package top

import chisel3.stage.ChiselCli
import firrtl.AnnotationSeq
import firrtl.annotations.NoTargetAnnotation
import firrtl.options.{HasShellOptions, Shell, ShellOption}
import firrtl.stage.{FirrtlCli, RunFirrtlTransformAnnotation}
8
// import xstransforms.ShowPrintTransform
9
import xstransforms.PrintModuleName
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

case class DisablePrintfAnnotation(m: String) extends NoTargetAnnotation

object DisablePrintfAnnotation extends HasShellOptions{

  val options = Seq(
    new ShellOption[String](
      longOption = "disable-module-print",
      toAnnotationSeq = s => Seq(DisablePrintfAnnotation(s)),
      helpText =
        "The verilog 'printf' in the <module> and it's submodules will be removed\n",
      shortOption = Some("dm"),
      helpValueName = Some("<module>")
    )
  )

}

L
linjiawei 已提交
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
case class EnablePrintfAnnotation(m: String) extends NoTargetAnnotation

object EnablePrintfAnnotation extends HasShellOptions {
  val options = Seq(
    new ShellOption[String](
      longOption = "enable-module-print",
      toAnnotationSeq = s => Seq(EnablePrintfAnnotation(s)),
      helpText =
        "The verilog 'printf' except the <module> and it's submodules will be removed\n",
      shortOption = Some("em"),
      helpValueName = Some("<module>")
    )
  )

}

44 45 46 47 48
case class DisableAllPrintAnnotation() extends NoTargetAnnotation

object DisableAllPrintAnnotation extends HasShellOptions {
  val options = Seq(
    new ShellOption[Unit](
49
      longOption = "disable-all",
50 51 52 53 54 55 56 57 58 59 60
      toAnnotationSeq = _ => Seq(DisableAllPrintAnnotation()),
      helpText =
        "All the verilog 'printf' will be removed\n",
      shortOption = Some("dall")
    )
  )
}

trait XiangShanCli { this: Shell =>
  parser.note("XiangShan Options")
  DisablePrintfAnnotation.addOptions(parser)
L
linjiawei 已提交
61
  EnablePrintfAnnotation.addOptions(parser)
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
  DisableAllPrintAnnotation.addOptions(parser)
}

class XiangShanStage extends chisel3.stage.ChiselStage {
  override val shell: Shell = new Shell("xiangshan")
    with XiangShanCli
    with ChiselCli
    with FirrtlCli
}

object XiangShanStage {
  def execute
  (
    args: Array[String],
    annotations: AnnotationSeq
  ): AnnotationSeq = {
    (new XiangShanStage).execute(
      args,
80
      annotations ++ Seq(
81
        // RunFirrtlTransformAnnotation(new ShowPrintTransform),
82 83
        RunFirrtlTransformAnnotation(new PrintModuleName)
      )
84 85 86
    )
  }
}