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