15db4956bSzhanglyGitpackage xiangshan.backend.issue 25db4956bSzhanglyGit 383ba63b3SXuan Huimport org.chipsalliance.cde.config.Parameters 45db4956bSzhanglyGitimport chisel3._ 55db4956bSzhanglyGitimport chisel3.util._ 65db4956bSzhanglyGitimport utility.HasCircularQueuePtrHelper 7a6938b17Ssinsanctionimport utils._ 8*4fa640e4Ssinsanctionimport utility._ 95db4956bSzhanglyGitimport xiangshan._ 105db4956bSzhanglyGitimport xiangshan.backend.Bundles._ 115db4956bSzhanglyGitimport xiangshan.backend.datapath.DataConfig.VAddrData 125db4956bSzhanglyGitimport xiangshan.backend.datapath.DataSource 135db4956bSzhanglyGitimport xiangshan.backend.fu.FuType 145db4956bSzhanglyGitimport xiangshan.backend.fu.vector.Utils.NOnes 155db4956bSzhanglyGitimport xiangshan.backend.rob.RobPtr 16aa2bcc31SzhanglyGitimport xiangshan.mem.{LqPtr, MemWaitUpdateReq, SqPtr} 17aa2bcc31SzhanglyGitimport xiangshan.backend.issue.EntryBundles._ 185db4956bSzhanglyGit 195db4956bSzhanglyGitclass Entries(implicit p: Parameters, params: IssueBlockParams) extends XSModule { 200721d1aaSXuan Hu override def desiredName: String = params.getEntryName 210721d1aaSXuan Hu 2227811ea4SXuan Hu require(params.numEnq <= 2, "number of enq should be no more than 2") 2327811ea4SXuan Hu 245db4956bSzhanglyGit private val EnqEntryNum = params.numEnq 255db4956bSzhanglyGit private val OthersEntryNum = params.numEntries - params.numEnq 2628607074Ssinsanction private val SimpEntryNum = params.numSimp 2728607074Ssinsanction private val CompEntryNum = params.numComp 285db4956bSzhanglyGit val io = IO(new EntriesIO) 295db4956bSzhanglyGit 30c838dea1SXuan Hu // only memAddrIQ use it 31c838dea1SXuan Hu val memEtyResps: MixedVec[ValidIO[EntryDeqRespBundle]] = { 32d3372210SzhanglyGit if (params.isLdAddrIQ && !params.isStAddrIQ) //LDU 33e07131b2Ssinsanction MixedVecInit(io.og0Resp ++ io.og1Resp ++ io.fromLoad.get.finalIssueResp ++ io.fromLoad.get.memAddrIssueResp) 34d3372210SzhanglyGit else if (params.isLdAddrIQ && params.isStAddrIQ || params.isHyAddrIQ) //HYU 35e07131b2Ssinsanction MixedVecInit(io.og0Resp ++ io.og1Resp ++ io.fromLoad.get.finalIssueResp ++ io.fromLoad.get.memAddrIssueResp ++ io.fromMem.get.fastResp ++ io.fromMem.get.slowResp) 36e07131b2Ssinsanction else if (params.isMemAddrIQ) //STU, VLDU, VSTU 376462eb1cSzhanglyGit MixedVecInit(io.og0Resp ++ io.og1Resp ++ io.fromMem.get.slowResp) 38c838dea1SXuan Hu else MixedVecInit(Seq()) 39c838dea1SXuan Hu } 40c838dea1SXuan Hu 41c38df446SzhanglyGit val resps: Vec[Vec[ValidIO[EntryDeqRespBundle]]] = { 42c38df446SzhanglyGit if (params.inVfSchd) 43c38df446SzhanglyGit VecInit(io.og0Resp, io.og1Resp, io.og2Resp.get, 0.U.asTypeOf(io.og0Resp)) 44c38df446SzhanglyGit else 45c38df446SzhanglyGit VecInit(io.og0Resp, io.og1Resp, 0.U.asTypeOf(io.og0Resp), 0.U.asTypeOf(io.og0Resp)) 46c38df446SzhanglyGit } 475db4956bSzhanglyGit 485db4956bSzhanglyGit //Module 49df26db8aSsinsanction val enqEntries = Seq.fill(EnqEntryNum)(Module(EnqEntry(isComp = true)(p, params))) 5028607074Ssinsanction val othersEntriesSimp = Seq.fill(SimpEntryNum)(Module(OthersEntry(isComp = false)(p, params))) 5128607074Ssinsanction val othersEntriesComp = Seq.fill(CompEntryNum)(Module(OthersEntry(isComp = true)(p, params))) 5228607074Ssinsanction val othersEntries = othersEntriesSimp ++ othersEntriesComp 5328607074Ssinsanction val othersTransPolicy = OptionWrapper(params.isAllComp || params.isAllSimp, Module(new EnqPolicy)) 5428607074Ssinsanction val simpTransPolicy = OptionWrapper(params.hasCompAndSimp, Module(new EnqPolicy)) 5528607074Ssinsanction val compTransPolicy = OptionWrapper(params.hasCompAndSimp, Module(new EnqPolicy)) 565db4956bSzhanglyGit 575db4956bSzhanglyGit //Wire 58aa2bcc31SzhanglyGit //entries status 595db4956bSzhanglyGit val entries = Wire(Vec(params.numEntries, ValidIO(new EntryBundle))) 60aa2bcc31SzhanglyGit val robIdxVec = Wire(Vec(params.numEntries, new RobPtr)) 615db4956bSzhanglyGit val validVec = Wire(Vec(params.numEntries, Bool())) 625db4956bSzhanglyGit val canIssueVec = Wire(Vec(params.numEntries, Bool())) 635db4956bSzhanglyGit val fuTypeVec = Wire(Vec(params.numEntries, FuType())) 645db4956bSzhanglyGit val isFirstIssueVec = Wire(Vec(params.numEntries, Bool())) 655db4956bSzhanglyGit val issueTimerVec = Wire(Vec(params.numEntries, UInt(2.W))) 6699944b79Ssinsanction val uopIdxVec = OptionWrapper(params.isVecMemIQ, Wire(Vec(params.numEntries, UopIdx()))) 67aa2bcc31SzhanglyGit //src status 68aa2bcc31SzhanglyGit val dataSourceVec = Wire(Vec(params.numEntries, Vec(params.numRegSrc, DataSource()))) 69eea4a3caSzhanglyGit val loadDependencyVec = Wire(Vec(params.numEntries, Vec(LoadPipelineWidth, UInt(3.W)))) 70eea4a3caSzhanglyGit val srcLoadDependencyVec= Wire(Vec(params.numEntries, Vec(params.numRegSrc, Vec(LoadPipelineWidth, UInt(3.W))))) 71aa2bcc31SzhanglyGit val srcWakeUpL1ExuOHVec = OptionWrapper(params.hasIQWakeUp, Wire(Vec(params.numEntries, Vec(params.numRegSrc, ExuVec())))) 72aa2bcc31SzhanglyGit //deq sel 73aa2bcc31SzhanglyGit val deqSelVec = Wire(Vec(params.numEntries, Bool())) 74aa2bcc31SzhanglyGit val issueRespVec = Wire(Vec(params.numEntries, ValidIO(new EntryDeqRespBundle))) 755db4956bSzhanglyGit val deqPortIdxWriteVec = Wire(Vec(params.numEntries, UInt(1.W))) 765db4956bSzhanglyGit val deqPortIdxReadVec = Wire(Vec(params.numEntries, UInt(1.W))) 77aa2bcc31SzhanglyGit //trans sel 7828607074Ssinsanction val othersEntryEnqReadyVec = Wire(Vec(OthersEntryNum, Bool())) 7928607074Ssinsanction val othersEntryEnqVec = Wire(Vec(OthersEntryNum, Valid(new EntryBundle))) 8028607074Ssinsanction val enqEntryTransVec = Wire(Vec(EnqEntryNum, Valid(new EntryBundle))) 8128607074Ssinsanction val simpEntryTransVec = OptionWrapper(params.hasCompAndSimp, Wire(Vec(SimpEntryNum, Valid(new EntryBundle)))) 8228607074Ssinsanction val compEnqVec = OptionWrapper(params.hasCompAndSimp, Wire(Vec(EnqEntryNum, Valid(new EntryBundle)))) 8328607074Ssinsanction 8428607074Ssinsanction val enqCanTrans2Simp = OptionWrapper(params.hasCompAndSimp, Wire(Bool())) 8528607074Ssinsanction val enqCanTrans2Comp = OptionWrapper(params.hasCompAndSimp, Wire(Bool())) 8628607074Ssinsanction val simpCanTrans2Comp = OptionWrapper(params.hasCompAndSimp, Wire(Vec(EnqEntryNum, Bool()))) 8728607074Ssinsanction val simpTransSelVec = OptionWrapper(params.hasCompAndSimp, Wire(Vec(EnqEntryNum, Valid(UInt(SimpEntryNum.W))))) 8828607074Ssinsanction val compTransSelVec = OptionWrapper(params.hasCompAndSimp, Wire(Vec(EnqEntryNum, Valid(UInt(CompEntryNum.W))))) 8928607074Ssinsanction val finalSimpTransSelVec = OptionWrapper(params.hasCompAndSimp, Wire(Vec(EnqEntryNum, UInt(SimpEntryNum.W)))) 9028607074Ssinsanction val finalCompTransSelVec = OptionWrapper(params.hasCompAndSimp, Wire(Vec(EnqEntryNum, UInt(CompEntryNum.W)))) 9128607074Ssinsanction 9228607074Ssinsanction val enqCanTrans2Others = OptionWrapper(params.isAllComp || params.isAllSimp, Wire(Bool())) 9328607074Ssinsanction val othersTransSelVec = OptionWrapper(params.isAllComp || params.isAllSimp, Wire(Vec(EnqEntryNum, Valid(UInt(OthersEntryNum.W))))) 9428607074Ssinsanction val finalOthersTransSelVec = OptionWrapper(params.isAllComp || params.isAllSimp, Wire(Vec(EnqEntryNum, UInt(OthersEntryNum.W)))) 9528607074Ssinsanction 9628607074Ssinsanction val simpEntryEnqReadyVec = othersEntryEnqReadyVec.take(SimpEntryNum) 9728607074Ssinsanction val compEntryEnqReadyVec = othersEntryEnqReadyVec.takeRight(CompEntryNum) 9828607074Ssinsanction val simpEntryEnqVec = othersEntryEnqVec.take(SimpEntryNum) 9928607074Ssinsanction val compEntryEnqVec = othersEntryEnqVec.takeRight(CompEntryNum) 100aa2bcc31SzhanglyGit //debug 101a6938b17Ssinsanction val entryInValidVec = Wire(Vec(params.numEntries, Bool())) 102a6938b17Ssinsanction val entryOutDeqValidVec = Wire(Vec(params.numEntries, Bool())) 103a6938b17Ssinsanction val entryOutTransValidVec = Wire(Vec(params.numEntries, Bool())) 104e3ef3537Ssinsanction val perfLdCancelVec = OptionWrapper(params.hasIQWakeUp, Wire(Vec(params.numEntries, Vec(params.numRegSrc, Bool())))) 105e3ef3537Ssinsanction val perfOg0CancelVec = OptionWrapper(params.hasIQWakeUp, Wire(Vec(params.numEntries, Vec(params.numRegSrc, Bool())))) 106e3ef3537Ssinsanction val perfWakeupByWBVec = Wire(Vec(params.numEntries, Vec(params.numRegSrc, Bool()))) 107e3ef3537Ssinsanction val perfWakeupByIQVec = OptionWrapper(params.hasIQWakeUp, Wire(Vec(params.numEntries, Vec(params.numRegSrc, Vec(params.numWakeupFromIQ, Bool()))))) 108a4d38a63SzhanglyGit //cancel bypass 109eea4a3caSzhanglyGit val cancelBypassVec = Wire(Vec(params.numEntries, Bool())) 1105db4956bSzhanglyGit 1115db4956bSzhanglyGit 1125db4956bSzhanglyGit //enqEntries 1135db4956bSzhanglyGit enqEntries.zipWithIndex.foreach { case (enqEntry, entryIdx) => 114aa2bcc31SzhanglyGit enqEntry.io.commonIn.enq := io.enq(entryIdx) 11528607074Ssinsanction enqEntry.io.commonIn.transSel := (if (params.isAllComp || params.isAllSimp) enqCanTrans2Others.get && othersTransSelVec.get(entryIdx).valid 11628607074Ssinsanction else enqCanTrans2Simp.get && simpTransSelVec.get(entryIdx).valid || enqCanTrans2Comp.get && compTransSelVec.get(entryIdx).valid) 117aa2bcc31SzhanglyGit EntriesConnect(enqEntry.io.commonIn, enqEntry.io.commonOut, entryIdx) 118*4fa640e4Ssinsanction enqEntry.io.enqDelayIn1.wakeUpFromWB := RegEnable(io.wakeUpFromWB, io.enq(entryIdx).valid) 119*4fa640e4Ssinsanction enqEntry.io.enqDelayIn1.wakeUpFromIQ := RegEnable(io.wakeUpFromIQ, io.enq(entryIdx).valid) 120*4fa640e4Ssinsanction enqEntry.io.enqDelayIn1.og0Cancel := RegNext(io.og0Cancel.asUInt) 121*4fa640e4Ssinsanction enqEntry.io.enqDelayIn1.ldCancel := RegNext(io.ldCancel) 122*4fa640e4Ssinsanction // note: these signals with 2 cycle delay should not be enabled by io.enq.valid 123*4fa640e4Ssinsanction enqEntry.io.enqDelayIn2.wakeUpFromWB := DelayN(io.wakeUpFromWB, 2) 124*4fa640e4Ssinsanction enqEntry.io.enqDelayIn2.wakeUpFromIQ := DelayN(io.wakeUpFromIQ, 2) 125*4fa640e4Ssinsanction enqEntry.io.enqDelayIn2.og0Cancel := DelayN(io.og0Cancel.asUInt, 2) 126*4fa640e4Ssinsanction enqEntry.io.enqDelayIn2.ldCancel := DelayN(io.ldCancel, 2) 12728607074Ssinsanction enqEntryTransVec(entryIdx) := enqEntry.io.commonOut.transEntry 1285db4956bSzhanglyGit } 1295db4956bSzhanglyGit //othersEntries 1305db4956bSzhanglyGit othersEntries.zipWithIndex.foreach { case (othersEntry, entryIdx) => 13128607074Ssinsanction othersEntry.io.commonIn.enq := othersEntryEnqVec(entryIdx) 13228607074Ssinsanction othersEntry.io.commonIn.transSel := (if (params.hasCompAndSimp && (entryIdx < SimpEntryNum)) 13328607074Ssinsanction io.simpEntryDeqSelVec.get.zip(simpCanTrans2Comp.get).map(x => x._1(entryIdx) && x._2).reduce(_ | _) 13428607074Ssinsanction else false.B) 135aa2bcc31SzhanglyGit EntriesConnect(othersEntry.io.commonIn, othersEntry.io.commonOut, entryIdx + EnqEntryNum) 13628607074Ssinsanction othersEntryEnqReadyVec(entryIdx) := othersEntry.io.commonOut.enqReady 13728607074Ssinsanction if (params.hasCompAndSimp && (entryIdx < SimpEntryNum)) { 13828607074Ssinsanction simpEntryTransVec.get(entryIdx) := othersEntry.io.commonOut.transEntry 13928607074Ssinsanction } 1405db4956bSzhanglyGit } 1415db4956bSzhanglyGit 1425db4956bSzhanglyGit 1435db4956bSzhanglyGit deqSelVec.zip(deqPortIdxWriteVec).zipWithIndex.foreach { case ((deqSel, deqPortIdxWrite), i) => 144aa2bcc31SzhanglyGit val deqVec = io.deqSelOH.zip(io.deqReady).map(x => x._1.valid && x._1.bits(i) && x._2) 1455db4956bSzhanglyGit deqPortIdxWrite := OHToUInt(deqVec) 1465db4956bSzhanglyGit deqSel := deqVec.reduce(_ | _) 1475db4956bSzhanglyGit } 1485db4956bSzhanglyGit 1495db4956bSzhanglyGit 15028607074Ssinsanction if (params.isAllComp || params.isAllSimp) { 1515db4956bSzhanglyGit //transPolicy 15228607074Ssinsanction othersTransPolicy.get.io.canEnq := othersEntryEnqReadyVec.asUInt 153b43488b9Ssinsanction 154b43488b9Ssinsanction // we only allow all or none of the enq entries transfering to others entries. 15528607074Ssinsanction enqCanTrans2Others.get := PopCount(validVec.take(EnqEntryNum)) <= PopCount(othersEntryEnqReadyVec) 156b43488b9Ssinsanction // othersTransSelVec(i) is the target others entry for enq entry [i]. 157b43488b9Ssinsanction // note that dispatch does not guarantee the validity of enq entries with low index. 158b43488b9Ssinsanction // that means in some cases enq entry [0] is invalid while enq entry [1] is valid. 159b43488b9Ssinsanction // in this case, enq entry [1] should use result [0] of TransPolicy. 16028607074Ssinsanction othersTransSelVec.get(0).valid := othersTransPolicy.get.io.enqSelOHVec(0).valid && validVec(0) 16128607074Ssinsanction othersTransSelVec.get(0).bits := othersTransPolicy.get.io.enqSelOHVec(0).bits 1628321ef33Ssinsanction if (params.numEnq == 2) { 16328607074Ssinsanction othersTransSelVec.get(1).valid := Mux(!validVec(0), othersTransPolicy.get.io.enqSelOHVec(0).valid, othersTransPolicy.get.io.enqSelOHVec(1).valid) 16428607074Ssinsanction othersTransSelVec.get(1).bits := Mux(!validVec(0), othersTransPolicy.get.io.enqSelOHVec(0).bits, othersTransPolicy.get.io.enqSelOHVec(1).bits) 1658321ef33Ssinsanction } 1668321ef33Ssinsanction 16728607074Ssinsanction finalOthersTransSelVec.get.zip(othersTransSelVec.get).zipWithIndex.foreach { case ((finalOH, selOH), enqIdx) => 16828607074Ssinsanction finalOH := Fill(OthersEntryNum, enqCanTrans2Others.get && selOH.valid) & selOH.bits 1695db4956bSzhanglyGit } 1705db4956bSzhanglyGit 17128607074Ssinsanction //othersEntryEnq 17228607074Ssinsanction othersEntryEnqVec.zipWithIndex.foreach { case (othersEntryEnq, othersIdx) => 17328607074Ssinsanction val othersEnqOH = finalOthersTransSelVec.get.map(_(othersIdx)) 17428607074Ssinsanction if (othersEnqOH.size == 1) 17528607074Ssinsanction othersEntryEnq := Mux(othersEnqOH.head, enqEntryTransVec.head, 0.U.asTypeOf(enqEntryTransVec.head)) 17628607074Ssinsanction else 17728607074Ssinsanction othersEntryEnq := Mux1H(othersEnqOH, enqEntryTransVec) 1785db4956bSzhanglyGit } 17928607074Ssinsanction } 18028607074Ssinsanction else { 18128607074Ssinsanction //transPolicy 18228607074Ssinsanction simpTransPolicy.get.io.canEnq := VecInit(simpEntryEnqReadyVec).asUInt 18328607074Ssinsanction compTransPolicy.get.io.canEnq := VecInit(validVec.takeRight(CompEntryNum).map(!_)).asUInt 18428607074Ssinsanction 185b43488b9Ssinsanction // we only allow all or none of the enq entries transfering to comp/simp entries. 186b43488b9Ssinsanction // when all of simp entries are empty and comp entries are enough, transfer to comp entries. 187b43488b9Ssinsanction // otherwise, transfer to simp entries. 18828607074Ssinsanction enqCanTrans2Comp.get := PopCount(validVec.take(EnqEntryNum)) <= PopCount(validVec.takeRight(CompEntryNum).map(!_)) && !validVec.drop(EnqEntryNum).take(SimpEntryNum).reduce(_ || _) 18928607074Ssinsanction enqCanTrans2Simp.get := !enqCanTrans2Comp.get && PopCount(validVec.take(EnqEntryNum)) <= PopCount(simpEntryEnqReadyVec) 19028607074Ssinsanction simpCanTrans2Comp.get.zipWithIndex.foreach { case (canTrans, idx) => 19128607074Ssinsanction canTrans := !enqCanTrans2Comp.get && PopCount(validVec.takeRight(CompEntryNum).map(!_)) >= (idx + 1).U 19228607074Ssinsanction } 19328607074Ssinsanction 194b43488b9Ssinsanction // simp/compTransSelVec(i) is the target simp/comp entry for enq entry [i]. 195b43488b9Ssinsanction // note that dispatch does not guarantee the validity of enq entries with low index. 196b43488b9Ssinsanction // that means in some cases enq entry [0] is invalid while enq entry [1] is valid. 197b43488b9Ssinsanction // in this case, enq entry [1] should use result [0] of TransPolicy. 19828607074Ssinsanction simpTransSelVec.get(0).valid := simpTransPolicy.get.io.enqSelOHVec(0).valid && validVec(0) 19928607074Ssinsanction simpTransSelVec.get(0).bits := simpTransPolicy.get.io.enqSelOHVec(0).bits 20028607074Ssinsanction compTransSelVec.get(0).valid := compTransPolicy.get.io.enqSelOHVec(0).valid && validVec(0) 20128607074Ssinsanction compTransSelVec.get(0).bits := compTransPolicy.get.io.enqSelOHVec(0).bits 20228607074Ssinsanction if (params.numEnq == 2) { 20328607074Ssinsanction simpTransSelVec.get(1).valid := Mux(!validVec(0), simpTransPolicy.get.io.enqSelOHVec(0).valid, simpTransPolicy.get.io.enqSelOHVec(1).valid) 20428607074Ssinsanction simpTransSelVec.get(1).bits := Mux(!validVec(0), simpTransPolicy.get.io.enqSelOHVec(0).bits, simpTransPolicy.get.io.enqSelOHVec(1).bits) 20528607074Ssinsanction compTransSelVec.get(1).valid := Mux(!validVec(0), compTransPolicy.get.io.enqSelOHVec(0).valid, compTransPolicy.get.io.enqSelOHVec(1).valid) 20628607074Ssinsanction compTransSelVec.get(1).bits := Mux(!validVec(0), compTransPolicy.get.io.enqSelOHVec(0).bits, compTransPolicy.get.io.enqSelOHVec(1).bits) 20728607074Ssinsanction } 20828607074Ssinsanction 20928607074Ssinsanction finalSimpTransSelVec.get.zip(simpTransSelVec.get).zipWithIndex.foreach { case ((finalOH, selOH), enqIdx) => 21028607074Ssinsanction finalOH := Fill(SimpEntryNum, enqCanTrans2Simp.get && selOH.valid) & selOH.bits 21128607074Ssinsanction } 21228607074Ssinsanction finalCompTransSelVec.get.zip(compTransSelVec.get).zip(compTransPolicy.get.io.enqSelOHVec).zipWithIndex.foreach { 21328607074Ssinsanction case (((finalOH, selOH), origSelOH), enqIdx) => 21428607074Ssinsanction finalOH := Mux(enqCanTrans2Comp.get, Fill(CompEntryNum, selOH.valid) & selOH.bits, Fill(CompEntryNum, origSelOH.valid) & origSelOH.bits) 21528607074Ssinsanction } 21628607074Ssinsanction 21728607074Ssinsanction //othersEntryEnq 21828607074Ssinsanction simpEntryEnqVec.zipWithIndex.foreach { case (simpEntryEnq, simpIdx) => 21928607074Ssinsanction val simpEnqOH = finalSimpTransSelVec.get.map(_(simpIdx)) 22028607074Ssinsanction // shit Mux1H directly returns in(0) if the seq has only 1 elements 22128607074Ssinsanction if (simpEnqOH.size == 1) 22228607074Ssinsanction simpEntryEnq := Mux(simpEnqOH.head, enqEntryTransVec.head, 0.U.asTypeOf(enqEntryTransVec.head)) 22328607074Ssinsanction else 22428607074Ssinsanction simpEntryEnq := Mux1H(simpEnqOH, enqEntryTransVec) 22528607074Ssinsanction } 22628607074Ssinsanction 22728607074Ssinsanction compEnqVec.get.zip(enqEntryTransVec).zip(io.simpEntryDeqSelVec.get).foreach { case ((compEnq, enqEntry), deqSel) => 22828607074Ssinsanction compEnq := Mux(enqCanTrans2Comp.get, enqEntry, Mux1H(deqSel, simpEntryTransVec.get)) 22928607074Ssinsanction } 23028607074Ssinsanction compEntryEnqVec.zipWithIndex.foreach { case (compEntryEnq, compIdx) => 23128607074Ssinsanction val compEnqOH = finalCompTransSelVec.get.map(_(compIdx)) 23228607074Ssinsanction // shit Mux1H directly returns in(0) if the seq has only 1 elements 23328607074Ssinsanction if (compEnqOH.size == 1) 23428607074Ssinsanction compEntryEnq := Mux(compEnqOH.head, compEnqVec.get.head, 0.U.asTypeOf(compEnqVec.get.head)) 23528607074Ssinsanction else 23628607074Ssinsanction compEntryEnq := Mux1H(compEnqOH, compEnqVec.get) 23728607074Ssinsanction } 23828607074Ssinsanction 23928607074Ssinsanction assert(PopCount(simpEntryEnqVec.map(_.valid)) <= params.numEnq.U, "the number of simpEntryEnq is more than numEnq\n") 24028607074Ssinsanction assert(PopCount(compEntryEnqVec.map(_.valid)) <= params.numEnq.U, "the number of compEntryEnq is more than numEnq\n") 24128607074Ssinsanction } 24228607074Ssinsanction 2438d081717Sszw_kaixin if(backendParams.debugEn) { 24428607074Ssinsanction dontTouch(othersEntryEnqVec) 2458d081717Sszw_kaixin } 2465db4956bSzhanglyGit 2475db4956bSzhanglyGit //issueRespVec 248887f9c3dSzhanglinjuan if (params.isVecMemIQ) { 249887f9c3dSzhanglinjuan // vector memory IQ 250887f9c3dSzhanglinjuan issueRespVec.zip(robIdxVec).zip(uopIdxVec.get).foreach { case ((issueResp, robIdx), uopIdx) => 251887f9c3dSzhanglinjuan val hitRespsVec = VecInit(resps.flatten.map(x => 252aa2bcc31SzhanglyGit x.valid && x.bits.robIdx === robIdx && x.bits.uopIdx.get === uopIdx 253887f9c3dSzhanglinjuan )) 254887f9c3dSzhanglinjuan issueResp.valid := hitRespsVec.reduce(_ | _) 255887f9c3dSzhanglinjuan issueResp.bits := Mux1H(hitRespsVec, resps.flatten.map(_.bits)) 256887f9c3dSzhanglinjuan } 257887f9c3dSzhanglinjuan } else if (params.isMemAddrIQ) { 258887f9c3dSzhanglinjuan // scalar memory IQ 2595db4956bSzhanglyGit issueRespVec.zip(robIdxVec).foreach { case (issueResp, robIdx) => 260c838dea1SXuan Hu val hitRespsVec = VecInit(memEtyResps.map(x => x.valid && (x.bits.robIdx === robIdx)).toSeq) 2615db4956bSzhanglyGit issueResp.valid := hitRespsVec.reduce(_ | _) 262c838dea1SXuan Hu issueResp.bits := Mux1H(hitRespsVec, memEtyResps.map(_.bits).toSeq) 2635db4956bSzhanglyGit } 2645db4956bSzhanglyGit } 2655db4956bSzhanglyGit else { 2665db4956bSzhanglyGit issueRespVec.zip(issueTimerVec).zip(deqPortIdxReadVec).foreach { case ((issueResp, issueTimer), deqPortIdx) => 2675db4956bSzhanglyGit val Resp = resps(issueTimer)(deqPortIdx) 2685db4956bSzhanglyGit issueResp := Resp 2695db4956bSzhanglyGit } 2705db4956bSzhanglyGit } 2715db4956bSzhanglyGit 27240283787Ssinsanction //deq 27328607074Ssinsanction val enqEntryOldest = Wire(Vec(params.numDeq, ValidIO(new EntryBundle))) 27428607074Ssinsanction val simpEntryOldest = OptionWrapper(params.hasCompAndSimp, Wire(Vec(params.numDeq, ValidIO(new EntryBundle)))) 27528607074Ssinsanction val compEntryOldest = OptionWrapper(params.hasCompAndSimp, Wire(Vec(params.numDeq, ValidIO(new EntryBundle)))) 27628607074Ssinsanction val othersEntryOldest = OptionWrapper(params.isAllComp || params.isAllSimp, Wire(Vec(params.numDeq, ValidIO(new EntryBundle)))) 27728607074Ssinsanction val enqEntryOldestCancel = Wire(Vec(params.numDeq, Bool())) 27828607074Ssinsanction val simpEntryOldestCancel = OptionWrapper(params.hasCompAndSimp, Wire(Vec(params.numDeq, Bool()))) 27928607074Ssinsanction val compEntryOldestCancel = OptionWrapper(params.hasCompAndSimp, Wire(Vec(params.numDeq, Bool()))) 28028607074Ssinsanction val othersEntryOldestCancel = OptionWrapper(params.isAllComp || params.isAllSimp, Wire(Vec(params.numDeq, Bool()))) 28128607074Ssinsanction 28228607074Ssinsanction io.enqEntryOldestSel.zipWithIndex.map { case (sel, deqIdx) => 28328607074Ssinsanction enqEntryOldest(deqIdx) := Mux1H(sel.bits, entries.take(EnqEntryNum)) 284eea4a3caSzhanglyGit enqEntryOldestCancel(deqIdx) := Mux1H(sel.bits, cancelBypassVec.take(EnqEntryNum)) 28540283787Ssinsanction } 28628607074Ssinsanction 28728607074Ssinsanction if (params.isAllComp || params.isAllSimp) { 28828607074Ssinsanction io.othersEntryOldestSel.get.zipWithIndex.map { case (sel, deqIdx) => 28928607074Ssinsanction othersEntryOldest.get(deqIdx) := Mux1H(sel.bits, entries.drop(EnqEntryNum)) 290eea4a3caSzhanglyGit othersEntryOldestCancel.get(deqIdx) := Mux1H(sel.bits, cancelBypassVec.drop(EnqEntryNum)) 291af4bd265SzhanglyGit } 29240283787Ssinsanction } 29328607074Ssinsanction else { 29428607074Ssinsanction io.simpEntryOldestSel.get.zipWithIndex.map { case (sel, deqIdx) => 29528607074Ssinsanction simpEntryOldest.get(deqIdx) := Mux1H(sel.bits, entries.drop(EnqEntryNum).take(SimpEntryNum)) 296eea4a3caSzhanglyGit simpEntryOldestCancel.get(deqIdx) := Mux1H(sel.bits, cancelBypassVec.drop(EnqEntryNum).take(SimpEntryNum)) 29728607074Ssinsanction } 29828607074Ssinsanction io.compEntryOldestSel.get.zipWithIndex.map { case (sel, deqIdx) => 29928607074Ssinsanction compEntryOldest.get(deqIdx) := Mux1H(sel.bits, entries.drop(EnqEntryNum).takeRight(CompEntryNum)) 300eea4a3caSzhanglyGit compEntryOldestCancel.get(deqIdx) := Mux1H(sel.bits, cancelBypassVec.drop(EnqEntryNum).takeRight(CompEntryNum)) 30128607074Ssinsanction } 302af4bd265SzhanglyGit } 303cf4a131aSsinsanction 304cf4a131aSsinsanction if (params.deqFuSame) { 305cf4a131aSsinsanction val subDeqPolicyEntryVec = Wire(Vec(params.numDeq, ValidIO(new EntryBundle))) 306cf4a131aSsinsanction val subDeqPolicyValidVec = Wire(Vec(params.numDeq, Bool())) 307a4d38a63SzhanglyGit val subDeqPolicyCancelBypassVec = Wire(Vec(params.numDeq, Bool())) 308cf4a131aSsinsanction 309aa2bcc31SzhanglyGit subDeqPolicyValidVec(0) := PopCount(io.subDeqRequest.get(0)) >= 1.U 310aa2bcc31SzhanglyGit subDeqPolicyValidVec(1) := PopCount(io.subDeqRequest.get(0)) >= 2.U 31128607074Ssinsanction 31228607074Ssinsanction if (params.isAllComp || params.isAllSimp) { 31328607074Ssinsanction subDeqPolicyEntryVec(0) := PriorityMux(io.subDeqRequest.get(0), entries) 31428607074Ssinsanction subDeqPolicyEntryVec(1) := PriorityMux(Reverse(io.subDeqRequest.get(0)), entries.reverse) 315eea4a3caSzhanglyGit subDeqPolicyCancelBypassVec(0) := PriorityMux(io.subDeqRequest.get(0), cancelBypassVec) 316eea4a3caSzhanglyGit subDeqPolicyCancelBypassVec(1) := PriorityMux(Reverse(io.subDeqRequest.get(0)), cancelBypassVec.reverse) 317cf4a131aSsinsanction 31828607074Ssinsanction io.deqEntry(0) := Mux(io.othersEntryOldestSel.get(0).valid, othersEntryOldest.get(0), subDeqPolicyEntryVec(1)) 319aa2bcc31SzhanglyGit io.deqEntry(1) := subDeqPolicyEntryVec(0) 32028607074Ssinsanction io.cancelDeqVec(0) := Mux(io.othersEntryOldestSel.get(0).valid, othersEntryOldestCancel.get(0), subDeqPolicyCancelBypassVec(1)) 321a4d38a63SzhanglyGit io.cancelDeqVec(1) := subDeqPolicyCancelBypassVec(0) 32228607074Ssinsanction } 32328607074Ssinsanction else { 32428607074Ssinsanction subDeqPolicyEntryVec(0) := PriorityMux(Reverse(io.subDeqRequest.get(0)), entries.reverse) 32528607074Ssinsanction subDeqPolicyEntryVec(1) := PriorityMux(io.subDeqRequest.get(0), entries) 326eea4a3caSzhanglyGit subDeqPolicyCancelBypassVec(0) := PriorityMux(Reverse(io.subDeqRequest.get(0)), cancelBypassVec.reverse) 327eea4a3caSzhanglyGit subDeqPolicyCancelBypassVec(1) := PriorityMux(io.subDeqRequest.get(0), cancelBypassVec) 32828607074Ssinsanction 32928607074Ssinsanction io.deqEntry(0) := Mux(io.compEntryOldestSel.get(0).valid, 33028607074Ssinsanction compEntryOldest.get(0), 33128607074Ssinsanction Mux(io.simpEntryOldestSel.get(0).valid, simpEntryOldest.get(0), subDeqPolicyEntryVec(1))) 33228607074Ssinsanction io.deqEntry(1) := subDeqPolicyEntryVec(0) 33328607074Ssinsanction io.cancelDeqVec(0) := Mux(io.compEntryOldestSel.get(0).valid, 33428607074Ssinsanction compEntryOldestCancel.get(0), 33528607074Ssinsanction Mux(io.simpEntryOldestSel.get(0).valid, simpEntryOldestCancel.get(0), subDeqPolicyCancelBypassVec(1))) 33628607074Ssinsanction io.cancelDeqVec(1) := subDeqPolicyCancelBypassVec(0) 33728607074Ssinsanction } 338cf4a131aSsinsanction 339cf4a131aSsinsanction when (subDeqPolicyValidVec(0)) { 340aa2bcc31SzhanglyGit assert(Mux1H(io.subDeqSelOH.get(0), entries).bits.status.robIdx === subDeqPolicyEntryVec(0).bits.status.robIdx, "subDeqSelOH(0) is not the same\n") 34140283787Ssinsanction } 342cf4a131aSsinsanction when (subDeqPolicyValidVec(1)) { 343aa2bcc31SzhanglyGit assert(Mux1H(io.subDeqSelOH.get(1), entries).bits.status.robIdx === subDeqPolicyEntryVec(1).bits.status.robIdx, "subDeqSelOH(1) is not the same\n") 344f7f73727Ssinsanction } 345f7f73727Ssinsanction } 346f7f73727Ssinsanction else { 34728607074Ssinsanction if (params.isAllComp || params.isAllSimp) { 34828607074Ssinsanction io.othersEntryOldestSel.get.zipWithIndex.foreach { case (sel, i) => 34928607074Ssinsanction io.deqEntry(i) := Mux(sel.valid, othersEntryOldest.get(i), enqEntryOldest(i)) 35028607074Ssinsanction io.cancelDeqVec(i) := Mux(sel.valid, othersEntryOldestCancel.get(i), enqEntryOldestCancel(i)) 35128607074Ssinsanction } 35228607074Ssinsanction } 35328607074Ssinsanction else { 35428607074Ssinsanction io.compEntryOldestSel.get.zip(io.simpEntryOldestSel.get).zipWithIndex.foreach { case ((compSel, simpSel), i) => 35528607074Ssinsanction io.deqEntry(i) := Mux(compSel.valid, 35628607074Ssinsanction compEntryOldest.get(i), 35728607074Ssinsanction Mux(simpSel.valid, simpEntryOldest.get(i), enqEntryOldest(i))) 35828607074Ssinsanction io.cancelDeqVec(i) := Mux(compSel.valid, 35928607074Ssinsanction compEntryOldestCancel.get(i), 36028607074Ssinsanction Mux(simpSel.valid, simpEntryOldestCancel.get(i), enqEntryOldestCancel(i))) 36128607074Ssinsanction } 362af4bd265SzhanglyGit } 363af4bd265SzhanglyGit } 364af4bd265SzhanglyGit 365eea4a3caSzhanglyGit cancelBypassVec.zip(srcLoadDependencyVec).foreach { case (cancelBypass, srcLoadDependency) => 366eea4a3caSzhanglyGit val cancelByLd = srcLoadDependency.map(x => LoadShouldCancel(Some(x), io.ldCancel)).reduce(_ | _) 367eea4a3caSzhanglyGit cancelBypass := cancelByLd 368eea4a3caSzhanglyGit } 36940283787Ssinsanction 3705db4956bSzhanglyGit io.valid := validVec.asUInt 3715db4956bSzhanglyGit io.canIssue := canIssueVec.asUInt 3725db4956bSzhanglyGit io.fuType := fuTypeVec 3735db4956bSzhanglyGit io.dataSources := dataSourceVec 374aa2bcc31SzhanglyGit io.srcWakeUpL1ExuOH.foreach(_ := srcWakeUpL1ExuOHVec.get.map(x => VecInit(x.map(_.asUInt)))) 375eea4a3caSzhanglyGit io.loadDependency := loadDependencyVec 376aa2bcc31SzhanglyGit io.isFirstIssue.zipWithIndex.foreach{ case (isFirstIssue, deqIdx) => 377aa2bcc31SzhanglyGit isFirstIssue := io.deqSelOH(deqIdx).valid && Mux1H(io.deqSelOH(deqIdx).bits, isFirstIssueVec) 3788d081717Sszw_kaixin } 37928607074Ssinsanction io.simpEntryEnqSelVec.foreach(_ := finalSimpTransSelVec.get.zip(enqEntryTransVec).map(x => x._1 & Fill(SimpEntryNum, x._2.valid))) 38028607074Ssinsanction io.compEntryEnqSelVec.foreach(_ := finalCompTransSelVec.get.zip(compEnqVec.get).map(x => x._1 & Fill(CompEntryNum, x._2.valid))) 38128607074Ssinsanction io.othersEntryEnqSelVec.foreach(_ := finalOthersTransSelVec.get.zip(enqEntryTransVec).map(x => x._1 & Fill(OthersEntryNum, x._2.valid))) 382aa2bcc31SzhanglyGit io.robIdx.foreach(_ := robIdxVec) 383aa2bcc31SzhanglyGit io.uopIdx.foreach(_ := uopIdxVec.get) 384aa2bcc31SzhanglyGit 385aa2bcc31SzhanglyGit def EntriesConnect(in: CommonInBundle, out: CommonOutBundle, entryIdx: Int) = { 386aa2bcc31SzhanglyGit in.flush := io.flush 387aa2bcc31SzhanglyGit in.wakeUpFromWB := io.wakeUpFromWB 388aa2bcc31SzhanglyGit in.wakeUpFromIQ := io.wakeUpFromIQ 389aa2bcc31SzhanglyGit in.og0Cancel := io.og0Cancel 390aa2bcc31SzhanglyGit in.og1Cancel := io.og1Cancel 391aa2bcc31SzhanglyGit in.ldCancel := io.ldCancel 392aa2bcc31SzhanglyGit in.deqSel := deqSelVec(entryIdx) 393aa2bcc31SzhanglyGit in.deqPortIdxWrite := deqPortIdxWriteVec(entryIdx) 394aa2bcc31SzhanglyGit in.issueResp := issueRespVec(entryIdx) 395aa2bcc31SzhanglyGit if (params.isVecMemIQ) { 396aa2bcc31SzhanglyGit in.fromLsq.get.sqDeqPtr := io.vecMemIn.get.sqDeqPtr 397aa2bcc31SzhanglyGit in.fromLsq.get.lqDeqPtr := io.vecMemIn.get.lqDeqPtr 398aa2bcc31SzhanglyGit } 399aa2bcc31SzhanglyGit validVec(entryIdx) := out.valid 400aa2bcc31SzhanglyGit canIssueVec(entryIdx) := out.canIssue 401aa2bcc31SzhanglyGit fuTypeVec(entryIdx) := out.fuType 402aa2bcc31SzhanglyGit robIdxVec(entryIdx) := out.robIdx 403aa2bcc31SzhanglyGit dataSourceVec(entryIdx) := out.dataSource 404aa2bcc31SzhanglyGit isFirstIssueVec(entryIdx) := out.isFirstIssue 405aa2bcc31SzhanglyGit entries(entryIdx) := out.entry 406aa2bcc31SzhanglyGit deqPortIdxReadVec(entryIdx) := out.deqPortIdxRead 407aa2bcc31SzhanglyGit issueTimerVec(entryIdx) := out.issueTimerRead 408eea4a3caSzhanglyGit srcLoadDependencyVec(entryIdx) := out.srcLoadDependency 409eea4a3caSzhanglyGit loadDependencyVec(entryIdx) := out.entry.bits.status.mergedLoadDependency 410aa2bcc31SzhanglyGit if (params.hasIQWakeUp) { 411aa2bcc31SzhanglyGit srcWakeUpL1ExuOHVec.get(entryIdx) := out.srcWakeUpL1ExuOH.get 412aa2bcc31SzhanglyGit } 413aa2bcc31SzhanglyGit if (params.isVecMemIQ) { 414aa2bcc31SzhanglyGit uopIdxVec.get(entryIdx) := out.uopIdx.get 415aa2bcc31SzhanglyGit } 416a6938b17Ssinsanction entryInValidVec(entryIdx) := out.entryInValid 417a6938b17Ssinsanction entryOutDeqValidVec(entryIdx) := out.entryOutDeqValid 418a6938b17Ssinsanction entryOutTransValidVec(entryIdx) := out.entryOutTransValid 419e3ef3537Ssinsanction perfWakeupByWBVec(entryIdx) := out.perfWakeupByWB 420e3ef3537Ssinsanction if (params.hasIQWakeUp) { 421e3ef3537Ssinsanction perfLdCancelVec.get(entryIdx) := out.perfLdCancel.get 422e3ef3537Ssinsanction perfOg0CancelVec.get(entryIdx) := out.perfOg0Cancel.get 423e3ef3537Ssinsanction perfWakeupByIQVec.get(entryIdx) := out.perfWakeupByIQ.get 424e3ef3537Ssinsanction } 425aa2bcc31SzhanglyGit } 426a6938b17Ssinsanction 427a6938b17Ssinsanction // entries perf counter 428a6938b17Ssinsanction // enq 429a6938b17Ssinsanction for (i <- 0 until params.numEnq) { 430a6938b17Ssinsanction XSPerfAccumulate(s"enqEntry_${i}_in_cnt", entryInValidVec(i)) 431a6938b17Ssinsanction XSPerfAccumulate(s"enqEntry_${i}_out_deq_cnt", entryOutDeqValidVec(i)) 432a6938b17Ssinsanction XSPerfAccumulate(s"enqEntry_${i}_out_trans_cnt", entryOutTransValidVec(i)) 433a6938b17Ssinsanction } 434a6938b17Ssinsanction // simple 435a6938b17Ssinsanction for (i <- 0 until params.numSimp) { 436a6938b17Ssinsanction XSPerfAccumulate(s"simpEntry_${i}_in_cnt", entryInValidVec(i + params.numEnq)) 437a6938b17Ssinsanction XSPerfAccumulate(s"simpEntry_${i}_out_deq_cnt", entryOutDeqValidVec(i + params.numEnq)) 438a6938b17Ssinsanction XSPerfAccumulate(s"simpEntry_${i}_out_trans_cnt", entryOutTransValidVec(i + params.numEnq)) 439a6938b17Ssinsanction } 440a6938b17Ssinsanction // complex 441a6938b17Ssinsanction for (i <- 0 until params.numComp) { 442a6938b17Ssinsanction XSPerfAccumulate(s"compEntry_${i}_in_cnt", entryInValidVec(i + params.numEnq + params.numSimp)) 443a6938b17Ssinsanction XSPerfAccumulate(s"compEntry_${i}_out_deq_cnt", entryOutDeqValidVec(i + params.numEnq + params.numSimp)) 444a6938b17Ssinsanction XSPerfAccumulate(s"compEntry_${i}_out_trans_cnt", entryOutTransValidVec(i + params.numEnq + params.numSimp)) 445a6938b17Ssinsanction } 446a6938b17Ssinsanction // total 447a6938b17Ssinsanction XSPerfAccumulate(s"enqEntry_all_in_cnt", PopCount(entryInValidVec.take(params.numEnq))) 448a6938b17Ssinsanction XSPerfAccumulate(s"enqEntry_all_out_deq_cnt", PopCount(entryOutDeqValidVec.take(params.numEnq))) 449a6938b17Ssinsanction XSPerfAccumulate(s"enqEntry_all_out_trans_cnt", PopCount(entryOutTransValidVec.take(params.numEnq))) 450e3ef3537Ssinsanction for (srcIdx <- 0 until params.numRegSrc) { 451e3ef3537Ssinsanction XSPerfAccumulate(s"enqEntry_all_wakeup_wb_src${srcIdx}_cnt", PopCount(perfWakeupByWBVec.take(params.numEnq).map(_(srcIdx)))) 452d280e426Slewislzh if (params.hasIQWakeUp) { 453e3ef3537Ssinsanction XSPerfAccumulate(s"enqEntry_all_ldCancel_src${srcIdx}_cnt", PopCount(perfLdCancelVec.get.take(params.numEnq).map(_(srcIdx)))) 454e3ef3537Ssinsanction XSPerfAccumulate(s"enqEntry_all_og0Cancel_src${srcIdx}_cnt", PopCount(perfOg0CancelVec.get.take(params.numEnq).map(_(srcIdx)))) 455e3ef3537Ssinsanction for (iqIdx <- 0 until params.numWakeupFromIQ) { 456e3ef3537Ssinsanction XSPerfAccumulate(s"enqEntry_all_wakeup_iq_from_exu${params.wakeUpSourceExuIdx(iqIdx)}_src${srcIdx}_cnt", PopCount(perfWakeupByIQVec.get.take(params.numEnq).map(_(srcIdx)(iqIdx)))) 457e3ef3537Ssinsanction } 458e3ef3537Ssinsanction } 459d280e426Slewislzh } 460a6938b17Ssinsanction 461a6938b17Ssinsanction XSPerfAccumulate(s"othersEntry_all_in_cnt", PopCount(entryInValidVec.drop(params.numEnq))) 462a6938b17Ssinsanction XSPerfAccumulate(s"othersEntry_all_out_deq_cnt", PopCount(entryOutDeqValidVec.drop(params.numEnq))) 463a6938b17Ssinsanction XSPerfAccumulate(s"othersEntry_all_out_trans_cnt", PopCount(entryOutTransValidVec.drop(params.numEnq))) 464e3ef3537Ssinsanction for (srcIdx <- 0 until params.numRegSrc) { 465e3ef3537Ssinsanction XSPerfAccumulate(s"othersEntry_all_wakeup_wb_src${srcIdx}_cnt", PopCount(perfWakeupByWBVec.drop(params.numEnq).map(_(srcIdx)))) 466d280e426Slewislzh if (params.hasIQWakeUp) { 467e3ef3537Ssinsanction XSPerfAccumulate(s"othersEntry_all_ldCancel_src${srcIdx}_cnt", PopCount(perfLdCancelVec.get.drop(params.numEnq).map(_(srcIdx)))) 468e3ef3537Ssinsanction XSPerfAccumulate(s"othersEntry_all_og0Cancel_src${srcIdx}_cnt", PopCount(perfOg0CancelVec.get.drop(params.numEnq).map(_(srcIdx)))) 469e3ef3537Ssinsanction for (iqIdx <- 0 until params.numWakeupFromIQ) { 470e3ef3537Ssinsanction XSPerfAccumulate(s"othersEntry_all_wakeup_iq_from_exu${params.wakeUpSourceExuIdx(iqIdx)}_src${srcIdx}_cnt", PopCount(perfWakeupByIQVec.get.drop(params.numEnq).map(_(srcIdx)(iqIdx)))) 471e3ef3537Ssinsanction } 472e3ef3537Ssinsanction } 473e3ef3537Ssinsanction } 474e3ef3537Ssinsanction 475e3ef3537Ssinsanction for (t <- FuType.functionNameMap.keys) { 476e3ef3537Ssinsanction val fuName = FuType.functionNameMap(t) 477e3ef3537Ssinsanction if (params.getFuCfgs.map(_.fuType == t).reduce(_ | _) && params.getFuCfgs.size > 1) { 478e3ef3537Ssinsanction for (srcIdx <- 0 until params.numRegSrc) { 479e3ef3537Ssinsanction XSPerfAccumulate(s"allEntry_futype_${fuName}_wakeup_wb_src${srcIdx}_cnt", PopCount(perfWakeupByWBVec.zip(fuTypeVec).map{ case(x, fu) => x(srcIdx) && fu(t.id) })) 480e3ef3537Ssinsanction if (params.hasIQWakeUp) { 481e3ef3537Ssinsanction XSPerfAccumulate(s"allEntry_futype_${fuName}_ldCancel_src${srcIdx}_cnt", PopCount(perfLdCancelVec.get.zip(fuTypeVec).map{ case(x, fu) => x(srcIdx) && fu(t.id) })) 482e3ef3537Ssinsanction XSPerfAccumulate(s"allEntry_futype_${fuName}_og0Cancel_src${srcIdx}_cnt", PopCount(perfOg0CancelVec.get.zip(fuTypeVec).map{ case(x, fu) => x(srcIdx) && fu(t.id) })) 483e3ef3537Ssinsanction for (iqIdx <- 0 until params.numWakeupFromIQ) { 484e3ef3537Ssinsanction XSPerfAccumulate(s"allEntry_futype_${fuName}_wakeup_iq_from_exu${params.wakeUpSourceExuIdx(iqIdx)}_src${srcIdx}_cnt", PopCount(perfWakeupByIQVec.get.zip(fuTypeVec).map{ case(x, fu) => x(srcIdx)(iqIdx) && fu(t.id) })) 485e3ef3537Ssinsanction } 486e3ef3537Ssinsanction } 487e3ef3537Ssinsanction } 488e3ef3537Ssinsanction } 489d280e426Slewislzh } 490aa2bcc31SzhanglyGit} 491aa2bcc31SzhanglyGit 492aa2bcc31SzhanglyGitclass EntriesIO(implicit p: Parameters, params: IssueBlockParams) extends XSBundle { 493aa2bcc31SzhanglyGit val flush = Flipped(ValidIO(new Redirect)) 494aa2bcc31SzhanglyGit //enq 495aa2bcc31SzhanglyGit val enq = Vec(params.numEnq, Flipped(ValidIO(new EntryBundle))) 496aa2bcc31SzhanglyGit val og0Resp = Vec(params.numDeq, Flipped(ValidIO(new EntryDeqRespBundle))) 497aa2bcc31SzhanglyGit val og1Resp = Vec(params.numDeq, Flipped(ValidIO(new EntryDeqRespBundle))) 498c38df446SzhanglyGit val og2Resp = OptionWrapper(params.inVfSchd, Vec(params.numDeq, Flipped(ValidIO(new EntryDeqRespBundle)))) 499aa2bcc31SzhanglyGit //deq sel 500aa2bcc31SzhanglyGit val deqReady = Vec(params.numDeq, Input(Bool())) 501aa2bcc31SzhanglyGit val deqSelOH = Vec(params.numDeq, Flipped(ValidIO(UInt(params.numEntries.W)))) 502aa2bcc31SzhanglyGit val enqEntryOldestSel = Vec(params.numDeq, Flipped(ValidIO(UInt(params.numEnq.W)))) 50328607074Ssinsanction val simpEntryOldestSel = OptionWrapper(params.hasCompAndSimp, Vec(params.numDeq, Flipped(ValidIO(UInt(params.numSimp.W))))) 50428607074Ssinsanction val compEntryOldestSel = OptionWrapper(params.hasCompAndSimp, Vec(params.numDeq, Flipped(ValidIO(UInt(params.numComp.W))))) 50528607074Ssinsanction val othersEntryOldestSel= OptionWrapper(params.isAllComp || params.isAllSimp, Vec(params.numDeq, Flipped(ValidIO(UInt((params.numEntries - params.numEnq).W))))) 506aa2bcc31SzhanglyGit val subDeqRequest = OptionWrapper(params.deqFuSame, Vec(params.numDeq, Input(UInt(params.numEntries.W)))) 507aa2bcc31SzhanglyGit val subDeqSelOH = OptionWrapper(params.deqFuSame, Vec(params.numDeq, Input(UInt(params.numEntries.W)))) 508aa2bcc31SzhanglyGit // wakeup 509aa2bcc31SzhanglyGit val wakeUpFromWB: MixedVec[ValidIO[IssueQueueWBWakeUpBundle]] = Flipped(params.genWBWakeUpSinkValidBundle) 510aa2bcc31SzhanglyGit val wakeUpFromIQ: MixedVec[ValidIO[IssueQueueIQWakeUpBundle]] = Flipped(params.genIQWakeUpSinkValidBundle) 511aa2bcc31SzhanglyGit val og0Cancel = Input(ExuOH(backendParams.numExu)) 512aa2bcc31SzhanglyGit val og1Cancel = Input(ExuOH(backendParams.numExu)) 513aa2bcc31SzhanglyGit val ldCancel = Vec(backendParams.LdExuCnt, Flipped(new LoadCancelIO)) 514aa2bcc31SzhanglyGit //entries status 515aa2bcc31SzhanglyGit val valid = Output(UInt(params.numEntries.W)) 516aa2bcc31SzhanglyGit val canIssue = Output(UInt(params.numEntries.W)) 517aa2bcc31SzhanglyGit val fuType = Vec(params.numEntries, Output(FuType())) 518aa2bcc31SzhanglyGit val dataSources = Vec(params.numEntries, Vec(params.numRegSrc, Output(DataSource()))) 519eea4a3caSzhanglyGit val loadDependency = Vec(params.numEntries, Vec(LoadPipelineWidth, UInt(3.W))) 520aa2bcc31SzhanglyGit val srcWakeUpL1ExuOH = OptionWrapper(params.hasIQWakeUp, Vec(params.numEntries, Vec(params.numRegSrc, Output(ExuOH())))) 521aa2bcc31SzhanglyGit //deq status 522aa2bcc31SzhanglyGit val isFirstIssue = Vec(params.numDeq, Output(Bool())) 523aa2bcc31SzhanglyGit val deqEntry = Vec(params.numDeq, ValidIO(new EntryBundle)) 524aa2bcc31SzhanglyGit val cancelDeqVec = Vec(params.numDeq, Output(Bool())) 525e07131b2Ssinsanction 526e07131b2Ssinsanction // load/hybird only 527e07131b2Ssinsanction val fromLoad = OptionWrapper(params.isLdAddrIQ || params.isHyAddrIQ, new Bundle { 528e07131b2Ssinsanction val finalIssueResp = Vec(params.numDeq, Flipped(ValidIO(new EntryDeqRespBundle))) 529e07131b2Ssinsanction val memAddrIssueResp = Vec(params.numDeq, Flipped(ValidIO(new EntryDeqRespBundle))) 530e07131b2Ssinsanction }) 531aa2bcc31SzhanglyGit // mem only 532e07131b2Ssinsanction val fromMem = OptionWrapper(params.isMemAddrIQ, new Bundle { 533aa2bcc31SzhanglyGit val slowResp = Vec(params.numDeq, Flipped(ValidIO(new EntryDeqRespBundle))) 534d3372210SzhanglyGit val fastResp = Vec(params.numDeq, Flipped(ValidIO(new EntryDeqRespBundle))) 535e07131b2Ssinsanction }) 53699944b79Ssinsanction // vec mem only 537aa2bcc31SzhanglyGit val vecMemIn = OptionWrapper(params.isVecMemIQ, new Bundle { 538aa2bcc31SzhanglyGit val sqDeqPtr = Input(new SqPtr) 539aa2bcc31SzhanglyGit val lqDeqPtr = Input(new LqPtr) 540aa2bcc31SzhanglyGit }) 541aa2bcc31SzhanglyGit val robIdx = OptionWrapper(params.isVecMemIQ, Output(Vec(params.numEntries, new RobPtr))) 542aa2bcc31SzhanglyGit val uopIdx = OptionWrapper(params.isVecMemIQ, Output(Vec(params.numEntries, UopIdx()))) 543aa2bcc31SzhanglyGit 54428607074Ssinsanction // trans 54528607074Ssinsanction val simpEntryDeqSelVec = OptionWrapper(params.hasCompAndSimp, Vec(params.numEnq, Input(UInt(params.numSimp.W)))) 54628607074Ssinsanction val simpEntryEnqSelVec = OptionWrapper(params.hasCompAndSimp, Vec(params.numEnq, Output(UInt(params.numSimp.W)))) 54728607074Ssinsanction val compEntryEnqSelVec = OptionWrapper(params.hasCompAndSimp, Vec(params.numEnq, Output(UInt(params.numComp.W)))) 54828607074Ssinsanction val othersEntryEnqSelVec = OptionWrapper(params.isAllComp || params.isAllSimp, Vec(params.numEnq, Output(UInt((params.numEntries - params.numEnq).W)))) 549aa2bcc31SzhanglyGit 550aa2bcc31SzhanglyGit def wakeup = wakeUpFromWB ++ wakeUpFromIQ 5515db4956bSzhanglyGit} 552