1*db3923feSGuanghui Chengpackage xiangshan.frontend 2*db3923feSGuanghui Cheng 3*db3923feSGuanghui Chengimport chisel3._ 4*db3923feSGuanghui Chengimport chiseltest._ 5*db3923feSGuanghui Chengimport org.scalatest.flatspec.AnyFlatSpec 6*db3923feSGuanghui Chengimport org.scalatest.matchers.must.Matchers 7*db3923feSGuanghui Chengimport top.DefaultConfig 8*db3923feSGuanghui Chengimport utility.{LogUtilsOptions, LogUtilsOptionsKey} 9*db3923feSGuanghui Chengimport xiangshan.{DebugOptionsKey, XSCoreParameters, XSCoreParamsKey} 10*db3923feSGuanghui Cheng 11*db3923feSGuanghui Cheng 12*db3923feSGuanghui Chengclass FrontendTriggerTest extends AnyFlatSpec with ChiselScalatestTester with Matchers { 13*db3923feSGuanghui Cheng val defaultConfig = (new DefaultConfig).alterPartial { 14*db3923feSGuanghui Cheng case XSCoreParamsKey => XSCoreParameters() 15*db3923feSGuanghui Cheng }.alter((site, here, up) => { 16*db3923feSGuanghui Cheng case LogUtilsOptionsKey => LogUtilsOptions( 17*db3923feSGuanghui Cheng here(DebugOptionsKey).EnableDebug, 18*db3923feSGuanghui Cheng here(DebugOptionsKey).EnablePerfDebug, 19*db3923feSGuanghui Cheng here(DebugOptionsKey).FPGAPlatform 20*db3923feSGuanghui Cheng ) 21*db3923feSGuanghui Cheng }) 22*db3923feSGuanghui Cheng 23*db3923feSGuanghui Cheng println("test start") 24*db3923feSGuanghui Cheng 25*db3923feSGuanghui Cheng behavior of "FrontendTrigger" 26*db3923feSGuanghui Cheng it should "run" in { 27*db3923feSGuanghui Cheng test(new FrontendTrigger()(defaultConfig)).withAnnotations(Seq(VerilatorBackendAnnotation)) { 28*db3923feSGuanghui Cheng m: FrontendTrigger => 29*db3923feSGuanghui Cheng m.io.frontendTrigger.debugMode.poke(false.B) 30*db3923feSGuanghui Cheng m.io.frontendTrigger.tEnableVec.map(_.poke(false.B)) 31*db3923feSGuanghui Cheng m.io.frontendTrigger.tEnableVec(1).poke(true.B) 32*db3923feSGuanghui Cheng m.io.frontendTrigger.triggerCanRaiseBpExp.poke(true.B) 33*db3923feSGuanghui Cheng m.io.frontendTrigger.tUpdate.valid.poke(true.B) 34*db3923feSGuanghui Cheng m.io.frontendTrigger.tUpdate.bits.addr.poke(1.U) 35*db3923feSGuanghui Cheng m.io.frontendTrigger.tUpdate.bits.tdata.matchType.poke(3.U) 36*db3923feSGuanghui Cheng m.io.frontendTrigger.tUpdate.bits.tdata.tdata2.poke("h1234_567f".U) 37*db3923feSGuanghui Cheng m.io.pc.zipWithIndex.map { case (pc, i) => 38*db3923feSGuanghui Cheng pc.poke((0x1234_5676 + 2 * i).U) 39*db3923feSGuanghui Cheng } 40*db3923feSGuanghui Cheng for (_ <- 0 until 4) { m.clock.step() } 41*db3923feSGuanghui Cheng m.io.triggered.zipWithIndex.map { case (action, i) => 42*db3923feSGuanghui Cheng println(s"out.triggerAction${i}:" + action.peek().litValue.toString(16) + "\n") 43*db3923feSGuanghui Cheng } 44*db3923feSGuanghui Cheng } 45*db3923feSGuanghui Cheng println("test done") 46*db3923feSGuanghui Cheng } 47*db3923feSGuanghui Cheng} 48