xref: /XiangShan/src/main/scala/xiangshan/mem/lsqueue/LoadQueueReplay.scala (revision a4d1b2d1ae4c6149f55fbcac48749c08714bfe0c)
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.mem
17
18import chisel3._
19import chisel3.util._
20import org.chipsalliance.cde.config._
21import xiangshan._
22import xiangshan.backend.rob.{RobLsqIO, RobPtr}
23import xiangshan.cache._
24import xiangshan.backend.fu.fpu.FPU
25import xiangshan.backend.fu.FuConfig._
26import xiangshan.cache._
27import xiangshan.cache.mmu._
28import xiangshan.frontend.FtqPtr
29import xiangshan.ExceptionNO._
30import xiangshan.cache.wpu.ReplayCarry
31import xiangshan.mem.mdp._
32import utils._
33import utility._
34import xiangshan.backend.Bundles.{DynInst, MemExuOutput}
35import math._
36
37object LoadReplayCauses {
38  // these causes have priority, lower coding has higher priority.
39  // when load replay happens, load unit will select highest priority
40  // from replay causes vector
41
42  /*
43   * Warning:
44   * ************************************************************
45   * * Don't change the priority. If the priority is changed,   *
46   * * deadlock may occur. If you really need to change or      *
47   * * add priority, please ensure that no deadlock will occur. *
48   * ************************************************************
49   *
50   */
51  // st-ld violation re-execute check
52  val C_MA  = 0
53  // tlb miss check
54  val C_TM  = 1
55  // store-to-load-forwarding check
56  val C_FF  = 2
57  // dcache replay check
58  val C_DR  = 3
59  // dcache miss check
60  val C_DM  = 4
61  // wpu predict fail
62  val C_WF  = 5
63  // dcache bank conflict check
64  val C_BC  = 6
65  // RAR queue accept check
66  val C_RAR = 7
67  // RAW queue accept check
68  val C_RAW = 8
69  // st-ld violation
70  val C_NK  = 9
71  // total causes
72  val allCauses = 10
73}
74
75class VecReplayInfo(implicit p: Parameters) extends XSBundle with HasVLSUParameters {
76  val isvec = Bool()
77  val isLastElem = Bool()
78  val is128bit = Bool()
79  val uop_unit_stride_fof = Bool()
80  val usSecondInv = Bool()
81  val elemIdx = UInt(elemIdxBits.W)
82  val alignedType = UInt(alignTypeBits.W)
83  val mbIndex = UInt(max(vlmBindexBits, vsmBindexBits).W)
84  val elemIdxInsideVd = UInt(elemIdxBits.W)
85  val reg_offset = UInt(vOffsetBits.W)
86  val vecActive = Bool()
87  val is_first_ele = Bool()
88  val mask = UInt((VLEN/8).W)
89}
90
91class AgeDetector(numEntries: Int, numEnq: Int, regOut: Boolean = true)(implicit p: Parameters) extends XSModule {
92  val io = IO(new Bundle {
93    // NOTE: deq and enq may come at the same cycle.
94    val enq = Vec(numEnq, Input(UInt(numEntries.W)))
95    val deq = Input(UInt(numEntries.W))
96    val ready = Input(UInt(numEntries.W))
97    val out = Output(UInt(numEntries.W))
98  })
99
100  // age(i)(j): entry i enters queue before entry j
101  val age = Seq.fill(numEntries)(Seq.fill(numEntries)(RegInit(false.B)))
102  val nextAge = Seq.fill(numEntries)(Seq.fill(numEntries)(Wire(Bool())))
103
104  // to reduce reg usage, only use upper matrix
105  def get_age(row: Int, col: Int): Bool = if (row <= col) age(row)(col) else !age(col)(row)
106  def get_next_age(row: Int, col: Int): Bool = if (row <= col) nextAge(row)(col) else !nextAge(col)(row)
107  def isFlushed(i: Int): Bool = io.deq(i)
108  def isEnqueued(i: Int, numPorts: Int = -1): Bool = {
109    val takePorts = if (numPorts == -1) io.enq.length else numPorts
110    takePorts match {
111      case 0 => false.B
112      case 1 => io.enq.head(i) && !isFlushed(i)
113      case n => VecInit(io.enq.take(n).map(_(i))).asUInt.orR && !isFlushed(i)
114    }
115  }
116
117  for ((row, i) <- nextAge.zipWithIndex) {
118    val thisValid = get_age(i, i) || isEnqueued(i)
119    for ((elem, j) <- row.zipWithIndex) {
120      when (isFlushed(i)) {
121        // (1) when entry i is flushed or dequeues, set row(i) to false.B
122        elem := false.B
123      }.elsewhen (isFlushed(j)) {
124        // (2) when entry j is flushed or dequeues, set column(j) to validVec
125        elem := thisValid
126      }.elsewhen (isEnqueued(i)) {
127        // (3) when entry i enqueues from port k,
128        // (3.1) if entry j enqueues from previous ports, set to false
129        // (3.2) otherwise, set to true if and only of entry j is invalid
130        // overall: !jEnqFromPreviousPorts && !jIsValid
131        val sel = io.enq.map(_(i))
132        val result = (0 until numEnq).map(k => isEnqueued(j, k))
133        // why ParallelMux: sel must be one-hot since enq is one-hot
134        elem := !get_age(j, j) && !ParallelMux(sel, result)
135      }.otherwise {
136        // default: unchanged
137        elem := get_age(i, j)
138      }
139      age(i)(j) := elem
140    }
141  }
142
143  def getOldest(get: (Int, Int) => Bool): UInt = {
144    VecInit((0 until numEntries).map(i => {
145      io.ready(i) & VecInit((0 until numEntries).map(j => if (i != j) !io.ready(j) || get(i, j) else true.B)).asUInt.andR
146    })).asUInt
147  }
148  val best = getOldest(get_age)
149  val nextBest = getOldest(get_next_age)
150
151  io.out := (if (regOut) best else nextBest)
152}
153
154object AgeDetector {
155  def apply(numEntries: Int, enq: Vec[UInt], deq: UInt, ready: UInt)(implicit p: Parameters): Valid[UInt] = {
156    val age = Module(new AgeDetector(numEntries, enq.length, regOut = true))
157    age.io.enq := enq
158    age.io.deq := deq
159    age.io.ready:= ready
160    val out = Wire(Valid(UInt(deq.getWidth.W)))
161    out.valid := age.io.out.orR
162    out.bits := age.io.out
163    out
164  }
165}
166
167
168class LoadQueueReplay(implicit p: Parameters) extends XSModule
169  with HasDCacheParameters
170  with HasCircularQueuePtrHelper
171  with HasLoadHelper
172  with HasTlbConst
173  with HasPerfEvents
174{
175  val io = IO(new Bundle() {
176    // control
177    val redirect = Flipped(ValidIO(new Redirect))
178    val vecFeedback = Vec(VecLoadPipelineWidth, Flipped(ValidIO(new FeedbackToLsqIO)))
179
180    // from load unit s3
181    val enq = Vec(LoadPipelineWidth, Flipped(Decoupled(new LqWriteBundle)))
182
183    // from sta s1
184    val storeAddrIn = Vec(StorePipelineWidth, Flipped(Valid(new LsPipelineBundle)))
185
186    // from std s1
187    val storeDataIn = Vec(StorePipelineWidth, Flipped(Valid(new MemExuOutput(isVector = true))))
188
189    // queue-based replay
190    val replay = Vec(LoadPipelineWidth, Decoupled(new LsPipelineBundle))
191   // val refill = Flipped(ValidIO(new Refill))
192    val tl_d_channel = Input(new DcacheToLduForwardIO)
193
194    // from StoreQueue
195    val stAddrReadySqPtr = Input(new SqPtr)
196    val stAddrReadyVec   = Input(Vec(StoreQueueSize, Bool()))
197    val stDataReadySqPtr = Input(new SqPtr)
198    val stDataReadyVec   = Input(Vec(StoreQueueSize, Bool()))
199
200    //
201    val sqEmpty = Input(Bool())
202    val lqFull  = Output(Bool())
203    val ldWbPtr = Input(new LqPtr)
204    val rarFull = Input(Bool())
205    val rawFull = Input(Bool())
206    val l2_hint  = Input(Valid(new L2ToL1Hint()))
207    val tlb_hint = Flipped(new TlbHintIO)
208    val tlbReplayDelayCycleCtrl = Vec(4, Input(UInt(ReSelectLen.W)))
209
210    val debugTopDown = new LoadQueueTopDownIO
211  })
212
213  println("LoadQueueReplay size: " + LoadQueueReplaySize)
214  //  LoadQueueReplay field:
215  //  +-----------+---------+-------+-------------+--------+
216  //  | Allocated | MicroOp | VAddr |    Cause    |  Flags |
217  //  +-----------+---------+-------+-------------+--------+
218  //  Allocated   : entry has been allocated already
219  //  MicroOp     : inst's microOp
220  //  VAddr       : virtual address
221  //  Cause       : replay cause
222  //  Flags       : rar/raw queue allocate flags
223  val allocated = RegInit(VecInit(List.fill(LoadQueueReplaySize)(false.B))) // The control signals need to explicitly indicate the initial value
224  val scheduled = RegInit(VecInit(List.fill(LoadQueueReplaySize)(false.B)))
225  val uop = Reg(Vec(LoadQueueReplaySize, new DynInst))
226  val vecReplay = Reg(Vec(LoadQueueReplaySize, new VecReplayInfo))
227  val vaddrModule = Module(new LqVAddrModule(
228    gen = UInt(VAddrBits.W),
229    numEntries = LoadQueueReplaySize,
230    numRead = LoadPipelineWidth,
231    numWrite = LoadPipelineWidth,
232    numWBank = LoadQueueNWriteBanks,
233    numWDelay = 2,
234    numCamPort = 0))
235  vaddrModule.io := DontCare
236  val debug_vaddr = RegInit(VecInit(List.fill(LoadQueueReplaySize)(0.U(VAddrBits.W))))
237  val cause = RegInit(VecInit(List.fill(LoadQueueReplaySize)(0.U(LoadReplayCauses.allCauses.W))))
238  val blocking = RegInit(VecInit(List.fill(LoadQueueReplaySize)(false.B)))
239  val strict = RegInit(VecInit(List.fill(LoadQueueReplaySize)(false.B)))
240
241  // freeliset: store valid entries index.
242  // +---+---+--------------+-----+-----+
243  // | 0 | 1 |      ......  | n-2 | n-1 |
244  // +---+---+--------------+-----+-----+
245  val freeList = Module(new FreeList(
246    size = LoadQueueReplaySize,
247    allocWidth = LoadPipelineWidth,
248    freeWidth = 4,
249    enablePreAlloc = true,
250    moduleName = "LoadQueueReplay freelist"
251  ))
252  freeList.io := DontCare
253  /**
254   * used for re-select control
255   */
256  val blockSqIdx = Reg(Vec(LoadQueueReplaySize, new SqPtr))
257  // DCache miss block
258  val missMSHRId = RegInit(VecInit(List.fill(LoadQueueReplaySize)(0.U((log2Up(cfg.nMissEntries+1).W)))))
259  val tlbHintId = RegInit(VecInit(List.fill(LoadQueueReplaySize)(0.U((log2Up(loadfiltersize+1).W)))))
260  // Has this load already updated dcache replacement?
261  val replacementUpdated = RegInit(VecInit(List.fill(LoadQueueReplaySize)(false.B)))
262  val missDbUpdated = RegInit(VecInit(List.fill(LoadQueueReplaySize)(false.B)))
263  val trueCacheMissReplay = WireInit(VecInit(cause.map(_(LoadReplayCauses.C_DM))))
264  val replayCarryReg = RegInit(VecInit(List.fill(LoadQueueReplaySize)(ReplayCarry(nWays, 0.U, false.B))))
265  val dataInLastBeatReg = RegInit(VecInit(List.fill(LoadQueueReplaySize)(false.B)))
266  //  LoadQueueReplay deallocate
267  val freeMaskVec = Wire(Vec(LoadQueueReplaySize, Bool()))
268
269  /**
270   * Enqueue
271   */
272  val canEnqueue = io.enq.map(_.valid)
273  val cancelEnq = io.enq.map(enq => enq.bits.uop.robIdx.needFlush(io.redirect))
274  val needReplay = io.enq.map(enq => enq.bits.rep_info.need_rep)
275  val hasExceptions = io.enq.map(enq => ExceptionNO.selectByFu(enq.bits.uop.exceptionVec, LduCfg).asUInt.orR && !enq.bits.tlbMiss)
276  val loadReplay = io.enq.map(enq => enq.bits.isLoadReplay)
277  val needEnqueue = VecInit((0 until LoadPipelineWidth).map(w => {
278    canEnqueue(w) && !cancelEnq(w) && needReplay(w) && !hasExceptions(w)
279  }))
280  val canFreeVec = VecInit((0 until LoadPipelineWidth).map(w => {
281    canEnqueue(w) && loadReplay(w) && (!needReplay(w) || hasExceptions(w))
282  }))
283
284  // select LoadPipelineWidth valid index.
285  val lqFull = freeList.io.empty
286  val lqFreeNums = freeList.io.validCount
287
288  // replay logic
289  // release logic generation
290  val storeAddrInSameCycleVec = Wire(Vec(LoadQueueReplaySize, Bool()))
291  val storeDataInSameCycleVec = Wire(Vec(LoadQueueReplaySize, Bool()))
292  val addrNotBlockVec = Wire(Vec(LoadQueueReplaySize, Bool()))
293  val dataNotBlockVec = Wire(Vec(LoadQueueReplaySize, Bool()))
294  val storeAddrValidVec = addrNotBlockVec.asUInt | storeAddrInSameCycleVec.asUInt
295  val storeDataValidVec = dataNotBlockVec.asUInt | storeDataInSameCycleVec.asUInt
296
297  // store data valid check
298  val stAddrReadyVec = io.stAddrReadyVec
299  val stDataReadyVec = io.stDataReadyVec
300
301  for (i <- 0 until LoadQueueReplaySize) {
302    // dequeue
303    //  FIXME: store*Ptr is not accurate
304    dataNotBlockVec(i) := isAfter(io.stDataReadySqPtr, blockSqIdx(i)) || stDataReadyVec(blockSqIdx(i).value) || io.sqEmpty // for better timing
305    addrNotBlockVec(i) := Mux(strict(i), isAfter(io.stAddrReadySqPtr, blockSqIdx(i)), stAddrReadyVec(blockSqIdx(i).value)) || io.sqEmpty // for better timing
306
307    // store address execute
308    storeAddrInSameCycleVec(i) := VecInit((0 until StorePipelineWidth).map(w => {
309      io.storeAddrIn(w).valid &&
310      !io.storeAddrIn(w).bits.miss &&
311      blockSqIdx(i) === io.storeAddrIn(w).bits.uop.sqIdx
312    })).asUInt.orR // for better timing
313
314    // store data execute
315    storeDataInSameCycleVec(i) := VecInit((0 until StorePipelineWidth).map(w => {
316      io.storeDataIn(w).valid &&
317      blockSqIdx(i) === io.storeDataIn(w).bits.uop.sqIdx
318    })).asUInt.orR // for better timing
319
320  }
321
322  // store addr issue check
323  val stAddrDeqVec = Wire(Vec(LoadQueueReplaySize, Bool()))
324  (0 until LoadQueueReplaySize).map(i => {
325    stAddrDeqVec(i) := allocated(i) && storeAddrValidVec(i)
326  })
327
328  // store data issue check
329  val stDataDeqVec = Wire(Vec(LoadQueueReplaySize, Bool()))
330  (0 until LoadQueueReplaySize).map(i => {
331    stDataDeqVec(i) := allocated(i) && storeDataValidVec(i)
332  })
333
334  // update blocking condition
335  (0 until LoadQueueReplaySize).map(i => {
336    // case C_MA
337    when (cause(i)(LoadReplayCauses.C_MA)) {
338      blocking(i) := Mux(stAddrDeqVec(i), false.B, blocking(i))
339    }
340    // case C_TM
341    when (cause(i)(LoadReplayCauses.C_TM)) {
342      blocking(i) := Mux(io.tlb_hint.resp.valid &&
343                     (io.tlb_hint.resp.bits.replay_all ||
344                     io.tlb_hint.resp.bits.id === tlbHintId(i)), false.B, blocking(i))
345    }
346    // case C_FF
347    when (cause(i)(LoadReplayCauses.C_FF)) {
348      blocking(i) := Mux(stDataDeqVec(i), false.B, blocking(i))
349    }
350    // case C_DM
351    when (cause(i)(LoadReplayCauses.C_DM)) {
352      blocking(i) := Mux(io.tl_d_channel.valid && io.tl_d_channel.mshrid === missMSHRId(i), false.B, blocking(i))
353    }
354    // case C_RAR
355    when (cause(i)(LoadReplayCauses.C_RAR)) {
356      blocking(i) := Mux((!io.rarFull || !isAfter(uop(i).lqIdx, io.ldWbPtr)), false.B, blocking(i))
357    }
358    // case C_RAW
359    when (cause(i)(LoadReplayCauses.C_RAW)) {
360      blocking(i) := Mux((!io.rawFull || !isAfter(uop(i).sqIdx, io.stAddrReadySqPtr)), false.B, blocking(i))
361    }
362  })
363
364  //  Replay is splitted into 3 stages
365  require((LoadQueueReplaySize % LoadPipelineWidth) == 0)
366  def getRemBits(input: UInt)(rem: Int): UInt = {
367    VecInit((0 until LoadQueueReplaySize / LoadPipelineWidth).map(i => { input(LoadPipelineWidth * i + rem) })).asUInt
368  }
369
370  def getRemSeq(input: Seq[Seq[Bool]])(rem: Int) = {
371    (0 until LoadQueueReplaySize / LoadPipelineWidth).map(i => { input(LoadPipelineWidth * i + rem) })
372  }
373
374  // stage1: select 2 entries and read their vaddr
375  val s0_oldestSel = Wire(Vec(LoadPipelineWidth, Valid(UInt(LoadQueueReplaySize.W))))
376  val s1_can_go = Wire(Vec(LoadPipelineWidth, Bool()))
377  val s1_oldestSel = Wire(Vec(LoadPipelineWidth, Valid(UInt(log2Up(LoadQueueReplaySize + 1).W))))
378  val s2_can_go = Wire(Vec(LoadPipelineWidth, Bool()))
379  val s2_oldestSel = Wire(Vec(LoadPipelineWidth, Valid(UInt(log2Up(LoadQueueReplaySize + 1).W))))
380
381  // generate mask
382  val needCancel = Wire(Vec(LoadQueueReplaySize, Bool()))
383  // generate enq mask
384  val enqIndexOH = Wire(Vec(LoadPipelineWidth, UInt(LoadQueueReplaySize.W)))
385  val s0_loadEnqFireMask = io.enq.map(x => x.fire && !x.bits.isLoadReplay && x.bits.rep_info.need_rep).zip(enqIndexOH).map(x => Mux(x._1, x._2, 0.U))
386  val s0_remLoadEnqFireVec = s0_loadEnqFireMask.map(x => VecInit((0 until LoadPipelineWidth).map(rem => getRemBits(x)(rem))))
387  val s0_remEnqSelVec = Seq.tabulate(LoadPipelineWidth)(w => VecInit(s0_remLoadEnqFireVec.map(x => x(w))))
388
389  // generate free mask
390  val s0_loadFreeSelMask = RegNext(freeMaskVec.asUInt)
391  val s0_remFreeSelVec = VecInit(Seq.tabulate(LoadPipelineWidth)(rem => getRemBits(s0_loadFreeSelMask)(rem)))
392
393  // l2 hint wakes up cache missed load
394  // l2 will send GrantData in next 2/3 cycle, wake up the missed load early and sent them to load pipe, so them will hit the data in D channel or mshr in load S1
395  val s0_loadHintWakeMask = VecInit((0 until LoadQueueReplaySize).map(i => {
396    allocated(i) && !scheduled(i) && cause(i)(LoadReplayCauses.C_DM) && blocking(i) && missMSHRId(i) === io.l2_hint.bits.sourceId && io.l2_hint.valid
397  })).asUInt
398  // l2 will send 2 beats data in 2 cycles, so if data needed by this load is in first beat, select it this cycle, otherwise next cycle
399  // when isKeyword = 1, s0_loadHintSelMask need overturn
400    val s0_loadHintSelMask = Mux(
401     io.l2_hint.bits.isKeyword,
402     s0_loadHintWakeMask & dataInLastBeatReg.asUInt,
403     s0_loadHintWakeMask & VecInit(dataInLastBeatReg.map(!_)).asUInt
404     )
405  val s0_remLoadHintSelMask = VecInit((0 until LoadPipelineWidth).map(rem => getRemBits(s0_loadHintSelMask)(rem)))
406  val s0_remHintSelValidVec = VecInit((0 until LoadPipelineWidth).map(rem => ParallelORR(s0_remLoadHintSelMask(rem))))
407  val s0_hintSelValid = ParallelORR(s0_loadHintSelMask)
408
409  // wake up cache missed load
410  (0 until LoadQueueReplaySize).foreach(i => {
411    when(s0_loadHintWakeMask(i)) {
412      blocking(i) := false.B
413    }
414  })
415
416  // generate replay mask
417  // replay select priority is given as follow
418  // 1. hint wake up load
419  // 2. higher priority load
420  // 3. lower priority load
421  val s0_loadHigherPriorityReplaySelMask = VecInit((0 until LoadQueueReplaySize).map(i => {
422    val hasHigherPriority = cause(i)(LoadReplayCauses.C_DM) || cause(i)(LoadReplayCauses.C_FF)
423    allocated(i) && !scheduled(i) && !blocking(i) && hasHigherPriority
424  })).asUInt // use uint instead vec to reduce verilog lines
425  val s0_remLoadHigherPriorityReplaySelMask = VecInit((0 until LoadPipelineWidth).map(rem => getRemBits(s0_loadHigherPriorityReplaySelMask)(rem)))
426  val s0_loadLowerPriorityReplaySelMask = VecInit((0 until LoadQueueReplaySize).map(i => {
427    val hasLowerPriority = !cause(i)(LoadReplayCauses.C_DM) && !cause(i)(LoadReplayCauses.C_FF)
428    allocated(i) && !scheduled(i) && !blocking(i) && hasLowerPriority
429  })).asUInt // use uint instead vec to reduce verilog lines
430  val s0_remLoadLowerPriorityReplaySelMask = VecInit((0 until LoadPipelineWidth).map(rem => getRemBits(s0_loadLowerPriorityReplaySelMask)(rem)))
431  val s0_loadNormalReplaySelMask = s0_loadLowerPriorityReplaySelMask | s0_loadHigherPriorityReplaySelMask | s0_loadHintSelMask
432  val s0_remNormalReplaySelVec = VecInit((0 until LoadPipelineWidth).map(rem => s0_remLoadLowerPriorityReplaySelMask(rem) | s0_remLoadHigherPriorityReplaySelMask(rem) | s0_remLoadHintSelMask(rem)))
433  val s0_remPriorityReplaySelVec = VecInit((0 until LoadPipelineWidth).map(rem => {
434        Mux(s0_remHintSelValidVec(rem), s0_remLoadHintSelMask(rem),
435          Mux(ParallelORR(s0_remLoadHigherPriorityReplaySelMask(rem)), s0_remLoadHigherPriorityReplaySelMask(rem), s0_remLoadLowerPriorityReplaySelMask(rem)))
436      }))
437  /******************************************************************************************************
438   * WARNING: Make sure that OldestSelectStride must less than or equal stages of load pipeline.        *
439   ******************************************************************************************************
440   */
441  val OldestSelectStride = 4
442  val oldestPtrExt = (0 until OldestSelectStride).map(i => io.ldWbPtr + i.U)
443  val s0_oldestMatchMaskVec = (0 until LoadQueueReplaySize).map(i => (0 until OldestSelectStride).map(j => s0_loadNormalReplaySelMask(i) && uop(i).lqIdx === oldestPtrExt(j)))
444  val s0_remOldsetMatchMaskVec = (0 until LoadPipelineWidth).map(rem => getRemSeq(s0_oldestMatchMaskVec.map(_.take(1)))(rem))
445  val s0_remOlderMatchMaskVec = (0 until LoadPipelineWidth).map(rem => getRemSeq(s0_oldestMatchMaskVec.map(_.drop(1)))(rem))
446  val s0_remOldestSelVec = VecInit(Seq.tabulate(LoadPipelineWidth)(rem => {
447    VecInit((0 until LoadQueueReplaySize / LoadPipelineWidth).map(i => {
448      Mux(ParallelORR(s0_remOldsetMatchMaskVec(rem).map(_(0))), s0_remOldsetMatchMaskVec(rem)(i)(0), s0_remOlderMatchMaskVec(rem)(i).reduce(_|_))
449    })).asUInt
450  }))
451  val s0_remOldestHintSelVec = s0_remOldestSelVec.zip(s0_remLoadHintSelMask).map {
452    case(oldestVec, hintVec) => oldestVec & hintVec
453  }
454
455  // select oldest logic
456  s0_oldestSel := VecInit((0 until LoadPipelineWidth).map(rport => {
457    // select enqueue earlest inst
458    val ageOldest = AgeDetector(LoadQueueReplaySize / LoadPipelineWidth, s0_remEnqSelVec(rport), s0_remFreeSelVec(rport), s0_remPriorityReplaySelVec(rport))
459    assert(!(ageOldest.valid && PopCount(ageOldest.bits) > 1.U), "oldest index must be one-hot!")
460    val ageOldestValid = ageOldest.valid
461    val ageOldestIndexOH = ageOldest.bits
462
463    // select program order oldest
464    val l2HintFirst = io.l2_hint.valid && ParallelORR(s0_remOldestHintSelVec(rport))
465    val issOldestValid = l2HintFirst || ParallelORR(s0_remOldestSelVec(rport))
466    val issOldestIndexOH = Mux(l2HintFirst, PriorityEncoderOH(s0_remOldestHintSelVec(rport)), PriorityEncoderOH(s0_remOldestSelVec(rport)))
467
468    val oldest = Wire(Valid(UInt()))
469    val oldestSel = Mux(issOldestValid, issOldestIndexOH, ageOldestIndexOH)
470    val oldestBitsVec = Wire(Vec(LoadQueueReplaySize, Bool()))
471
472    require((LoadQueueReplaySize % LoadPipelineWidth) == 0)
473    oldestBitsVec.foreach(e => e := false.B)
474    for (i <- 0 until LoadQueueReplaySize / LoadPipelineWidth) {
475      oldestBitsVec(i * LoadPipelineWidth + rport) := oldestSel(i)
476    }
477
478    oldest.valid := ageOldest.valid || issOldestValid
479    oldest.bits := oldestBitsVec.asUInt
480    oldest
481  }))
482
483  // stage2: send replay request to load unit
484  // replay cold down
485  val ColdDownCycles = 16
486  val coldCounter = RegInit(VecInit(List.fill(LoadPipelineWidth)(0.U(log2Up(ColdDownCycles).W))))
487  val ColdDownThreshold = Wire(UInt(log2Up(ColdDownCycles).W))
488  ColdDownThreshold := Constantin.createRecord(s"ColdDownThreshold_${p(XSCoreParamsKey).HartId}", initValue = 12)
489  assert(ColdDownCycles.U > ColdDownThreshold, "ColdDownCycles must great than ColdDownThreshold!")
490
491  def replayCanFire(i: Int) = coldCounter(i) >= 0.U && coldCounter(i) < ColdDownThreshold
492  def coldDownNow(i: Int) = coldCounter(i) >= ColdDownThreshold
493
494  val replay_req = Wire(Vec(LoadPipelineWidth, DecoupledIO(new LsPipelineBundle)))
495
496  for (i <- 0 until LoadPipelineWidth) {
497    val s0_can_go = s1_can_go(i) ||
498                    uop(s1_oldestSel(i).bits).robIdx.needFlush(io.redirect) ||
499                    uop(s1_oldestSel(i).bits).robIdx.needFlush(RegNext(io.redirect))
500    val s0_oldestSelIndexOH = s0_oldestSel(i).bits // one-hot
501    s1_oldestSel(i).valid := RegEnable(s0_oldestSel(i).valid, false.B, s0_can_go)
502    s1_oldestSel(i).bits := RegEnable(OHToUInt(s0_oldestSel(i).bits), s0_can_go)
503
504    for (j <- 0 until LoadQueueReplaySize) {
505      when (s0_can_go && s0_oldestSel(i).valid && s0_oldestSelIndexOH(j)) {
506        scheduled(j) := true.B
507      }
508    }
509  }
510  val s2_cancelReplay = Wire(Vec(LoadPipelineWidth, Bool()))
511  for (i <- 0 until LoadPipelineWidth) {
512    val s1_cancel = uop(s1_oldestSel(i).bits).robIdx.needFlush(io.redirect) ||
513                    uop(s1_oldestSel(i).bits).robIdx.needFlush(RegNext(io.redirect))
514    val s1_oldestSelV = s1_oldestSel(i).valid && !s1_cancel
515    s1_can_go(i)          := replayCanFire(i) && (!s2_oldestSel(i).valid || replay_req(i).fire) || s2_cancelReplay(i)
516    s2_oldestSel(i).valid := RegEnable(Mux(s1_can_go(i), s1_oldestSelV, false.B), false.B, (s1_can_go(i) || replay_req(i).fire))
517    s2_oldestSel(i).bits  := RegEnable(s1_oldestSel(i).bits, s1_can_go(i))
518
519    vaddrModule.io.ren(i) := s1_oldestSel(i).valid && s1_can_go(i)
520    vaddrModule.io.raddr(i) := s1_oldestSel(i).bits
521  }
522
523  for (i <- 0 until LoadPipelineWidth) {
524    val s1_replayIdx = s1_oldestSel(i).bits
525    val s2_replayUop = RegEnable(uop(s1_replayIdx), s1_can_go(i))
526    val s2_vecReplay = RegEnable(vecReplay(s1_replayIdx), s1_can_go(i))
527    val s2_replayMSHRId = RegEnable(missMSHRId(s1_replayIdx), s1_can_go(i))
528    val s2_replacementUpdated = RegEnable(replacementUpdated(s1_replayIdx), s1_can_go(i))
529    val s2_missDbUpdated = RegEnable(missDbUpdated(s1_replayIdx), s1_can_go(i))
530    val s2_replayCauses = RegEnable(cause(s1_replayIdx), s1_can_go(i))
531    val s2_replayCarry = RegEnable(replayCarryReg(s1_replayIdx), s1_can_go(i))
532    val s2_replayCacheMissReplay = RegEnable(trueCacheMissReplay(s1_replayIdx), s1_can_go(i))
533    s2_cancelReplay(i) := s2_replayUop.robIdx.needFlush(io.redirect)
534
535    s2_can_go(i) := DontCare
536    replay_req(i).valid             := s2_oldestSel(i).valid
537    replay_req(i).bits              := DontCare
538    replay_req(i).bits.uop          := s2_replayUop
539    replay_req(i).bits.isvec        := s2_vecReplay.isvec
540    replay_req(i).bits.isLastElem   := s2_vecReplay.isLastElem
541    replay_req(i).bits.is128bit     := s2_vecReplay.is128bit
542    replay_req(i).bits.uop_unit_stride_fof := s2_vecReplay.uop_unit_stride_fof
543    replay_req(i).bits.usSecondInv  := s2_vecReplay.usSecondInv
544    replay_req(i).bits.elemIdx      := s2_vecReplay.elemIdx
545    replay_req(i).bits.alignedType  := s2_vecReplay.alignedType
546    replay_req(i).bits.mbIndex      := s2_vecReplay.mbIndex
547    replay_req(i).bits.elemIdxInsideVd := s2_vecReplay.elemIdxInsideVd
548    replay_req(i).bits.reg_offset   := s2_vecReplay.reg_offset
549    replay_req(i).bits.vecActive    := s2_vecReplay.vecActive
550    replay_req(i).bits.is_first_ele := s2_vecReplay.is_first_ele
551    replay_req(i).bits.mask         := s2_vecReplay.mask
552    replay_req(i).bits.vaddr        := vaddrModule.io.rdata(i)
553    replay_req(i).bits.isFirstIssue := false.B
554    replay_req(i).bits.isLoadReplay := true.B
555    replay_req(i).bits.replayCarry  := s2_replayCarry
556    replay_req(i).bits.mshrid       := s2_replayMSHRId
557    replay_req(i).bits.replacementUpdated := s2_replacementUpdated
558    replay_req(i).bits.missDbUpdated := s2_missDbUpdated
559    replay_req(i).bits.forward_tlDchannel := s2_replayCauses(LoadReplayCauses.C_DM)
560    replay_req(i).bits.schedIndex   := s2_oldestSel(i).bits
561    replay_req(i).bits.uop.loadWaitStrict := false.B
562
563    when (replay_req(i).fire) {
564      XSError(!allocated(s2_oldestSel(i).bits), p"LoadQueueReplay: why replay an invalid entry ${s2_oldestSel(i).bits} ?")
565    }
566  }
567
568  val EnableHybridUnitReplay = Constantin.createRecord("EnableHybridUnitReplay", true)
569  when(EnableHybridUnitReplay) {
570    for (i <- 0 until LoadPipelineWidth)
571      io.replay(i) <> replay_req(i)
572  }.otherwise {
573    io.replay(0) <> replay_req(0)
574    io.replay(2).valid := false.B
575    io.replay(2).bits := DontCare
576
577    val arbiter = Module(new RRArbiter(new LsPipelineBundle, 2))
578    arbiter.io.in(0) <> replay_req(1)
579    arbiter.io.in(1) <> replay_req(2)
580    io.replay(1) <> arbiter.io.out
581  }
582  // update cold counter
583  val lastReplay = RegNext(VecInit(io.replay.map(_.fire)))
584  for (i <- 0 until LoadPipelineWidth) {
585    when (lastReplay(i) && io.replay(i).fire) {
586      coldCounter(i) := coldCounter(i) + 1.U
587    } .elsewhen (coldDownNow(i)) {
588      coldCounter(i) := coldCounter(i) + 1.U
589    } .otherwise {
590      coldCounter(i) := 0.U
591    }
592  }
593
594 // when(io.refill.valid) {
595 //   XSDebug("miss resp: paddr:0x%x data %x\n", io.refill.bits.addr, io.refill.bits.data)
596 // }
597
598  // init
599  freeMaskVec.map(e => e := false.B)
600
601  // Allocate logic
602  val newEnqueue = (0 until LoadPipelineWidth).map(i => {
603    needEnqueue(i) && !io.enq(i).bits.isLoadReplay
604  })
605
606  for ((enq, w) <- io.enq.zipWithIndex) {
607    vaddrModule.io.wen(w) := false.B
608    freeList.io.doAllocate(w) := false.B
609
610    freeList.io.allocateReq(w) := true.B
611
612    //  Allocated ready
613    val offset = PopCount(newEnqueue.take(w))
614    val canAccept = freeList.io.canAllocate(offset)
615    val enqIndex = Mux(enq.bits.isLoadReplay, enq.bits.schedIndex, freeList.io.allocateSlot(offset))
616    enqIndexOH(w) := UIntToOH(enqIndex)
617    enq.ready := Mux(enq.bits.isLoadReplay, true.B, canAccept)
618
619    when (needEnqueue(w) && enq.ready) {
620
621      val debug_robIdx = enq.bits.uop.robIdx.asUInt
622      XSError(allocated(enqIndex) && !enq.bits.isLoadReplay, p"LoadQueueReplay: can not accept more load, check: ldu $w, robIdx $debug_robIdx!")
623      XSError(hasExceptions(w), p"LoadQueueReplay: The instruction has exception, it can not be replay, check: ldu $w, robIdx $debug_robIdx!")
624
625      freeList.io.doAllocate(w) := !enq.bits.isLoadReplay
626
627      //  Allocate new entry
628      allocated(enqIndex) := true.B
629      scheduled(enqIndex) := false.B
630      uop(enqIndex)       := enq.bits.uop
631      vecReplay(enqIndex).isvec := enq.bits.isvec
632      vecReplay(enqIndex).isLastElem := enq.bits.isLastElem
633      vecReplay(enqIndex).is128bit := enq.bits.is128bit
634      vecReplay(enqIndex).uop_unit_stride_fof := enq.bits.uop_unit_stride_fof
635      vecReplay(enqIndex).usSecondInv := enq.bits.usSecondInv
636      vecReplay(enqIndex).elemIdx := enq.bits.elemIdx
637      vecReplay(enqIndex).alignedType:= enq.bits.alignedType
638      vecReplay(enqIndex).mbIndex := enq.bits.mbIndex
639      vecReplay(enqIndex).elemIdxInsideVd := enq.bits.elemIdxInsideVd
640      vecReplay(enqIndex).reg_offset := enq.bits.reg_offset
641      vecReplay(enqIndex).vecActive := enq.bits.vecActive
642      vecReplay(enqIndex).is_first_ele := enq.bits.is_first_ele
643      vecReplay(enqIndex).mask         := enq.bits.mask
644
645      vaddrModule.io.wen(w)   := true.B
646      vaddrModule.io.waddr(w) := enqIndex
647      vaddrModule.io.wdata(w) := enq.bits.vaddr
648      debug_vaddr(enqIndex)   := enq.bits.vaddr
649
650      /**
651       * used for feedback and replay
652       */
653      // set flags
654      val replayInfo = enq.bits.rep_info
655      val dataInLastBeat = replayInfo.last_beat
656      cause(enqIndex) := replayInfo.cause.asUInt
657
658
659      // init
660      blocking(enqIndex)     := true.B
661      strict(enqIndex)       := false.B
662
663      // update blocking pointer
664      when (replayInfo.cause(LoadReplayCauses.C_BC) ||
665            replayInfo.cause(LoadReplayCauses.C_NK) ||
666            replayInfo.cause(LoadReplayCauses.C_DR) ||
667            replayInfo.cause(LoadReplayCauses.C_WF)) {
668        // normal case: bank conflict or schedule error or dcache replay
669        // can replay next cycle
670        blocking(enqIndex) := false.B
671      }
672
673      // special case: tlb miss
674      when (replayInfo.cause(LoadReplayCauses.C_TM)) {
675        blocking(enqIndex) := !replayInfo.tlb_full &&
676          !(io.tlb_hint.resp.valid && (io.tlb_hint.resp.bits.id === replayInfo.tlb_id || io.tlb_hint.resp.bits.replay_all))
677        tlbHintId(enqIndex) := replayInfo.tlb_id
678      }
679
680      // special case: dcache miss
681      when (replayInfo.cause(LoadReplayCauses.C_DM) && enq.bits.handledByMSHR) {
682        blocking(enqIndex) := !replayInfo.full_fwd && //  dcache miss
683                              !(io.tl_d_channel.valid && io.tl_d_channel.mshrid === replayInfo.mshr_id) // no refill in this cycle
684      }
685
686      // special case: st-ld violation
687      when (replayInfo.cause(LoadReplayCauses.C_MA)) {
688        blockSqIdx(enqIndex) := replayInfo.addr_inv_sq_idx
689        strict(enqIndex) := enq.bits.uop.loadWaitStrict
690      }
691
692      // special case: data forward fail
693      when (replayInfo.cause(LoadReplayCauses.C_FF)) {
694        blockSqIdx(enqIndex) := replayInfo.data_inv_sq_idx
695      }
696      // extra info
697      replayCarryReg(enqIndex) := replayInfo.rep_carry
698      replacementUpdated(enqIndex) := enq.bits.replacementUpdated
699      missDbUpdated(enqIndex) := enq.bits.missDbUpdated
700      // update mshr_id only when the load has already been handled by mshr
701      when(enq.bits.handledByMSHR) {
702        missMSHRId(enqIndex) := replayInfo.mshr_id
703      }
704      dataInLastBeatReg(enqIndex) := dataInLastBeat
705      //dataInLastBeatReg(enqIndex) := Mux(io.l2_hint.bits.isKeyword, !dataInLastBeat, dataInLastBeat)
706    }
707
708    //
709    val schedIndex = enq.bits.schedIndex
710    when (enq.valid && enq.bits.isLoadReplay) {
711      when (!needReplay(w) || hasExceptions(w)) {
712        allocated(schedIndex) := false.B
713        freeMaskVec(schedIndex) := true.B
714      } .otherwise {
715        scheduled(schedIndex) := false.B
716      }
717    }
718  }
719
720  // vector load, all replay entries of same robidx and uopidx
721  // should be released when vlmergebuffer commit or flush
722  val vecLdCanceltmp = Wire(Vec(LoadQueueReplaySize, Vec(VecLoadPipelineWidth, Bool())))
723  val vecLdCancel = Wire(Vec(LoadQueueReplaySize, Bool()))
724  val vecLdCommittmp = Wire(Vec(LoadQueueReplaySize, Vec(VecLoadPipelineWidth, Bool())))
725  val vecLdCommit = Wire(Vec(LoadQueueReplaySize, Bool()))
726  for (i <- 0 until LoadQueueReplaySize) {
727    val fbk = io.vecFeedback
728    for (j <- 0 until VecLoadPipelineWidth) {
729      vecLdCanceltmp(i)(j) := fbk(j).valid && fbk(j).bits.isFlush && uop(i).robIdx === fbk(j).bits.robidx && uop(i).uopIdx === fbk(j).bits.uopidx
730      vecLdCommittmp(i)(j) := fbk(j).valid && fbk(j).bits.isCommit && uop(i).robIdx === fbk(j).bits.robidx && uop(i).uopIdx === fbk(j).bits.uopidx
731    }
732    vecLdCancel(i) := vecLdCanceltmp(i).reduce(_ || _)
733    vecLdCommit(i) := vecLdCommittmp(i).reduce(_ || _)
734    XSError((vecLdCancel(i) || vecLdCommit(i) && allocated(i)), s"vector load, should not have replay entry $i when commit or flush.\n")
735  }
736
737  // misprediction recovery / exception redirect
738  for (i <- 0 until LoadQueueReplaySize) {
739    needCancel(i) := uop(i).robIdx.needFlush(io.redirect) && allocated(i)
740    when (needCancel(i)) {
741      allocated(i) := false.B
742      freeMaskVec(i) := true.B
743    }
744  }
745
746  freeList.io.free := freeMaskVec.asUInt
747
748  io.lqFull := lqFull
749
750  // Topdown
751  val robHeadVaddr = io.debugTopDown.robHeadVaddr
752
753  val uop_wrapper = Wire(Vec(LoadQueueReplaySize, new XSBundleWithMicroOp))
754  (uop_wrapper.zipWithIndex).foreach {
755    case (u, i) => {
756      u.uop := uop(i)
757    }
758  }
759  val lq_match_vec = (debug_vaddr.zip(allocated)).map{case(va, alloc) => alloc && (va === robHeadVaddr.bits)}
760  val rob_head_lq_match = ParallelOperation(lq_match_vec.zip(uop_wrapper), (a: Tuple2[Bool, XSBundleWithMicroOp], b: Tuple2[Bool, XSBundleWithMicroOp]) => {
761    val (a_v, a_uop) = (a._1, a._2)
762    val (b_v, b_uop) = (b._1, b._2)
763
764    val res = Mux(a_v && b_v, Mux(isAfter(a_uop.uop.robIdx, b_uop.uop.robIdx), b_uop, a_uop),
765                  Mux(a_v, a_uop,
766                      Mux(b_v, b_uop,
767                                a_uop)))
768    (a_v || b_v, res)
769  })
770
771  val lq_match_bits = rob_head_lq_match._2.uop
772  val lq_match      = rob_head_lq_match._1 && robHeadVaddr.valid
773  val lq_match_idx  = lq_match_bits.lqIdx.value
774
775  val rob_head_tlb_miss        = lq_match && cause(lq_match_idx)(LoadReplayCauses.C_TM)
776  val rob_head_nuke            = lq_match && cause(lq_match_idx)(LoadReplayCauses.C_NK)
777  val rob_head_mem_amb         = lq_match && cause(lq_match_idx)(LoadReplayCauses.C_MA)
778  val rob_head_confilct_replay = lq_match && cause(lq_match_idx)(LoadReplayCauses.C_BC)
779  val rob_head_forward_fail    = lq_match && cause(lq_match_idx)(LoadReplayCauses.C_FF)
780  val rob_head_mshrfull_replay = lq_match && cause(lq_match_idx)(LoadReplayCauses.C_DR)
781  val rob_head_dcache_miss     = lq_match && cause(lq_match_idx)(LoadReplayCauses.C_DM)
782  val rob_head_rar_nack        = lq_match && cause(lq_match_idx)(LoadReplayCauses.C_RAR)
783  val rob_head_raw_nack        = lq_match && cause(lq_match_idx)(LoadReplayCauses.C_RAW)
784  val rob_head_other_replay    = lq_match && (rob_head_rar_nack || rob_head_raw_nack || rob_head_forward_fail)
785
786  val rob_head_vio_replay = rob_head_nuke || rob_head_mem_amb
787
788  val rob_head_miss_in_dtlb = io.debugTopDown.robHeadMissInDTlb
789  io.debugTopDown.robHeadTlbReplay := rob_head_tlb_miss && !rob_head_miss_in_dtlb
790  io.debugTopDown.robHeadTlbMiss := rob_head_tlb_miss && rob_head_miss_in_dtlb
791  io.debugTopDown.robHeadLoadVio := rob_head_vio_replay
792  io.debugTopDown.robHeadLoadMSHR := rob_head_mshrfull_replay
793  io.debugTopDown.robHeadOtherReplay := rob_head_other_replay
794  val perfValidCount = RegNext(PopCount(allocated))
795
796  //  perf cnt
797  val enqNumber               = PopCount(io.enq.map(enq => enq.fire && !enq.bits.isLoadReplay))
798  val deqNumber               = PopCount(io.replay.map(_.fire))
799  val deqBlockCount           = PopCount(io.replay.map(r => r.valid && !r.ready))
800  val replayTlbMissCount      = PopCount(io.enq.map(enq => enq.fire && !enq.bits.isLoadReplay && enq.bits.rep_info.cause(LoadReplayCauses.C_TM)))
801  val replayMemAmbCount       = PopCount(io.enq.map(enq => enq.fire && !enq.bits.isLoadReplay && enq.bits.rep_info.cause(LoadReplayCauses.C_MA)))
802  val replayNukeCount         = PopCount(io.enq.map(enq => enq.fire && !enq.bits.isLoadReplay && enq.bits.rep_info.cause(LoadReplayCauses.C_NK)))
803  val replayRARRejectCount    = PopCount(io.enq.map(enq => enq.fire && !enq.bits.isLoadReplay && enq.bits.rep_info.cause(LoadReplayCauses.C_RAR)))
804  val replayRAWRejectCount    = PopCount(io.enq.map(enq => enq.fire && !enq.bits.isLoadReplay && enq.bits.rep_info.cause(LoadReplayCauses.C_RAW)))
805  val replayBankConflictCount = PopCount(io.enq.map(enq => enq.fire && !enq.bits.isLoadReplay && enq.bits.rep_info.cause(LoadReplayCauses.C_BC)))
806  val replayDCacheReplayCount = PopCount(io.enq.map(enq => enq.fire && !enq.bits.isLoadReplay && enq.bits.rep_info.cause(LoadReplayCauses.C_DR)))
807  val replayForwardFailCount  = PopCount(io.enq.map(enq => enq.fire && !enq.bits.isLoadReplay && enq.bits.rep_info.cause(LoadReplayCauses.C_FF)))
808  val replayDCacheMissCount   = PopCount(io.enq.map(enq => enq.fire && !enq.bits.isLoadReplay && enq.bits.rep_info.cause(LoadReplayCauses.C_DM)))
809  XSPerfAccumulate("enq", enqNumber)
810  XSPerfAccumulate("deq", deqNumber)
811  XSPerfAccumulate("deq_block", deqBlockCount)
812  XSPerfAccumulate("replay_full", io.lqFull)
813  XSPerfAccumulate("replay_rar_nack", replayRARRejectCount)
814  XSPerfAccumulate("replay_raw_nack", replayRAWRejectCount)
815  XSPerfAccumulate("replay_nuke", replayNukeCount)
816  XSPerfAccumulate("replay_mem_amb", replayMemAmbCount)
817  XSPerfAccumulate("replay_tlb_miss", replayTlbMissCount)
818  XSPerfAccumulate("replay_bank_conflict", replayBankConflictCount)
819  XSPerfAccumulate("replay_dcache_replay", replayDCacheReplayCount)
820  XSPerfAccumulate("replay_forward_fail", replayForwardFailCount)
821  XSPerfAccumulate("replay_dcache_miss", replayDCacheMissCount)
822  XSPerfAccumulate("replay_hint_wakeup", s0_hintSelValid)
823  XSPerfAccumulate("replay_hint_priority_beat1", io.l2_hint.valid && io.l2_hint.bits.isKeyword)
824
825  val perfEvents: Seq[(String, UInt)] = Seq(
826    ("enq", enqNumber),
827    ("deq", deqNumber),
828    ("deq_block", deqBlockCount),
829    ("replay_full", io.lqFull),
830    ("replay_rar_nack", replayRARRejectCount),
831    ("replay_raw_nack", replayRAWRejectCount),
832    ("replay_nuke", replayNukeCount),
833    ("replay_mem_amb", replayMemAmbCount),
834    ("replay_tlb_miss", replayTlbMissCount),
835    ("replay_bank_conflict", replayBankConflictCount),
836    ("replay_dcache_replay", replayDCacheReplayCount),
837    ("replay_forward_fail", replayForwardFailCount),
838    ("replay_dcache_miss", replayDCacheMissCount),
839  )
840  generatePerfEvent()
841  // end
842}
843