1/*************************************************************************************** 2* Copyright (c) 2024 Beijing Institute of Open Source Chip (BOSC) 3* Copyright (c) 2020-2024 Institute of Computing Technology, Chinese Academy of Sciences 4* Copyright (c) 2020-2021 Peng Cheng Laboratory 5* 6* XiangShan is licensed under Mulan PSL v2. 7* You can use this software according to the terms and conditions of the Mulan PSL v2. 8* You may obtain a copy of Mulan PSL v2 at: 9* http://license.coscl.org.cn/MulanPSL2 10* 11* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 12* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 13* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 14* 15* See the Mulan PSL v2 for more details. 16***************************************************************************************/ 17 18package xiangshan.mem 19 20import chisel3._ 21import chisel3.util._ 22import difftest._ 23import difftest.common.DifftestMem 24import org.chipsalliance.cde.config.Parameters 25import utility._ 26import utils._ 27import xiangshan._ 28import xiangshan.cache._ 29import xiangshan.cache.{DCacheLineIO, DCacheWordIO, MemoryOpConstants} 30import xiangshan.backend._ 31import xiangshan.backend.rob.{RobLsqIO, RobPtr} 32import xiangshan.backend.Bundles.{DynInst, MemExuOutput} 33import xiangshan.backend.decode.isa.bitfield.{Riscv32BitInst, XSInstBitFields} 34import xiangshan.backend.fu.FuConfig._ 35import xiangshan.backend.fu.FuType 36import xiangshan.ExceptionNO._ 37 38class SqPtr(implicit p: Parameters) extends CircularQueuePtr[SqPtr]( 39 p => p(XSCoreParamsKey).StoreQueueSize 40){ 41} 42 43object SqPtr { 44 def apply(f: Bool, v: UInt)(implicit p: Parameters): SqPtr = { 45 val ptr = Wire(new SqPtr) 46 ptr.flag := f 47 ptr.value := v 48 ptr 49 } 50} 51 52class SqEnqIO(implicit p: Parameters) extends MemBlockBundle { 53 val canAccept = Output(Bool()) 54 val lqCanAccept = Input(Bool()) 55 val needAlloc = Vec(LSQEnqWidth, Input(Bool())) 56 val req = Vec(LSQEnqWidth, Flipped(ValidIO(new DynInst))) 57 val resp = Vec(LSQEnqWidth, Output(new SqPtr)) 58} 59 60class DataBufferEntry (implicit p: Parameters) extends DCacheBundle { 61 val addr = UInt(PAddrBits.W) 62 val vaddr = UInt(VAddrBits.W) 63 val data = UInt(VLEN.W) 64 val mask = UInt((VLEN/8).W) 65 val wline = Bool() 66 val sqPtr = new SqPtr 67 val prefetch = Bool() 68 val vecValid = Bool() 69} 70 71class StoreExceptionBuffer(implicit p: Parameters) extends XSModule with HasCircularQueuePtrHelper { 72 val io = IO(new Bundle() { 73 val redirect = Flipped(ValidIO(new Redirect)) 74 val storeAddrIn = Vec(StorePipelineWidth * 2 + VecStorePipelineWidth, Flipped(ValidIO(new LsPipelineBundle()))) 75 val flushFrmMaBuf = Input(Bool()) 76 val exceptionAddr = new ExceptionAddrIO 77 }) 78 79 val req_valid = RegInit(false.B) 80 val req = Reg(new LsPipelineBundle()) 81 82 // enqueue 83 // S1: 84 val s1_req = VecInit(io.storeAddrIn.map(_.bits)) 85 val s1_valid = VecInit(io.storeAddrIn.map(_.valid)) 86 87 // S2: delay 1 cycle 88 val s2_req = (0 until StorePipelineWidth * 2 + VecStorePipelineWidth).map(i => 89 RegEnable(s1_req(i), s1_valid(i))) 90 val s2_valid = (0 until StorePipelineWidth * 2 + VecStorePipelineWidth).map(i => 91 RegNext(s1_valid(i)) && 92 !s2_req(i).uop.robIdx.needFlush(RegNext(io.redirect)) && 93 !s2_req(i).uop.robIdx.needFlush(io.redirect) 94 ) 95 val s2_has_exception = s2_req.map(x => ExceptionNO.selectByFu(x.uop.exceptionVec, StaCfg).asUInt.orR) 96 97 val s2_enqueue = Wire(Vec(StorePipelineWidth * 2 + VecStorePipelineWidth, Bool())) 98 for (w <- 0 until StorePipelineWidth * 2 + VecStorePipelineWidth) { 99 s2_enqueue(w) := s2_valid(w) && s2_has_exception(w) 100 } 101 102 when (req_valid && req.uop.robIdx.needFlush(io.redirect)) { 103 req_valid := s2_enqueue.asUInt.orR 104 }.elsewhen (s2_enqueue.asUInt.orR) { 105 req_valid := req_valid || true.B 106 } 107 108 def selectOldest[T <: LsPipelineBundle](valid: Seq[Bool], bits: Seq[T]): (Seq[Bool], Seq[T]) = { 109 assert(valid.length == bits.length) 110 if (valid.length == 0 || valid.length == 1) { 111 (valid, bits) 112 } else if (valid.length == 2) { 113 val res = Seq.fill(2)(Wire(Valid(chiselTypeOf(bits(0))))) 114 for (i <- res.indices) { 115 res(i).valid := valid(i) 116 res(i).bits := bits(i) 117 } 118 val oldest = Mux(valid(0) && valid(1), 119 Mux(isAfter(bits(0).uop.robIdx, bits(1).uop.robIdx) || 120 (isNotBefore(bits(0).uop.robIdx, bits(1).uop.robIdx) && bits(0).uop.uopIdx > bits(1).uop.uopIdx), res(1), res(0)), 121 Mux(valid(0) && !valid(1), res(0), res(1))) 122 (Seq(oldest.valid), Seq(oldest.bits)) 123 } else { 124 val left = selectOldest(valid.take(valid.length / 2), bits.take(bits.length / 2)) 125 val right = selectOldest(valid.takeRight(valid.length - (valid.length / 2)), bits.takeRight(bits.length - (bits.length / 2))) 126 selectOldest(left._1 ++ right._1, left._2 ++ right._2) 127 } 128 } 129 130 val reqSel = selectOldest(s2_enqueue, s2_req) 131 132 when (req_valid) { 133 req := Mux( 134 reqSel._1(0) && (isAfter(req.uop.robIdx, reqSel._2(0).uop.robIdx) || (isNotBefore(req.uop.robIdx, reqSel._2(0).uop.robIdx) && req.uop.uopIdx > reqSel._2(0).uop.uopIdx)), 135 reqSel._2(0), 136 req) 137 } .elsewhen (s2_enqueue.asUInt.orR) { 138 req := reqSel._2(0) 139 } 140 141 io.exceptionAddr.vaddr := req.vaddr 142 io.exceptionAddr.gpaddr := req.gpaddr 143 io.exceptionAddr.vstart := req.uop.vpu.vstart 144 io.exceptionAddr.vl := req.uop.vpu.vl 145 146 when(req_valid && io.flushFrmMaBuf) { 147 req_valid := false.B 148 } 149} 150 151// Store Queue 152class StoreQueue(implicit p: Parameters) extends XSModule 153 with HasDCacheParameters 154 with HasCircularQueuePtrHelper 155 with HasPerfEvents 156 with HasVLSUParameters { 157 val io = IO(new Bundle() { 158 val hartId = Input(UInt(hartIdLen.W)) 159 val enq = new SqEnqIO 160 val brqRedirect = Flipped(ValidIO(new Redirect)) 161 val vecFeedback = Vec(VecLoadPipelineWidth, Flipped(ValidIO(new FeedbackToLsqIO))) 162 val storeAddrIn = Vec(StorePipelineWidth, Flipped(Valid(new LsPipelineBundle))) // store addr, data is not included 163 val storeAddrInRe = Vec(StorePipelineWidth, Input(new LsPipelineBundle())) // store more mmio and exception 164 val storeDataIn = Vec(StorePipelineWidth, Flipped(Valid(new MemExuOutput(isVector = true)))) // store data, send to sq from rs 165 val storeMaskIn = Vec(StorePipelineWidth, Flipped(Valid(new StoreMaskBundle))) // store mask, send to sq from rs 166 val sbuffer = Vec(EnsbufferWidth, Decoupled(new DCacheWordReqWithVaddrAndPfFlag)) // write committed store to sbuffer 167 val sbufferVecDifftestInfo = Vec(EnsbufferWidth, Decoupled(new DynInst)) // The vector store difftest needs is, write committed store to sbuffer 168 val uncacheOutstanding = Input(Bool()) 169 val mmioStout = DecoupledIO(new MemExuOutput) // writeback uncached store 170 val vecmmioStout = DecoupledIO(new MemExuOutput(isVector = true)) 171 val forward = Vec(LoadPipelineWidth, Flipped(new PipeLoadForwardQueryIO)) 172 // TODO: scommit is only for scalar store 173 val rob = Flipped(new RobLsqIO) 174 val uncache = new UncacheWordIO 175 // val refill = Flipped(Valid(new DCacheLineReq )) 176 val exceptionAddr = new ExceptionAddrIO 177 val sqEmpty = Output(Bool()) 178 val stAddrReadySqPtr = Output(new SqPtr) 179 val stAddrReadyVec = Output(Vec(StoreQueueSize, Bool())) 180 val stDataReadySqPtr = Output(new SqPtr) 181 val stDataReadyVec = Output(Vec(StoreQueueSize, Bool())) 182 val stIssuePtr = Output(new SqPtr) 183 val sqDeqPtr = Output(new SqPtr) 184 val sqFull = Output(Bool()) 185 val sqCancelCnt = Output(UInt(log2Up(StoreQueueSize + 1).W)) 186 val sqDeq = Output(UInt(log2Ceil(EnsbufferWidth + 1).W)) 187 val force_write = Output(Bool()) 188 val maControl = Flipped(new StoreMaBufToSqControlIO) 189 }) 190 191 println("StoreQueue: size:" + StoreQueueSize) 192 193 // data modules 194 val uop = Reg(Vec(StoreQueueSize, new DynInst)) 195 // val data = Reg(Vec(StoreQueueSize, new LsqEntry)) 196 val dataModule = Module(new SQDataModule( 197 numEntries = StoreQueueSize, 198 numRead = EnsbufferWidth, 199 numWrite = StorePipelineWidth, 200 numForward = LoadPipelineWidth 201 )) 202 dataModule.io := DontCare 203 val paddrModule = Module(new SQAddrModule( 204 dataWidth = PAddrBits, 205 numEntries = StoreQueueSize, 206 numRead = EnsbufferWidth, 207 numWrite = StorePipelineWidth, 208 numForward = LoadPipelineWidth 209 )) 210 paddrModule.io := DontCare 211 val vaddrModule = Module(new SQAddrModule( 212 dataWidth = VAddrBits, 213 numEntries = StoreQueueSize, 214 numRead = EnsbufferWidth, // sbuffer; badvaddr will be sent from exceptionBuffer 215 numWrite = StorePipelineWidth, 216 numForward = LoadPipelineWidth 217 )) 218 vaddrModule.io := DontCare 219 val dataBuffer = Module(new DatamoduleResultBuffer(new DataBufferEntry)) 220 val difftestBuffer = if (env.EnableDifftest) Some(Module(new DatamoduleResultBuffer(new DynInst))) else None 221 val exceptionBuffer = Module(new StoreExceptionBuffer) 222 exceptionBuffer.io.redirect := io.brqRedirect 223 exceptionBuffer.io.exceptionAddr.isStore := DontCare 224 // vlsu exception! 225 for (i <- 0 until VecStorePipelineWidth) { 226 exceptionBuffer.io.storeAddrIn(StorePipelineWidth * 2 + i).valid := io.vecFeedback(i).valid && io.vecFeedback(i).bits.feedback(VecFeedbacks.FLUSH) // have exception 227 exceptionBuffer.io.storeAddrIn(StorePipelineWidth * 2 + i).bits := DontCare 228 exceptionBuffer.io.storeAddrIn(StorePipelineWidth * 2 + i).bits.vaddr := io.vecFeedback(i).bits.vaddr 229 exceptionBuffer.io.storeAddrIn(StorePipelineWidth * 2 + i).bits.uop.uopIdx := io.vecFeedback(i).bits.uopidx 230 exceptionBuffer.io.storeAddrIn(StorePipelineWidth * 2 + i).bits.uop.robIdx := io.vecFeedback(i).bits.robidx 231 exceptionBuffer.io.storeAddrIn(StorePipelineWidth * 2 + i).bits.uop.vpu.vstart := io.vecFeedback(i).bits.vstart 232 exceptionBuffer.io.storeAddrIn(StorePipelineWidth * 2 + i).bits.uop.vpu.vl := io.vecFeedback(i).bits.vl 233 exceptionBuffer.io.storeAddrIn(StorePipelineWidth * 2 + i).bits.uop.exceptionVec := io.vecFeedback(i).bits.exceptionVec 234 } 235 236 237 val debug_paddr = Reg(Vec(StoreQueueSize, UInt((PAddrBits).W))) 238 val debug_vaddr = Reg(Vec(StoreQueueSize, UInt((VAddrBits).W))) 239 val debug_data = Reg(Vec(StoreQueueSize, UInt((XLEN).W))) 240 241 // state & misc 242 val allocated = RegInit(VecInit(List.fill(StoreQueueSize)(false.B))) // sq entry has been allocated 243 val addrvalid = RegInit(VecInit(List.fill(StoreQueueSize)(false.B))) // non-mmio addr is valid 244 val datavalid = RegInit(VecInit(List.fill(StoreQueueSize)(false.B))) // non-mmio data is valid 245 val allvalid = VecInit((0 until StoreQueueSize).map(i => addrvalid(i) && datavalid(i))) // non-mmio data & addr is valid 246 val committed = RegInit(VecInit(List.fill(StoreQueueSize)(false.B))) // inst has been committed by rob 247 val unaligned = RegInit(VecInit(List.fill(StoreQueueSize)(false.B))) // unaligned store 248 val pending = RegInit(VecInit(List.fill(StoreQueueSize)(false.B))) // mmio pending: inst is an mmio inst, it will not be executed until it reachs the end of rob 249 val mmio = RegInit(VecInit(List.fill(StoreQueueSize)(false.B))) // mmio: inst is an mmio inst 250 val atomic = RegInit(VecInit(List.fill(StoreQueueSize)(false.B))) 251 val prefetch = RegInit(VecInit(List.fill(StoreQueueSize)(false.B))) // need prefetch when committing this store to sbuffer? 252 val isVec = RegInit(VecInit(List.fill(StoreQueueSize)(false.B))) // vector store instruction 253 //val vec_lastuop = Reg(Vec(StoreQueueSize, Bool())) // last uop of vector store instruction 254 val vecMbCommit = RegInit(VecInit(List.fill(StoreQueueSize)(false.B))) // vector store committed from merge buffer to rob 255 val vecDataValid = RegInit(VecInit(List.fill(StoreQueueSize)(false.B))) // vector store need write to sbuffer 256 val hasException = RegInit(VecInit(List.fill(StoreQueueSize)(false.B))) // store has exception, should deq but not write sbuffer 257 val waitStoreS2 = RegInit(VecInit(List.fill(StoreQueueSize)(false.B))) // wait for mmio and exception result until store_s2 258 // val vec_robCommit = Reg(Vec(StoreQueueSize, Bool())) // vector store committed by rob 259 // val vec_secondInv = RegInit(VecInit(List.fill(StoreQueueSize)(false.B))) // Vector unit-stride, second entry is invalid 260 val vecExceptionFlag = RegInit(0.U.asTypeOf(Valid(new DynInst))) 261 262 // ptr 263 val enqPtrExt = RegInit(VecInit((0 until io.enq.req.length).map(_.U.asTypeOf(new SqPtr)))) 264 val rdataPtrExt = RegInit(VecInit((0 until EnsbufferWidth).map(_.U.asTypeOf(new SqPtr)))) 265 val deqPtrExt = RegInit(VecInit((0 until EnsbufferWidth).map(_.U.asTypeOf(new SqPtr)))) 266 val cmtPtrExt = RegInit(VecInit((0 until CommitWidth).map(_.U.asTypeOf(new SqPtr)))) 267 val addrReadyPtrExt = RegInit(0.U.asTypeOf(new SqPtr)) 268 val dataReadyPtrExt = RegInit(0.U.asTypeOf(new SqPtr)) 269 270 val enqPtr = enqPtrExt(0).value 271 val deqPtr = deqPtrExt(0).value 272 val cmtPtr = cmtPtrExt(0).value 273 274 val validCount = distanceBetween(enqPtrExt(0), deqPtrExt(0)) 275 val allowEnqueue = validCount <= (StoreQueueSize - LSQStEnqWidth).U 276 277 val deqMask = UIntToMask(deqPtr, StoreQueueSize) 278 val enqMask = UIntToMask(enqPtr, StoreQueueSize) 279 280 val commitCount = WireInit(0.U(log2Ceil(CommitWidth + 1).W)) 281 val scommit = GatedRegNext(io.rob.scommit) 282 283 // RegNext misalign control for better timing 284 val doMisalignSt = GatedValidRegNext((rdataPtrExt(0).value === deqPtr) && (cmtPtr === deqPtr) && allocated(deqPtr) && datavalid(deqPtr) && unaligned(deqPtr)) 285 val finishMisalignSt = GatedValidRegNext(doMisalignSt && io.maControl.control.removeSq && !io.maControl.control.hasException) 286 val misalignBlock = doMisalignSt && !finishMisalignSt 287 288 // store miss align info 289 io.maControl.storeInfo.data := dataModule.io.rdata(0).data 290 io.maControl.storeInfo.dataReady := doMisalignSt 291 io.maControl.storeInfo.completeSbTrans := doMisalignSt && dataBuffer.io.enq(0).fire 292 293 // store can be committed by ROB 294 io.rob.mmio := DontCare 295 io.rob.uop := DontCare 296 297 // Read dataModule 298 assert(EnsbufferWidth <= 2) 299 // rdataPtrExtNext and rdataPtrExtNext+1 entry will be read from dataModule 300 val rdataPtrExtNext = Wire(Vec(EnsbufferWidth, new SqPtr)) 301 rdataPtrExtNext := WireInit(Mux(dataBuffer.io.enq(1).fire, 302 VecInit(rdataPtrExt.map(_ + 2.U)), 303 Mux(dataBuffer.io.enq(0).fire || io.mmioStout.fire || io.vecmmioStout.fire, 304 VecInit(rdataPtrExt.map(_ + 1.U)), 305 rdataPtrExt 306 ) 307 )) 308 309 // deqPtrExtNext traces which inst is about to leave store queue 310 // 311 // io.sbuffer(i).fire is RegNexted, as sbuffer data write takes 2 cycles. 312 // Before data write finish, sbuffer is unable to provide store to load 313 // forward data. As an workaround, deqPtrExt and allocated flag update 314 // is delayed so that load can get the right data from store queue. 315 // 316 // Modify deqPtrExtNext and io.sqDeq with care! 317 val deqPtrExtNext = Wire(Vec(EnsbufferWidth, new SqPtr)) 318 deqPtrExtNext := Mux(RegNext(io.sbuffer(1).fire), 319 VecInit(deqPtrExt.map(_ + 2.U)), 320 Mux((RegNext(io.sbuffer(0).fire)) || io.mmioStout.fire || io.vecmmioStout.fire, 321 VecInit(deqPtrExt.map(_ + 1.U)), 322 deqPtrExt 323 ) 324 ) 325 326 io.sqDeq := RegNext(Mux(RegNext(io.sbuffer(1).fire && !misalignBlock), 2.U, 327 Mux((RegNext(io.sbuffer(0).fire && !misalignBlock)) || io.mmioStout.fire || io.vecmmioStout.fire || finishMisalignSt, 1.U, 0.U) 328 )) 329 assert(!RegNext(RegNext(io.sbuffer(0).fire) && (io.mmioStout.fire || io.vecmmioStout.fire))) 330 331 for (i <- 0 until EnsbufferWidth) { 332 dataModule.io.raddr(i) := rdataPtrExtNext(i).value 333 paddrModule.io.raddr(i) := rdataPtrExtNext(i).value 334 vaddrModule.io.raddr(i) := rdataPtrExtNext(i).value 335 } 336 337 /** 338 * Enqueue at dispatch 339 * 340 * Currently, StoreQueue only allows enqueue when #emptyEntries > EnqWidth 341 */ 342 io.enq.canAccept := allowEnqueue 343 val canEnqueue = io.enq.req.map(_.valid) 344 val enqCancel = io.enq.req.map(_.bits.robIdx.needFlush(io.brqRedirect)) 345 val vStoreFlow = io.enq.req.map(_.bits.numLsElem) 346 val validVStoreFlow = vStoreFlow.zipWithIndex.map{case (vLoadFlowNumItem, index) => Mux(!RegNext(io.brqRedirect.valid) && io.enq.canAccept && io.enq.lqCanAccept && canEnqueue(index), vLoadFlowNumItem, 0.U)} 347 val validVStoreOffset = vStoreFlow.zip(io.enq.needAlloc).map{case (flow, needAllocItem) => Mux(needAllocItem, flow, 0.U)} 348 val validVStoreOffsetRShift = 0.U +: validVStoreOffset.take(vStoreFlow.length - 1) 349 350 for (i <- 0 until io.enq.req.length) { 351 val sqIdx = enqPtrExt(0) + validVStoreOffsetRShift.take(i + 1).reduce(_ + _) 352 val index = io.enq.req(i).bits.sqIdx 353 val enqInstr = io.enq.req(i).bits.instr.asTypeOf(new XSInstBitFields) 354 when (canEnqueue(i) && !enqCancel(i)) { 355 // The maximum 'numLsElem' number that can be emitted per dispatch port is: 356 // 16 2 2 2 2 2. 357 // Therefore, VecMemLSQEnqIteratorNumberSeq = Seq(16, 2, 2, 2, 2, 2) 358 for (j <- 0 until VecMemLSQEnqIteratorNumberSeq(i)) { 359 when (j.U < validVStoreOffset(i)) { 360 uop((index + j.U).value) := io.enq.req(i).bits 361 // NOTE: the index will be used when replay 362 uop((index + j.U).value).sqIdx := sqIdx + j.U 363 allocated((index + j.U).value) := true.B 364 datavalid((index + j.U).value) := false.B 365 addrvalid((index + j.U).value) := false.B 366 unaligned((index + j.U).value) := false.B 367 committed((index + j.U).value) := false.B 368 pending((index + j.U).value) := false.B 369 prefetch((index + j.U).value) := false.B 370 mmio((index + j.U).value) := false.B 371 isVec((index + j.U).value) := enqInstr.isVecStore // check vector store by the encoding of inst 372 vecMbCommit((index + j.U).value) := false.B 373 vecDataValid((index + j.U).value) := false.B 374 hasException((index + j.U).value) := false.B 375 waitStoreS2((index + j.U).value) := true.B 376 XSError(!io.enq.canAccept || !io.enq.lqCanAccept, s"must accept $i\n") 377 XSError(index.value =/= sqIdx.value, s"must be the same entry $i\n") 378 } 379 } 380 } 381 io.enq.resp(i) := sqIdx 382 } 383 XSDebug(p"(ready, valid): ${io.enq.canAccept}, ${Binary(Cat(io.enq.req.map(_.valid)))}\n") 384 385 /** 386 * Update addr/dataReadyPtr when issue from rs 387 */ 388 // update issuePtr 389 val IssuePtrMoveStride = 4 390 require(IssuePtrMoveStride >= 2) 391 392 val addrReadyLookupVec = (0 until IssuePtrMoveStride).map(addrReadyPtrExt + _.U) 393 val addrReadyLookup = addrReadyLookupVec.map(ptr => allocated(ptr.value) && 394 (mmio(ptr.value) || addrvalid(ptr.value) || vecMbCommit(ptr.value)) 395 && ptr =/= enqPtrExt(0)) 396 val nextAddrReadyPtr = addrReadyPtrExt + PriorityEncoder(VecInit(addrReadyLookup.map(!_) :+ true.B)) 397 addrReadyPtrExt := nextAddrReadyPtr 398 399 val stAddrReadyVecReg = Wire(Vec(StoreQueueSize, Bool())) 400 (0 until StoreQueueSize).map(i => { 401 stAddrReadyVecReg(i) := allocated(i) && (mmio(i) || addrvalid(i) || (isVec(i) && vecMbCommit(i))) 402 }) 403 io.stAddrReadyVec := GatedValidRegNext(stAddrReadyVecReg) 404 405 when (io.brqRedirect.valid) { 406 addrReadyPtrExt := Mux( 407 isAfter(cmtPtrExt(0), deqPtrExt(0)), 408 cmtPtrExt(0), 409 deqPtrExtNext(0) // for mmio insts, deqPtr may be ahead of cmtPtr 410 ) 411 } 412 413 io.stAddrReadySqPtr := addrReadyPtrExt 414 415 // update 416 val dataReadyLookupVec = (0 until IssuePtrMoveStride).map(dataReadyPtrExt + _.U) 417 val dataReadyLookup = dataReadyLookupVec.map(ptr => allocated(ptr.value) && 418 (mmio(ptr.value) || datavalid(ptr.value) || vecMbCommit(ptr.value)) 419 && ptr =/= enqPtrExt(0)) 420 val nextDataReadyPtr = dataReadyPtrExt + PriorityEncoder(VecInit(dataReadyLookup.map(!_) :+ true.B)) 421 dataReadyPtrExt := nextDataReadyPtr 422 423 val stDataReadyVecReg = Wire(Vec(StoreQueueSize, Bool())) 424 (0 until StoreQueueSize).map(i => { 425 stDataReadyVecReg(i) := allocated(i) && (mmio(i) || datavalid(i) || (isVec(i) && vecMbCommit(i))) 426 }) 427 io.stDataReadyVec := GatedValidRegNext(stDataReadyVecReg) 428 429 when (io.brqRedirect.valid) { 430 dataReadyPtrExt := Mux( 431 isAfter(cmtPtrExt(0), deqPtrExt(0)), 432 cmtPtrExt(0), 433 deqPtrExtNext(0) // for mmio insts, deqPtr may be ahead of cmtPtr 434 ) 435 } 436 437 io.stDataReadySqPtr := dataReadyPtrExt 438 io.stIssuePtr := enqPtrExt(0) 439 io.sqDeqPtr := deqPtrExt(0) 440 441 /** 442 * Writeback store from store units 443 * 444 * Most store instructions writeback to regfile in the previous cycle. 445 * However, 446 * (1) For an mmio instruction with exceptions, we need to mark it as addrvalid 447 * (in this way it will trigger an exception when it reaches ROB's head) 448 * instead of pending to avoid sending them to lower level. 449 * (2) For an mmio instruction without exceptions, we mark it as pending. 450 * When the instruction reaches ROB's head, StoreQueue sends it to uncache channel. 451 * Upon receiving the response, StoreQueue writes back the instruction 452 * through arbiter with store units. It will later commit as normal. 453 */ 454 455 // Write addr to sq 456 for (i <- 0 until StorePipelineWidth) { 457 paddrModule.io.wen(i) := false.B 458 vaddrModule.io.wen(i) := false.B 459 dataModule.io.mask.wen(i) := false.B 460 val stWbIndex = io.storeAddrIn(i).bits.uop.sqIdx.value 461 exceptionBuffer.io.storeAddrIn(i).valid := io.storeAddrIn(i).fire && !io.storeAddrIn(i).bits.miss && !io.storeAddrIn(i).bits.isvec 462 exceptionBuffer.io.storeAddrIn(i).bits := io.storeAddrIn(i).bits 463 // will re-enter exceptionbuffer at store_s2 464 exceptionBuffer.io.storeAddrIn(StorePipelineWidth + i).valid := false.B 465 exceptionBuffer.io.storeAddrIn(StorePipelineWidth + i).bits := 0.U.asTypeOf(new LsPipelineBundle) 466 467 when (io.storeAddrIn(i).fire) { 468 val addr_valid = !io.storeAddrIn(i).bits.miss 469 addrvalid(stWbIndex) := addr_valid //!io.storeAddrIn(i).bits.mmio 470 // pending(stWbIndex) := io.storeAddrIn(i).bits.mmio 471 unaligned(stWbIndex) := io.storeAddrIn(i).bits.uop.exceptionVec(storeAddrMisaligned) 472 473 paddrModule.io.waddr(i) := stWbIndex 474 paddrModule.io.wdata(i) := io.storeAddrIn(i).bits.paddr 475 paddrModule.io.wmask(i) := io.storeAddrIn(i).bits.mask 476 paddrModule.io.wlineflag(i) := io.storeAddrIn(i).bits.wlineflag 477 paddrModule.io.wen(i) := true.B 478 479 vaddrModule.io.waddr(i) := stWbIndex 480 vaddrModule.io.wdata(i) := io.storeAddrIn(i).bits.vaddr 481 vaddrModule.io.wmask(i) := io.storeAddrIn(i).bits.mask 482 vaddrModule.io.wlineflag(i) := io.storeAddrIn(i).bits.wlineflag 483 vaddrModule.io.wen(i) := true.B 484 485 debug_paddr(paddrModule.io.waddr(i)) := paddrModule.io.wdata(i) 486 487 // mmio(stWbIndex) := io.storeAddrIn(i).bits.mmio 488 489 uop(stWbIndex) := io.storeAddrIn(i).bits.uop 490 uop(stWbIndex).debugInfo := io.storeAddrIn(i).bits.uop.debugInfo 491 492 vecDataValid(stWbIndex) := io.storeAddrIn(i).bits.isvec 493 494 XSInfo("store addr write to sq idx %d pc 0x%x miss:%d vaddr %x paddr %x mmio %x isvec %x\n", 495 io.storeAddrIn(i).bits.uop.sqIdx.value, 496 io.storeAddrIn(i).bits.uop.pc, 497 io.storeAddrIn(i).bits.miss, 498 io.storeAddrIn(i).bits.vaddr, 499 io.storeAddrIn(i).bits.paddr, 500 io.storeAddrIn(i).bits.mmio, 501 io.storeAddrIn(i).bits.isvec 502 ) 503 } 504 505 // re-replinish mmio, for pma/pmp will get mmio one cycle later 506 val storeAddrInFireReg = RegNext(io.storeAddrIn(i).fire && !io.storeAddrIn(i).bits.miss) 507 //val stWbIndexReg = RegNext(stWbIndex) 508 val stWbIndexReg = RegEnable(stWbIndex, io.storeAddrIn(i).fire) 509 when (storeAddrInFireReg) { 510 pending(stWbIndexReg) := io.storeAddrInRe(i).mmio 511 mmio(stWbIndexReg) := io.storeAddrInRe(i).mmio 512 atomic(stWbIndexReg) := io.storeAddrInRe(i).atomic 513 hasException(stWbIndexReg) := ExceptionNO.selectByFu(uop(stWbIndexReg).exceptionVec, StaCfg).asUInt.orR || io.storeAddrInRe(i).af 514 waitStoreS2(stWbIndexReg) := false.B 515 } 516 // dcache miss info (one cycle later than storeIn) 517 // if dcache report a miss in sta pipeline, this store will trigger a prefetch when committing to sbuffer (if EnableAtCommitMissTrigger) 518 when (storeAddrInFireReg) { 519 prefetch(stWbIndexReg) := io.storeAddrInRe(i).miss 520 } 521 // enter exceptionbuffer again 522 when (storeAddrInFireReg) { 523 exceptionBuffer.io.storeAddrIn(StorePipelineWidth + i).valid := io.storeAddrInRe(i).af 524 exceptionBuffer.io.storeAddrIn(StorePipelineWidth + i).bits := RegEnable(io.storeAddrIn(i).bits, io.storeAddrIn(i).fire && !io.storeAddrIn(i).bits.miss) 525 exceptionBuffer.io.storeAddrIn(StorePipelineWidth + i).bits.uop.exceptionVec(storeAccessFault) := io.storeAddrInRe(i).af 526 } 527 528 when(vaddrModule.io.wen(i)){ 529 debug_vaddr(vaddrModule.io.waddr(i)) := vaddrModule.io.wdata(i) 530 } 531 } 532 533 // Write data to sq 534 // Now store data pipeline is actually 2 stages 535 for (i <- 0 until StorePipelineWidth) { 536 dataModule.io.data.wen(i) := false.B 537 val stWbIndex = io.storeDataIn(i).bits.uop.sqIdx.value 538 val isVec = FuType.isVStore(io.storeDataIn(i).bits.uop.fuType) 539 // sq data write takes 2 cycles: 540 // sq data write s0 541 when (io.storeDataIn(i).fire) { 542 // send data write req to data module 543 dataModule.io.data.waddr(i) := stWbIndex 544 dataModule.io.data.wdata(i) := Mux(io.storeDataIn(i).bits.uop.fuOpType === LSUOpType.cbo_zero, 545 0.U, 546 Mux(isVec, 547 io.storeDataIn(i).bits.data, 548 genVWdata(io.storeDataIn(i).bits.data, io.storeDataIn(i).bits.uop.fuOpType(2,0))) 549 ) 550 dataModule.io.data.wen(i) := true.B 551 552 debug_data(dataModule.io.data.waddr(i)) := dataModule.io.data.wdata(i) 553 554 XSInfo("store data write to sq idx %d pc 0x%x data %x -> %x\n", 555 io.storeDataIn(i).bits.uop.sqIdx.value, 556 io.storeDataIn(i).bits.uop.pc, 557 io.storeDataIn(i).bits.data, 558 dataModule.io.data.wdata(i) 559 ) 560 } 561 // sq data write s1 562 when ( 563 RegNext(io.storeDataIn(i).fire) 564 // && !RegNext(io.storeDataIn(i).bits.uop).robIdx.needFlush(io.brqRedirect) 565 ) { 566 datavalid(RegEnable(stWbIndex, io.storeDataIn(i).fire)) := true.B 567 } 568 } 569 570 // Write mask to sq 571 for (i <- 0 until StorePipelineWidth) { 572 // sq mask write s0 573 when (io.storeMaskIn(i).fire) { 574 // send data write req to data module 575 dataModule.io.mask.waddr(i) := io.storeMaskIn(i).bits.sqIdx.value 576 dataModule.io.mask.wdata(i) := io.storeMaskIn(i).bits.mask 577 dataModule.io.mask.wen(i) := true.B 578 } 579 } 580 581 /** 582 * load forward query 583 * 584 * Check store queue for instructions that is older than the load. 585 * The response will be valid at the next cycle after req. 586 */ 587 // check over all lq entries and forward data from the first matched store 588 for (i <- 0 until LoadPipelineWidth) { 589 // Compare deqPtr (deqPtr) and forward.sqIdx, we have two cases: 590 // (1) if they have the same flag, we need to check range(tail, sqIdx) 591 // (2) if they have different flags, we need to check range(tail, VirtualLoadQueueSize) and range(0, sqIdx) 592 // Forward1: Mux(same_flag, range(tail, sqIdx), range(tail, VirtualLoadQueueSize)) 593 // Forward2: Mux(same_flag, 0.U, range(0, sqIdx) ) 594 // i.e. forward1 is the target entries with the same flag bits and forward2 otherwise 595 val differentFlag = deqPtrExt(0).flag =/= io.forward(i).sqIdx.flag 596 val forwardMask = io.forward(i).sqIdxMask 597 // all addrvalid terms need to be checked 598 // Real Vaild: all scalar stores, and vector store with (!inactive && !secondInvalid) 599 val addrRealValidVec = WireInit(VecInit((0 until StoreQueueSize).map(j => addrvalid(j) && allocated(j)))) 600 // vector store will consider all inactive || secondInvalid flows as valid 601 val addrValidVec = WireInit(VecInit((0 until StoreQueueSize).map(j => addrvalid(j) && allocated(j)))) 602 val dataValidVec = WireInit(VecInit((0 until StoreQueueSize).map(j => datavalid(j)))) 603 val allValidVec = WireInit(VecInit((0 until StoreQueueSize).map(j => addrvalid(j) && datavalid(j) && allocated(j)))) 604 605 val lfstEnable = Constantin.createRecord("LFSTEnable", LFSTEnable) 606 val storeSetHitVec = Mux(lfstEnable, 607 WireInit(VecInit((0 until StoreQueueSize).map(j => io.forward(i).uop.loadWaitBit && uop(j).robIdx === io.forward(i).uop.waitForRobIdx))), 608 WireInit(VecInit((0 until StoreQueueSize).map(j => uop(j).storeSetHit && uop(j).ssid === io.forward(i).uop.ssid))) 609 ) 610 611 val forwardMask1 = Mux(differentFlag, ~deqMask, deqMask ^ forwardMask) 612 val forwardMask2 = Mux(differentFlag, forwardMask, 0.U(StoreQueueSize.W)) 613 val canForward1 = forwardMask1 & allValidVec.asUInt 614 val canForward2 = forwardMask2 & allValidVec.asUInt 615 val needForward = Mux(differentFlag, ~deqMask | forwardMask, deqMask ^ forwardMask) 616 617 XSDebug(p"$i f1 ${Binary(canForward1)} f2 ${Binary(canForward2)} " + 618 p"sqIdx ${io.forward(i).sqIdx} pa ${Hexadecimal(io.forward(i).paddr)}\n" 619 ) 620 621 // do real fwd query (cam lookup in load_s1) 622 dataModule.io.needForward(i)(0) := canForward1 & vaddrModule.io.forwardMmask(i).asUInt 623 dataModule.io.needForward(i)(1) := canForward2 & vaddrModule.io.forwardMmask(i).asUInt 624 625 vaddrModule.io.forwardMdata(i) := io.forward(i).vaddr 626 vaddrModule.io.forwardDataMask(i) := io.forward(i).mask 627 paddrModule.io.forwardMdata(i) := io.forward(i).paddr 628 paddrModule.io.forwardDataMask(i) := io.forward(i).mask 629 630 // vaddr cam result does not equal to paddr cam result 631 // replay needed 632 // val vpmaskNotEqual = ((paddrModule.io.forwardMmask(i).asUInt ^ vaddrModule.io.forwardMmask(i).asUInt) & needForward) =/= 0.U 633 // val vaddrMatchFailed = vpmaskNotEqual && io.forward(i).valid 634 val vpmaskNotEqual = ( 635 (RegEnable(paddrModule.io.forwardMmask(i).asUInt, io.forward(i).valid) ^ RegEnable(vaddrModule.io.forwardMmask(i).asUInt, io.forward(i).valid)) & 636 RegNext(needForward) & 637 GatedRegNext(addrRealValidVec.asUInt) 638 ) =/= 0.U 639 val vaddrMatchFailed = vpmaskNotEqual && RegNext(io.forward(i).valid) 640 when (vaddrMatchFailed) { 641 XSInfo("vaddrMatchFailed: pc %x pmask %x vmask %x\n", 642 RegEnable(io.forward(i).uop.pc, io.forward(i).valid), 643 RegEnable(needForward & paddrModule.io.forwardMmask(i).asUInt, io.forward(i).valid), 644 RegEnable(needForward & vaddrModule.io.forwardMmask(i).asUInt, io.forward(i).valid) 645 ); 646 } 647 XSPerfAccumulate("vaddr_match_failed", vpmaskNotEqual) 648 XSPerfAccumulate("vaddr_match_really_failed", vaddrMatchFailed) 649 650 // Fast forward mask will be generated immediately (load_s1) 651 io.forward(i).forwardMaskFast := dataModule.io.forwardMaskFast(i) 652 653 // Forward result will be generated 1 cycle later (load_s2) 654 io.forward(i).forwardMask := dataModule.io.forwardMask(i) 655 io.forward(i).forwardData := dataModule.io.forwardData(i) 656 // If addr match, data not ready, mark it as dataInvalid 657 // load_s1: generate dataInvalid in load_s1 to set fastUop 658 val dataInvalidMask1 = (addrValidVec.asUInt & ~dataValidVec.asUInt & vaddrModule.io.forwardMmask(i).asUInt & forwardMask1.asUInt) 659 val dataInvalidMask2 = (addrValidVec.asUInt & ~dataValidVec.asUInt & vaddrModule.io.forwardMmask(i).asUInt & forwardMask2.asUInt) 660 val dataInvalidMask = dataInvalidMask1 | dataInvalidMask2 661 io.forward(i).dataInvalidFast := dataInvalidMask.orR 662 663 // make chisel happy 664 val dataInvalidMask1Reg = Wire(UInt(StoreQueueSize.W)) 665 dataInvalidMask1Reg := RegNext(dataInvalidMask1) 666 // make chisel happy 667 val dataInvalidMask2Reg = Wire(UInt(StoreQueueSize.W)) 668 dataInvalidMask2Reg := RegNext(dataInvalidMask2) 669 val dataInvalidMaskReg = dataInvalidMask1Reg | dataInvalidMask2Reg 670 671 // If SSID match, address not ready, mark it as addrInvalid 672 // load_s2: generate addrInvalid 673 val addrInvalidMask1 = (~addrValidVec.asUInt & storeSetHitVec.asUInt & forwardMask1.asUInt) 674 val addrInvalidMask2 = (~addrValidVec.asUInt & storeSetHitVec.asUInt & forwardMask2.asUInt) 675 // make chisel happy 676 val addrInvalidMask1Reg = Wire(UInt(StoreQueueSize.W)) 677 addrInvalidMask1Reg := RegNext(addrInvalidMask1) 678 // make chisel happy 679 val addrInvalidMask2Reg = Wire(UInt(StoreQueueSize.W)) 680 addrInvalidMask2Reg := RegNext(addrInvalidMask2) 681 val addrInvalidMaskReg = addrInvalidMask1Reg | addrInvalidMask2Reg 682 683 // load_s2 684 io.forward(i).dataInvalid := RegNext(io.forward(i).dataInvalidFast) 685 // check if vaddr forward mismatched 686 io.forward(i).matchInvalid := vaddrMatchFailed 687 688 // data invalid sq index 689 // check whether false fail 690 // check flag 691 val s2_differentFlag = RegNext(differentFlag) 692 val s2_enqPtrExt = RegNext(enqPtrExt(0)) 693 val s2_deqPtrExt = RegNext(deqPtrExt(0)) 694 695 // addr invalid sq index 696 // make chisel happy 697 val addrInvalidMaskRegWire = Wire(UInt(StoreQueueSize.W)) 698 addrInvalidMaskRegWire := addrInvalidMaskReg 699 val addrInvalidFlag = addrInvalidMaskRegWire.orR 700 val hasInvalidAddr = (~addrValidVec.asUInt & needForward).orR 701 702 val addrInvalidSqIdx1 = OHToUInt(Reverse(PriorityEncoderOH(Reverse(addrInvalidMask1Reg)))) 703 val addrInvalidSqIdx2 = OHToUInt(Reverse(PriorityEncoderOH(Reverse(addrInvalidMask2Reg)))) 704 val addrInvalidSqIdx = Mux(addrInvalidMask2Reg.orR, addrInvalidSqIdx2, addrInvalidSqIdx1) 705 706 // store-set content management 707 // +-----------------------+ 708 // | Search a SSID for the | 709 // | load operation | 710 // +-----------------------+ 711 // | 712 // V 713 // +-------------------+ 714 // | load wait strict? | 715 // +-------------------+ 716 // | 717 // V 718 // +----------------------+ 719 // Set| |Clean 720 // V V 721 // +------------------------+ +------------------------------+ 722 // | Waiting for all older | | Wait until the corresponding | 723 // | stores operations | | older store operations | 724 // +------------------------+ +------------------------------+ 725 726 727 728 when (RegEnable(io.forward(i).uop.loadWaitStrict, io.forward(i).valid)) { 729 io.forward(i).addrInvalidSqIdx := RegEnable((io.forward(i).uop.sqIdx - 1.U), io.forward(i).valid) 730 } .elsewhen (addrInvalidFlag) { 731 io.forward(i).addrInvalidSqIdx.flag := Mux(!s2_differentFlag || addrInvalidSqIdx >= s2_deqPtrExt.value, s2_deqPtrExt.flag, s2_enqPtrExt.flag) 732 io.forward(i).addrInvalidSqIdx.value := addrInvalidSqIdx 733 } .otherwise { 734 // may be store inst has been written to sbuffer already. 735 io.forward(i).addrInvalidSqIdx := RegEnable(io.forward(i).uop.sqIdx, io.forward(i).valid) 736 } 737 io.forward(i).addrInvalid := Mux(RegEnable(io.forward(i).uop.loadWaitStrict, io.forward(i).valid), RegNext(hasInvalidAddr), addrInvalidFlag) 738 739 // data invalid sq index 740 // make chisel happy 741 val dataInvalidMaskRegWire = Wire(UInt(StoreQueueSize.W)) 742 dataInvalidMaskRegWire := dataInvalidMaskReg 743 val dataInvalidFlag = dataInvalidMaskRegWire.orR 744 745 val dataInvalidSqIdx1 = OHToUInt(Reverse(PriorityEncoderOH(Reverse(dataInvalidMask1Reg)))) 746 val dataInvalidSqIdx2 = OHToUInt(Reverse(PriorityEncoderOH(Reverse(dataInvalidMask2Reg)))) 747 val dataInvalidSqIdx = Mux(dataInvalidMask2Reg.orR, dataInvalidSqIdx2, dataInvalidSqIdx1) 748 749 when (dataInvalidFlag) { 750 io.forward(i).dataInvalidSqIdx.flag := Mux(!s2_differentFlag || dataInvalidSqIdx >= s2_deqPtrExt.value, s2_deqPtrExt.flag, s2_enqPtrExt.flag) 751 io.forward(i).dataInvalidSqIdx.value := dataInvalidSqIdx 752 } .otherwise { 753 // may be store inst has been written to sbuffer already. 754 io.forward(i).dataInvalidSqIdx := RegEnable(io.forward(i).uop.sqIdx, io.forward(i).valid) 755 } 756 } 757 758 /** 759 * Memory mapped IO / other uncached operations 760 * 761 * States: 762 * (1) writeback from store units: mark as pending 763 * (2) when they reach ROB's head, they can be sent to uncache channel 764 * (3) response from uncache channel: mark as datavalidmask.wen 765 * (4) writeback to ROB (and other units): mark as writebacked 766 * (5) ROB commits the instruction: same as normal instructions 767 */ 768 //(2) when they reach ROB's head, they can be sent to uncache channel 769 // TODO: CAN NOT deal with vector mmio now! 770 val s_idle :: s_req :: s_resp :: s_wb :: s_wait :: Nil = Enum(5) 771 val uncacheState = RegInit(s_idle) 772 val uncacheUop = Reg(new DynInst) 773 switch(uncacheState) { 774 is(s_idle) { 775 when(RegNext(io.rob.pendingst && uop(deqPtr).robIdx === io.rob.pendingPtr && pending(deqPtr) && allocated(deqPtr) && datavalid(deqPtr) && addrvalid(deqPtr))) { 776 uncacheState := s_req 777 uncacheUop := uop(deqPtr) 778 } 779 } 780 is(s_req) { 781 when (io.uncache.req.fire) { 782 when (io.uncacheOutstanding) { 783 uncacheState := s_wb 784 } .otherwise { 785 uncacheState := s_resp 786 } 787 } 788 } 789 is(s_resp) { 790 when(io.uncache.resp.fire) { 791 uncacheState := s_wb 792 793 when (io.uncache.resp.bits.nderr) { 794 uop(deqPtr).exceptionVec(storeAccessFault) := true.B 795 } 796 } 797 } 798 is(s_wb) { 799 when (io.mmioStout.fire || io.vecmmioStout.fire) { 800 uncacheState := s_wait 801 } 802 } 803 is(s_wait) { 804 // A MMIO store can always move cmtPtrExt as it must be ROB head 805 when(scommit > 0.U) { 806 uncacheState := s_idle // ready for next mmio 807 } 808 } 809 } 810 io.uncache.req.valid := uncacheState === s_req 811 812 io.uncache.req.bits := DontCare 813 io.uncache.req.bits.cmd := MemoryOpConstants.M_XWR 814 io.uncache.req.bits.addr := paddrModule.io.rdata(0) // data(deqPtr) -> rdata(0) 815 io.uncache.req.bits.data := shiftDataToLow(paddrModule.io.rdata(0), dataModule.io.rdata(0).data) 816 io.uncache.req.bits.mask := shiftMaskToLow(paddrModule.io.rdata(0), dataModule.io.rdata(0).mask) 817 818 // CBO op type check can be delayed for 1 cycle, 819 // as uncache op will not start in s_idle 820 val cbo_mmio_addr = paddrModule.io.rdata(0) >> 2 << 2 // clear lowest 2 bits for op 821 val cbo_mmio_op = 0.U //TODO 822 val cbo_mmio_data = cbo_mmio_addr | cbo_mmio_op 823 when(RegNext(LSUOpType.isCbo(uop(deqPtr).fuOpType))){ 824 io.uncache.req.bits.addr := DontCare // TODO 825 io.uncache.req.bits.data := paddrModule.io.rdata(0) 826 io.uncache.req.bits.mask := DontCare // TODO 827 } 828 829 io.uncache.req.bits.atomic := atomic(GatedRegNext(rdataPtrExtNext(0)).value) 830 831 when(io.uncache.req.fire){ 832 // mmio store should not be committed until uncache req is sent 833 pending(deqPtr) := false.B 834 835 XSDebug( 836 p"uncache req: pc ${Hexadecimal(uop(deqPtr).pc)} " + 837 p"addr ${Hexadecimal(io.uncache.req.bits.addr)} " + 838 p"data ${Hexadecimal(io.uncache.req.bits.data)} " + 839 p"op ${Hexadecimal(io.uncache.req.bits.cmd)} " + 840 p"mask ${Hexadecimal(io.uncache.req.bits.mask)}\n" 841 ) 842 } 843 844 // (3) response from uncache channel: mark as datavalid 845 io.uncache.resp.ready := true.B 846 847 // (4) scalar store: writeback to ROB (and other units): mark as writebacked 848 io.mmioStout.valid := uncacheState === s_wb && !isVec(deqPtr) 849 io.mmioStout.bits.uop := uncacheUop 850 io.mmioStout.bits.uop.sqIdx := deqPtrExt(0) 851 io.mmioStout.bits.data := shiftDataToLow(paddrModule.io.rdata(0), dataModule.io.rdata(0).data) // dataModule.io.rdata.read(deqPtr) 852 io.mmioStout.bits.debug.isMMIO := true.B 853 io.mmioStout.bits.debug.paddr := DontCare 854 io.mmioStout.bits.debug.isPerfCnt := false.B 855 io.mmioStout.bits.debug.vaddr := DontCare 856 // Remove MMIO inst from store queue after MMIO request is being sent 857 // That inst will be traced by uncache state machine 858 when (io.mmioStout.fire) { 859 allocated(deqPtr) := false.B 860 } 861 862 // (4) or vector store: 863 // TODO: implement it! 864 io.vecmmioStout := DontCare 865 io.vecmmioStout.valid := false.B //uncacheState === s_wb && isVec(deqPtr) 866 io.vecmmioStout.bits.uop := uop(deqPtr) 867 io.vecmmioStout.bits.uop.sqIdx := deqPtrExt(0) 868 io.vecmmioStout.bits.data := shiftDataToLow(paddrModule.io.rdata(0), dataModule.io.rdata(0).data) // dataModule.io.rdata.read(deqPtr) 869 io.vecmmioStout.bits.debug.isMMIO := true.B 870 io.vecmmioStout.bits.debug.paddr := DontCare 871 io.vecmmioStout.bits.debug.isPerfCnt := false.B 872 io.vecmmioStout.bits.debug.vaddr := DontCare 873 // Remove MMIO inst from store queue after MMIO request is being sent 874 // That inst will be traced by uncache state machine 875 when (io.vecmmioStout.fire) { 876 allocated(deqPtr) := false.B 877 } 878 879 /** 880 * ROB commits store instructions (mark them as committed) 881 * 882 * (1) When store commits, mark it as committed. 883 * (2) They will not be cancelled and can be sent to lower level. 884 */ 885 XSError(uncacheState =/= s_idle && uncacheState =/= s_wait && commitCount > 0.U, 886 "should not commit instruction when MMIO has not been finished\n") 887 888 val commitVec = WireInit(VecInit(Seq.fill(CommitWidth)(false.B))) 889 val needCancel = Wire(Vec(StoreQueueSize, Bool())) // Will be assigned later 890 dontTouch(commitVec) 891 // TODO: Deal with vector store mmio 892 for (i <- 0 until CommitWidth) { 893 when (allocated(cmtPtrExt(i).value) && isNotAfter(uop(cmtPtrExt(i).value).robIdx, GatedRegNext(io.rob.pendingPtr)) && !needCancel(cmtPtrExt(i).value) && (!waitStoreS2(cmtPtrExt(i).value) || isVec(cmtPtrExt(i).value))) { 894 // don't commit while doing misalign 895 if (i == 0){ 896 // TODO: fixme for vector mmio 897 when ((uncacheState === s_idle) || (uncacheState === s_wait && scommit > 0.U)){ 898 when ((isVec(cmtPtrExt(i).value) && vecMbCommit(cmtPtrExt(i).value)) || !isVec(cmtPtrExt(i).value)) { 899 committed(cmtPtrExt(0).value) := Mux(misalignBlock, false.B, true.B) 900 commitVec(0) := Mux(misalignBlock, false.B, true.B) 901 } 902 } 903 } else { 904 when ((isVec(cmtPtrExt(i).value) && vecMbCommit(cmtPtrExt(i).value)) || !isVec(cmtPtrExt(i).value)) { 905 committed(cmtPtrExt(i).value) := Mux(misalignBlock, false.B, commitVec(i - 1) || committed(cmtPtrExt(i).value)) 906 commitVec(i) := Mux(misalignBlock, false.B, commitVec(i - 1)) 907 } 908 } 909 } 910 } 911 912 commitCount := PopCount(commitVec) 913 cmtPtrExt := cmtPtrExt.map(_ + commitCount) 914 915 // committed stores will not be cancelled and can be sent to lower level. 916 // remove retired insts from sq, add retired store to sbuffer 917 918 // Read data from data module 919 // As store queue grows larger and larger, time needed to read data from data 920 // module keeps growing higher. Now we give data read a whole cycle. 921 for (i <- 0 until EnsbufferWidth) { 922 val ptr = rdataPtrExt(i).value 923 val mmioStall = if(i == 0) mmio(rdataPtrExt(0).value) else (mmio(rdataPtrExt(i).value) || mmio(rdataPtrExt(i-1).value)) 924 val exceptionValid = if(i == 0) hasException(rdataPtrExt(0).value) else { 925 hasException(rdataPtrExt(i).value) || (hasException(rdataPtrExt(i-1).value) && uop(rdataPtrExt(i).value).robIdx === uop(rdataPtrExt(i-1).value).robIdx) 926 } 927 val vecNotAllMask = dataModule.io.rdata(i).mask.orR 928 // Vector instructions that prevent triggered exceptions from being written to the 'databuffer'. 929 val vecHasExceptionFlagValid = vecExceptionFlag.valid && isVec(ptr) && vecExceptionFlag.bits.robIdx === uop(ptr).robIdx 930 if (i == 0) { 931 // use dataBuffer write port 0 to writeback missaligned store out 932 dataBuffer.io.enq(i).valid := Mux( 933 doMisalignSt, 934 io.maControl.control.writeSb, 935 allocated(ptr) && committed(ptr) && ((!isVec(ptr) && (allvalid(ptr) || hasException(ptr))) || vecMbCommit(ptr)) && !mmioStall 936 ) 937 } else { 938 dataBuffer.io.enq(i).valid := Mux( 939 doMisalignSt, 940 false.B, 941 allocated(ptr) && committed(ptr) && ((!isVec(ptr) && (allvalid(ptr) || hasException(ptr))) || vecMbCommit(ptr)) && !mmioStall 942 ) 943 } 944 // Note that store data/addr should both be valid after store's commit 945 assert(!dataBuffer.io.enq(i).valid || allvalid(ptr) || doMisalignSt || (allocated(ptr) && vecMbCommit(ptr))) 946 dataBuffer.io.enq(i).bits.addr := Mux(doMisalignSt, io.maControl.control.paddr, paddrModule.io.rdata(i)) 947 dataBuffer.io.enq(i).bits.vaddr := Mux(doMisalignSt, io.maControl.control.vaddr, vaddrModule.io.rdata(i)) 948 dataBuffer.io.enq(i).bits.data := Mux(doMisalignSt, io.maControl.control.wdata, dataModule.io.rdata(i).data) 949 dataBuffer.io.enq(i).bits.mask := Mux(doMisalignSt, io.maControl.control.wmask, dataModule.io.rdata(i).mask) 950 dataBuffer.io.enq(i).bits.wline := Mux(doMisalignSt, false.B, paddrModule.io.rlineflag(i)) 951 dataBuffer.io.enq(i).bits.sqPtr := rdataPtrExt(i) 952 dataBuffer.io.enq(i).bits.prefetch := Mux(doMisalignSt, false.B, prefetch(ptr)) 953 // when scalar has exception, will also not write into sbuffer 954 dataBuffer.io.enq(i).bits.vecValid := Mux(doMisalignSt, true.B, (!isVec(ptr) || (vecDataValid(ptr) && vecNotAllMask)) && !exceptionValid && !vecHasExceptionFlagValid) 955// dataBuffer.io.enq(i).bits.vecValid := (!isVec(ptr) || vecDataValid(ptr)) && !hasException(ptr) 956 } 957 958 // Send data stored in sbufferReqBitsReg to sbuffer 959 for (i <- 0 until EnsbufferWidth) { 960 io.sbuffer(i).valid := dataBuffer.io.deq(i).valid 961 dataBuffer.io.deq(i).ready := io.sbuffer(i).ready 962 // Write line request should have all 1 mask 963 assert(!(io.sbuffer(i).valid && io.sbuffer(i).bits.wline && io.sbuffer(i).bits.vecValid && !io.sbuffer(i).bits.mask.andR)) 964 io.sbuffer(i).bits := DontCare 965 io.sbuffer(i).bits.cmd := MemoryOpConstants.M_XWR 966 io.sbuffer(i).bits.addr := dataBuffer.io.deq(i).bits.addr 967 io.sbuffer(i).bits.vaddr := dataBuffer.io.deq(i).bits.vaddr 968 io.sbuffer(i).bits.data := dataBuffer.io.deq(i).bits.data 969 io.sbuffer(i).bits.mask := dataBuffer.io.deq(i).bits.mask 970 io.sbuffer(i).bits.wline := dataBuffer.io.deq(i).bits.wline && dataBuffer.io.deq(i).bits.vecValid 971 io.sbuffer(i).bits.prefetch := dataBuffer.io.deq(i).bits.prefetch 972 io.sbuffer(i).bits.vecValid := dataBuffer.io.deq(i).bits.vecValid 973 // io.sbuffer(i).fire is RegNexted, as sbuffer data write takes 2 cycles. 974 // Before data write finish, sbuffer is unable to provide store to load 975 // forward data. As an workaround, deqPtrExt and allocated flag update 976 // is delayed so that load can get the right data from store queue. 977 val ptr = dataBuffer.io.deq(i).bits.sqPtr.value 978 when (RegNext(io.sbuffer(i).fire && !doMisalignSt)) { 979 allocated(RegEnable(ptr, io.sbuffer(i).fire)) := false.B 980 XSDebug("sbuffer "+i+" fire: ptr %d\n", ptr) 981 } 982 } 983 984 // All vector instruction uop normally dequeue, but the Uop after the exception is raised does not write to the 'sbuffer'. 985 // Flags are used to record whether there are any exceptions when the queue is displayed. 986 // This is determined each time a write is made to the 'databuffer', prevent subsequent uop of the same instruction from writing to the 'dataBuffer'. 987 val vecCommitHasException = (0 until EnsbufferWidth).map{ i => 988 val ptr = rdataPtrExt(i).value 989 val mmioStall = if(i == 0) mmio(rdataPtrExt(0).value) else (mmio(rdataPtrExt(i).value) || mmio(rdataPtrExt(i-1).value)) 990 val exceptionVliad = allocated(ptr) && committed(ptr) && vecMbCommit(ptr) && !mmioStall && isVec(ptr) && vecDataValid(ptr) && hasException(ptr) 991 (exceptionVliad, uop(ptr)) 992 } 993 994 val vecCommitHasExceptionValid = vecCommitHasException.map(_._1) 995 val vecCommitHasExceptionUop = vecCommitHasException.map(_._2) 996 val vecCommitHasExceptionValidOR = vecCommitHasExceptionValid.reduce(_ || _) 997 // Just select the last Uop tah has an exception. 998 val vecCommitHasExceptionSelectUop = ParallelPosteriorityMux(vecCommitHasExceptionValid, vecCommitHasExceptionUop) 999 // If the last Uop with an exception is the LastUop of this instruction, the flag is not set. 1000 val vecCommitLastUop = vecCommitHasExceptionSelectUop.lastUop 1001 1002 val vecExceptionFlagCancel = (0 until EnsbufferWidth).map{ i => 1003 val ptr = rdataPtrExt(i).value 1004 val mmioStall = if(i == 0) mmio(rdataPtrExt(0).value) else (mmio(rdataPtrExt(i).value) || mmio(rdataPtrExt(i-1).value)) 1005 val vecLastUopCommit = uop(ptr).lastUop && (uop(ptr).robIdx === vecExceptionFlag.bits.robIdx) && 1006 allocated(ptr) && committed(ptr) && vecMbCommit(ptr) && !mmioStall && isVec(ptr) && vecDataValid(ptr) 1007 vecLastUopCommit 1008 }.reduce(_ || _) 1009 1010 // When a LastUop with an exception instruction is commited, clear the flag. 1011 when(!vecExceptionFlag.valid && vecCommitHasExceptionValidOR && !vecCommitLastUop) { 1012 vecExceptionFlag.valid := true.B 1013 vecExceptionFlag.bits := vecCommitHasExceptionSelectUop 1014 }.elsewhen(vecExceptionFlag.valid && vecExceptionFlagCancel) { 1015 vecExceptionFlag.valid := false.B 1016 vecExceptionFlag.bits := 0.U.asTypeOf(new DynInst) 1017 } 1018 1019 // A dumb defensive code. The flag should not be placed for a long period of time. 1020 // A relatively large timeout period, not have any special meaning. 1021 // If an assert appears and you confirm that it is not a Bug: Increase the timeout or remove the assert. 1022 TimeOutAssert(vecExceptionFlag.valid, 3000, "vecExceptionFlag timeout, Plase check for bugs or add timeouts.") 1023 1024 // Initialize when unenabled difftest. 1025 for (i <- 0 until EnsbufferWidth) { 1026 io.sbufferVecDifftestInfo(i) := DontCare 1027 } 1028 // Consistent with the logic above. 1029 // Only the vector store difftest required signal is separated from the rtl code. 1030 if (env.EnableDifftest) { 1031 for (i <- 0 until EnsbufferWidth) { 1032 val ptr = rdataPtrExt(i).value 1033 val mmioStall = if(i == 0) mmio(rdataPtrExt(0).value) else (mmio(rdataPtrExt(i).value) || mmio(rdataPtrExt(i-1).value)) 1034 difftestBuffer.get.io.enq(i).valid := allocated(ptr) && committed(ptr) && (!isVec(ptr) || vecMbCommit(ptr)) && !mmioStall 1035 difftestBuffer.get.io.enq(i).bits := uop(ptr) 1036 } 1037 for (i <- 0 until EnsbufferWidth) { 1038 io.sbufferVecDifftestInfo(i).valid := difftestBuffer.get.io.deq(i).valid 1039 difftestBuffer.get.io.deq(i).ready := io.sbufferVecDifftestInfo(i).ready 1040 1041 io.sbufferVecDifftestInfo(i).bits := difftestBuffer.get.io.deq(i).bits 1042 } 1043 } 1044 1045 (1 until EnsbufferWidth).foreach(i => when(io.sbuffer(i).fire) { assert(io.sbuffer(i - 1).fire) }) 1046 if (coreParams.dcacheParametersOpt.isEmpty) { 1047 for (i <- 0 until EnsbufferWidth) { 1048 val ptr = deqPtrExt(i).value 1049 val ram = DifftestMem(64L * 1024 * 1024 * 1024, 8) 1050 val wen = allocated(ptr) && committed(ptr) && !mmio(ptr) 1051 val waddr = ((paddrModule.io.rdata(i) - "h80000000".U) >> 3).asUInt 1052 val wdata = Mux(paddrModule.io.rdata(i)(3), dataModule.io.rdata(i).data(127, 64), dataModule.io.rdata(i).data(63, 0)) 1053 val wmask = Mux(paddrModule.io.rdata(i)(3), dataModule.io.rdata(i).mask(15, 8), dataModule.io.rdata(i).mask(7, 0)) 1054 when (wen) { 1055 ram.write(waddr, wdata.asTypeOf(Vec(8, UInt(8.W))), wmask.asBools) 1056 } 1057 } 1058 } 1059 1060 // Read vaddr for mem exception 1061 io.exceptionAddr.vaddr := exceptionBuffer.io.exceptionAddr.vaddr 1062 io.exceptionAddr.gpaddr := exceptionBuffer.io.exceptionAddr.gpaddr 1063 io.exceptionAddr.vstart := exceptionBuffer.io.exceptionAddr.vstart 1064 io.exceptionAddr.vl := exceptionBuffer.io.exceptionAddr.vl 1065 1066 // vector commit or replay from 1067 val vecCommittmp = Wire(Vec(StoreQueueSize, Vec(VecStorePipelineWidth, Bool()))) 1068 val vecCommit = Wire(Vec(StoreQueueSize, Bool())) 1069 for (i <- 0 until StoreQueueSize) { 1070 val fbk = io.vecFeedback 1071 for (j <- 0 until VecStorePipelineWidth) { 1072 vecCommittmp(i)(j) := fbk(j).valid && (fbk(j).bits.isCommit || fbk(j).bits.isFlush) && 1073 uop(i).robIdx === fbk(j).bits.robidx && uop(i).uopIdx === fbk(j).bits.uopidx && allocated(i) 1074 } 1075 vecCommit(i) := vecCommittmp(i).reduce(_ || _) 1076 1077 when (vecCommit(i)) { 1078 vecMbCommit(i) := true.B 1079 } 1080 } 1081 1082 // misprediction recovery / exception redirect 1083 // invalidate sq term using robIdx 1084 for (i <- 0 until StoreQueueSize) { 1085 needCancel(i) := uop(i).robIdx.needFlush(io.brqRedirect) && allocated(i) && !committed(i) && 1086 (!isVec(i) || !(uop(i).robIdx === io.brqRedirect.bits.robIdx)) 1087 when (needCancel(i)) { 1088 allocated(i) := false.B 1089 } 1090 } 1091 1092 /** 1093* update pointers 1094**/ 1095 val enqCancelValid = canEnqueue.zip(io.enq.req).map{case (v , x) => 1096 v && x.bits.robIdx.needFlush(io.brqRedirect) 1097 } 1098 val enqCancelNum = enqCancelValid.zip(io.enq.req).map{case (v, req) => 1099 Mux(v, req.bits.numLsElem, 0.U) 1100 } 1101 val lastEnqCancel = RegEnable(enqCancelNum.reduce(_ + _), io.brqRedirect.valid) // 1 cycle after redirect 1102 1103 val lastCycleCancelCount = PopCount(RegEnable(needCancel, io.brqRedirect.valid)) // 1 cycle after redirect 1104 val lastCycleRedirect = RegNext(io.brqRedirect.valid) // 1 cycle after redirect 1105 val enqNumber = validVStoreFlow.reduce(_ + _) 1106 1107 val lastlastCycleRedirect=RegNext(lastCycleRedirect)// 2 cycle after redirect 1108 val redirectCancelCount = RegEnable(lastCycleCancelCount + lastEnqCancel, 0.U, lastCycleRedirect) // 2 cycle after redirect 1109 1110 when (lastlastCycleRedirect) { 1111 // we recover the pointers in 2 cycle after redirect for better timing 1112 enqPtrExt := VecInit(enqPtrExt.map(_ - redirectCancelCount)) 1113 }.otherwise { 1114 // lastCycleRedirect.valid or nornal case 1115 // when lastCycleRedirect.valid, enqNumber === 0.U, enqPtrExt will not change 1116 enqPtrExt := VecInit(enqPtrExt.map(_ + enqNumber)) 1117 } 1118 assert(!(lastCycleRedirect && enqNumber =/= 0.U)) 1119 1120 exceptionBuffer.io.flushFrmMaBuf := finishMisalignSt 1121 // special case (store miss align) in updating ptr 1122 when (doMisalignSt) { 1123 when (!finishMisalignSt) { 1124 // dont move deqPtr and rdataPtr until all split store has been written to sb 1125 deqPtrExtNext := deqPtrExt 1126 rdataPtrExtNext := rdataPtrExt 1127 } .otherwise { 1128 // remove this unaligned store from sq 1129 allocated(deqPtr) := false.B 1130 committed(deqPtr) := true.B 1131 cmtPtrExt := cmtPtrExt.map(_ + 1.U) 1132 deqPtrExtNext := deqPtrExt.map(_ + 1.U) 1133 rdataPtrExtNext := rdataPtrExt.map(_ + 1.U) 1134 } 1135 } 1136 1137 deqPtrExt := deqPtrExtNext 1138 rdataPtrExt := rdataPtrExtNext 1139 1140 // val dequeueCount = Mux(io.sbuffer(1).fire, 2.U, Mux(io.sbuffer(0).fire || io.mmioStout.fire, 1.U, 0.U)) 1141 1142 // If redirect at T0, sqCancelCnt is at T2 1143 io.sqCancelCnt := redirectCancelCount 1144 val ForceWriteUpper = Wire(UInt(log2Up(StoreQueueSize + 1).W)) 1145 ForceWriteUpper := Constantin.createRecord(s"ForceWriteUpper_${p(XSCoreParamsKey).HartId}", initValue = 60) 1146 val ForceWriteLower = Wire(UInt(log2Up(StoreQueueSize + 1).W)) 1147 ForceWriteLower := Constantin.createRecord(s"ForceWriteLower_${p(XSCoreParamsKey).HartId}", initValue = 55) 1148 1149 val valid_cnt = PopCount(allocated) 1150 io.force_write := RegNext(Mux(valid_cnt >= ForceWriteUpper, true.B, valid_cnt >= ForceWriteLower && io.force_write), init = false.B) 1151 1152 // io.sqempty will be used by sbuffer 1153 // We delay it for 1 cycle for better timing 1154 // When sbuffer need to check if it is empty, the pipeline is blocked, which means delay io.sqempty 1155 // for 1 cycle will also promise that sq is empty in that cycle 1156 io.sqEmpty := RegNext( 1157 enqPtrExt(0).value === deqPtrExt(0).value && 1158 enqPtrExt(0).flag === deqPtrExt(0).flag 1159 ) 1160 // perf counter 1161 QueuePerf(StoreQueueSize, validCount, !allowEnqueue) 1162 val vecValidVec = WireInit(VecInit((0 until StoreQueueSize).map(i => allocated(i) && isVec(i)))) 1163 QueuePerf(StoreQueueSize, PopCount(vecValidVec), !allowEnqueue) 1164 io.sqFull := !allowEnqueue 1165 XSPerfAccumulate("mmioCycle", uncacheState =/= s_idle) // lq is busy dealing with uncache req 1166 XSPerfAccumulate("mmioCnt", io.uncache.req.fire) 1167 XSPerfAccumulate("mmio_wb_success", io.mmioStout.fire || io.vecmmioStout.fire) 1168 XSPerfAccumulate("mmio_wb_blocked", (io.mmioStout.valid && !io.mmioStout.ready) || (io.vecmmioStout.valid && !io.vecmmioStout.ready)) 1169 XSPerfAccumulate("validEntryCnt", distanceBetween(enqPtrExt(0), deqPtrExt(0))) 1170 XSPerfAccumulate("cmtEntryCnt", distanceBetween(cmtPtrExt(0), deqPtrExt(0))) 1171 XSPerfAccumulate("nCmtEntryCnt", distanceBetween(enqPtrExt(0), cmtPtrExt(0))) 1172 1173 val perfValidCount = distanceBetween(enqPtrExt(0), deqPtrExt(0)) 1174 val perfEvents = Seq( 1175 ("mmioCycle ", uncacheState =/= s_idle), 1176 ("mmioCnt ", io.uncache.req.fire), 1177 ("mmio_wb_success", io.mmioStout.fire || io.vecmmioStout.fire), 1178 ("mmio_wb_blocked", (io.mmioStout.valid && !io.mmioStout.ready) || (io.vecmmioStout.valid && !io.vecmmioStout.ready)), 1179 ("stq_1_4_valid ", (perfValidCount < (StoreQueueSize.U/4.U))), 1180 ("stq_2_4_valid ", (perfValidCount > (StoreQueueSize.U/4.U)) & (perfValidCount <= (StoreQueueSize.U/2.U))), 1181 ("stq_3_4_valid ", (perfValidCount > (StoreQueueSize.U/2.U)) & (perfValidCount <= (StoreQueueSize.U*3.U/4.U))), 1182 ("stq_4_4_valid ", (perfValidCount > (StoreQueueSize.U*3.U/4.U))), 1183 ) 1184 generatePerfEvent() 1185 1186 // debug info 1187 XSDebug("enqPtrExt %d:%d deqPtrExt %d:%d\n", enqPtrExt(0).flag, enqPtr, deqPtrExt(0).flag, deqPtr) 1188 1189 def PrintFlag(flag: Bool, name: String): Unit = { 1190 when(flag) { 1191 XSDebug(false, true.B, name) 1192 }.otherwise { 1193 XSDebug(false, true.B, " ") 1194 } 1195 } 1196 1197 for (i <- 0 until StoreQueueSize) { 1198 XSDebug(s"$i: pc %x va %x pa %x data %x ", 1199 uop(i).pc, 1200 debug_vaddr(i), 1201 debug_paddr(i), 1202 debug_data(i) 1203 ) 1204 PrintFlag(allocated(i), "a") 1205 PrintFlag(allocated(i) && addrvalid(i), "a") 1206 PrintFlag(allocated(i) && datavalid(i), "d") 1207 PrintFlag(allocated(i) && committed(i), "c") 1208 PrintFlag(allocated(i) && pending(i), "p") 1209 PrintFlag(allocated(i) && mmio(i), "m") 1210 XSDebug(false, true.B, "\n") 1211 } 1212 1213} 1214