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