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* 16* 17* Acknowledgement 18* 19* This implementation is inspired by several key papers: 20* [1] André Seznec. "[Tage-sc-l branch predictors.](https://inria.hal.science/hal-01086920)" The Journal of 21* Instruction-Level Parallelism (JILP) 4th JILP Workshop on Computer Architecture Competitions (JWAC): Championship 22* Branch Prediction (CBP). 2014. 23* [2] André Seznec. "[Tage-sc-l branch predictors again.](https://inria.hal.science/hal-01354253)" The Journal of 24* Instruction-Level Parallelism (JILP) 5th JILP Workshop on Computer Architecture Competitions (JWAC): Championship 25* Branch Prediction (CBP). 2016. 26***************************************************************************************/ 27 28package xiangshan.frontend 29 30import chisel3._ 31import chisel3.util._ 32import org.chipsalliance.cde.config.Parameters 33import scala.{Tuple2 => &} 34import scala.math.min 35import utility._ 36import xiangshan._ 37 38trait HasSCParameter extends TageParams {} 39 40class SCReq(implicit p: Parameters) extends TageReq 41 42abstract class SCBundle(implicit p: Parameters) extends TageBundle with HasSCParameter {} 43abstract class SCModule(implicit p: Parameters) extends TageModule with HasSCParameter {} 44 45class SCMeta(val ntables: Int)(implicit p: Parameters) extends XSBundle with HasSCParameter { 46 val scPreds = Vec(numBr, Bool()) 47 // Suppose ctrbits of all tables are identical 48 val ctrs = Vec(numBr, Vec(ntables, SInt(SCCtrBits.W))) 49} 50 51class SCResp(val ctrBits: Int = 6)(implicit p: Parameters) extends SCBundle { 52 val ctrs = Vec(numBr, Vec(2, SInt(ctrBits.W))) 53} 54 55class SCUpdate(val ctrBits: Int = 6)(implicit p: Parameters) extends SCBundle { 56 val pc = UInt(VAddrBits.W) 57 val ghist = UInt(HistoryLength.W) 58 val mask = Vec(numBr, Bool()) 59 val oldCtrs = Vec(numBr, SInt(ctrBits.W)) 60 val tagePreds = Vec(numBr, Bool()) 61 val takens = Vec(numBr, Bool()) 62} 63 64class SCTableIO(val ctrBits: Int = 6)(implicit p: Parameters) extends SCBundle { 65 val req = Input(Valid(new SCReq)) 66 val resp = Output(new SCResp(ctrBits)) 67 val update = Input(new SCUpdate(ctrBits)) 68} 69 70class SCTable(val nRows: Int, val ctrBits: Int, val histLen: Int)(implicit p: Parameters) 71 extends SCModule with HasFoldedHistory { 72 val io = IO(new SCTableIO(ctrBits)) 73 74 // val table = Module(new SRAMTemplate(SInt(ctrBits.W), set=nRows, way=2*TageBanks, shouldReset=true, holdRead=true, singlePort=false)) 75 val table = Module(new SRAMTemplate( 76 SInt(ctrBits.W), 77 set = nRows, 78 way = 2 * TageBanks, 79 shouldReset = true, 80 holdRead = true, 81 singlePort = false, 82 bypassWrite = true, 83 withClockGate = true 84 )) 85 86 // def getIdx(hist: UInt, pc: UInt) = { 87 // (compute_folded_ghist(hist, log2Ceil(nRows)) ^ (pc >> instOffsetBits))(log2Ceil(nRows)-1,0) 88 // } 89 90 val idxFhInfo = (histLen, min(log2Ceil(nRows), histLen)) 91 92 def getFoldedHistoryInfo = Set(idxFhInfo).filter(_._1 > 0) 93 94 def getIdx(pc: UInt, allFh: AllFoldedHistories) = 95 if (histLen > 0) { 96 val idx_fh = allFh.getHistWithInfo(idxFhInfo).folded_hist 97 // require(idx_fh.getWidth == log2Ceil(nRows)) 98 ((pc >> instOffsetBits) ^ idx_fh)(log2Ceil(nRows) - 1, 0) 99 } else { 100 (pc >> instOffsetBits)(log2Ceil(nRows) - 1, 0) 101 } 102 103 def ctrUpdate(ctr: SInt, cond: Bool): SInt = signedSatUpdate(ctr, ctrBits, cond) 104 105 val s0_idx = getIdx(io.req.bits.pc, io.req.bits.folded_hist) 106 val s1_idx = RegEnable(s0_idx, io.req.valid) 107 108 val s1_pc = RegEnable(io.req.bits.pc, io.req.fire) 109 val s1_unhashed_idx = s1_pc >> instOffsetBits 110 111 table.io.r.req.valid := io.req.valid 112 table.io.r.req.bits.setIdx := s0_idx 113 114 val update_wdata = Wire(Vec(numBr, SInt(ctrBits.W))) // correspond to physical bridx 115 val update_wdata_packed = VecInit(update_wdata.map(Seq.fill(2)(_)).reduce(_ ++ _)) 116 val updateWayMask = Wire(Vec(2 * numBr, Bool())) // correspond to physical bridx 117 118 val update_unhashed_idx = io.update.pc >> instOffsetBits 119 for (pi <- 0 until numBr) { 120 updateWayMask(2 * pi) := Seq.tabulate(numBr)(li => 121 io.update.mask(li) && get_phy_br_idx(update_unhashed_idx, li) === pi.U && !io.update.tagePreds(li) 122 ).reduce(_ || _) 123 updateWayMask(2 * pi + 1) := Seq.tabulate(numBr)(li => 124 io.update.mask(li) && get_phy_br_idx(update_unhashed_idx, li) === pi.U && io.update.tagePreds(li) 125 ).reduce(_ || _) 126 } 127 128 val update_folded_hist = WireInit(0.U.asTypeOf(new AllFoldedHistories(foldedGHistInfos))) 129 if (histLen > 0) { 130 update_folded_hist.getHistWithInfo(idxFhInfo).folded_hist := compute_folded_ghist(io.update.ghist, log2Ceil(nRows)) 131 } 132 val update_idx = getIdx(io.update.pc, update_folded_hist) 133 134 // SCTable dual port SRAM reads and writes to the same address processing 135 val conflict_buffer_valid = RegInit(false.B) 136 val conflict_buffer_data = RegInit(0.U.asTypeOf(update_wdata_packed)) 137 val conflict_buffer_idx = RegInit(0.U.asTypeOf(update_idx)) 138 val conflict_buffer_waymask = RegInit(0.U.asTypeOf(updateWayMask)) 139 140 val write_conflict = update_idx === s0_idx && io.update.mask.reduce(_ || _) && io.req.valid 141 val can_write = (conflict_buffer_idx =/= s0_idx || !io.req.valid) && conflict_buffer_valid 142 143 when(write_conflict) { 144 conflict_buffer_valid := true.B 145 conflict_buffer_data := update_wdata_packed 146 conflict_buffer_idx := update_idx 147 conflict_buffer_waymask := updateWayMask 148 } 149 when(can_write) { 150 conflict_buffer_valid := false.B 151 } 152 153 // Using buffer data for prediction 154 val use_conflict_data = conflict_buffer_valid && conflict_buffer_idx === s1_idx 155 val conflict_data_bypass = conflict_buffer_data.zip(conflict_buffer_waymask).map { case (data, mask) => 156 Mux(mask, data, 0.U.asTypeOf(data)) 157 } 158 val conflict_prediction_data = conflict_data_bypass.sliding(2, 2).toSeq.map(VecInit(_)) 159 val per_br_ctrs_unshuffled = table.io.r.resp.data.sliding(2, 2).toSeq.map(VecInit(_)) 160 val per_br_ctrs = VecInit((0 until numBr).map(i => 161 Mux1H( 162 UIntToOH(get_phy_br_idx(s1_unhashed_idx, i), numBr), 163 per_br_ctrs_unshuffled 164 ) 165 )) 166 val conflict_br_ctrs = VecInit((0 until numBr).map(i => 167 Mux1H( 168 UIntToOH(get_phy_br_idx(s1_unhashed_idx, i), numBr), 169 conflict_prediction_data 170 ) 171 )) 172 173 io.resp.ctrs := Mux(use_conflict_data, conflict_br_ctrs, per_br_ctrs) 174 175 table.io.w.apply( 176 valid = (io.update.mask.reduce(_ || _) && !write_conflict) || can_write, 177 data = Mux(can_write, conflict_buffer_data, update_wdata_packed), 178 setIdx = Mux(can_write, conflict_buffer_idx, update_idx), 179 waymask = Mux(can_write, conflict_buffer_waymask.asUInt, updateWayMask.asUInt) 180 ) 181 182 val wrBypassEntries = 16 183 184 // let it corresponds to logical brIdx 185 val wrbypasses = Seq.fill(numBr)(Module(new WrBypass(SInt(ctrBits.W), wrBypassEntries, log2Ceil(nRows), numWays = 2))) 186 187 for (pi <- 0 until numBr) { 188 val br_lidx = get_lgc_br_idx(update_unhashed_idx, pi.U(log2Ceil(numBr).W)) 189 190 val wrbypass_io = Mux1H(UIntToOH(br_lidx, numBr), wrbypasses.map(_.io)) 191 192 val ctrPos = Mux1H(UIntToOH(br_lidx, numBr), io.update.tagePreds) 193 val bypass_ctr = wrbypass_io.hit_data(ctrPos) 194 val previous_ctr = Mux1H(UIntToOH(br_lidx, numBr), io.update.oldCtrs) 195 val hit_and_valid = wrbypass_io.hit && bypass_ctr.valid 196 val oldCtr = Mux(hit_and_valid, bypass_ctr.bits, previous_ctr) 197 val taken = Mux1H(UIntToOH(br_lidx, numBr), io.update.takens) 198 update_wdata(pi) := ctrUpdate(oldCtr, taken) 199 } 200 201 val per_br_update_wdata_packed = update_wdata_packed.sliding(2, 2).map(VecInit(_)).toSeq 202 val per_br_update_way_mask = updateWayMask.sliding(2, 2).map(VecInit(_)).toSeq 203 for (li <- 0 until numBr) { 204 val wrbypass = wrbypasses(li) 205 val br_pidx = get_phy_br_idx(update_unhashed_idx, li) 206 wrbypass.io.wen := io.update.mask(li) 207 wrbypass.io.write_idx := update_idx 208 wrbypass.io.write_data := Mux1H(UIntToOH(br_pidx, numBr), per_br_update_wdata_packed) 209 wrbypass.io.write_way_mask.map(_ := Mux1H(UIntToOH(br_pidx, numBr), per_br_update_way_mask)) 210 } 211 212 val u = io.update 213 XSDebug( 214 io.req.valid, 215 p"scTableReq: pc=0x${Hexadecimal(io.req.bits.pc)}, " + 216 p"s0_idx=${s0_idx}\n" 217 ) 218 XSDebug( 219 RegNext(io.req.valid), 220 p"scTableResp: s1_idx=${s1_idx}," + 221 p"ctr:${io.resp.ctrs}\n" 222 ) 223 XSDebug( 224 io.update.mask.reduce(_ || _), 225 p"update Table: pc:${Hexadecimal(u.pc)}, " + 226 p"tageTakens:${u.tagePreds}, taken:${u.takens}, oldCtr:${u.oldCtrs}\n" 227 ) 228} 229 230class SCThreshold(val ctrBits: Int = 6)(implicit p: Parameters) extends SCBundle { 231 val ctr = UInt(ctrBits.W) 232 def satPos(ctr: UInt = this.ctr) = ctr === ((1.U << ctrBits) - 1.U) 233 def satNeg(ctr: UInt = this.ctr) = ctr === 0.U 234 def neutralVal = (1 << (ctrBits - 1)).U 235 val thres = UInt(8.W) 236 def initVal = 6.U 237 def minThres = 6.U 238 def maxThres = 31.U 239 def update(cause: Bool): SCThreshold = { 240 val res = Wire(new SCThreshold(this.ctrBits)) 241 val newCtr = satUpdate(this.ctr, this.ctrBits, cause) 242 val newThres = Mux( 243 res.satPos(newCtr) && this.thres <= maxThres, 244 this.thres + 2.U, 245 Mux(res.satNeg(newCtr) && this.thres >= minThres, this.thres - 2.U, this.thres) 246 ) 247 res.thres := newThres 248 res.ctr := Mux(res.satPos(newCtr) || res.satNeg(newCtr), res.neutralVal, newCtr) 249 // XSDebug(true.B, p"scThres Update: cause${cause} newCtr ${newCtr} newThres ${newThres}\n") 250 res 251 } 252} 253 254object SCThreshold { 255 def apply(bits: Int)(implicit p: Parameters) = { 256 val t = Wire(new SCThreshold(ctrBits = bits)) 257 t.ctr := t.neutralVal 258 t.thres := t.initVal 259 t 260 } 261} 262 263trait HasSC extends HasSCParameter with HasPerfEvents { this: Tage => 264 val update_on_mispred, update_on_unconf = WireInit(0.U.asTypeOf(Vec(TageBanks, Bool()))) 265 var sc_fh_info = Set[FoldedHistoryInfo]() 266 if (EnableSC) { 267 val scTables = SCTableInfos.map { 268 case (nRows, ctrBits, histLen) => { 269 val t = Module(new SCTable(nRows / TageBanks, ctrBits, histLen)) 270 val req = t.io.req 271 req.valid := io.s0_fire(3) 272 req.bits.pc := s0_pc_dup(3) 273 req.bits.folded_hist := io.in.bits.folded_hist(3) 274 req.bits.ghist := DontCare 275 if (!EnableSC) { t.io.update := DontCare } 276 t 277 } 278 } 279 sc_fh_info = scTables.map(_.getFoldedHistoryInfo).reduce(_ ++ _).toSet 280 281 val scThresholds = List.fill(TageBanks)(RegInit(SCThreshold(5))) 282 val useThresholds = VecInit(scThresholds map (_.thres)) 283 284 def sign(x: SInt) = x(x.getWidth - 1) 285 def pos(x: SInt) = !sign(x) 286 def neg(x: SInt) = sign(x) 287 288 def aboveThreshold(scSum: SInt, tagePvdr: SInt, threshold: UInt): Bool = { 289 val signedThres = threshold.zext 290 val totalSum = scSum +& tagePvdr 291 (scSum > signedThres - tagePvdr) && pos(totalSum) || 292 (scSum < -signedThres - tagePvdr) && neg(totalSum) 293 } 294 val updateThresholds = VecInit(useThresholds map (t => (t << 3) +& 21.U)) 295 296 val s1_scResps = VecInit(scTables.map(t => t.io.resp)) 297 298 val scUpdateMask = WireInit(0.U.asTypeOf(Vec(numBr, Vec(SCNTables, Bool())))) 299 val scUpdateTagePreds = Wire(Vec(TageBanks, Bool())) 300 val scUpdateTakens = Wire(Vec(TageBanks, Bool())) 301 val scUpdateOldCtrs = Wire(Vec(numBr, Vec(SCNTables, SInt(SCCtrBits.W)))) 302 scUpdateTagePreds := DontCare 303 scUpdateTakens := DontCare 304 scUpdateOldCtrs := DontCare 305 306 val updateSCMeta = updateMeta.scMeta.get 307 308 val s2_sc_used, s2_conf, s2_unconf, s2_agree, s2_disagree = 309 WireInit(0.U.asTypeOf(Vec(TageBanks, Bool()))) 310 val update_sc_used, update_conf, update_unconf, update_agree, update_disagree = 311 WireInit(0.U.asTypeOf(Vec(TageBanks, Bool()))) 312 val sc_misp_tage_corr, sc_corr_tage_misp = 313 WireInit(0.U.asTypeOf(Vec(TageBanks, Bool()))) 314 315 // for sc ctrs 316 def getCentered(ctr: SInt): SInt = Cat(ctr, 1.U(1.W)).asSInt 317 // for tage ctrs, (2*(ctr-4)+1)*8 318 def getPvdrCentered(ctr: UInt): SInt = Cat(ctr ^ (1 << (TageCtrBits - 1)).U, 1.U(1.W), 0.U(3.W)).asSInt 319 320 val scMeta = resp_meta.scMeta.get 321 scMeta := DontCare 322 for (w <- 0 until TageBanks) { 323 // do summation in s2 324 val s1_scTableSums = VecInit( 325 (0 to 1) map { i => 326 ParallelSingedExpandingAdd(s1_scResps map (r => getCentered(r.ctrs(w)(i)))) // TODO: rewrite with wallace tree 327 } 328 ) 329 val s2_scTableSums = RegEnable(s1_scTableSums, io.s1_fire(3)) 330 val s2_tagePrvdCtrCentered = getPvdrCentered(RegEnable(s1_providerResps(w).ctr, io.s1_fire(3))) 331 val s2_totalSums = s2_scTableSums.map(_ +& s2_tagePrvdCtrCentered) 332 val s2_sumAboveThresholds = 333 VecInit((0 to 1).map(i => aboveThreshold(s2_scTableSums(i), s2_tagePrvdCtrCentered, useThresholds(w)))) 334 val s2_scPreds = VecInit(s2_totalSums.map(_ >= 0.S)) 335 336 val s2_scResps = VecInit(RegEnable(s1_scResps, io.s1_fire(3)).map(_.ctrs(w))) 337 val s2_scCtrs = VecInit(s2_scResps.map(_(s2_tageTakens_dup(3)(w).asUInt))) 338 val s2_chooseBit = s2_tageTakens_dup(3)(w) 339 340 val s2_pred = 341 Mux(s2_provideds(w) && s2_sumAboveThresholds(s2_chooseBit), s2_scPreds(s2_chooseBit), s2_tageTakens_dup(3)(w)) 342 343 val s3_disagree = RegEnable(s2_disagree, io.s2_fire(3)) 344 io.out.last_stage_spec_info.sc_disagree.map(_ := s3_disagree) 345 346 scMeta.scPreds(w) := RegEnable(s2_scPreds(s2_chooseBit), io.s2_fire(3)) 347 scMeta.ctrs(w) := RegEnable(s2_scCtrs, io.s2_fire(3)) 348 349 val pred = s2_scPreds(s2_chooseBit) 350 val debug_pc = Cat(debug_pc_s2, w.U, 0.U(instOffsetBits.W)) 351 when(s2_provideds(w)) { 352 s2_sc_used(w) := true.B 353 s2_unconf(w) := !s2_sumAboveThresholds(s2_chooseBit) 354 s2_conf(w) := s2_sumAboveThresholds(s2_chooseBit) 355 // Use prediction from Statistical Corrector 356 when(s2_sumAboveThresholds(s2_chooseBit)) { 357 s2_agree(w) := s2_tageTakens_dup(3)(w) === pred 358 s2_disagree(w) := s2_tageTakens_dup(3)(w) =/= pred 359 // fit to always-taken condition 360 // io.out.s2.full_pred.br_taken_mask(w) := pred 361 } 362 } 363 XSDebug(s2_provideds(w), p"---------tage_bank_${w} provided so that sc used---------\n") 364 XSDebug( 365 s2_provideds(w) && s2_sumAboveThresholds(s2_chooseBit), 366 p"pc(${Hexadecimal(debug_pc)}) SC(${w.U}) overriden pred to ${pred}\n" 367 ) 368 369 val s3_pred_dup = io.s2_fire.map(f => RegEnable(s2_pred, f)) 370 val sc_enable_dup = dup(RegNext(io.ctrl.sc_enable)) 371 for ( 372 sc_enable & fp & s3_pred <- 373 sc_enable_dup zip io.out.s3.full_pred zip s3_pred_dup 374 ) { 375 when(sc_enable) { 376 fp.br_taken_mask(w) := s3_pred 377 } 378 } 379 380 val updateTageMeta = updateMeta 381 val scPred = updateSCMeta.scPreds(w) 382 val tagePred = updateTageMeta.takens(w) 383 val taken = update.br_taken_mask(w) 384 val scOldCtrs = updateSCMeta.ctrs(w) 385 val pvdrCtr = updateTageMeta.providerResps(w).ctr 386 val tableSum = ParallelSingedExpandingAdd(scOldCtrs.map(getCentered)) 387 val totalSumAbs = (tableSum +& getPvdrCentered(pvdrCtr)).abs.asUInt 388 val updateThres = updateThresholds(w) 389 val sumAboveThreshold = aboveThreshold(tableSum, getPvdrCentered(pvdrCtr), updateThres) 390 val thres = useThresholds(w) 391 val newThres = scThresholds(w).update(scPred =/= taken) 392 when(updateValids(w) && updateTageMeta.providers(w).valid) { 393 scUpdateTagePreds(w) := tagePred 394 scUpdateTakens(w) := taken 395 (scUpdateOldCtrs(w) zip scOldCtrs).foreach { case (t, c) => t := c } 396 397 update_sc_used(w) := true.B 398 update_unconf(w) := !sumAboveThreshold 399 update_conf(w) := sumAboveThreshold 400 update_agree(w) := scPred === tagePred 401 update_disagree(w) := scPred =/= tagePred 402 sc_corr_tage_misp(w) := scPred === taken && tagePred =/= taken && update_conf(w) 403 sc_misp_tage_corr(w) := scPred =/= taken && tagePred === taken && update_conf(w) 404 405 when(scPred =/= tagePred && totalSumAbs >= thres - 4.U && totalSumAbs <= thres - 2.U) { 406 scThresholds(w) := newThres 407 } 408 409 when(scPred =/= taken || !sumAboveThreshold) { 410 scUpdateMask(w).foreach(_ := true.B) 411 update_on_mispred(w) := scPred =/= taken 412 update_on_unconf(w) := scPred === taken 413 } 414 } 415 XSDebug( 416 updateValids(w) && updateTageMeta.providers(w).valid && 417 scPred =/= tagePred && totalSumAbs >= thres - 4.U && totalSumAbs <= thres - 2.U, 418 p"scThres $w update: old ${useThresholds(w)} --> new ${newThres.thres}\n" 419 ) 420 XSDebug( 421 updateValids(w) && updateTageMeta.providers(w).valid && 422 (scPred =/= taken || !sumAboveThreshold) && 423 tableSum < 0.S, 424 p"scUpdate: bank(${w}), scPred(${scPred}), tagePred(${tagePred}), " + 425 p"scSum(-${tableSum.abs}), mispred: sc(${scPred =/= taken}), tage(${updateMisPreds(w)})\n" 426 ) 427 XSDebug( 428 updateValids(w) && updateTageMeta.providers(w).valid && 429 (scPred =/= taken || !sumAboveThreshold) && 430 tableSum >= 0.S, 431 p"scUpdate: bank(${w}), scPred(${scPred}), tagePred(${tagePred}), " + 432 p"scSum(+${tableSum.abs}), mispred: sc(${scPred =/= taken}), tage(${updateMisPreds(w)})\n" 433 ) 434 XSDebug( 435 updateValids(w) && updateTageMeta.providers(w).valid && 436 (scPred =/= taken || !sumAboveThreshold), 437 p"bank(${w}), update: sc: ${updateSCMeta}\n" 438 ) 439 } 440 441 val realWens = scUpdateMask.transpose.map(v => v.reduce(_ | _)) 442 for (b <- 0 until TageBanks) { 443 for (i <- 0 until SCNTables) { 444 val realWen = realWens(i) 445 scTables(i).io.update.mask(b) := RegNext(scUpdateMask(b)(i)) 446 scTables(i).io.update.tagePreds(b) := RegEnable(scUpdateTagePreds(b), realWen) 447 scTables(i).io.update.takens(b) := RegEnable(scUpdateTakens(b), realWen) 448 scTables(i).io.update.oldCtrs(b) := RegEnable(scUpdateOldCtrs(b)(i), realWen) 449 scTables(i).io.update.pc := RegEnable(update_pc, realWen) 450 scTables(i).io.update.ghist := RegEnable(update.ghist, realWen) 451 } 452 } 453 454 tage_perf("sc_conf", PopCount(s2_conf), PopCount(update_conf)) 455 tage_perf("sc_unconf", PopCount(s2_unconf), PopCount(update_unconf)) 456 tage_perf("sc_agree", PopCount(s2_agree), PopCount(update_agree)) 457 tage_perf("sc_disagree", PopCount(s2_disagree), PopCount(update_disagree)) 458 tage_perf("sc_used", PopCount(s2_sc_used), PopCount(update_sc_used)) 459 XSPerfAccumulate("sc_update_on_mispred", PopCount(update_on_mispred)) 460 XSPerfAccumulate("sc_update_on_unconf", PopCount(update_on_unconf)) 461 XSPerfAccumulate("sc_mispred_but_tage_correct", PopCount(sc_misp_tage_corr)) 462 XSPerfAccumulate("sc_correct_and_tage_wrong", PopCount(sc_corr_tage_misp)) 463 464 } 465 466 override def getFoldedHistoryInfo = Some(tage_fh_info ++ sc_fh_info) 467 468 override val perfEvents = Seq( 469 ("tage_tht_hit ", PopCount(updateMeta.providers.map(_.valid))), 470 ("sc_update_on_mispred ", PopCount(update_on_mispred)), 471 ("sc_update_on_unconf ", PopCount(update_on_unconf)) 472 ) 473 generatePerfEvent() 474} 475