xref: /XiangShan/src/main/scala/xiangshan/frontend/FTB.scala (revision 9473e04d5cab97eaf63add958b2392eec3d876a2)
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
17package xiangshan.frontend
18
19import chipsalliance.rocketchip.config.Parameters
20import chisel3._
21import chisel3.stage.{ChiselGeneratorAnnotation, ChiselStage}
22import chisel3.util._
23import xiangshan._
24import utils._
25import utility._
26import chisel3.experimental.chiselName
27
28import scala.math.min
29import os.copy
30
31
32trait FTBParams extends HasXSParameter with HasBPUConst {
33  val numEntries = FtbSize
34  val numWays    = FtbWays
35  val numSets    = numEntries/numWays // 512
36  val tagSize    = 20
37
38
39
40  val TAR_STAT_SZ = 2
41  def TAR_FIT = 0.U(TAR_STAT_SZ.W)
42  def TAR_OVF = 1.U(TAR_STAT_SZ.W)
43  def TAR_UDF = 2.U(TAR_STAT_SZ.W)
44
45  def BR_OFFSET_LEN = 12
46  def JMP_OFFSET_LEN = 20
47}
48
49class FtbSlot(val offsetLen: Int, val subOffsetLen: Option[Int] = None)(implicit p: Parameters) extends XSBundle with FTBParams {
50  if (subOffsetLen.isDefined) {
51    require(subOffsetLen.get <= offsetLen)
52  }
53  val offset  = UInt(log2Ceil(PredictWidth).W)
54  val lower   = UInt(offsetLen.W)
55  val tarStat = UInt(TAR_STAT_SZ.W)
56  val sharing = Bool()
57  val valid   = Bool()
58
59  def setLowerStatByTarget(pc: UInt, target: UInt, isShare: Boolean) = {
60    def getTargetStatByHigher(pc_higher: UInt, target_higher: UInt) =
61      Mux(target_higher > pc_higher, TAR_OVF,
62        Mux(target_higher < pc_higher, TAR_UDF, TAR_FIT))
63    def getLowerByTarget(target: UInt, offsetLen: Int) = target(offsetLen, 1)
64    val offLen = if (isShare) this.subOffsetLen.get else this.offsetLen
65    val pc_higher = pc(VAddrBits-1, offLen+1)
66    val target_higher = target(VAddrBits-1, offLen+1)
67    val stat = getTargetStatByHigher(pc_higher, target_higher)
68    val lower = ZeroExt(getLowerByTarget(target, offLen), this.offsetLen)
69    this.lower := lower
70    this.tarStat := stat
71    this.sharing := isShare.B
72  }
73
74  def getTarget(pc: UInt, last_stage: Option[Tuple2[UInt, Bool]] = None) = {
75    def getTarget(offLen: Int)(pc: UInt, lower: UInt, stat: UInt,
76      last_stage: Option[Tuple2[UInt, Bool]] = None) = {
77      val h = pc(VAddrBits-1, offLen+1)
78      val higher = Wire(UInt((VAddrBits-offLen-1).W))
79      val higher_plus_one = Wire(UInt((VAddrBits-offLen-1).W))
80      val higher_minus_one = Wire(UInt((VAddrBits-offLen-1).W))
81      if (last_stage.isDefined) {
82        val last_stage_pc = last_stage.get._1
83        val last_stage_pc_h = last_stage_pc(VAddrBits-1, offLen+1)
84        val stage_en = last_stage.get._2
85        higher := RegEnable(last_stage_pc_h, stage_en)
86        higher_plus_one := RegEnable(last_stage_pc_h+1.U, stage_en)
87        higher_minus_one := RegEnable(last_stage_pc_h-1.U, stage_en)
88      } else {
89        higher := h
90        higher_plus_one := h + 1.U
91        higher_minus_one := h - 1.U
92      }
93      val target =
94        Cat(
95          Mux1H(Seq(
96            (stat === TAR_OVF, higher_plus_one),
97            (stat === TAR_UDF, higher_minus_one),
98            (stat === TAR_FIT, higher),
99          )),
100          lower(offLen-1, 0), 0.U(1.W)
101        )
102      require(target.getWidth == VAddrBits)
103      require(offLen != 0)
104      target
105    }
106    if (subOffsetLen.isDefined)
107      Mux(sharing,
108        getTarget(subOffsetLen.get)(pc, lower, tarStat, last_stage),
109        getTarget(offsetLen)(pc, lower, tarStat, last_stage)
110      )
111    else
112      getTarget(offsetLen)(pc, lower, tarStat, last_stage)
113  }
114  def fromAnotherSlot(that: FtbSlot) = {
115    require(
116      this.offsetLen > that.offsetLen && this.subOffsetLen.map(_ == that.offsetLen).getOrElse(true) ||
117      this.offsetLen == that.offsetLen
118    )
119    this.offset := that.offset
120    this.tarStat := that.tarStat
121    this.sharing := (this.offsetLen > that.offsetLen && that.offsetLen == this.subOffsetLen.get).B
122    this.valid := that.valid
123    this.lower := ZeroExt(that.lower, this.offsetLen)
124  }
125
126}
127
128class FTBEntry(implicit p: Parameters) extends XSBundle with FTBParams with BPUUtils {
129
130
131  val valid       = Bool()
132
133  val brSlots = Vec(numBrSlot, new FtbSlot(BR_OFFSET_LEN))
134
135  val tailSlot = new FtbSlot(JMP_OFFSET_LEN, Some(BR_OFFSET_LEN))
136
137  // Partial Fall-Through Address
138  val pftAddr     = UInt(log2Up(PredictWidth).W)
139  val carry       = Bool()
140
141  val isCall      = Bool()
142  val isRet       = Bool()
143  val isJalr      = Bool()
144
145  val last_may_be_rvi_call = Bool()
146
147  val always_taken = Vec(numBr, Bool())
148
149  def getSlotForBr(idx: Int): FtbSlot = {
150    require(idx <= numBr-1)
151    (idx, numBr) match {
152      case (i, n) if i == n-1 => this.tailSlot
153      case _ => this.brSlots(idx)
154    }
155  }
156  def allSlotsForBr = {
157    (0 until numBr).map(getSlotForBr(_))
158  }
159  def setByBrTarget(brIdx: Int, pc: UInt, target: UInt) = {
160    val slot = getSlotForBr(brIdx)
161    slot.setLowerStatByTarget(pc, target, brIdx == numBr-1)
162  }
163  def setByJmpTarget(pc: UInt, target: UInt) = {
164    this.tailSlot.setLowerStatByTarget(pc, target, false)
165  }
166
167  def getTargetVec(pc: UInt, last_stage: Option[Tuple2[UInt, Bool]] = None) = {
168    VecInit((brSlots :+ tailSlot).map(_.getTarget(pc, last_stage)))
169  }
170
171  def getOffsetVec = VecInit(brSlots.map(_.offset) :+ tailSlot.offset)
172  def isJal = !isJalr
173  def getFallThrough(pc: UInt) = getFallThroughAddr(pc, carry, pftAddr)
174  def hasBr(offset: UInt) =
175    brSlots.map{ s => s.valid && s.offset <= offset}.reduce(_||_) ||
176    (tailSlot.valid && tailSlot.offset <= offset && tailSlot.sharing)
177
178  def getBrMaskByOffset(offset: UInt) =
179    brSlots.map{ s => s.valid && s.offset <= offset } :+
180    (tailSlot.valid && tailSlot.offset <= offset && tailSlot.sharing)
181
182  def getBrRecordedVec(offset: UInt) = {
183    VecInit(
184      brSlots.map(s => s.valid && s.offset === offset) :+
185      (tailSlot.valid && tailSlot.offset === offset && tailSlot.sharing)
186    )
187  }
188
189  def brIsSaved(offset: UInt) = getBrRecordedVec(offset).reduce(_||_)
190
191  def brValids = {
192    VecInit(
193      brSlots.map(_.valid) :+ (tailSlot.valid && tailSlot.sharing)
194    )
195  }
196
197  def noEmptySlotForNewBr = {
198    VecInit(brSlots.map(_.valid) :+ tailSlot.valid).reduce(_&&_)
199  }
200
201  def newBrCanNotInsert(offset: UInt) = {
202    val lastSlotForBr = tailSlot
203    lastSlotForBr.valid && lastSlotForBr.offset < offset
204  }
205
206  def jmpValid = {
207    tailSlot.valid && !tailSlot.sharing
208  }
209
210  def brOffset = {
211    VecInit(brSlots.map(_.offset) :+ tailSlot.offset)
212  }
213
214  def display(cond: Bool): Unit = {
215    XSDebug(cond, p"-----------FTB entry----------- \n")
216    XSDebug(cond, p"v=${valid}\n")
217    for(i <- 0 until numBr) {
218      XSDebug(cond, p"[br$i]: v=${allSlotsForBr(i).valid}, offset=${allSlotsForBr(i).offset}," +
219        p"lower=${Hexadecimal(allSlotsForBr(i).lower)}\n")
220    }
221    XSDebug(cond, p"[tailSlot]: v=${tailSlot.valid}, offset=${tailSlot.offset}," +
222      p"lower=${Hexadecimal(tailSlot.lower)}, sharing=${tailSlot.sharing}}\n")
223    XSDebug(cond, p"pftAddr=${Hexadecimal(pftAddr)}, carry=$carry\n")
224    XSDebug(cond, p"isCall=$isCall, isRet=$isRet, isjalr=$isJalr\n")
225    XSDebug(cond, p"last_may_be_rvi_call=$last_may_be_rvi_call\n")
226    XSDebug(cond, p"------------------------------- \n")
227  }
228
229}
230
231class FTBEntryWithTag(implicit p: Parameters) extends XSBundle with FTBParams with BPUUtils {
232  val entry = new FTBEntry
233  val tag = UInt(tagSize.W)
234  def display(cond: Bool): Unit = {
235    entry.display(cond)
236    XSDebug(cond, p"tag is ${Hexadecimal(tag)}\n------------------------------- \n")
237  }
238}
239
240class FTBMeta(implicit p: Parameters) extends XSBundle with FTBParams {
241  val writeWay = UInt(log2Ceil(numWays).W)
242  val hit = Bool()
243  val pred_cycle = if (!env.FPGAPlatform) Some(UInt(64.W)) else None
244}
245
246object FTBMeta {
247  def apply(writeWay: UInt, hit: Bool, pred_cycle: UInt)(implicit p: Parameters): FTBMeta = {
248    val e = Wire(new FTBMeta)
249    e.writeWay := writeWay
250    e.hit := hit
251    e.pred_cycle.map(_ := pred_cycle)
252    e
253  }
254}
255
256// class UpdateQueueEntry(implicit p: Parameters) extends XSBundle with FTBParams {
257//   val pc = UInt(VAddrBits.W)
258//   val ftb_entry = new FTBEntry
259//   val hit = Bool()
260//   val hit_way = UInt(log2Ceil(numWays).W)
261// }
262//
263// object UpdateQueueEntry {
264//   def apply(pc: UInt, fe: FTBEntry, hit: Bool, hit_way: UInt)(implicit p: Parameters): UpdateQueueEntry = {
265//     val e = Wire(new UpdateQueueEntry)
266//     e.pc := pc
267//     e.ftb_entry := fe
268//     e.hit := hit
269//     e.hit_way := hit_way
270//     e
271//   }
272// }
273
274class FTB(implicit p: Parameters) extends BasePredictor with FTBParams with BPUUtils
275  with HasCircularQueuePtrHelper with HasPerfEvents {
276  override val meta_size = WireInit(0.U.asTypeOf(new FTBMeta)).getWidth
277
278  val ftbAddr = new TableAddr(log2Up(numSets), 1)
279
280  class FTBBank(val numSets: Int, val nWays: Int) extends XSModule with BPUUtils {
281    val io = IO(new Bundle {
282      val s1_fire = Input(Bool())
283
284      // when ftb hit, read_hits.valid is true, and read_hits.bits is OH of hit way
285      // when ftb not hit, read_hits.valid is false, and read_hits is OH of allocWay
286      // val read_hits = Valid(Vec(numWays, Bool()))
287      val req_pc = Flipped(DecoupledIO(UInt(VAddrBits.W)))
288      val read_resp = Output(new FTBEntry)
289      val read_hits = Valid(UInt(log2Ceil(numWays).W))
290
291      val u_req_pc = Flipped(DecoupledIO(UInt(VAddrBits.W)))
292      val update_hits = Valid(UInt(log2Ceil(numWays).W))
293      val update_access = Input(Bool())
294
295      val update_pc = Input(UInt(VAddrBits.W))
296      val update_write_data = Flipped(Valid(new FTBEntryWithTag))
297      val update_write_way = Input(UInt(log2Ceil(numWays).W))
298      val update_write_alloc = Input(Bool())
299    })
300
301    // Extract holdRead logic to fix bug that update read override predict read result
302    val ftb = Module(new SRAMTemplate(new FTBEntryWithTag, set = numSets, way = numWays, shouldReset = true, holdRead = false, singlePort = true))
303    val ftb_r_entries = ftb.io.r.resp.data.map(_.entry)
304
305    val pred_rdata   = HoldUnless(ftb.io.r.resp.data, RegNext(io.req_pc.valid && !io.update_access))
306    ftb.io.r.req.valid := io.req_pc.valid || io.u_req_pc.valid // io.s0_fire
307    ftb.io.r.req.bits.setIdx := Mux(io.u_req_pc.valid, ftbAddr.getIdx(io.u_req_pc.bits), ftbAddr.getIdx(io.req_pc.bits)) // s0_idx
308
309    assert(!(io.req_pc.valid && io.u_req_pc.valid))
310
311    io.req_pc.ready := ftb.io.r.req.ready
312    io.u_req_pc.ready := ftb.io.r.req.ready
313
314    val req_tag = RegEnable(ftbAddr.getTag(io.req_pc.bits)(tagSize-1, 0), io.req_pc.valid)
315    val req_idx = RegEnable(ftbAddr.getIdx(io.req_pc.bits), io.req_pc.valid)
316
317    val u_req_tag = RegEnable(ftbAddr.getTag(io.u_req_pc.bits)(tagSize-1, 0), io.u_req_pc.valid)
318
319    val read_entries = pred_rdata.map(_.entry)
320    val read_tags    = pred_rdata.map(_.tag)
321
322    val total_hits = VecInit((0 until numWays).map(b => read_tags(b) === req_tag && read_entries(b).valid && io.s1_fire))
323    val hit = total_hits.reduce(_||_)
324    // val hit_way_1h = VecInit(PriorityEncoderOH(total_hits))
325    val hit_way = OHToUInt(total_hits)
326
327    val u_total_hits = VecInit((0 until numWays).map(b =>
328        ftb.io.r.resp.data(b).tag === u_req_tag && ftb.io.r.resp.data(b).entry.valid && RegNext(io.update_access)))
329    val u_hit = u_total_hits.reduce(_||_)
330    // val hit_way_1h = VecInit(PriorityEncoderOH(total_hits))
331    val u_hit_way = OHToUInt(u_total_hits)
332
333    // assert(PopCount(total_hits) === 1.U || PopCount(total_hits) === 0.U)
334    // assert(PopCount(u_total_hits) === 1.U || PopCount(u_total_hits) === 0.U)
335    for (n <- 1 to numWays) {
336      XSPerfAccumulate(f"ftb_pred_${n}_way_hit", PopCount(total_hits) === n.U)
337      XSPerfAccumulate(f"ftb_update_${n}_way_hit", PopCount(u_total_hits) === n.U)
338    }
339
340    val replacer = ReplacementPolicy.fromString(Some("setplru"), numWays, numSets)
341    // val allocWriteWay = replacer.way(req_idx)
342
343    val touch_set = Seq.fill(1)(Wire(UInt(log2Ceil(numSets).W)))
344    val touch_way = Seq.fill(1)(Wire(Valid(UInt(log2Ceil(numWays).W))))
345
346    val write_set = Wire(UInt(log2Ceil(numSets).W))
347    val write_way = Wire(Valid(UInt(log2Ceil(numWays).W)))
348
349    val read_set = Wire(UInt(log2Ceil(numSets).W))
350    val read_way = Wire(Valid(UInt(log2Ceil(numWays).W)))
351
352    read_set := req_idx
353    read_way.valid := hit
354    read_way.bits  := hit_way
355
356    touch_set(0) := Mux(write_way.valid, write_set, read_set)
357
358    touch_way(0).valid := write_way.valid || read_way.valid
359    touch_way(0).bits := Mux(write_way.valid, write_way.bits, read_way.bits)
360
361    replacer.access(touch_set, touch_way)
362
363    def allocWay(valids: UInt, idx: UInt): UInt = {
364      if (numWays > 1) {
365        val w = Wire(UInt(log2Up(numWays).W))
366        val valid = WireInit(valids.andR)
367        w := Mux(valid, replacer.way(idx), PriorityEncoder(~valids))
368        w
369      } else {
370        val w = WireInit(0.U(log2Up(numWays).W))
371        w
372      }
373    }
374
375    io.read_resp := Mux1H(total_hits, read_entries) // Mux1H
376    io.read_hits.valid := hit
377    io.read_hits.bits := hit_way
378
379    io.update_hits.valid := u_hit
380    io.update_hits.bits := u_hit_way
381
382    // Update logic
383    val u_valid = io.update_write_data.valid
384    val u_data = io.update_write_data.bits
385    val u_idx = ftbAddr.getIdx(io.update_pc)
386    val allocWriteWay = allocWay(RegNext(VecInit(ftb_r_entries.map(_.valid))).asUInt, u_idx)
387    val u_way = Mux(io.update_write_alloc, allocWriteWay, io.update_write_way)
388    val u_mask = UIntToOH(u_way)
389
390    for (i <- 0 until numWays) {
391      XSPerfAccumulate(f"ftb_replace_way$i", u_valid && io.update_write_alloc && u_way === i.U)
392      XSPerfAccumulate(f"ftb_replace_way${i}_has_empty", u_valid && io.update_write_alloc && !ftb_r_entries.map(_.valid).reduce(_&&_) && u_way === i.U)
393      XSPerfAccumulate(f"ftb_hit_way$i", hit && !io.update_access && hit_way === i.U)
394    }
395
396    ftb.io.w.apply(u_valid, u_data, u_idx, u_mask)
397
398    // for replacer
399    write_set := u_idx
400    write_way.valid := u_valid
401    write_way.bits := Mux(io.update_write_alloc, allocWriteWay, io.update_write_way)
402
403    // print hit entry info
404    Mux1H(total_hits, ftb.io.r.resp.data).display(true.B)
405  } // FTBBank
406
407  val ftbBank = Module(new FTBBank(numSets, numWays))
408
409  ftbBank.io.req_pc.valid := io.s0_fire
410  ftbBank.io.req_pc.bits := s0_pc
411
412  val ftb_entry = RegEnable(ftbBank.io.read_resp, io.s1_fire)
413  val s3_ftb_entry = RegEnable(ftb_entry, io.s2_fire)
414  val s1_hit = ftbBank.io.read_hits.valid && io.ctrl.btb_enable
415  val s2_hit = RegEnable(s1_hit, io.s1_fire)
416  val s3_hit = RegEnable(s2_hit, io.s2_fire)
417  val writeWay = ftbBank.io.read_hits.bits
418
419  val fallThruAddr = getFallThroughAddr(s2_pc, ftb_entry.carry, ftb_entry.pftAddr)
420
421  // io.out.bits.resp := RegEnable(io.in.bits.resp_in(0), 0.U.asTypeOf(new BranchPredictionResp), io.s1_fire)
422  io.out := io.in.bits.resp_in(0)
423
424  val s1_latch_call_is_rvc   = DontCare // TODO: modify when add RAS
425
426  io.out.s2.full_pred.hit       := s2_hit
427  io.out.s2.pc                  := s2_pc
428  io.out.s2.full_pred.fromFtbEntry(ftb_entry, s2_pc, Some((s1_pc, io.s1_fire)))
429
430  io.out.s3.full_pred.hit := s3_hit
431  io.out.s3.pc                  := s3_pc
432  io.out.s3.full_pred.fromFtbEntry(s3_ftb_entry, s3_pc, Some((s2_pc, io.s2_fire)))
433
434  io.out.last_stage_ftb_entry := s3_ftb_entry
435  io.out.last_stage_meta := RegEnable(RegEnable(FTBMeta(writeWay.asUInt(), s1_hit, GTimer()).asUInt(), io.s1_fire), io.s2_fire)
436
437  // always taken logic
438  for (i <- 0 until numBr) {
439    io.out.s2.full_pred.br_taken_mask(i) := io.in.bits.resp_in(0).s2.full_pred.br_taken_mask(i) || s2_hit && ftb_entry.always_taken(i)
440    io.out.s3.full_pred.br_taken_mask(i) := io.in.bits.resp_in(0).s3.full_pred.br_taken_mask(i) || s3_hit && s3_ftb_entry.always_taken(i)
441  }
442
443  // Update logic
444  val update = io.update.bits
445
446  val u_meta = update.meta.asTypeOf(new FTBMeta)
447  val u_valid = io.update.valid && !io.update.bits.old_entry
448
449  val delay2_pc = DelayN(update.pc, 2)
450  val delay2_entry = DelayN(update.ftb_entry, 2)
451
452
453  val update_now = u_valid && u_meta.hit
454  val update_need_read = u_valid && !u_meta.hit
455  // stall one more cycle because we use a whole cycle to do update read tag hit
456  io.s1_ready := ftbBank.io.req_pc.ready && !(update_need_read) && !RegNext(update_need_read)
457
458  ftbBank.io.u_req_pc.valid := update_need_read
459  ftbBank.io.u_req_pc.bits := update.pc
460
461
462
463  val ftb_write = Wire(new FTBEntryWithTag)
464  ftb_write.entry := Mux(update_now, update.ftb_entry, delay2_entry)
465  ftb_write.tag   := ftbAddr.getTag(Mux(update_now, update.pc, delay2_pc))(tagSize-1, 0)
466
467  val write_valid = update_now || DelayN(u_valid && !u_meta.hit, 2)
468
469  ftbBank.io.update_write_data.valid := write_valid
470  ftbBank.io.update_write_data.bits := ftb_write
471  ftbBank.io.update_pc          := Mux(update_now, update.pc,       delay2_pc)
472  ftbBank.io.update_write_way   := Mux(update_now, u_meta.writeWay, RegNext(ftbBank.io.update_hits.bits)) // use it one cycle later
473  ftbBank.io.update_write_alloc := Mux(update_now, false.B,         RegNext(!ftbBank.io.update_hits.valid)) // use it one cycle later
474  ftbBank.io.update_access := u_valid && !u_meta.hit
475  ftbBank.io.s1_fire := io.s1_fire
476
477  XSDebug("req_v=%b, req_pc=%x, ready=%b (resp at next cycle)\n", io.s0_fire, s0_pc, ftbBank.io.req_pc.ready)
478  XSDebug("s2_hit=%b, hit_way=%b\n", s2_hit, writeWay.asUInt)
479  XSDebug("s2_br_taken_mask=%b, s2_real_taken_mask=%b\n",
480    io.in.bits.resp_in(0).s2.full_pred.br_taken_mask.asUInt, io.out.s2.full_pred.real_slot_taken_mask().asUInt)
481  XSDebug("s2_target=%x\n", io.out.s2.getTarget)
482
483  ftb_entry.display(true.B)
484
485  XSPerfAccumulate("ftb_read_hits", RegNext(io.s0_fire) && s1_hit)
486  XSPerfAccumulate("ftb_read_misses", RegNext(io.s0_fire) && !s1_hit)
487
488  XSPerfAccumulate("ftb_commit_hits", io.update.valid && u_meta.hit)
489  XSPerfAccumulate("ftb_commit_misses", io.update.valid && !u_meta.hit)
490
491  XSPerfAccumulate("ftb_update_req", io.update.valid)
492  XSPerfAccumulate("ftb_update_ignored", io.update.valid && io.update.bits.old_entry)
493  XSPerfAccumulate("ftb_updated", u_valid)
494
495  override val perfEvents = Seq(
496    ("ftb_commit_hits            ", RegNext(io.update.valid)  &&  u_meta.hit),
497    ("ftb_commit_misses          ", RegNext(io.update.valid)  && !u_meta.hit),
498  )
499  generatePerfEvent()
500}
501