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