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