xref: /XiangShan/src/main/scala/xiangshan/frontend/FrontendBundle.scala (revision ab890bfe778f5cadc6bc0079061b1498d214c7a1)
1/***************************************************************************************
2* Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences
3* Copyright (c) 2020-2021 Peng Cheng Laboratory
4*
5* XiangShan is licensed under Mulan PSL v2.
6* You can use this software according to the terms and conditions of the Mulan PSL v2.
7* You may obtain a copy of Mulan PSL v2 at:
8*          http://license.coscl.org.cn/MulanPSL2
9*
10* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13*
14* See the Mulan PSL v2 for more details.
15***************************************************************************************/
16package xiangshan.frontend
17
18import chipsalliance.rocketchip.config.Parameters
19import chisel3._
20import chisel3.util._
21import chisel3.experimental.chiselName
22import xiangshan._
23import utils._
24import scala.math._
25
26@chiselName
27class FetchRequestBundle(implicit p: Parameters) extends XSBundle {
28  val startAddr       = UInt(VAddrBits.W)
29  val fallThruAddr    = UInt(VAddrBits.W)
30  val fallThruError   = Bool()
31  val ftqIdx          = new FtqPtr
32  val ftqOffset       = ValidUndirectioned(UInt(log2Ceil(PredictWidth).W))
33  val target          = UInt(VAddrBits.W)
34  val oversize        = Bool()
35
36  def fallThroughError() = {
37    def carryPos = instOffsetBits+log2Ceil(PredictWidth)+1
38    def getLower(pc: UInt) = pc(instOffsetBits+log2Ceil(PredictWidth), instOffsetBits)
39    val carry = (startAddr(carryPos) =/= fallThruAddr(carryPos)).asUInt
40    val startLower        = Cat(0.U(1.W), getLower(startAddr))
41    val endLowerwithCarry = Cat(carry,    getLower(fallThruAddr))
42    require(startLower.getWidth == log2Ceil(PredictWidth)+2)
43    require(endLowerwithCarry.getWidth == log2Ceil(PredictWidth)+2)
44    startLower >= endLowerwithCarry || (endLowerwithCarry - startLower) > (PredictWidth+1).U
45  }
46  def fromFtqPcBundle(b: Ftq_RF_Components) = {
47    this.startAddr := b.startAddr
48    this.fallThruAddr := b.getFallThrough()
49    this.oversize := b.oversize
50    this
51  }
52  def fromBpuResp(resp: BranchPredictionBundle) = {
53    // only used to bypass, so some fields remains unchanged
54    this.startAddr := resp.pc
55    this.target := resp.target
56    this.ftqOffset := resp.genCfiIndex
57    this.fallThruAddr := resp.fallThroughAddr
58    this.oversize := resp.ftb_entry.oversize
59    this
60  }
61  override def toPrintable: Printable = {
62    p"[start] ${Hexadecimal(startAddr)} [pft] ${Hexadecimal(fallThruAddr)}" +
63      p"[tgt] ${Hexadecimal(target)} [ftqIdx] $ftqIdx [jmp] v:${ftqOffset.valid}" +
64      p" offset: ${ftqOffset.bits}\n"
65  }
66}
67
68class PredecodeWritebackBundle(implicit p:Parameters) extends XSBundle {
69  val pc           = Vec(PredictWidth, UInt(VAddrBits.W))
70  val pd           = Vec(PredictWidth, new PreDecodeInfo) // TODO: redefine Predecode
71  val ftqIdx       = new FtqPtr
72  val ftqOffset    = UInt(log2Ceil(PredictWidth).W)
73  val misOffset    = ValidUndirectioned(UInt(log2Ceil(PredictWidth).W))
74  val cfiOffset    = ValidUndirectioned(UInt(log2Ceil(PredictWidth).W))
75  val target       = UInt(VAddrBits.W)
76  val jalTarget    = UInt(VAddrBits.W)
77  val instrRange   = Vec(PredictWidth, Bool())
78}
79
80class Exception(implicit p: Parameters) extends XSBundle {
81
82}
83
84class FetchToIBuffer(implicit p: Parameters) extends XSBundle {
85  val instrs    = Vec(PredictWidth, UInt(32.W))
86  val valid     = UInt(PredictWidth.W)
87  val pd        = Vec(PredictWidth, new PreDecodeInfo)
88  val pc        = Vec(PredictWidth, UInt(VAddrBits.W))
89  val foldpc    = Vec(PredictWidth, UInt(MemPredPCWidth.W))
90  //val exception = new Exception
91  val ftqPtr       = new FtqPtr
92  val ftqOffset    = Vec(PredictWidth, ValidUndirectioned(UInt(log2Ceil(PredictWidth).W)))
93  val ipf          = Vec(PredictWidth, Bool())
94  val acf          = Vec(PredictWidth, Bool())
95  val crossPageIPFFix = Vec(PredictWidth, Bool())
96  val triggered    = Vec(PredictWidth, new TriggerCf)
97}
98
99// class BitWiseUInt(val width: Int, val init: UInt) extends Module {
100//   val io = IO(new Bundle {
101//     val set
102//   })
103// }
104// Move from BPU
105abstract class GlobalHistory(implicit p: Parameters) extends XSBundle with HasBPUConst {
106  def update(br_valids: Vec[Bool], real_taken_mask: Vec[Bool]): GlobalHistory
107}
108
109class ShiftingGlobalHistory(implicit p: Parameters) extends GlobalHistory {
110  val predHist = UInt(HistoryLength.W)
111
112  def update(shift: UInt, taken: Bool, hist: UInt = this.predHist): ShiftingGlobalHistory = {
113    val g = Wire(new ShiftingGlobalHistory)
114    g.predHist := (hist << shift) | taken
115    g
116  }
117
118  def update(br_valids: Vec[Bool], real_taken_mask: Vec[Bool]): ShiftingGlobalHistory = {
119    require(br_valids.length == numBr)
120    require(real_taken_mask.length == numBr)
121    val last_valid_idx = PriorityMux(
122      br_valids.reverse :+ true.B,
123      (numBr to 0 by -1).map(_.U(log2Ceil(numBr+1).W))
124    )
125    val first_taken_idx = PriorityEncoder(false.B +: real_taken_mask)
126    val smaller = Mux(last_valid_idx < first_taken_idx,
127      last_valid_idx,
128      first_taken_idx
129    )
130    val shift = smaller
131    val taken = real_taken_mask.reduce(_||_)
132    update(shift, taken, this.predHist)
133  }
134
135  // static read
136  def read(n: Int): Bool = predHist.asBools()(n)
137
138  final def === (that: ShiftingGlobalHistory): Bool = {
139    predHist === that.predHist
140  }
141
142  final def =/= (that: ShiftingGlobalHistory): Bool = !(this === that)
143}
144
145// circular global history pointer
146class CGHPtr(implicit p: Parameters) extends CircularQueuePtr[CGHPtr](
147  p => p(XSCoreParamsKey).HistoryLength
148){
149  override def cloneType = (new CGHPtr).asInstanceOf[this.type]
150}
151class CircularGlobalHistory(implicit p: Parameters) extends GlobalHistory {
152  val buffer = Vec(HistoryLength, Bool())
153  type HistPtr = UInt
154  def update(br_valids: Vec[Bool], real_taken_mask: Vec[Bool]): CircularGlobalHistory = {
155    this
156  }
157}
158
159class FoldedHistory(val len: Int, val compLen: Int, val max_update_num: Int)(implicit p: Parameters)
160  extends XSBundle with HasBPUConst {
161  require(compLen >= 1)
162  require(len > 0)
163  // require(folded_len <= len)
164  require(compLen >= max_update_num)
165  val folded_hist = UInt(compLen.W)
166
167  def info = (len, compLen)
168  def oldest_bit_to_get_from_ghr = (0 until max_update_num).map(len - _ - 1)
169  def oldest_bit_pos_in_folded = oldest_bit_to_get_from_ghr map (_ % compLen)
170  def oldest_bit_wrap_around = oldest_bit_to_get_from_ghr map (_ / compLen > 0)
171  def oldest_bit_start = oldest_bit_pos_in_folded.head
172
173  def get_oldest_bits_from_ghr(ghr: Vec[Bool], histPtr: CGHPtr) = {
174    // TODO: wrap inc for histPtr value
175    oldest_bit_to_get_from_ghr.map(i => ghr((histPtr + (i+1).U).value))
176  }
177
178  def circular_shift_left(src: UInt, shamt: Int) = {
179    val srcLen = src.getWidth
180    val src_doubled = Cat(src, src)
181    val shifted = src_doubled(srcLen*2-1-shamt, srcLen-shamt)
182    shifted
183  }
184
185
186  def update(ghr: Vec[Bool], histPtr: CGHPtr, num: Int, taken: Bool): FoldedHistory = {
187    // do xors for several bitsets at specified bits
188    def bitsets_xor(len: Int, bitsets: Seq[Seq[Tuple2[Int, Bool]]]) = {
189      val res = Wire(Vec(len, Bool()))
190      // println(f"num bitsets: ${bitsets.length}")
191      // println(f"bitsets $bitsets")
192      val resArr = Array.fill(len)(List[Bool]())
193      for (bs <- bitsets) {
194        for ((n, b) <- bs) {
195          resArr(n) = b :: resArr(n)
196        }
197      }
198      // println(f"${resArr.mkString}")
199      // println(f"histLen: ${this.len}, foldedLen: $folded_len")
200      for (i <- 0 until len) {
201        // println(f"bit[$i], ${resArr(i).mkString}")
202        if (resArr(i).length > 2) {
203          println(f"[warning] update logic of foldest history has two or more levels of xor gates! " +
204            f"histlen:${this.len}, compLen:$compLen")
205        }
206        if (resArr(i).length == 0) {
207          println(f"[error] bits $i is not assigned in folded hist update logic! histlen:${this.len}, compLen:$compLen")
208        }
209        res(i) := resArr(i).foldLeft(false.B)(_^_)
210      }
211      res.asUInt
212    }
213    val oldest_bits = get_oldest_bits_from_ghr(ghr, histPtr)
214
215    // mask off bits that do not update
216    val oldest_bits_masked = oldest_bits.zipWithIndex.map{
217      case (ob, i) => ob && (i < num).B
218    }
219    // if a bit does not wrap around, it should not be xored when it exits
220    val oldest_bits_set = (0 until max_update_num).filter(oldest_bit_wrap_around).map(i => (oldest_bit_pos_in_folded(i), oldest_bits_masked(i)))
221
222    // println(f"old bits pos ${oldest_bits_set.map(_._1)}")
223
224    // only the last bit could be 1, as we have at most one taken branch at a time
225    val newest_bits_masked = VecInit((0 until max_update_num).map(i => taken && ((i+1) == num).B)).asUInt
226    // if a bit does not wrap around, newest bits should not be xored onto it either
227    val newest_bits_set = (0 until max_update_num).map(i => (compLen-1-i, newest_bits_masked(i)))
228
229    // println(f"new bits set ${newest_bits_set.map(_._1)}")
230    //
231    val original_bits_masked = VecInit(folded_hist.asBools.zipWithIndex.map{
232      case (fb, i) => fb && !(num >= (len-i)).B
233    })
234    val original_bits_set = (0 until compLen).map(i => (i, original_bits_masked(i)))
235
236
237    // histLen too short to wrap around
238    val new_folded_hist =
239      if (len <= compLen) {
240        ((folded_hist << num) | taken)(compLen-1,0)
241        // circular_shift_left(max_update_num)(Cat(Reverse(newest_bits_masked), folded_hist(compLen-max_update_num-1,0)), num)
242      } else {
243        // do xor then shift
244        val xored = bitsets_xor(compLen, Seq(original_bits_set, oldest_bits_set, newest_bits_set))
245        circular_shift_left(xored, num)
246      }
247    val fh = WireInit(this)
248    fh.folded_hist := new_folded_hist
249    fh
250  }
251
252  // def update(ghr: Vec[Bool], histPtr: CGHPtr, valids: Vec[Bool], takens: Vec[Bool]): FoldedHistory = {
253  //   val fh = WireInit(this)
254  //   require(valids.length == max_update_num)
255  //   require(takens.length == max_update_num)
256  //   val last_valid_idx = PriorityMux(
257  //     valids.reverse :+ true.B,
258  //     (max_update_num to 0 by -1).map(_.U(log2Ceil(max_update_num+1).W))
259  //     )
260  //   val first_taken_idx = PriorityEncoder(false.B +: takens)
261  //   val smaller = Mux(last_valid_idx < first_taken_idx,
262  //     last_valid_idx,
263  //     first_taken_idx
264  //   )
265  //   // update folded_hist
266  //   fh.update(ghr, histPtr, smaller, takens.reduce(_||_))
267  // }
268  // println(f"folded hist original length: ${len}, folded len: ${folded_len} " +
269  //   f"oldest bits' pos in folded: ${oldest_bit_pos_in_folded}")
270
271
272}
273
274class TableAddr(val idxBits: Int, val banks: Int)(implicit p: Parameters) extends XSBundle{
275  def tagBits = VAddrBits - idxBits - instOffsetBits
276
277  val tag = UInt(tagBits.W)
278  val idx = UInt(idxBits.W)
279  val offset = UInt(instOffsetBits.W)
280
281  def fromUInt(x: UInt) = x.asTypeOf(UInt(VAddrBits.W)).asTypeOf(this)
282  def getTag(x: UInt) = fromUInt(x).tag
283  def getIdx(x: UInt) = fromUInt(x).idx
284  def getBank(x: UInt) = if (banks > 1) getIdx(x)(log2Up(banks) - 1, 0) else 0.U
285  def getBankIdx(x: UInt) = if (banks > 1) getIdx(x)(idxBits - 1, log2Up(banks)) else getIdx(x)
286}
287
288@chiselName
289class BranchPrediction(implicit p: Parameters) extends XSBundle with HasBPUConst {
290  val br_taken_mask = Vec(numBr, Bool())
291
292  val slot_valids = Vec(totalSlot, Bool())
293
294  val targets = Vec(totalSlot, UInt(VAddrBits.W))
295
296  val is_jal = Bool()
297  val is_jalr = Bool()
298  val is_call = Bool()
299  val is_ret = Bool()
300  val is_br_sharing = Bool()
301
302  // val call_is_rvc = Bool()
303  val hit = Bool()
304
305  def br_slot_valids = slot_valids.init
306  def tail_slot_valid = slot_valids.last
307
308  def br_valids = {
309    VecInit(
310      if (shareTailSlot)
311        br_slot_valids :+ (tail_slot_valid && is_br_sharing)
312      else
313        br_slot_valids
314    )
315  }
316
317  def taken_mask_on_slot = {
318    VecInit(
319      if (shareTailSlot)
320        (br_slot_valids zip br_taken_mask.init).map{ case (t, v) => t && v } :+ (
321          (br_taken_mask.last && tail_slot_valid && is_br_sharing) ||
322          tail_slot_valid && !is_br_sharing
323        )
324      else
325        (br_slot_valids zip br_taken_mask).map{ case (v, t) => v && t } :+
326        tail_slot_valid
327    )
328  }
329
330  def taken = br_taken_mask.reduce(_||_) || slot_valids.last // || (is_jal || is_jalr)
331
332  def fromFtbEntry(entry: FTBEntry, pc: UInt) = {
333    slot_valids := entry.brSlots.map(_.valid) :+ entry.tailSlot.valid
334    targets := entry.getTargetVec(pc)
335    is_jal := entry.tailSlot.valid && entry.isJal
336    is_jalr := entry.tailSlot.valid && entry.isJalr
337    is_call := entry.tailSlot.valid && entry.isCall
338    is_ret := entry.tailSlot.valid && entry.isRet
339    is_br_sharing := entry.tailSlot.valid && entry.tailSlot.sharing
340  }
341  // override def toPrintable: Printable = {
342  //   p"-----------BranchPrediction----------- " +
343  //     p"[taken_mask] ${Binary(taken_mask.asUInt)} " +
344  //     p"[is_br] ${Binary(is_br.asUInt)}, [is_jal] ${Binary(is_jal.asUInt)} " +
345  //     p"[is_jalr] ${Binary(is_jalr.asUInt)}, [is_call] ${Binary(is_call.asUInt)}, [is_ret] ${Binary(is_ret.asUInt)} " +
346  //     p"[target] ${Hexadecimal(target)}}, [hit] $hit "
347  // }
348
349  def display(cond: Bool): Unit = {
350    XSDebug(cond, p"[taken_mask] ${Binary(br_taken_mask.asUInt)} [hit] $hit\n")
351  }
352}
353
354@chiselName
355class BranchPredictionBundle(implicit p: Parameters) extends XSBundle with HasBPUConst with BPUUtils{
356  val pc = UInt(VAddrBits.W)
357
358  val valid = Bool()
359
360  val hasRedirect = Bool()
361  val ftq_idx = new FtqPtr
362  // val hit = Bool()
363  val preds = new BranchPrediction
364
365  val folded_hist = new AllFoldedHistories(foldedGHistInfos)
366  val histPtr = new CGHPtr
367  val phist = UInt(PathHistoryLength.W)
368  val rasSp = UInt(log2Ceil(RasSize).W)
369  val rasTop = new RASEntry
370  val specCnt = Vec(numBr, UInt(10.W))
371  // val meta = UInt(MaxMetaLength.W)
372
373  val ftb_entry = new FTBEntry() // TODO: Send this entry to ftq
374
375  def real_slot_taken_mask(): Vec[Bool] = {
376    VecInit(preds.taken_mask_on_slot.map(_ && preds.hit))
377  }
378
379  // len numBr
380  def real_br_taken_mask(): Vec[Bool] = {
381    if (shareTailSlot)
382      VecInit(
383        preds.taken_mask_on_slot.map(_ && preds.hit).init :+
384        (preds.br_taken_mask.last && preds.tail_slot_valid && preds.is_br_sharing && preds.hit)
385      )
386    else
387      VecInit(real_slot_taken_mask().init)
388  }
389
390  // the vec indicating if ghr should shift on each branch
391  def shouldShiftVec =
392    VecInit(preds.br_valids.zipWithIndex.map{ case (v, i) =>
393      v && !real_br_taken_mask.take(i).reduceOption(_||_).getOrElse(false.B)})
394
395  def lastBrPosOH =
396    (!preds.hit || !preds.br_valids.reduce(_||_)) +: // not hit or no brs in entry
397    VecInit((0 until numBr).map(i =>
398      preds.br_valids(i) &&
399      !real_br_taken_mask.take(i).reduceOption(_||_).getOrElse(false.B) && // no brs taken in front it
400      (real_br_taken_mask()(i) || !preds.br_valids.drop(i+1).reduceOption(_||_).getOrElse(false.B)) && // no brs behind it
401      preds.hit
402    ))
403
404  def br_count(): UInt = {
405    val last_valid_idx = PriorityMux(
406      preds.br_valids.reverse :+ true.B,
407      (numBr to 0 by -1).map(_.U(log2Ceil(numBr+1).W))
408      )
409    val first_taken_idx = PriorityEncoder(false.B +: real_br_taken_mask)
410    Mux(last_valid_idx < first_taken_idx,
411      last_valid_idx,
412      first_taken_idx
413    )
414  }
415
416  def hit_taken_on_jmp =
417    !real_slot_taken_mask().init.reduce(_||_) &&
418    real_slot_taken_mask().last && !preds.is_br_sharing
419  def hit_taken_on_call = hit_taken_on_jmp && preds.is_call
420  def hit_taken_on_ret  = hit_taken_on_jmp && preds.is_ret
421  def hit_taken_on_jalr = hit_taken_on_jmp && preds.is_jalr
422
423  def fallThroughAddr = getFallThroughAddr(pc, ftb_entry.carry, ftb_entry.pftAddr)
424
425  def target(): UInt = {
426    val targetVec = preds.targets :+ fallThroughAddr :+ (pc + (FetchWidth*4).U)
427    val selVec = real_slot_taken_mask() :+ (preds.hit && !real_slot_taken_mask().asUInt.orR) :+ true.B
428    PriorityMux(selVec zip targetVec)
429  }
430  def genCfiIndex = {
431    val cfiIndex = Wire(ValidUndirectioned(UInt(log2Ceil(PredictWidth).W)))
432    cfiIndex.valid := real_slot_taken_mask().asUInt.orR
433    // when no takens, set cfiIndex to PredictWidth-1
434    cfiIndex.bits :=
435      ParallelPriorityMux(real_slot_taken_mask(), ftb_entry.getOffsetVec) |
436      Fill(log2Ceil(PredictWidth), (!real_slot_taken_mask().asUInt.orR).asUInt)
437    cfiIndex
438  }
439
440  def display(cond: Bool): Unit = {
441    XSDebug(cond, p"[pc] ${Hexadecimal(pc)}\n")
442    folded_hist.display(cond)
443    preds.display(cond)
444    ftb_entry.display(cond)
445  }
446}
447
448@chiselName
449class BranchPredictionResp(implicit p: Parameters) extends XSBundle with HasBPUConst {
450  // val valids = Vec(3, Bool())
451  val s1 = new BranchPredictionBundle()
452  val s2 = new BranchPredictionBundle()
453  val s3 = new BranchPredictionBundle()
454
455  def selectedResp =
456    PriorityMux(Seq(
457      ((s3.valid && s3.hasRedirect) -> s3),
458      ((s2.valid && s2.hasRedirect) -> s2),
459      (s1.valid -> s1)
460    ))
461  def selectedRespIdx =
462    PriorityMux(Seq(
463      ((s3.valid && s3.hasRedirect) -> BP_S3),
464      ((s2.valid && s2.hasRedirect) -> BP_S2),
465      (s1.valid -> BP_S1)
466    ))
467  def lastStage = s3
468}
469
470class BpuToFtqBundle(implicit p: Parameters) extends BranchPredictionResp with HasBPUConst {
471  val meta = UInt(MaxMetaLength.W)
472}
473
474object BpuToFtqBundle {
475  def apply(resp: BranchPredictionResp)(implicit p: Parameters): BpuToFtqBundle = {
476    val e = Wire(new BpuToFtqBundle())
477    e.s1 := resp.s1
478    e.s2 := resp.s2
479    e.s3 := resp.s3
480
481    e.meta := DontCare
482    e
483  }
484}
485
486class BranchPredictionUpdate(implicit p: Parameters) extends BranchPredictionBundle with HasBPUConst {
487  val mispred_mask = Vec(numBr+1, Bool())
488  val false_hit = Bool()
489  val new_br_insert_pos = Vec(numBr, Bool())
490  val old_entry = Bool()
491  val meta = UInt(MaxMetaLength.W)
492  val full_target = UInt(VAddrBits.W)
493
494  def fromFtqRedirectSram(entry: Ftq_Redirect_SRAMEntry) = {
495    folded_hist := entry.folded_hist
496    histPtr := entry.histPtr
497    phist := entry.phist
498    rasSp := entry.rasSp
499    rasTop := entry.rasEntry
500    specCnt := entry.specCnt
501    this
502  }
503
504  override def display(cond: Bool) = {
505    XSDebug(cond, p"-----------BranchPredictionUpdate-----------\n")
506    XSDebug(cond, p"[mispred_mask] ${Binary(mispred_mask.asUInt)} [false_hit] $false_hit\n")
507    XSDebug(cond, p"[new_br_insert_pos] ${Binary(new_br_insert_pos.asUInt)}\n")
508    super.display(cond)
509    XSDebug(cond, p"--------------------------------------------\n")
510  }
511}
512
513class BranchPredictionRedirect(implicit p: Parameters) extends Redirect with HasBPUConst {
514  // override def toPrintable: Printable = {
515  //   p"-----------BranchPredictionRedirect----------- " +
516  //     p"-----------cfiUpdate----------- " +
517  //     p"[pc] ${Hexadecimal(cfiUpdate.pc)} " +
518  //     p"[predTaken] ${cfiUpdate.predTaken}, [taken] ${cfiUpdate.taken}, [isMisPred] ${cfiUpdate.isMisPred} " +
519  //     p"[target] ${Hexadecimal(cfiUpdate.target)} " +
520  //     p"------------------------------- " +
521  //     p"[robPtr] f=${robIdx.flag} v=${robIdx.value} " +
522  //     p"[ftqPtr] f=${ftqIdx.flag} v=${ftqIdx.value} " +
523  //     p"[ftqOffset] ${ftqOffset} " +
524  //     p"[level] ${level}, [interrupt] ${interrupt} " +
525  //     p"[stFtqIdx] f=${stFtqIdx.flag} v=${stFtqIdx.value} " +
526  //     p"[stFtqOffset] ${stFtqOffset} " +
527  //     p"\n"
528
529  // }
530
531  def display(cond: Bool): Unit = {
532    XSDebug(cond, p"-----------BranchPredictionRedirect----------- \n")
533    XSDebug(cond, p"-----------cfiUpdate----------- \n")
534    XSDebug(cond, p"[pc] ${Hexadecimal(cfiUpdate.pc)}\n")
535    // XSDebug(cond, p"[hist] ${Binary(cfiUpdate.hist.predHist)}\n")
536    XSDebug(cond, p"[br_hit] ${cfiUpdate.br_hit} [isMisPred] ${cfiUpdate.isMisPred}\n")
537    XSDebug(cond, p"[pred_taken] ${cfiUpdate.predTaken} [taken] ${cfiUpdate.taken} [isMisPred] ${cfiUpdate.isMisPred}\n")
538    XSDebug(cond, p"[target] ${Hexadecimal(cfiUpdate.target)} \n")
539    XSDebug(cond, p"[shift] ${cfiUpdate.shift}\n")
540    XSDebug(cond, p"------------------------------- \n")
541    XSDebug(cond, p"[robPtr] f=${robIdx.flag} v=${robIdx.value}\n")
542    XSDebug(cond, p"[ftqPtr] f=${ftqIdx.flag} v=${ftqIdx.value} \n")
543    XSDebug(cond, p"[ftqOffset] ${ftqOffset} \n")
544    XSDebug(cond, p"[stFtqIdx] f=${stFtqIdx.flag} v=${stFtqIdx.value}\n")
545    XSDebug(cond, p"[stFtqOffset] ${stFtqOffset}\n")
546    XSDebug(cond, p"---------------------------------------------- \n")
547  }
548}
549