xref: /XiangShan/src/test/scala/xiangshan/DecodeTest.scala (revision e3da8bad334fc71ba0d72f0607e2e93245ddaece)
151981c77SbugGeneratorpackage xiangshan
251981c77SbugGenerator
351981c77SbugGeneratorimport chisel3._
451e45dbbSTang Haojinimport chisel3.stage.ChiselGeneratorAnnotation
551981c77SbugGeneratorimport chiseltest._
651981c77SbugGeneratorimport chiseltest.VerilatorBackendAnnotation
751e45dbbSTang Haojinimport chiseltest.simulator.VerilatorFlags
851981c77SbugGeneratorimport top.ArgParser
951981c77SbugGeneratorimport xiangshan.backend.decode.DecodeUnit
108a00ff56SXuan Huimport xiangshan.backend.regfile.IntPregParams
11*e3da8badSTang Haojinimport circt.stage.ChiselStage
12*e3da8badSTang Haojinimport firrtl2.options.TargetDirAnnotation
135931ace3STang Haojinimport xiangshan.transforms.PrintModuleName
1451981c77SbugGenerator
157f37d55fSTang Haojinobject DecodeMain extends App {
1651e45dbbSTang Haojin  val (config, firrtlOpts, firtoolOpts) = ArgParser.parse(args)
1751981c77SbugGenerator  // //val soc = DisableMonitors(p => LazyModule(new XSTop()(p)))(config)
1851981c77SbugGenerator  // If Complex Params are needed, wrap it with a Top Module to do dirty works,
1951981c77SbugGenerator  // and use "chisel3.aop.Select.collectDeep[ModuleWanted](WrapperModule){case a: ModuleWanted => a}.head.Params"
2051981c77SbugGenerator  val defaultConfig = config.alterPartial({
2151981c77SbugGenerator    // Get XSCoreParams and pass it to the "small module"
2251981c77SbugGenerator    case XSCoreParamsKey => config(XSTileKey).head.copy(
2351981c77SbugGenerator      // Example of how to change params
248a00ff56SXuan Hu      intPreg = IntPregParams(
258a00ff56SXuan Hu          numEntries = 64,
2639c59369SXuan Hu          numRead = Some(14),
2739c59369SXuan Hu          numWrite = Some(8),
288a00ff56SXuan Hu        ),
2951981c77SbugGenerator    )
3051981c77SbugGenerator  })
3151981c77SbugGenerator  (new ChiselStage).execute(args, Seq(
3251981c77SbugGenerator    ChiselGeneratorAnnotation(() => new DecodeUnit()(defaultConfig)
3351981c77SbugGenerator  )))
3451981c77SbugGenerator//  // Generate files when compiling. Used by ChiselDB.
35876196b7SMaxpicca-Li//  FileRegisters.write("./build")
3651981c77SbugGenerator}
3751981c77SbugGenerator
3851981c77SbugGeneratorclass DecodeUnitTest extends XSTester {
3951981c77SbugGenerator  behavior of "DecodeUnit"
4051981c77SbugGenerator  it should "pass" in {
4151981c77SbugGenerator    test(new DecodeUnit()(config)).withAnnotations(Seq(
4251981c77SbugGenerator      VerilatorBackendAnnotation,
4351981c77SbugGenerator      VerilatorFlags(Seq()),
4451981c77SbugGenerator      WriteVcdAnnotation,
4551e45dbbSTang Haojin      TargetDirAnnotation("./build")
46*e3da8badSTang Haojin    )){ dut =>
4751981c77SbugGenerator      dut.clock.step(10)
4851981c77SbugGenerator    }
4951981c77SbugGenerator  }
5051981c77SbugGenerator}
51