xref: /XiangShan/src/main/scala/xiangshan/frontend/BPU.scala (revision 05596c2b50e42dead43a81f18a6d7c34c1c44dd6)
1package xiangshan.frontend
2
3import chisel3._
4import chisel3.util._
5import utils._
6import xiangshan._
7import xiangshan.backend.ALUOpType
8import xiangshan.backend.JumpOpType
9
10class TableAddr(val idxBits: Int, val banks: Int) extends XSBundle {
11  def tagBits = VAddrBits - idxBits - 1
12
13  val tag = UInt(tagBits.W)
14  val idx = UInt(idxBits.W)
15  val offset = UInt(1.W)
16
17  def fromUInt(x: UInt) = x.asTypeOf(UInt(VAddrBits.W)).asTypeOf(this)
18  def getTag(x: UInt) = fromUInt(x).tag
19  def getIdx(x: UInt) = fromUInt(x).idx
20  def getBank(x: UInt) = getIdx(x)(log2Up(banks) - 1, 0)
21  def getBankIdx(x: UInt) = getIdx(x)(idxBits - 1, log2Up(banks))
22}
23
24class PredictorResponse extends XSBundle {
25  class UbtbResp extends XSBundle {
26  // the valid bits indicates whether a target is hit
27    val targets = Vec(PredictWidth, UInt(VAddrBits.W))
28    val hits = Vec(PredictWidth, Bool())
29    val takens = Vec(PredictWidth, Bool())
30    val notTakens = Vec(PredictWidth, Bool())
31    val is_RVC = Vec(PredictWidth, Bool())
32  }
33  class BtbResp extends XSBundle {
34  // the valid bits indicates whether a target is hit
35    val targets = Vec(PredictWidth, UInt(VAddrBits.W))
36    val hits = Vec(PredictWidth, Bool())
37    val types = Vec(PredictWidth, UInt(2.W))
38    val isRVC = Vec(PredictWidth, Bool())
39  }
40  class BimResp extends XSBundle {
41    val ctrs = Vec(PredictWidth, UInt(2.W))
42  }
43  class TageResp extends XSBundle {
44  // the valid bits indicates whether a prediction is hit
45    val takens = Vec(PredictWidth, Bool())
46    val hits = Vec(PredictWidth, Bool())
47  }
48  class LoopResp extends XSBundle {
49    val exit = Vec(PredictWidth, Bool())
50  }
51
52  val ubtb = new UbtbResp
53  val btb = new BtbResp
54  val bim = new BimResp
55  val tage = new TageResp
56  val loop = new LoopResp
57}
58
59abstract class BasePredictor extends XSModule {
60  val metaLen = 0
61
62  // An implementation MUST extend the IO bundle with a response
63  // and the special input from other predictors, as well as
64  // the metas to store in BRQ
65  abstract class Resp extends XSBundle {}
66  abstract class FromOthers extends XSBundle {}
67  abstract class Meta extends XSBundle {}
68
69  class DefaultBasePredictorIO extends XSBundle {
70    val flush = Input(Bool())
71    val pc = Flipped(ValidIO(UInt(VAddrBits.W)))
72    val hist = Input(UInt(HistoryLength.W))
73    val inMask = Input(UInt(PredictWidth.W))
74    val update = Flipped(ValidIO(new BranchUpdateInfoWithHist))
75  }
76
77  val io = new DefaultBasePredictorIO
78
79  // circular shifting
80  def circularShiftLeft(source: UInt, len: Int, shamt: UInt): UInt = {
81    val res = Wire(UInt(len.W))
82    val higher = source << shamt
83    val lower = source >> (len.U - shamt)
84    res := higher | lower
85    res
86  }
87
88  def circularShiftRight(source: UInt, len: Int, shamt: UInt): UInt = {
89    val res = Wire(UInt(len.W))
90    val higher = source << (len.U - shamt)
91    val lower = source >> shamt
92    res := higher | lower
93    res
94  }
95}
96
97class BPUStageIO extends XSBundle {
98  val pc = UInt(VAddrBits.W)
99  val mask = UInt(PredictWidth.W)
100  val resp = new PredictorResponse
101  val target = UInt(VAddrBits.W)
102  val brInfo = Vec(PredictWidth, new BranchInfo)
103}
104
105
106abstract class BPUStage extends XSModule {
107  class DefaultIO extends XSBundle {
108    val flush = Input(Bool())
109    val in = Flipped(Decoupled(new BPUStageIO))
110    val pred = Decoupled(new BranchPrediction)
111    val out = Decoupled(new BPUStageIO)
112    val predecode = Flipped(ValidIO(new Predecode))
113  }
114  val io = IO(new DefaultIO)
115
116  val predValid = RegInit(false.B)
117
118  io.in.ready := !predValid || io.out.fire() && io.pred.fire() || io.flush
119
120  def npc(pc: UInt, instCount: UInt) = pc + (instCount << 1.U)
121
122  val inFire = io.in.fire()
123  val inLatch = RegEnable(io.in.bits, inFire)
124
125  val outFire = io.out.fire()
126
127  // Each stage has its own logic to decide
128  // takens, notTakens and target
129
130  val takens = Wire(Vec(PredictWidth, Bool()))
131  val notTakens = Wire(Vec(PredictWidth, Bool()))
132  val jmpIdx = PriorityEncoder(takens)
133  val hasNTBr = (0 until PredictWidth).map(i => i.U <= jmpIdx && notTakens(i)).reduce(_||_)
134  val taken = takens.reduce(_||_)
135  // get the last valid inst
136  // val lastValidPos = MuxCase(0.U, (PredictWidth-1 to 0).map(i => (inLatch.mask(i), i.U)))
137  val lastValidPos = PriorityMux(Reverse(inLatch.mask), (PredictWidth-1 to 0 by -1).map(i => i.U))
138  val lastHit   = Wire(Bool())
139  val lastIsRVC = Wire(Bool())
140  // val lastValidPos = WireInit(0.U(log2Up(PredictWidth).W))
141  // for (i <- 0 until PredictWidth) {
142  //   when (inLatch.mask(i)) { lastValidPos := i.U }
143  // }
144  val targetSrc = Wire(Vec(PredictWidth, UInt(VAddrBits.W)))
145  val target = Mux(taken, targetSrc(jmpIdx), npc(inLatch.pc, PopCount(inLatch.mask)))
146
147  io.pred.bits <> DontCare
148  io.pred.bits.redirect := target =/= inLatch.target
149  io.pred.bits.taken := taken
150  io.pred.bits.jmpIdx := jmpIdx
151  io.pred.bits.hasNotTakenBrs := hasNTBr
152  io.pred.bits.target := target
153  io.pred.bits.saveHalfRVI := ((lastValidPos === jmpIdx && taken) || !taken ) && !lastIsRVC && lastHit
154
155  io.out.bits <> DontCare
156  io.out.bits.pc := inLatch.pc
157  io.out.bits.mask := inLatch.mask
158  io.out.bits.target := target
159  io.out.bits.resp <> inLatch.resp
160  io.out.bits.brInfo := inLatch.brInfo
161
162  // Default logic
163  //  pred.ready not taken into consideration
164  //  could be broken
165  when (io.flush)     { predValid := false.B }
166  .elsewhen (inFire)  { predValid := true.B }
167  .elsewhen (outFire) { predValid := false.B }
168  .otherwise          { predValid := predValid }
169
170  io.out.valid  := predValid && !io.flush
171  io.pred.valid := predValid && !io.flush
172
173  XSDebug(io.in.fire(), "in:(%d %d) pc=%x, mask=%b, target=%x\n",
174    io.in.valid, io.in.ready, io.in.bits.pc, io.in.bits.mask, io.in.bits.target)
175  XSDebug(io.out.fire(), "out:(%d %d) pc=%x, mask=%b, target=%x\n",
176    io.out.valid, io.out.ready, io.out.bits.pc, io.out.bits.mask, io.out.bits.target)
177  XSDebug("flush=%d\n", io.flush)
178  XSDebug("taken=%d, takens=%b, notTakens=%b, jmpIdx=%d, hasNTBr=%d, lastValidPos=%d, target=%x\n",
179    taken, takens.asUInt, notTakens.asUInt, jmpIdx, hasNTBr, lastValidPos, target)
180  val p = io.pred.bits
181  XSDebug(io.pred.fire(), "outPred: redirect=%d, taken=%d, jmpIdx=%d, hasNTBrs=%d, target=%x, saveHalfRVI=%d\n",
182    p.redirect, p.taken, p.jmpIdx, p.hasNotTakenBrs, p.target, p.saveHalfRVI)
183  XSDebug(io.pred.fire() && p.taken, "outPredTaken: fetchPC:%x, jmpPC:%x\n",
184    inLatch.pc, inLatch.pc + (jmpIdx << 1.U))
185  XSDebug(io.pred.fire() && p.redirect, "outPred: previous target:%x redirected to %x \n",
186    inLatch.target, p.target)
187  XSDebug(io.pred.fire(), "outPred targetSrc: ")
188  for (i <- 0 until PredictWidth) {
189    XSDebug(false, io.pred.fire(), "(%d):%x ", i.U, targetSrc(i))
190  }
191  XSDebug(false, io.pred.fire(), "\n")
192}
193
194class BPUStage1 extends BPUStage {
195
196  // 'overrides' default logic
197  // when flush, the prediction should also starts
198  when (inFire)        { predValid := true.B }
199  .elsewhen (io.flush) { predValid := false.B }
200  .elsewhen (outFire)  { predValid := false.B }
201  .otherwise           { predValid := predValid }
202  // io.out.valid := predValid
203
204  // ubtb is accessed with inLatch pc in s1,
205  // so we use io.in instead of inLatch
206  val ubtbResp = io.in.bits.resp.ubtb
207  // the read operation is already masked, so we do not need to mask here
208  takens    := VecInit((0 until PredictWidth).map(i => ubtbResp.hits(i) && ubtbResp.takens(i)))
209  notTakens := VecInit((0 until PredictWidth).map(i => ubtbResp.hits(i) && ubtbResp.notTakens(i)))
210  targetSrc := ubtbResp.targets
211
212  lastIsRVC := ubtbResp.is_RVC(lastValidPos)
213  lastHit   := ubtbResp.hits(lastValidPos)
214
215  // resp and brInfo are from the components,
216  // so it does not need to be latched
217  io.out.bits.resp <> io.in.bits.resp
218  io.out.bits.brInfo := io.in.bits.brInfo
219  io.out.bits.brInfo.map(_.debug_ubtb_cycle := GTimer())
220
221  XSDebug(io.pred.fire(), "outPred using ubtb resp: hits:%b, takens:%b, notTakens:%b, isRVC:%b\n",
222    ubtbResp.hits.asUInt, ubtbResp.takens.asUInt, ubtbResp.notTakens.asUInt, ubtbResp.is_RVC.asUInt)
223}
224
225class BPUStage2 extends BPUStage {
226
227  // Use latched response from s1
228  val btbResp = inLatch.resp.btb
229  val bimResp = inLatch.resp.bim
230  takens    := VecInit((0 until PredictWidth).map(i => btbResp.hits(i) && (btbResp.types(i) === BTBtype.B && bimResp.ctrs(i)(1) || btbResp.types(i) =/= BTBtype.B)))
231  notTakens := VecInit((0 until PredictWidth).map(i => btbResp.hits(i) && btbResp.types(i) === BTBtype.B && !bimResp.ctrs(i)(1)))
232  targetSrc := btbResp.targets
233
234  lastIsRVC := btbResp.isRVC(lastValidPos)
235  lastHit   := btbResp.hits(lastValidPos)
236
237  io.out.bits.brInfo.map(_.debug_btb_cycle := GTimer())
238
239  XSDebug(io.pred.fire(), "outPred using btb&bim resp: hits:%b, ctrTakens:%b\n",
240    btbResp.hits.asUInt, VecInit(bimResp.ctrs.map(_(1))).asUInt)
241}
242
243class BPUStage3 extends BPUStage {
244
245  io.out.valid := predValid && io.predecode.valid && !io.flush
246
247  // TAGE has its own pipelines and the
248  // response comes directly from s3,
249  // so we do not use those from inLatch
250  val tageResp = io.in.bits.resp.tage
251  val tageTakens = tageResp.takens
252
253  val loopResp = io.in.bits.resp.loop.exit
254
255  val pdMask = io.predecode.bits.mask
256  val pds    = io.predecode.bits.pd
257
258  val btbHits   = inLatch.resp.btb.hits.asUInt
259  val bimTakens = VecInit(inLatch.resp.bim.ctrs.map(_(1)))
260
261  val brs   = pdMask & Reverse(Cat(pds.map(_.isBr)))
262  val jals  = pdMask & Reverse(Cat(pds.map(_.isJal)))
263  val jalrs = pdMask & Reverse(Cat(pds.map(_.isJalr)))
264  // val calls = pdMask & Reverse(Cat(pds.map(_.isCall)))
265  // val rets  = pdMask & Reverse(Cat(pds.map(_.isRet)))
266
267  // val callIdx = PriorityEncoder(calls)
268  // val retIdx  = PriorityEncoder(rets)
269
270  val brTakens = brs &
271    (if (EnableBPD) Reverse(Cat((0 until PredictWidth).map(i => tageTakens(i)))) else Reverse(Cat((0 until PredictWidth).map(i => bimTakens(i))))) &
272    (if (EnableLoop) ~loopResp.asUInt else Fill(PredictWidth, 1.U(1.W)))
273    // if (EnableBPD) {
274    //   brs & Reverse(Cat((0 until PredictWidth).map(i => tageValidTakens(i))))
275    // } else {
276    //   brs & Reverse(Cat((0 until PredictWidth).map(i => bimTakens(i))))
277    // }
278
279  // predict taken only if btb has a target, jal targets will be provided by IFU
280  takens := VecInit((0 until PredictWidth).map(i => (brTakens(i) || jalrs(i)) && btbHits(i) || jals(i)))
281  // Whether should we count in branches that are not recorded in btb?
282  // PS: Currently counted in. Whenever tage does not provide a valid
283  //     taken prediction, the branch is counted as a not taken branch
284  notTakens := (if (EnableBPD) { VecInit((0 until PredictWidth).map(i => brs(i) && !tageTakens(i)))}
285                else           { VecInit((0 until PredictWidth).map(i => brs(i) && !bimTakens(i)))})
286  targetSrc := inLatch.resp.btb.targets
287
288  lastIsRVC := pds(lastValidPos).isRVC
289  when (lastValidPos === 1.U) {
290    lastHit := pdMask(1) |
291      !pdMask(0) & !pdMask(1) |
292      pdMask(0) & !pdMask(1) & (pds(0).isRVC | !io.predecode.bits.isFetchpcEqualFirstpc)
293  }.elsewhen (lastValidPos > 0.U) {
294    lastHit := pdMask(lastValidPos) |
295      !pdMask(lastValidPos - 1.U) & !pdMask(lastValidPos) |
296      pdMask(lastValidPos - 1.U) & !pdMask(lastValidPos) & pds(lastValidPos - 1.U).isRVC
297  }.otherwise {
298    lastHit := pdMask(0) | !pdMask(0) & !pds(0).isRVC
299  }
300
301  io.out.bits.brInfo.map(_.debug_tage_cycle := GTimer())
302
303  // Wrap tage resp and tage meta in
304  // This is ugly
305  io.out.bits.resp.tage <> io.in.bits.resp.tage
306  io.out.bits.resp.loop <> io.in.bits.resp.loop
307  for (i <- 0 until PredictWidth) {
308    io.out.bits.brInfo(i).tageMeta := io.in.bits.brInfo(i).tageMeta
309    io.out.bits.brInfo(i).specCnt := io.in.bits.brInfo(i).specCnt
310  }
311
312  XSDebug(io.predecode.valid, "predecode: pc:%x, mask:%b\n", inLatch.pc, io.predecode.bits.mask)
313  for (i <- 0 until PredictWidth) {
314    val p = io.predecode.bits.pd(i)
315    XSDebug(io.predecode.valid && io.predecode.bits.mask(i), "predecode(%d): brType:%d, br:%d, jal:%d, jalr:%d, call:%d, ret:%d, RVC:%d, excType:%d\n",
316      i.U, p.brType, p.isBr, p.isJal, p.isJalr, p.isCall, p.isRet, p.isRVC, p.excType)
317  }
318}
319
320trait BranchPredictorComponents extends HasXSParameter {
321  val ubtb = Module(new MicroBTB)
322  val btb = Module(new BTB)
323  val bim = Module(new BIM)
324  val tage = (if(EnableBPD) { Module(new Tage) }
325              else          { Module(new FakeTage) })
326  val loop = Module(new LoopPredictor)
327  val preds = Seq(ubtb, btb, bim, tage, loop)
328  preds.map(_.io := DontCare)
329}
330
331class BPUReq extends XSBundle {
332  val pc = UInt(VAddrBits.W)
333  val hist = UInt(HistoryLength.W)
334  val inMask = UInt(PredictWidth.W)
335}
336
337class BranchUpdateInfoWithHist extends XSBundle {
338  val ui = new BranchUpdateInfo
339  val hist = UInt(HistoryLength.W)
340}
341
342object BranchUpdateInfoWithHist {
343  def apply (brInfo: BranchUpdateInfo, hist: UInt) = {
344    val b = Wire(new BranchUpdateInfoWithHist)
345    b.ui <> brInfo
346    b.hist := hist
347    b
348  }
349}
350
351abstract class BaseBPU extends XSModule with BranchPredictorComponents{
352  val io = IO(new Bundle() {
353    // from backend
354    val inOrderBrInfo    = Flipped(ValidIO(new BranchUpdateInfoWithHist))
355    val outOfOrderBrInfo = Flipped(ValidIO(new BranchUpdateInfoWithHist))
356    // from ifu, frontend redirect
357    val flush = Input(Vec(3, Bool()))
358    // from if1
359    val in = Flipped(ValidIO(new BPUReq))
360    // to if2/if3/if4
361    val out = Vec(3, Decoupled(new BranchPrediction))
362    // from if4
363    val predecode = Flipped(ValidIO(new Predecode))
364    // to if4, some bpu info used for updating
365    val branchInfo = Decoupled(Vec(PredictWidth, new BranchInfo))
366  })
367
368  def npc(pc: UInt, instCount: UInt) = pc + (instCount << 1.U)
369
370  preds.map(_.io.update <> io.outOfOrderBrInfo)
371  tage.io.update <> io.inOrderBrInfo
372
373  val s1 = Module(new BPUStage1)
374  val s2 = Module(new BPUStage2)
375  val s3 = Module(new BPUStage3)
376
377  s1.io.flush := io.flush(0)
378  s2.io.flush := io.flush(1)
379  s3.io.flush := io.flush(2)
380
381  s1.io.in <> DontCare
382  s2.io.in <> s1.io.out
383  s3.io.in <> s2.io.out
384
385  io.out(0) <> s1.io.pred
386  io.out(1) <> s2.io.pred
387  io.out(2) <> s3.io.pred
388
389  s1.io.predecode <> DontCare
390  s2.io.predecode <> DontCare
391  s3.io.predecode <> io.predecode
392
393  io.branchInfo.valid := s3.io.out.valid
394  io.branchInfo.bits := s3.io.out.bits.brInfo
395  s3.io.out.ready := io.branchInfo.ready
396
397  XSDebug(io.branchInfo.fire(), "branchInfo sent!\n")
398  for (i <- 0 until PredictWidth) {
399    val b = io.branchInfo.bits(i)
400    XSDebug(io.branchInfo.fire(), "brInfo(%d): ubtbWrWay:%d, ubtbHit:%d, btbWrWay:%d, btbHitJal:%d, bimCtr:%d, fetchIdx:%d\n",
401      i.U, b.ubtbWriteWay, b.ubtbHits, b.btbWriteWay, b.btbHitJal, b.bimCtr, b.fetchIdx)
402    val t = b.tageMeta
403    XSDebug(io.branchInfo.fire(), "  tageMeta: pvder(%d):%d, altDiffers:%d, pvderU:%d, pvderCtr:%d, allocate(%d):%d\n",
404      t.provider.valid, t.provider.bits, t.altDiffers, t.providerU, t.providerCtr, t.allocate.valid, t.allocate.bits)
405  }
406  val debug_verbose = false
407}
408
409
410class FakeBPU extends BaseBPU {
411  io.out.foreach(i => {
412    // Provide not takens
413    i.valid := true.B
414    i.bits <> DontCare
415    i.bits.redirect := false.B
416  })
417  io.branchInfo <> DontCare
418}
419
420class BPU extends BaseBPU {
421
422  //**********************Stage 1****************************//
423  val s1_fire = s1.io.in.fire()
424  val s1_resp_in = Wire(new PredictorResponse)
425  val s1_brInfo_in = Wire(Vec(PredictWidth, new BranchInfo))
426
427  s1_resp_in.tage := DontCare
428  s1_resp_in.loop := DontCare
429  s1_brInfo_in    := DontCare
430  (0 until PredictWidth).foreach(i => s1_brInfo_in(i).fetchIdx := i.U)
431
432  val s1_inLatch = RegEnable(io.in, s1_fire)
433  ubtb.io.flush := io.flush(0) // TODO: fix this
434  ubtb.io.pc.valid := s1_inLatch.valid
435  ubtb.io.pc.bits := s1_inLatch.bits.pc
436  ubtb.io.inMask := s1_inLatch.bits.inMask
437
438
439
440  // Wrap ubtb response into resp_in and brInfo_in
441  s1_resp_in.ubtb <> ubtb.io.out
442  for (i <- 0 until PredictWidth) {
443    s1_brInfo_in(i).ubtbWriteWay := ubtb.io.uBTBBranchInfo.writeWay(i)
444    s1_brInfo_in(i).ubtbHits := ubtb.io.uBTBBranchInfo.hits(i)
445  }
446
447  btb.io.flush := io.flush(0) // TODO: fix this
448  btb.io.pc.valid := io.in.valid
449  btb.io.pc.bits := io.in.bits.pc
450  btb.io.inMask := io.in.bits.inMask
451
452
453
454  // Wrap btb response into resp_in and brInfo_in
455  s1_resp_in.btb <> btb.io.resp
456  for (i <- 0 until PredictWidth) {
457    s1_brInfo_in(i).btbWriteWay := btb.io.meta.writeWay(i)
458    s1_brInfo_in(i).btbHitJal   := btb.io.meta.hitJal(i)
459  }
460
461  bim.io.flush := io.flush(0) // TODO: fix this
462  bim.io.pc.valid := io.in.valid
463  bim.io.pc.bits := io.in.bits.pc
464  bim.io.inMask := io.in.bits.inMask
465
466
467  // Wrap bim response into resp_in and brInfo_in
468  s1_resp_in.bim <> bim.io.resp
469  for (i <- 0 until PredictWidth) {
470    s1_brInfo_in(i).bimCtr := bim.io.meta.ctrs(i)
471  }
472
473
474  s1.io.in.valid := io.in.valid
475  s1.io.in.bits.pc := io.in.bits.pc
476  s1.io.in.bits.mask := io.in.bits.inMask
477  s1.io.in.bits.target := npc(io.in.bits.pc, PopCount(io.in.bits.inMask)) // Deault target npc
478  s1.io.in.bits.resp <> s1_resp_in
479  s1.io.in.bits.brInfo <> s1_brInfo_in
480
481  val s1_hist = RegEnable(io.in.bits.hist, enable=io.in.valid)
482
483  //**********************Stage 2****************************//
484  tage.io.flush := io.flush(1) // TODO: fix this
485  tage.io.pc.valid := s1.io.out.fire()
486  tage.io.pc.bits := s1.io.out.bits.pc // PC from s1
487  tage.io.hist := s1_hist // The inst is from s1
488  tage.io.inMask := s1.io.out.bits.mask
489  tage.io.s3Fire := s3.io.in.fire() // Tell tage to march 1 stage
490  tage.io.bim <> s1.io.out.bits.resp.bim // Use bim results from s1
491
492  //**********************Stage 3****************************//
493  // Wrap tage response and meta into s3.io.in.bits
494  // This is ugly
495
496  loop.io.flush := io.flush(2)
497  loop.io.pc.valid := s2.io.out.fire()
498  loop.io.pc.bits := s2.io.out.bits.pc
499
500  s3.io.in.bits.resp.tage <> tage.io.resp
501  s3.io.in.bits.resp.loop <> loop.io.resp
502  for (i <- 0 until PredictWidth) {
503    s3.io.in.bits.brInfo(i).tageMeta := tage.io.meta(i)
504    s3.io.in.bits.brInfo(i).specCnt := loop.io.meta.specCnts(i)
505  }
506
507  if (debug_verbose) {
508    val uo = ubtb.io.out
509    XSDebug("debug: ubtb hits:%b, takens:%b, notTakens:%b\n", uo.hits.asUInt, uo.takens.asUInt, uo.notTakens.asUInt)
510    val bio = bim.io.resp
511    XSDebug("debug: bim takens:%b\n", VecInit(bio.ctrs.map(_(1))).asUInt)
512    val bo = btb.io.resp
513    XSDebug("debug: btb hits:%b\n", bo.hits.asUInt)
514  }
515
516}
517