xref: /XiangShan/src/test/scala/xiangshan/DecodeTest.scala (revision 195ef4a53ab54326d879e884c4e1568f424f2668)
1package xiangshan
2
3import chisel3._
4import chisel3.stage.ChiselGeneratorAnnotation
5import chiseltest._
6import chiseltest.VerilatorBackendAnnotation
7import chiseltest.simulator.VerilatorFlags
8import top.ArgParser
9import xiangshan.backend.decode.DecodeUnit
10import xiangshan.backend.regfile.IntPregParams
11import types.ChiselStage
12import xiangshan.test.types._
13import xiangshan.transforms.PrintModuleName
14
15object DecodeMain extends App {
16  val (config, firrtlOpts, firtoolOpts) = ArgParser.parse(args)
17  // //val soc = DisableMonitors(p => LazyModule(new XSTop()(p)))(config)
18  // If Complex Params are needed, wrap it with a Top Module to do dirty works,
19  // and use "chisel3.aop.Select.collectDeep[ModuleWanted](WrapperModule){case a: ModuleWanted => a}.head.Params"
20  val defaultConfig = config.alterPartial({
21    // Get XSCoreParams and pass it to the "small module"
22    case XSCoreParamsKey => config(XSTileKey).head.copy(
23      // Example of how to change params
24      intPreg = IntPregParams(
25          numEntries = 64,
26          numRead = Some(14),
27          numWrite = Some(8),
28        ),
29    )
30  })
31  (new ChiselStage).execute(args, Seq(
32    ChiselGeneratorAnnotation(() => new DecodeUnit()(defaultConfig)
33  )))
34//  // Generate files when compiling. Used by ChiselDB.
35//  FileRegisters.write("./build")
36}
37
38class DecodeUnitTest extends XSTester {
39  behavior of "DecodeUnit"
40  it should "pass" in {
41    val printModuleNameAnno = chisel3.BuildInfo.version match {
42      case "3.6.0" => Seq(RunFirrtlTransformAnnotation(new PrintModuleName))
43      case _ => Seq()
44    }
45
46    test(new DecodeUnit()(config)).withAnnotations(Seq(
47      VerilatorBackendAnnotation,
48      VerilatorFlags(Seq()),
49      WriteVcdAnnotation,
50      TargetDirAnnotation("./build")
51    ) ++ printModuleNameAnno){ dut =>
52      dut.clock.step(10)
53    }
54  }
55}
56