1package xiangshan.mem 2 3import chipsalliance.rocketchip.config.Parameters 4import chisel3._ 5import chisel3.util._ 6import utils._ 7import xiangshan._ 8import xiangshan.cache._ 9import xiangshan.cache.{DCacheWordIO, DCacheLineIO, TlbRequestIO, MemoryOpConstants} 10import xiangshan.backend.roq.{RoqLsqIO, RoqPtr} 11import difftest._ 12import device.RAMHelper 13 14class SqPtr(implicit p: Parameters) extends CircularQueuePtr[SqPtr]( 15 p => p(XSCoreParamsKey).StoreQueueSize 16){ 17 override def cloneType = (new SqPtr).asInstanceOf[this.type] 18} 19 20object SqPtr { 21 def apply(f: Bool, v: UInt)(implicit p: Parameters): SqPtr = { 22 val ptr = Wire(new SqPtr) 23 ptr.flag := f 24 ptr.value := v 25 ptr 26 } 27} 28 29class SqEnqIO(implicit p: Parameters) extends XSBundle { 30 val canAccept = Output(Bool()) 31 val lqCanAccept = Input(Bool()) 32 val needAlloc = Vec(RenameWidth, Input(Bool())) 33 val req = Vec(RenameWidth, Flipped(ValidIO(new MicroOp))) 34 val resp = Vec(RenameWidth, Output(new SqPtr)) 35} 36 37// Store Queue 38class StoreQueue(implicit p: Parameters) extends XSModule with HasDCacheParameters with HasCircularQueuePtrHelper { 39 val io = IO(new Bundle() { 40 val enq = new SqEnqIO 41 val brqRedirect = Flipped(ValidIO(new Redirect)) 42 val flush = Input(Bool()) 43 val storeIn = Vec(StorePipelineWidth, Flipped(Valid(new LsPipelineBundle))) // store addr, data is not included 44 val storeDataIn = Vec(StorePipelineWidth, Flipped(Valid(new StoreDataBundle))) // store data, send to sq from rs 45 val sbuffer = Vec(StorePipelineWidth, Decoupled(new DCacheWordReq)) // write commited store to sbuffer 46 val mmioStout = DecoupledIO(new ExuOutput) // writeback uncached store 47 val forward = Vec(LoadPipelineWidth, Flipped(new PipeLoadForwardQueryIO)) 48 val roq = Flipped(new RoqLsqIO) 49 val uncache = new DCacheWordIO 50 // val refill = Flipped(Valid(new DCacheLineReq )) 51 val exceptionAddr = new ExceptionAddrIO 52 val sqempty = Output(Bool()) 53 val issuePtrExt = Output(new SqPtr) // used to wake up delayed load/store 54 val storeIssue = Vec(StorePipelineWidth, Flipped(Valid(new ExuInput))) // used to update issuePtrExt 55 val sqFull = Output(Bool()) 56 }) 57 58 // data modules 59 val uop = Reg(Vec(StoreQueueSize, new MicroOp)) 60 // val data = Reg(Vec(StoreQueueSize, new LsqEntry)) 61 val dataModule = Module(new SQDataModule(StoreQueueSize, numRead = StorePipelineWidth, numWrite = StorePipelineWidth, numForward = StorePipelineWidth)) 62 dataModule.io := DontCare 63 val paddrModule = Module(new SQPaddrModule(StoreQueueSize, numRead = StorePipelineWidth, numWrite = StorePipelineWidth, numForward = StorePipelineWidth)) 64 paddrModule.io := DontCare 65 val vaddrModule = Module(new SyncDataModuleTemplate(UInt(VAddrBits.W), StoreQueueSize, numRead = 1, numWrite = StorePipelineWidth)) 66 vaddrModule.io := DontCare 67 68 // state & misc 69 val allocated = RegInit(VecInit(List.fill(StoreQueueSize)(false.B))) // sq entry has been allocated 70 val addrvalid = RegInit(VecInit(List.fill(StoreQueueSize)(false.B))) // non-mmio addr is valid 71 val datavalid = RegInit(VecInit(List.fill(StoreQueueSize)(false.B))) // non-mmio data is valid 72 val allvalid = VecInit((0 until StoreQueueSize).map(i => addrvalid(i) && datavalid(i))) // non-mmio data & addr is valid 73 val issued = Reg(Vec(StoreQueueSize, Bool())) // inst has been issued by rs 74 val commited = Reg(Vec(StoreQueueSize, Bool())) // inst has been commited by roq 75 val pending = Reg(Vec(StoreQueueSize, Bool())) // mmio pending: inst is an mmio inst, it will not be executed until it reachs the end of roq 76 val mmio = Reg(Vec(StoreQueueSize, Bool())) // mmio: inst is an mmio inst 77 78 // ptr 79 require(StoreQueueSize > RenameWidth) 80 val enqPtrExt = RegInit(VecInit((0 until RenameWidth).map(_.U.asTypeOf(new SqPtr)))) 81 val deqPtrExt = RegInit(VecInit((0 until StorePipelineWidth).map(_.U.asTypeOf(new SqPtr)))) 82 val cmtPtrExt = RegInit(VecInit((0 until CommitWidth).map(_.U.asTypeOf(new SqPtr)))) 83 val issuePtrExt = RegInit(0.U.asTypeOf(new SqPtr)) 84 val validCounter = RegInit(0.U(log2Ceil(LoadQueueSize + 1).W)) 85 val allowEnqueue = RegInit(true.B) 86 87 val enqPtr = enqPtrExt(0).value 88 val deqPtr = deqPtrExt(0).value 89 val cmtPtr = cmtPtrExt(0).value 90 91 val deqMask = UIntToMask(deqPtr, StoreQueueSize) 92 val enqMask = UIntToMask(enqPtr, StoreQueueSize) 93 94 val commitCount = RegNext(io.roq.scommit) 95 96 // Read dataModule 97 // deqPtrExtNext and deqPtrExtNext+1 entry will be read from dataModule 98 // if !sbuffer.fire(), read the same ptr 99 // if sbuffer.fire(), read next 100 val deqPtrExtNext = WireInit(Mux(io.sbuffer(1).fire(), 101 VecInit(deqPtrExt.map(_ + 2.U)), 102 Mux(io.sbuffer(0).fire() || io.mmioStout.fire(), 103 VecInit(deqPtrExt.map(_ + 1.U)), 104 deqPtrExt 105 ) 106 )) 107 for (i <- 0 until StorePipelineWidth) { 108 dataModule.io.raddr(i) := deqPtrExtNext(i).value 109 paddrModule.io.raddr(i) := deqPtrExtNext(i).value 110 } 111 112 // no inst will be commited 1 cycle before tval update 113 vaddrModule.io.raddr(0) := (cmtPtrExt(0) + commitCount).value 114 115 /** 116 * Enqueue at dispatch 117 * 118 * Currently, StoreQueue only allows enqueue when #emptyEntries > RenameWidth(EnqWidth) 119 */ 120 io.enq.canAccept := allowEnqueue 121 for (i <- 0 until RenameWidth) { 122 val offset = if (i == 0) 0.U else PopCount(io.enq.needAlloc.take(i)) 123 val sqIdx = enqPtrExt(offset) 124 val index = sqIdx.value 125 when (io.enq.req(i).valid && io.enq.canAccept && io.enq.lqCanAccept && !(io.brqRedirect.valid || io.flush)) { 126 uop(index) := io.enq.req(i).bits 127 allocated(index) := true.B 128 datavalid(index) := false.B 129 addrvalid(index) := false.B 130 issued(index) := false.B 131 commited(index) := false.B 132 pending(index) := false.B 133 } 134 io.enq.resp(i) := sqIdx 135 } 136 XSDebug(p"(ready, valid): ${io.enq.canAccept}, ${Binary(Cat(io.enq.req.map(_.valid)))}\n") 137 138 /** 139 * Update issuePtr when issue from rs 140 */ 141 142 // update state bit issued 143 for (i <- 0 until StorePipelineWidth) { 144 when (io.storeIssue(i).valid) { 145 issued(io.storeIssue(i).bits.uop.sqIdx.value) := true.B 146 } 147 } 148 149 // update issuePtr 150 val IssuePtrMoveStride = 4 151 require(IssuePtrMoveStride >= 2) 152 153 val issueLookupVec = (0 until IssuePtrMoveStride).map(issuePtrExt + _.U) 154 val issueLookup = issueLookupVec.map(ptr => allocated(ptr.value) && issued(ptr.value) && ptr =/= enqPtrExt(0)) 155 val nextIssuePtr = issuePtrExt + PriorityEncoder(VecInit(issueLookup.map(!_) :+ true.B)) 156 issuePtrExt := nextIssuePtr 157 158 when (io.brqRedirect.valid || io.flush) { 159 issuePtrExt := Mux( 160 isAfter(cmtPtrExt(0), deqPtrExt(0)), 161 cmtPtrExt(0), 162 deqPtrExtNext(0) // for mmio insts, deqPtr may be ahead of cmtPtr 163 ) 164 } 165 // send issuePtrExt to rs 166 // io.issuePtrExt := cmtPtrExt(0) 167 io.issuePtrExt := issuePtrExt 168 169 /** 170 * Writeback store from store units 171 * 172 * Most store instructions writeback to regfile in the previous cycle. 173 * However, 174 * (1) For an mmio instruction with exceptions, we need to mark it as addrvalid 175 * (in this way it will trigger an exception when it reaches ROB's head) 176 * instead of pending to avoid sending them to lower level. 177 * (2) For an mmio instruction without exceptions, we mark it as pending. 178 * When the instruction reaches ROB's head, StoreQueue sends it to uncache channel. 179 * Upon receiving the response, StoreQueue writes back the instruction 180 * through arbiter with store units. It will later commit as normal. 181 */ 182 183 // Write addr to sq 184 for (i <- 0 until StorePipelineWidth) { 185 paddrModule.io.wen(i) := false.B 186 dataModule.io.mask.wen(i) := false.B 187 val stWbIndex = io.storeIn(i).bits.uop.sqIdx.value 188 when (io.storeIn(i).fire()) { 189 addrvalid(stWbIndex) := true.B//!io.storeIn(i).bits.mmio 190 pending(stWbIndex) := io.storeIn(i).bits.mmio 191 192 dataModule.io.mask.waddr(i) := stWbIndex 193 dataModule.io.mask.wdata(i) := io.storeIn(i).bits.mask 194 dataModule.io.mask.wen(i) := true.B 195 196 paddrModule.io.waddr(i) := stWbIndex 197 paddrModule.io.wdata(i) := io.storeIn(i).bits.paddr 198 paddrModule.io.wen(i) := true.B 199 200 mmio(stWbIndex) := io.storeIn(i).bits.mmio 201 202 XSInfo("store addr write to sq idx %d pc 0x%x vaddr %x paddr %x mmio %x\n", 203 io.storeIn(i).bits.uop.sqIdx.value, 204 io.storeIn(i).bits.uop.cf.pc, 205 io.storeIn(i).bits.vaddr, 206 io.storeIn(i).bits.paddr, 207 io.storeIn(i).bits.mmio 208 ) 209 } 210 // vaddrModule write is delayed, as vaddrModule will not be read right after write 211 vaddrModule.io.waddr(i) := RegNext(stWbIndex) 212 vaddrModule.io.wdata(i) := RegNext(io.storeIn(i).bits.vaddr) 213 vaddrModule.io.wen(i) := RegNext(io.storeIn(i).fire()) 214 } 215 216 // Write data to sq 217 for (i <- 0 until StorePipelineWidth) { 218 dataModule.io.data.wen(i) := false.B 219 io.roq.storeDataRoqWb(i).valid := false.B 220 io.roq.storeDataRoqWb(i).bits := DontCare 221 val stWbIndex = io.storeDataIn(i).bits.uop.sqIdx.value 222 when (io.storeDataIn(i).fire()) { 223 datavalid(stWbIndex) := true.B 224 225 dataModule.io.data.waddr(i) := stWbIndex 226 dataModule.io.data.wdata(i) := genWdata(io.storeDataIn(i).bits.data, io.storeDataIn(i).bits.uop.ctrl.fuOpType(1,0)) 227 dataModule.io.data.wen(i) := true.B 228 229 io.roq.storeDataRoqWb(i).valid := true.B 230 io.roq.storeDataRoqWb(i).bits := io.storeDataIn(i).bits.uop.roqIdx 231 232 XSInfo("store data write to sq idx %d pc 0x%x data %x -> %x\n", 233 io.storeDataIn(i).bits.uop.sqIdx.value, 234 io.storeDataIn(i).bits.uop.cf.pc, 235 io.storeDataIn(i).bits.data, 236 dataModule.io.data.wdata(i) 237 ) 238 } 239 } 240 241 /** 242 * load forward query 243 * 244 * Check store queue for instructions that is older than the load. 245 * The response will be valid at the next cycle after req. 246 */ 247 // check over all lq entries and forward data from the first matched store 248 for (i <- 0 until LoadPipelineWidth) { 249 io.forward(i).forwardMask := 0.U(8.W).asBools 250 io.forward(i).forwardData := DontCare 251 252 // Compare deqPtr (deqPtr) and forward.sqIdx, we have two cases: 253 // (1) if they have the same flag, we need to check range(tail, sqIdx) 254 // (2) if they have different flags, we need to check range(tail, LoadQueueSize) and range(0, sqIdx) 255 // Forward1: Mux(same_flag, range(tail, sqIdx), range(tail, LoadQueueSize)) 256 // Forward2: Mux(same_flag, 0.U, range(0, sqIdx) ) 257 // i.e. forward1 is the target entries with the same flag bits and forward2 otherwise 258 val differentFlag = deqPtrExt(0).flag =/= io.forward(i).sqIdx.flag 259 val forwardMask = io.forward(i).sqIdxMask 260 // all addrvalid terms need to be checked 261 val addrValidVec = WireInit(VecInit((0 until StoreQueueSize).map(i => addrvalid(i) && allocated(i)))) 262 val dataValidVec = WireInit(VecInit((0 until StoreQueueSize).map(i => datavalid(i)))) 263 val allValidVec = WireInit(VecInit((0 until StoreQueueSize).map(i => addrvalid(i) && datavalid(i) && allocated(i)))) 264 val canForward1 = Mux(differentFlag, ~deqMask, deqMask ^ forwardMask) & allValidVec.asUInt 265 val canForward2 = Mux(differentFlag, forwardMask, 0.U(StoreQueueSize.W)) & allValidVec.asUInt 266 val needForward = Mux(differentFlag, ~deqMask | forwardMask, deqMask ^ forwardMask) 267 268 XSDebug(p"$i f1 ${Binary(canForward1)} f2 ${Binary(canForward2)} " + 269 p"sqIdx ${io.forward(i).sqIdx} pa ${Hexadecimal(io.forward(i).paddr)}\n" 270 ) 271 272 // do real fwd query (cam lookup in load_s1) 273 dataModule.io.needForward(i)(0) := canForward1 & paddrModule.io.forwardMmask(i).asUInt 274 dataModule.io.needForward(i)(1) := canForward2 & paddrModule.io.forwardMmask(i).asUInt 275 276 paddrModule.io.forwardMdata(i) := io.forward(i).paddr 277 278 // Forward result will be generated 1 cycle later (load_s2) 279 io.forward(i).forwardMask := dataModule.io.forwardMask(i) 280 io.forward(i).forwardData := dataModule.io.forwardData(i) 281 282 // If addr match, data not ready, mark it as dataInvalid 283 // load_s1: generate dataInvalid in load_s1 to set fastUop to 284 io.forward(i).dataInvalidFast := (addrValidVec.asUInt & ~dataValidVec.asUInt & paddrModule.io.forwardMmask(i).asUInt & needForward).orR 285 // load_s2 286 io.forward(i).dataInvalid := RegNext(io.forward(i).dataInvalidFast) 287 } 288 289 /** 290 * Memory mapped IO / other uncached operations 291 * 292 * States: 293 * (1) writeback from store units: mark as pending 294 * (2) when they reach ROB's head, they can be sent to uncache channel 295 * (3) response from uncache channel: mark as datavalidmask.wen 296 * (4) writeback to ROB (and other units): mark as writebacked 297 * (5) ROB commits the instruction: same as normal instructions 298 */ 299 //(2) when they reach ROB's head, they can be sent to uncache channel 300 val s_idle :: s_req :: s_resp :: s_wb :: s_wait :: Nil = Enum(5) 301 val uncacheState = RegInit(s_idle) 302 switch(uncacheState) { 303 is(s_idle) { 304 when(io.roq.pendingst && pending(deqPtr) && allocated(deqPtr) && datavalid(deqPtr) && addrvalid(deqPtr)) { 305 uncacheState := s_req 306 } 307 } 308 is(s_req) { 309 when(io.uncache.req.fire()) { 310 uncacheState := s_resp 311 } 312 } 313 is(s_resp) { 314 when(io.uncache.resp.fire()) { 315 uncacheState := s_wb 316 } 317 } 318 is(s_wb) { 319 when (io.mmioStout.fire()) { 320 uncacheState := s_wait 321 } 322 } 323 is(s_wait) { 324 when(io.roq.commit) { 325 uncacheState := s_idle // ready for next mmio 326 } 327 } 328 } 329 io.uncache.req.valid := uncacheState === s_req 330 331 io.uncache.req.bits.cmd := MemoryOpConstants.M_XWR 332 io.uncache.req.bits.addr := paddrModule.io.rdata(0) // data(deqPtr) -> rdata(0) 333 io.uncache.req.bits.data := dataModule.io.rdata(0).data 334 io.uncache.req.bits.mask := dataModule.io.rdata(0).mask 335 336 io.uncache.req.bits.id := DontCare 337 338 when(io.uncache.req.fire()){ 339 // mmio store should not be committed until uncache req is sent 340 pending(deqPtr) := false.B 341 342 XSDebug( 343 p"uncache req: pc ${Hexadecimal(uop(deqPtr).cf.pc)} " + 344 p"addr ${Hexadecimal(io.uncache.req.bits.addr)} " + 345 p"data ${Hexadecimal(io.uncache.req.bits.data)} " + 346 p"op ${Hexadecimal(io.uncache.req.bits.cmd)} " + 347 p"mask ${Hexadecimal(io.uncache.req.bits.mask)}\n" 348 ) 349 } 350 351 // (3) response from uncache channel: mark as datavalid 352 io.uncache.resp.ready := true.B 353 354 // (4) writeback to ROB (and other units): mark as writebacked 355 io.mmioStout.valid := uncacheState === s_wb 356 io.mmioStout.bits.uop := uop(deqPtr) 357 io.mmioStout.bits.uop.sqIdx := deqPtrExt(0) 358 io.mmioStout.bits.data := dataModule.io.rdata(0).data // dataModule.io.rdata.read(deqPtr) 359 io.mmioStout.bits.redirectValid := false.B 360 io.mmioStout.bits.redirect := DontCare 361 io.mmioStout.bits.debug.isMMIO := true.B 362 io.mmioStout.bits.debug.paddr := DontCare 363 io.mmioStout.bits.debug.isPerfCnt := false.B 364 io.mmioStout.bits.fflags := DontCare 365 when (io.mmioStout.fire()) { 366 allocated(deqPtr) := false.B 367 } 368 369 /** 370 * ROB commits store instructions (mark them as commited) 371 * 372 * (1) When store commits, mark it as commited. 373 * (2) They will not be cancelled and can be sent to lower level. 374 */ 375 for (i <- 0 until CommitWidth) { 376 when (commitCount > i.U) { 377 commited(cmtPtrExt(i).value) := true.B 378 } 379 } 380 cmtPtrExt := cmtPtrExt.map(_ + commitCount) 381 382 // Commited stores will not be cancelled and can be sent to lower level. 383 // remove retired insts from sq, add retired store to sbuffer 384 for (i <- 0 until StorePipelineWidth) { 385 // We use RegNext to prepare data for sbuffer 386 val ptr = deqPtrExt(i).value 387 // if !sbuffer.fire(), read the same ptr 388 // if sbuffer.fire(), read next 389 io.sbuffer(i).valid := allocated(ptr) && commited(ptr) && !mmio(ptr) 390 // Note that store data/addr should both be valid after store's commit 391 assert(!io.sbuffer(i).valid || allvalid(ptr)) 392 io.sbuffer(i).bits.cmd := MemoryOpConstants.M_XWR 393 io.sbuffer(i).bits.addr := paddrModule.io.rdata(i) 394 io.sbuffer(i).bits.data := dataModule.io.rdata(i).data 395 io.sbuffer(i).bits.mask := dataModule.io.rdata(i).mask 396 io.sbuffer(i).bits.id := DontCare 397 398 when (io.sbuffer(i).fire()) { 399 allocated(ptr) := false.B 400 XSDebug("sbuffer "+i+" fire: ptr %d\n", ptr) 401 } 402 } 403 when (io.sbuffer(1).fire()) { 404 assert(io.sbuffer(0).fire()) 405 } 406 if (useFakeDCache) { 407 for (i <- 0 until StorePipelineWidth) { 408 val ptr = deqPtrExt(i).value 409 val fakeRAM = Module(new RAMHelper(64L * 1024 * 1024 * 1024)) 410 fakeRAM.io.clk := clock 411 fakeRAM.io.en := allocated(ptr) && commited(ptr) && !mmio(ptr) 412 fakeRAM.io.rIdx := 0.U 413 fakeRAM.io.wIdx := (paddrModule.io.rdata(i) - "h80000000".U) >> 3 414 fakeRAM.io.wdata := dataModule.io.rdata(i).data 415 fakeRAM.io.wmask := MaskExpand(dataModule.io.rdata(i).mask) 416 fakeRAM.io.wen := allocated(ptr) && commited(ptr) && !mmio(ptr) 417 } 418 } 419 420 if (!env.FPGAPlatform) { 421 for (i <- 0 until StorePipelineWidth) { 422 val storeCommit = io.sbuffer(i).fire() 423 val waddr = SignExt(io.sbuffer(i).bits.addr, 64) 424 val wdata = io.sbuffer(i).bits.data & MaskExpand(io.sbuffer(i).bits.mask) 425 val wmask = io.sbuffer(i).bits.mask 426 427 val difftest = Module(new DifftestStoreEvent) 428 difftest.io.clock := clock 429 difftest.io.coreid := hardId.U 430 difftest.io.index := i.U 431 difftest.io.valid := storeCommit 432 difftest.io.storeAddr := waddr 433 difftest.io.storeData := wdata 434 difftest.io.storeMask := wmask 435 } 436 } 437 438 // Read vaddr for mem exception 439 io.exceptionAddr.vaddr := vaddrModule.io.rdata(0) 440 441 // misprediction recovery / exception redirect 442 // invalidate sq term using robIdx 443 val needCancel = Wire(Vec(StoreQueueSize, Bool())) 444 for (i <- 0 until StoreQueueSize) { 445 needCancel(i) := uop(i).roqIdx.needFlush(io.brqRedirect, io.flush) && allocated(i) && !commited(i) 446 when (needCancel(i)) { 447 allocated(i) := false.B 448 } 449 } 450 451 /** 452 * update pointers 453 */ 454 val lastCycleRedirect = RegNext(io.brqRedirect.valid) 455 val lastCycleFlush = RegNext(io.flush) 456 val lastCycleCancelCount = PopCount(RegNext(needCancel)) 457 // when io.brqRedirect.valid, we don't allow eneuque even though it may fire. 458 val enqNumber = Mux(io.enq.canAccept && io.enq.lqCanAccept && !(io.brqRedirect.valid || io.flush), PopCount(io.enq.req.map(_.valid)), 0.U) 459 when (lastCycleRedirect || lastCycleFlush) { 460 // we recover the pointers in the next cycle after redirect 461 enqPtrExt := VecInit(enqPtrExt.map(_ - lastCycleCancelCount)) 462 }.otherwise { 463 enqPtrExt := VecInit(enqPtrExt.map(_ + enqNumber)) 464 } 465 466 deqPtrExt := deqPtrExtNext 467 468 val dequeueCount = Mux(io.sbuffer(1).fire(), 2.U, Mux(io.sbuffer(0).fire() || io.mmioStout.fire(), 1.U, 0.U)) 469 val validCount = distanceBetween(enqPtrExt(0), deqPtrExt(0)) 470 471 allowEnqueue := validCount + enqNumber <= (StoreQueueSize - RenameWidth).U 472 473 // io.sqempty will be used by sbuffer 474 // We delay it for 1 cycle for better timing 475 // When sbuffer need to check if it is empty, the pipeline is blocked, which means delay io.sqempty 476 // for 1 cycle will also promise that sq is empty in that cycle 477 io.sqempty := RegNext(enqPtrExt(0).value === deqPtrExt(0).value && enqPtrExt(0).flag === deqPtrExt(0).flag) 478 479 // perf counter 480 QueuePerf(StoreQueueSize, validCount, !allowEnqueue) 481 io.sqFull := !allowEnqueue 482 XSPerfAccumulate("mmioCycle", uncacheState =/= s_idle) // lq is busy dealing with uncache req 483 XSPerfAccumulate("mmioCnt", io.uncache.req.fire()) 484 XSPerfAccumulate("mmio_wb_success", io.mmioStout.fire()) 485 XSPerfAccumulate("mmio_wb_blocked", io.mmioStout.valid && !io.mmioStout.ready) 486 XSPerfAccumulate("validEntryCnt", distanceBetween(enqPtrExt(0), deqPtrExt(0))) 487 XSPerfAccumulate("cmtEntryCnt", distanceBetween(cmtPtrExt(0), deqPtrExt(0))) 488 XSPerfAccumulate("nCmtEntryCnt", distanceBetween(enqPtrExt(0), cmtPtrExt(0))) 489 490 // debug info 491 XSDebug("enqPtrExt %d:%d deqPtrExt %d:%d\n", enqPtrExt(0).flag, enqPtr, deqPtrExt(0).flag, deqPtr) 492 493 def PrintFlag(flag: Bool, name: String): Unit = { 494 when(flag) { 495 XSDebug(false, true.B, name) 496 }.otherwise { 497 XSDebug(false, true.B, " ") 498 } 499 } 500 501 for (i <- 0 until StoreQueueSize) { 502 if (i % 4 == 0) XSDebug("") 503 XSDebug(false, true.B, "%x ", uop(i).cf.pc) 504 PrintFlag(allocated(i), "a") 505 PrintFlag(allocated(i) && addrvalid(i), "a") 506 PrintFlag(allocated(i) && datavalid(i), "d") 507 PrintFlag(allocated(i) && commited(i), "c") 508 PrintFlag(allocated(i) && pending(i), "p") 509 PrintFlag(allocated(i) && mmio(i), "m") 510 XSDebug(false, true.B, " ") 511 if (i % 4 == 3 || i == StoreQueueSize - 1) XSDebug(false, true.B, "\n") 512 } 513 514} 515