uBTBTest.scala 2.2 KB
Newer Older
1 2 3
package xiangshan.frontend

import chisel3._
L
LinJiawei 已提交
4 5
import chiseltest._
import org.scalatest._
J
Jiuyang liu 已提交
6 7
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.must.Matchers
8 9 10
import xiangshan.testutils._


J
Jiuyang liu 已提交
11
class uBTBTest extends AnyFlatSpec
12 13 14 15 16 17 18 19
with ChiselScalatestTester 
with Matchers 
with ParallelTestExecution
with HasPartialDecoupledDriver {
  it should "test uBTBTest" in {
    test(new MicroBTB) { c =>
        def genUpdateReq(pc: Long,target: Long,taken: Boolean,fetchIdx: Int,isMiss: Boolean,write_way: Int,hit: Boolean) = {
          c.io.update.valid.poke(true.B)
L
Lingrui98 已提交
20 21 22 23 24 25 26 27
          c.io.update.bits.ui.pc.poke(pc.U)
          c.io.update.bits.ui.target.poke(target.U)
          c.io.update.bits.ui.taken.poke(taken.B)
          c.io.update.bits.ui.fetchIdx.poke(fetchIdx.U)
          c.io.update.bits.ui.isMisPred.poke(isMiss.B)
          c.io.update.bits.ui.brInfo.ubtbWriteWay.poke(write_way.U)
          c.io.update.bits.ui.brInfo.ubtbHits.poke(hit.B)
          c.io.update.bits.ui.pd.brType.poke(BrType.branch)
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
        }

        def genReadReq(fetchpc: Long){
          c.io.pc.valid.poke(true.B)
          c.io.pc.bits.poke(fetchpc.U)
          c.io.inMask.poke("b1111111111111111".U)
          c.clock.step(1)
          c.io.pc.valid.poke(false.B)
        }

        def UpdateOnly(pc: Long,target: Long,taken: Boolean,fetchIdx: Int,isMiss: Boolean,write_way: Int,hit: Boolean){
          genUpdateReq(pc,target,taken,fetchIdx,isMiss,write_way,hit)
          c.clock.step(1)
          c.io.update.valid.poke(false.B)
        }

        def Bypass(pc: Long,target: Long,taken: Boolean,fetchIdx: Int,isMiss: Boolean,write_way: Int,hit: Boolean){
          genUpdateReq(pc,target,taken,fetchIdx,isMiss,write_way,hit)
          genReadReq(fetchpc = pc + 2)
          c.clock.step(1)
          c.io.update.valid.poke(false.B)
          c.io.pc.valid.poke(false.B)
        }
        genReadReq(fetchpc = 0x60002010)
52
        UpdateOnly(pc=0x6000202a, target=0x60001000, taken = true , fetchIdx=6, isMiss = true , write_way=2, hit=false)
53
        genReadReq(fetchpc = 0x60002010)
J
jinyue110 已提交
54
        //Bypass(pc=0x60002034, target=0x600020b0, taken = true , fetchIdx=5, isMiss = true , write_way=5, hit=false)
55 56 57 58
    
    }
  }
}