1730cfbc0SXuan Hupackage xiangshan.backend.issue 2730cfbc0SXuan Hu 3730cfbc0SXuan Huimport chipsalliance.rocketchip.config.Parameters 4730cfbc0SXuan Huimport chisel3._ 5730cfbc0SXuan Huimport chisel3.util._ 6730cfbc0SXuan Huimport freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp} 7730cfbc0SXuan Huimport xiangshan._ 810fe9778SXuan Huimport xiangshan.backend.Bundles._ 939c59369SXuan Huimport xiangshan.backend.datapath.DataConfig.{IntData, VAddrData, VecData} 1039c59369SXuan Huimport xiangshan.backend.datapath.WbConfig.{IntWB, VfWB} 11730cfbc0SXuan Huimport xiangshan.backend.regfile.RfWritePortWithConfig 12730cfbc0SXuan Huimport xiangshan.backend.rename.BusyTable 13730cfbc0SXuan Huimport xiangshan.mem.{LsqEnqCtrl, LsqEnqIO, MemWaitUpdateReq, SqPtr} 14730cfbc0SXuan Hu 15730cfbc0SXuan Husealed trait SchedulerType 16730cfbc0SXuan Hu 17730cfbc0SXuan Hucase class IntScheduler() extends SchedulerType 18730cfbc0SXuan Hucase class MemScheduler() extends SchedulerType 19730cfbc0SXuan Hucase class VfScheduler() extends SchedulerType 20730cfbc0SXuan Hucase class NoScheduler() extends SchedulerType 21730cfbc0SXuan Hu 22730cfbc0SXuan Huclass Scheduler(val params: SchdBlockParams)(implicit p: Parameters) extends LazyModule with HasXSParameter { 2339c59369SXuan Hu val numIntStateWrite = backendParams.numPregWb(IntData()) 2439c59369SXuan Hu val numVfStateWrite = backendParams.numPregWb(VecData()) 25730cfbc0SXuan Hu 26730cfbc0SXuan Hu val dispatch2Iq = LazyModule(new Dispatch2Iq(params)) 27730cfbc0SXuan Hu val issueQueue = params.issueBlockParams.map(x => LazyModule(new IssueQueue(x).suggestName(x.getIQName))) 28730cfbc0SXuan Hu 29730cfbc0SXuan Hu lazy val module = params.schdType match { 30730cfbc0SXuan Hu case IntScheduler() => new SchedulerArithImp(this)(params, p) 31730cfbc0SXuan Hu case MemScheduler() => new SchedulerMemImp(this)(params, p) 32730cfbc0SXuan Hu case VfScheduler() => new SchedulerArithImp(this)(params, p) 33730cfbc0SXuan Hu case _ => null 34730cfbc0SXuan Hu } 35730cfbc0SXuan Hu} 36730cfbc0SXuan Hu 377f8233d5SHaojin Tangclass SchedulerIO()(implicit params: SchdBlockParams, p: Parameters) extends XSBundle { 3868d13085SXuan Hu // params alias 397f8233d5SHaojin Tang private val LoadQueueSize = VirtualLoadQueueSize 4068d13085SXuan Hu 41730cfbc0SXuan Hu val fromTop = new Bundle { 42730cfbc0SXuan Hu val hartId = Input(UInt(8.W)) 43730cfbc0SXuan Hu } 442e0a7dc5Sfdy val fromWbFuBusyTable = new Bundle{ 452e0a7dc5Sfdy val fuBusyTableRead = MixedVec(params.issueBlockParams.map(x => Input(x.genWbFuBusyTableReadBundle))) 462e0a7dc5Sfdy } 47dd970561SzhanglyGit val wbFuBusyTable = MixedVec(params.issueBlockParams.map(x => Output(x.genWbFuBusyTableWriteBundle))) 48dd970561SzhanglyGit 49730cfbc0SXuan Hu val fromCtrlBlock = new Bundle { 50730cfbc0SXuan Hu val pcVec = Input(Vec(params.numPcReadPort, UInt(VAddrData().dataWidth.W))) 51730cfbc0SXuan Hu val flush = Flipped(ValidIO(new Redirect)) 52730cfbc0SXuan Hu } 53730cfbc0SXuan Hu val fromDispatch = new Bundle { 54730cfbc0SXuan Hu val allocPregs = Vec(RenameWidth, Input(new ResetPregStateReq)) 55730cfbc0SXuan Hu val uops = Vec(params.numUopIn, Flipped(DecoupledIO(new DynInst))) 56730cfbc0SXuan Hu } 5739c59369SXuan Hu val intWriteBack = MixedVec(Vec(backendParams.numPregWb(IntData()), 58730cfbc0SXuan Hu new RfWritePortWithConfig(backendParams.intPregParams.dataCfg, backendParams.intPregParams.addrWidth))) 5939c59369SXuan Hu val vfWriteBack = MixedVec(Vec(backendParams.numPregWb(VecData()), 60730cfbc0SXuan Hu new RfWritePortWithConfig(backendParams.vfPregParams.dataCfg, backendParams.vfPregParams.addrWidth))) 6110fe9778SXuan Hu val toDataPath: MixedVec[MixedVec[DecoupledIO[IssueQueueIssueBundle]]] = MixedVec(params.issueBlockParams.map(_.genIssueDecoupledBundle)) 6259ef6009Sxiaofeibao-xjtu val toDataPathAfterDelay: MixedVec[MixedVec[DecoupledIO[IssueQueueIssueBundle]]] = MixedVec(params.issueBlockParams.map(_.genIssueDecoupledBundle)) 6359ef6009Sxiaofeibao-xjtu val fromCancelNetwork = Flipped(MixedVec(params.issueBlockParams.map(_.genIssueDecoupledBundle))) 64730cfbc0SXuan Hu 65bf35baadSXuan Hu val fromSchedulers = new Bundle { 66c0be7f33SXuan Hu val wakeupVec: MixedVec[ValidIO[IssueQueueIQWakeUpBundle]] = Flipped(params.genIQWakeUpInValidBundle) 67bf35baadSXuan Hu } 68bf35baadSXuan Hu 69bf35baadSXuan Hu val toSchedulers = new Bundle { 70c0be7f33SXuan Hu val wakeupVec: MixedVec[ValidIO[IssueQueueIQWakeUpBundle]] = params.genIQWakeUpOutValidBundle 71bf35baadSXuan Hu } 72bf35baadSXuan Hu 73c0be7f33SXuan Hu val fromDataPath = new Bundle { 7410fe9778SXuan Hu val resp: MixedVec[MixedVec[OGRespBundle]] = MixedVec(params.issueBlockParams.map(x => Flipped(x.genOGRespBundle))) 75ea46c302SXuan Hu val og0Cancel = Input(ExuVec(backendParams.numExu)) 76ea46c302SXuan Hu // Todo: remove this after no cancel signal from og1 77ea46c302SXuan Hu val og1Cancel = Input(ExuVec(backendParams.numExu)) 78bc7d6943SzhanglyGit val cancelToBusyTable = Vec(backendParams.numExu, Flipped(ValidIO(new CancelSignal))) 79c0be7f33SXuan Hu // just be compatible to old code 80c0be7f33SXuan Hu def apply(i: Int)(j: Int) = resp(i)(j) 81c0be7f33SXuan Hu } 82c0be7f33SXuan Hu 830f55a0d3SHaojin Tang val loadFinalIssueResp = MixedVec(params.issueBlockParams.map(x => MixedVec(Vec(x.LduCnt, Flipped(ValidIO(new IssueQueueDeqRespBundle()(p, x))))))) 840f55a0d3SHaojin Tang 850f55a0d3SHaojin Tang val ldCancel = Vec(backendParams.LduCnt, Flipped(new LoadCancelIO)) 86c0be7f33SXuan Hu 87730cfbc0SXuan Hu val memIO = if (params.isMemSchd) Some(new Bundle { 88730cfbc0SXuan Hu val lsqEnqIO = Flipped(new LsqEnqIO) 89730cfbc0SXuan Hu }) else None 90730cfbc0SXuan Hu val fromMem = if (params.isMemSchd) Some(new Bundle { 917b753bebSXuan Hu val ldaFeedback = Flipped(Vec(params.LduCnt, new MemRSFeedbackIO)) 927b753bebSXuan Hu val staFeedback = Flipped(Vec(params.StaCnt, new MemRSFeedbackIO)) 93730cfbc0SXuan Hu val stIssuePtr = Input(new SqPtr()) 94730cfbc0SXuan Hu val lcommit = Input(UInt(log2Up(CommitWidth + 1).W)) 95730cfbc0SXuan Hu val scommit = Input(UInt(log2Ceil(EnsbufferWidth + 1).W)) // connected to `memBlock.io.sqDeq` instead of ROB 96730cfbc0SXuan Hu // from lsq 97730cfbc0SXuan Hu val lqCancelCnt = Input(UInt(log2Up(LoadQueueSize + 1).W)) 98730cfbc0SXuan Hu val sqCancelCnt = Input(UInt(log2Up(StoreQueueSize + 1).W)) 99730cfbc0SXuan Hu val memWaitUpdateReq = Flipped(new MemWaitUpdateReq) 100730cfbc0SXuan Hu }) else None 101730cfbc0SXuan Hu val toMem = if (params.isMemSchd) Some(new Bundle { 102730cfbc0SXuan Hu val loadFastMatch = Output(Vec(params.LduCnt, new IssueQueueLoadBundle)) 103730cfbc0SXuan Hu }) else None 104730cfbc0SXuan Hu} 105730cfbc0SXuan Hu 106730cfbc0SXuan Huabstract class SchedulerImpBase(wrapper: Scheduler)(implicit params: SchdBlockParams, p: Parameters) 107730cfbc0SXuan Hu extends LazyModuleImp(wrapper) 108730cfbc0SXuan Hu with HasXSParameter 109730cfbc0SXuan Hu{ 110730cfbc0SXuan Hu val io = IO(new SchedulerIO()) 111730cfbc0SXuan Hu 112730cfbc0SXuan Hu // alias 113c0be7f33SXuan Hu private val iqWakeUpInMap: Map[Int, ValidIO[IssueQueueIQWakeUpBundle]] = 114c0be7f33SXuan Hu io.fromSchedulers.wakeupVec.map(x => (x.bits.exuIdx, x)).toMap 115730cfbc0SXuan Hu private val schdType = params.schdType 116730cfbc0SXuan Hu 117730cfbc0SXuan Hu // Modules 118730cfbc0SXuan Hu val dispatch2Iq: Dispatch2IqImp = wrapper.dispatch2Iq.module 119730cfbc0SXuan Hu val issueQueues: Seq[IssueQueueImp] = wrapper.issueQueue.map(_.module) 120730cfbc0SXuan Hu 121730cfbc0SXuan Hu // BusyTable Modules 122730cfbc0SXuan Hu val intBusyTable = schdType match { 123bc7d6943SzhanglyGit case IntScheduler() | MemScheduler() => Some(Module(new BusyTable(dispatch2Iq.numIntStateRead, wrapper.numIntStateWrite, IntPhyRegs, IntWB()))) 124730cfbc0SXuan Hu case _ => None 125730cfbc0SXuan Hu } 126730cfbc0SXuan Hu 127730cfbc0SXuan Hu val vfBusyTable = schdType match { 128bc7d6943SzhanglyGit case VfScheduler() | MemScheduler() => Some(Module(new BusyTable(dispatch2Iq.numVfStateRead, wrapper.numVfStateWrite, VfPhyRegs, VfWB()))) 129730cfbc0SXuan Hu case _ => None 130730cfbc0SXuan Hu } 131730cfbc0SXuan Hu 132730cfbc0SXuan Hu dispatch2Iq.io match { case dp2iq => 133730cfbc0SXuan Hu dp2iq.redirect <> io.fromCtrlBlock.flush 134730cfbc0SXuan Hu dp2iq.in <> io.fromDispatch.uops 135730cfbc0SXuan Hu dp2iq.readIntState.foreach(_ <> intBusyTable.get.io.read) 136730cfbc0SXuan Hu dp2iq.readVfState.foreach(_ <> vfBusyTable.get.io.read) 137730cfbc0SXuan Hu } 138730cfbc0SXuan Hu 139730cfbc0SXuan Hu intBusyTable match { 140730cfbc0SXuan Hu case Some(bt) => 141730cfbc0SXuan Hu bt.io.allocPregs.zip(io.fromDispatch.allocPregs).foreach { case (btAllocPregs, dpAllocPregs) => 142730cfbc0SXuan Hu btAllocPregs.valid := dpAllocPregs.isInt 143730cfbc0SXuan Hu btAllocPregs.bits := dpAllocPregs.preg 144730cfbc0SXuan Hu } 145730cfbc0SXuan Hu bt.io.wbPregs.zipWithIndex.foreach { case (wb, i) => 146730cfbc0SXuan Hu wb.valid := io.intWriteBack(i).wen && io.intWriteBack(i).intWen 147730cfbc0SXuan Hu wb.bits := io.intWriteBack(i).addr 148730cfbc0SXuan Hu } 149bc7d6943SzhanglyGit bt.io.wakeUp := io.fromSchedulers.wakeupVec 150bc7d6943SzhanglyGit bt.io.cancel := io.fromDataPath.cancelToBusyTable 151730cfbc0SXuan Hu case None => 152730cfbc0SXuan Hu } 153730cfbc0SXuan Hu 154730cfbc0SXuan Hu vfBusyTable match { 155730cfbc0SXuan Hu case Some(bt) => 156730cfbc0SXuan Hu bt.io.allocPregs.zip(io.fromDispatch.allocPregs).foreach { case (btAllocPregs, dpAllocPregs) => 157730cfbc0SXuan Hu btAllocPregs.valid := dpAllocPregs.isFp 158730cfbc0SXuan Hu btAllocPregs.bits := dpAllocPregs.preg 159730cfbc0SXuan Hu } 160730cfbc0SXuan Hu bt.io.wbPregs.zipWithIndex.foreach { case (wb, i) => 161730cfbc0SXuan Hu wb.valid := io.vfWriteBack(i).wen && (io.vfWriteBack(i).fpWen || io.vfWriteBack(i).vecWen) 162730cfbc0SXuan Hu wb.bits := io.vfWriteBack(i).addr 163730cfbc0SXuan Hu } 164bc7d6943SzhanglyGit bt.io.wakeUp := io.fromSchedulers.wakeupVec 165bc7d6943SzhanglyGit bt.io.cancel := io.fromDataPath.cancelToBusyTable 166730cfbc0SXuan Hu case None => 167730cfbc0SXuan Hu } 168730cfbc0SXuan Hu 169c0be7f33SXuan Hu val wakeupFromWBVec = Wire(params.genWBWakeUpSinkValidBundle) 170730cfbc0SXuan Hu val writeback = params.schdType match { 171730cfbc0SXuan Hu case IntScheduler() => io.intWriteBack 172730cfbc0SXuan Hu case MemScheduler() => io.intWriteBack ++ io.vfWriteBack 173730cfbc0SXuan Hu case VfScheduler() => io.vfWriteBack 174730cfbc0SXuan Hu case _ => Seq() 175730cfbc0SXuan Hu } 176730cfbc0SXuan Hu wakeupFromWBVec.zip(writeback).foreach { case (sink, source) => 177730cfbc0SXuan Hu sink.valid := source.wen 178730cfbc0SXuan Hu sink.bits.rfWen := source.intWen 179730cfbc0SXuan Hu sink.bits.fpWen := source.fpWen 180730cfbc0SXuan Hu sink.bits.vecWen := source.vecWen 181730cfbc0SXuan Hu sink.bits.pdest := source.addr 182730cfbc0SXuan Hu } 183730cfbc0SXuan Hu 184bf35baadSXuan Hu // Connect bundles having the same wakeup source 18559ef6009Sxiaofeibao-xjtu issueQueues.zipWithIndex.foreach { case(iq, i) => 186bf35baadSXuan Hu iq.io.wakeupFromIQ.foreach { wakeUp => 187c0be7f33SXuan Hu wakeUp := iqWakeUpInMap(wakeUp.bits.exuIdx) 188bf35baadSXuan Hu } 189ea46c302SXuan Hu iq.io.og0Cancel := io.fromDataPath.og0Cancel 190ea46c302SXuan Hu iq.io.og1Cancel := io.fromDataPath.og1Cancel 1910f55a0d3SHaojin Tang iq.io.ldCancel := io.ldCancel 19259ef6009Sxiaofeibao-xjtu iq.io.fromCancelNetwork <> io.fromCancelNetwork(i) 193bf35baadSXuan Hu } 194bf35baadSXuan Hu 195c0be7f33SXuan Hu private val iqWakeUpOutMap: Map[Int, ValidIO[IssueQueueIQWakeUpBundle]] = 196bf35baadSXuan Hu issueQueues.flatMap(_.io.wakeupToIQ) 197c0be7f33SXuan Hu .map(x => (x.bits.exuIdx, x)) 198bf35baadSXuan Hu .toMap 199bf35baadSXuan Hu 200bf35baadSXuan Hu // Connect bundles having the same wakeup source 201bf35baadSXuan Hu io.toSchedulers.wakeupVec.foreach { wakeUp => 202c0be7f33SXuan Hu wakeUp := iqWakeUpOutMap(wakeUp.bits.exuIdx) 203bf35baadSXuan Hu } 204bf35baadSXuan Hu 205730cfbc0SXuan Hu io.toDataPath.zipWithIndex.foreach { case (toDp, i) => 206730cfbc0SXuan Hu toDp <> issueQueues(i).io.deq 207730cfbc0SXuan Hu } 20859ef6009Sxiaofeibao-xjtu io.toDataPathAfterDelay.zipWithIndex.foreach { case (toDpDy, i) => 20959ef6009Sxiaofeibao-xjtu toDpDy <> issueQueues(i).io.deqDelay 21059ef6009Sxiaofeibao-xjtu } 211bf35baadSXuan Hu 212c0be7f33SXuan Hu println(s"[Scheduler] io.fromSchedulers.wakeupVec: ${io.fromSchedulers.wakeupVec.map(x => backendParams.getExuName(x.bits.exuIdx))}") 213bf35baadSXuan Hu println(s"[Scheduler] iqWakeUpInKeys: ${iqWakeUpInMap.keys}") 214bf35baadSXuan Hu 215bf35baadSXuan Hu println(s"[Scheduler] iqWakeUpOutKeys: ${iqWakeUpOutMap.keys}") 216c0be7f33SXuan Hu println(s"[Scheduler] io.toSchedulers.wakeupVec: ${io.toSchedulers.wakeupVec.map(x => backendParams.getExuName(x.bits.exuIdx))}") 217730cfbc0SXuan Hu} 218730cfbc0SXuan Hu 219730cfbc0SXuan Huclass SchedulerArithImp(override val wrapper: Scheduler)(implicit params: SchdBlockParams, p: Parameters) 220730cfbc0SXuan Hu extends SchedulerImpBase(wrapper) 221730cfbc0SXuan Hu with HasXSParameter 222730cfbc0SXuan Hu{ 2232e0a7dc5Sfdy// dontTouch(io.vfWbFuBusyTable) 224730cfbc0SXuan Hu println(s"[SchedulerArithImp] " + 225730cfbc0SXuan Hu s"has intBusyTable: ${intBusyTable.nonEmpty}, " + 226730cfbc0SXuan Hu s"has vfBusyTable: ${vfBusyTable.nonEmpty}") 227730cfbc0SXuan Hu 228730cfbc0SXuan Hu issueQueues.zipWithIndex.foreach { case (iq, i) => 229730cfbc0SXuan Hu iq.io.flush <> io.fromCtrlBlock.flush 230730cfbc0SXuan Hu iq.io.enq <> dispatch2Iq.io.out(i) 231bf35baadSXuan Hu iq.io.wakeupFromWB := wakeupFromWBVec 232730cfbc0SXuan Hu iq.io.deqResp.zipWithIndex.foreach { case (deqResp, j) => 233ea0f92d8Sczw deqResp.valid := iq.io.deq(j).valid && io.toDataPath(i)(j).ready 234ea0f92d8Sczw deqResp.bits.respType := RSFeedbackType.issueSuccess 2355db4956bSzhanglyGit deqResp.bits.robIdx := iq.io.deq(j).bits.common.robIdx 2368d29ec32Sczw deqResp.bits.rfWen := iq.io.deq(j).bits.common.rfWen.getOrElse(false.B) 2378d29ec32Sczw deqResp.bits.fuType := iq.io.deq(j).bits.common.fuType 2388d29ec32Sczw 239730cfbc0SXuan Hu } 240730cfbc0SXuan Hu iq.io.og0Resp.zipWithIndex.foreach { case (og0Resp, j) => 241730cfbc0SXuan Hu og0Resp.valid := io.fromDataPath(i)(j).og0resp.valid 242730cfbc0SXuan Hu og0Resp.bits.respType := io.fromDataPath(i)(j).og0resp.bits.respType 2435db4956bSzhanglyGit og0Resp.bits.robIdx := io.fromDataPath(i)(j).og0resp.bits.robIdx 2448d29ec32Sczw og0Resp.bits.rfWen := io.fromDataPath(i)(j).og0resp.bits.rfWen 2458d29ec32Sczw og0Resp.bits.fuType := io.fromDataPath(i)(j).og0resp.bits.fuType 2468d29ec32Sczw 247730cfbc0SXuan Hu } 248730cfbc0SXuan Hu iq.io.og1Resp.zipWithIndex.foreach { case (og1Resp, j) => 249730cfbc0SXuan Hu og1Resp.valid := io.fromDataPath(i)(j).og1resp.valid 250730cfbc0SXuan Hu og1Resp.bits.respType := io.fromDataPath(i)(j).og1resp.bits.respType 2515db4956bSzhanglyGit og1Resp.bits.robIdx := io.fromDataPath(i)(j).og1resp.bits.robIdx 2528d29ec32Sczw og1Resp.bits.rfWen := io.fromDataPath(i)(j).og1resp.bits.rfWen 2538d29ec32Sczw og1Resp.bits.fuType := io.fromDataPath(i)(j).og1resp.bits.fuType 2548d29ec32Sczw 255730cfbc0SXuan Hu } 2562e0a7dc5Sfdy 2572e0a7dc5Sfdy iq.io.wbBusyTableRead := io.fromWbFuBusyTable.fuBusyTableRead(i) 258dd970561SzhanglyGit io.wbFuBusyTable(i) := iq.io.wbBusyTableWrite 259730cfbc0SXuan Hu } 260730cfbc0SXuan Hu 261730cfbc0SXuan Hu val iqJumpBundleVec: Seq[IssueQueueJumpBundle] = issueQueues.map { 262730cfbc0SXuan Hu case imp: IssueQueueIntImp => imp.io.enqJmp 263730cfbc0SXuan Hu case _ => None 264730cfbc0SXuan Hu }.filter(_.nonEmpty).flatMap(_.get) 265730cfbc0SXuan Hu println(s"[Scheduler] iqJumpBundleVec: ${iqJumpBundleVec}") 266730cfbc0SXuan Hu 267*d8a24b06SzhanglyGit iqJumpBundleVec.zip(io.fromCtrlBlock.pcVec).foreach { case (iqJmp, pc) => 268730cfbc0SXuan Hu iqJmp.pc := pc 269730cfbc0SXuan Hu } 270730cfbc0SXuan Hu} 271730cfbc0SXuan Hu 272730cfbc0SXuan Huclass SchedulerMemImp(override val wrapper: Scheduler)(implicit params: SchdBlockParams, p: Parameters) 273730cfbc0SXuan Hu extends SchedulerImpBase(wrapper) 274730cfbc0SXuan Hu with HasXSParameter 275730cfbc0SXuan Hu{ 276730cfbc0SXuan Hu println(s"[SchedulerMemImp] " + 277730cfbc0SXuan Hu s"has intBusyTable: ${intBusyTable.nonEmpty}, " + 278730cfbc0SXuan Hu s"has vfBusyTable: ${vfBusyTable.nonEmpty}") 279730cfbc0SXuan Hu 280730cfbc0SXuan Hu val memAddrIQs = issueQueues.filter(iq => iq.params.StdCnt == 0) 281730cfbc0SXuan Hu val stAddrIQs = issueQueues.filter(iq => iq.params.StaCnt > 0) // included in memAddrIQs 2827b753bebSXuan Hu val ldAddrIQs = issueQueues.filter(iq => iq.params.LduCnt > 0) 283730cfbc0SXuan Hu val stDataIQs = issueQueues.filter(iq => iq.params.StdCnt > 0) 284730cfbc0SXuan Hu require(memAddrIQs.nonEmpty && stDataIQs.nonEmpty) 285730cfbc0SXuan Hu 286730cfbc0SXuan Hu issueQueues.zipWithIndex.foreach { case (iq, i) => 287730cfbc0SXuan Hu iq.io.deqResp.zipWithIndex.foreach { case (deqResp, j) => 288ea0f92d8Sczw deqResp.valid := iq.io.deq(j).valid && io.toDataPath(i)(j).ready 289ea0f92d8Sczw deqResp.bits.respType := RSFeedbackType.issueSuccess 2905db4956bSzhanglyGit deqResp.bits.robIdx := iq.io.deq(j).bits.common.robIdx 2918d29ec32Sczw deqResp.bits.rfWen := iq.io.deq(j).bits.common.rfWen.getOrElse(false.B) 2928d29ec32Sczw deqResp.bits.fuType := iq.io.deq(j).bits.common.fuType 2938d29ec32Sczw 294730cfbc0SXuan Hu } 295730cfbc0SXuan Hu iq.io.og0Resp.zipWithIndex.foreach { case (og0Resp, j) => 296730cfbc0SXuan Hu og0Resp.valid := io.fromDataPath(i)(j).og0resp.valid 297730cfbc0SXuan Hu og0Resp.bits.respType := io.fromDataPath(i)(j).og0resp.bits.respType 2985db4956bSzhanglyGit og0Resp.bits.robIdx := io.fromDataPath(i)(j).og0resp.bits.robIdx 2998d29ec32Sczw og0Resp.bits.rfWen := io.fromDataPath(i)(j).og0resp.bits.rfWen 3008d29ec32Sczw og0Resp.bits.fuType := io.fromDataPath(i)(j).og0resp.bits.fuType 3018d29ec32Sczw 302730cfbc0SXuan Hu } 303730cfbc0SXuan Hu iq.io.og1Resp.zipWithIndex.foreach { case (og1Resp, j) => 304730cfbc0SXuan Hu og1Resp.valid := io.fromDataPath(i)(j).og1resp.valid 305730cfbc0SXuan Hu og1Resp.bits.respType := io.fromDataPath(i)(j).og1resp.bits.respType 3065db4956bSzhanglyGit og1Resp.bits.robIdx := io.fromDataPath(i)(j).og1resp.bits.robIdx 3078d29ec32Sczw og1Resp.bits.rfWen := io.fromDataPath(i)(j).og1resp.bits.rfWen 3088d29ec32Sczw og1Resp.bits.fuType := io.fromDataPath(i)(j).og1resp.bits.fuType 3098d29ec32Sczw 310730cfbc0SXuan Hu } 3110f55a0d3SHaojin Tang iq.io.finalIssueResp.foreach(_.zipWithIndex.foreach { case (finalIssueResp, j) => 3120f55a0d3SHaojin Tang finalIssueResp := io.loadFinalIssueResp(i)(j) 3130f55a0d3SHaojin Tang }) 3142e0a7dc5Sfdy iq.io.wbBusyTableRead := io.fromWbFuBusyTable.fuBusyTableRead(i) 315dd970561SzhanglyGit io.wbFuBusyTable(i) := iq.io.wbBusyTableWrite 316730cfbc0SXuan Hu } 317730cfbc0SXuan Hu 318730cfbc0SXuan Hu memAddrIQs.zipWithIndex.foreach { case (iq, i) => 319730cfbc0SXuan Hu iq.io.flush <> io.fromCtrlBlock.flush 320730cfbc0SXuan Hu iq.io.enq <> dispatch2Iq.io.out(i) 321bf35baadSXuan Hu iq.io.wakeupFromWB := wakeupFromWBVec 322730cfbc0SXuan Hu } 323730cfbc0SXuan Hu 3247b753bebSXuan Hu ldAddrIQs.foreach { 325de784418SXuan Hu case imp: IssueQueueMemAddrImp => 326de784418SXuan Hu imp.io.memIO.get.feedbackIO <> io.fromMem.get.ldaFeedback 327de784418SXuan Hu imp.io.memIO.get.checkWait.memWaitUpdateReq := io.fromMem.get.memWaitUpdateReq 3287b753bebSXuan Hu case _ => 3297b753bebSXuan Hu } 3307b753bebSXuan Hu 3317b753bebSXuan Hu stAddrIQs.foreach { 3327b753bebSXuan Hu case imp: IssueQueueMemAddrImp => imp.io.memIO.get.feedbackIO <> io.fromMem.get.staFeedback 3337b753bebSXuan Hu case _ => 3347b753bebSXuan Hu } 335730cfbc0SXuan Hu 3369b258a00Sxgkiri private val staIdxSeq = issueQueues.filter(iq => iq.params.StaCnt > 0).map(iq => iq.params.idxInSchBlk) 3379b258a00Sxgkiri 3389b258a00Sxgkiri for ((idxInSchBlk, i) <- staIdxSeq.zipWithIndex) { 3399b258a00Sxgkiri dispatch2Iq.io.out(idxInSchBlk).zip(stAddrIQs(i).io.enq).zip(stDataIQs(i).io.enq).foreach{ case((di, staIQ), stdIQ) => 340730cfbc0SXuan Hu val isAllReady = staIQ.ready && stdIQ.ready 341730cfbc0SXuan Hu di.ready := isAllReady 342730cfbc0SXuan Hu staIQ.valid := di.valid && isAllReady 343730cfbc0SXuan Hu stdIQ.valid := di.valid && isAllReady 344730cfbc0SXuan Hu } 3459b258a00Sxgkiri } 346730cfbc0SXuan Hu 347730cfbc0SXuan Hu require(stAddrIQs.size == stDataIQs.size, s"number of store address IQs(${stAddrIQs.size}) " + 348730cfbc0SXuan Hu s"should be equal to number of data IQs(${stDataIQs})") 349730cfbc0SXuan Hu stDataIQs.zip(stAddrIQs).zipWithIndex.foreach { case ((stdIQ, staIQ), i) => 350730cfbc0SXuan Hu stdIQ.io.flush <> io.fromCtrlBlock.flush 351730cfbc0SXuan Hu 352730cfbc0SXuan Hu stdIQ.io.enq.zip(staIQ.io.enq).foreach { case (stdIQEnq, staIQEnq) => 353730cfbc0SXuan Hu stdIQEnq.bits := staIQEnq.bits 354730cfbc0SXuan Hu // Store data reuses store addr src(1) in dispatch2iq 355730cfbc0SXuan Hu // [dispatch2iq] --src*------src*(0)--> [staIQ] 356730cfbc0SXuan Hu // \ 357730cfbc0SXuan Hu // ---src*(1)--> [stdIQ] 358730cfbc0SXuan Hu // Since the src(1) of sta is easier to get, stdIQEnq.bits.src*(0) is assigned to staIQEnq.bits.src*(1) 359730cfbc0SXuan Hu // instead of dispatch2Iq.io.out(x).bits.src*(1) 360730cfbc0SXuan Hu stdIQEnq.bits.srcState(0) := staIQEnq.bits.srcState(1) 361730cfbc0SXuan Hu stdIQEnq.bits.srcType(0) := staIQEnq.bits.srcType(1) 362bc7d6943SzhanglyGit stdIQEnq.bits.dataSource(0) := staIQEnq.bits.dataSource(1) 363bc7d6943SzhanglyGit stdIQEnq.bits.l1ExuOH(0) := staIQEnq.bits.l1ExuOH(1) 364730cfbc0SXuan Hu stdIQEnq.bits.psrc(0) := staIQEnq.bits.psrc(1) 365730cfbc0SXuan Hu stdIQEnq.bits.sqIdx := staIQEnq.bits.sqIdx 366730cfbc0SXuan Hu } 367bf35baadSXuan Hu stdIQ.io.wakeupFromWB := wakeupFromWBVec 368730cfbc0SXuan Hu } 369730cfbc0SXuan Hu 370730cfbc0SXuan Hu val lsqEnqCtrl = Module(new LsqEnqCtrl) 371730cfbc0SXuan Hu 372730cfbc0SXuan Hu lsqEnqCtrl.io.redirect <> io.fromCtrlBlock.flush 373730cfbc0SXuan Hu lsqEnqCtrl.io.enq <> dispatch2Iq.io.enqLsqIO.get 374730cfbc0SXuan Hu lsqEnqCtrl.io.lcommit := io.fromMem.get.lcommit 375730cfbc0SXuan Hu lsqEnqCtrl.io.scommit := io.fromMem.get.scommit 376730cfbc0SXuan Hu lsqEnqCtrl.io.lqCancelCnt := io.fromMem.get.lqCancelCnt 377730cfbc0SXuan Hu lsqEnqCtrl.io.sqCancelCnt := io.fromMem.get.sqCancelCnt 378730cfbc0SXuan Hu io.memIO.get.lsqEnqIO <> lsqEnqCtrl.io.enqLsq 379730cfbc0SXuan Hu} 380