15db4956bSzhanglyGitpackage xiangshan.backend.issue 25db4956bSzhanglyGit 383ba63b3SXuan Huimport org.chipsalliance.cde.config.Parameters 45db4956bSzhanglyGitimport chisel3._ 55db4956bSzhanglyGitimport chisel3.util._ 65db4956bSzhanglyGitimport utility.HasCircularQueuePtrHelper 7a6938b17Ssinsanctionimport utils._ 84fa640e4Ssinsanctionimport 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 317e471bf8SXuan Hu val memEtyResps: Seq[ValidIO[EntryDeqRespBundle]] = { 327e471bf8SXuan Hu val resps = 33d3372210SzhanglyGit if (params.isLdAddrIQ && !params.isStAddrIQ) //LDU 347e471bf8SXuan Hu Seq(io.og0Resp, io.og1Resp, io.fromLoad.get.finalIssueResp, io.fromLoad.get.memAddrIssueResp) 35d3372210SzhanglyGit else if (params.isLdAddrIQ && params.isStAddrIQ || params.isHyAddrIQ) //HYU 367e471bf8SXuan Hu Seq(io.og0Resp, io.og1Resp, io.fromLoad.get.finalIssueResp, io.fromLoad.get.memAddrIssueResp, io.fromMem.get.fastResp, io.fromMem.get.slowResp) 377e471bf8SXuan Hu else if (params.isStAddrIQ) //STU 387e471bf8SXuan Hu Seq(io.og0Resp, io.og1Resp, io.fromMem.get.slowResp) 398f3cbbcfSXuan Hu else if (params.isVecLduIQ && params.isVecStuIQ) // Vector store IQ need no vecLdIn.resp, but for now vector store share the vector load IQ 408f3cbbcfSXuan Hu Seq(io.og0Resp, io.og1Resp, io.vecLdIn.get.resp, io.fromMem.get.slowResp) 418f3cbbcfSXuan Hu else if (params.isVecLduIQ) 427e471bf8SXuan Hu Seq(io.og0Resp, io.og1Resp, io.vecLdIn.get.resp) 437e471bf8SXuan Hu else if (params.isVecStuIQ) 447e471bf8SXuan Hu Seq(io.og0Resp, io.og1Resp, io.fromMem.get.slowResp) 457e471bf8SXuan Hu else Seq() 467e471bf8SXuan Hu if (params.isMemAddrIQ) { 477e471bf8SXuan Hu println(s"[${this.desiredName}] resp: {" + 487e471bf8SXuan Hu s"og0Resp: ${resps.contains(io.og0Resp)}, " + 497e471bf8SXuan Hu s"og1Resp: ${resps.contains(io.og1Resp)}, " + 507e471bf8SXuan Hu s"finalResp: ${io.fromLoad.nonEmpty && resps.contains(io.fromLoad.get.finalIssueResp)}, " + 517e471bf8SXuan Hu s"loadBorderResp: ${io.fromLoad.nonEmpty && resps.contains(io.fromLoad.get.memAddrIssueResp)}, " + 527e471bf8SXuan Hu s"memFastResp: ${io.fromMem.nonEmpty && resps.contains(io.fromMem.get.fastResp)}, " + 537e471bf8SXuan Hu s"memSlowResp: ${io.fromMem.nonEmpty && resps.contains(io.fromMem.get.slowResp)}, " + 547e471bf8SXuan Hu s"vecLoadBorderResp: ${io.vecLdIn.nonEmpty && resps.contains(io.vecLdIn.get.resp)}, " + 557e471bf8SXuan Hu s"}" 567e471bf8SXuan Hu ) 577e471bf8SXuan Hu } 587e471bf8SXuan Hu resps.flatten 59c838dea1SXuan Hu } 60c838dea1SXuan Hu 61c38df446SzhanglyGit val resps: Vec[Vec[ValidIO[EntryDeqRespBundle]]] = { 62c38df446SzhanglyGit if (params.inVfSchd) 63c38df446SzhanglyGit VecInit(io.og0Resp, io.og1Resp, io.og2Resp.get, 0.U.asTypeOf(io.og0Resp)) 64c38df446SzhanglyGit else 65c38df446SzhanglyGit VecInit(io.og0Resp, io.og1Resp, 0.U.asTypeOf(io.og0Resp), 0.U.asTypeOf(io.og0Resp)) 66c38df446SzhanglyGit } 675db4956bSzhanglyGit 687e471bf8SXuan Hu 697e471bf8SXuan Hu 705db4956bSzhanglyGit //Module 71df26db8aSsinsanction val enqEntries = Seq.fill(EnqEntryNum)(Module(EnqEntry(isComp = true)(p, params))) 7228607074Ssinsanction val othersEntriesSimp = Seq.fill(SimpEntryNum)(Module(OthersEntry(isComp = false)(p, params))) 7328607074Ssinsanction val othersEntriesComp = Seq.fill(CompEntryNum)(Module(OthersEntry(isComp = true)(p, params))) 7428607074Ssinsanction val othersEntries = othersEntriesSimp ++ othersEntriesComp 7528607074Ssinsanction val othersTransPolicy = OptionWrapper(params.isAllComp || params.isAllSimp, Module(new EnqPolicy)) 7628607074Ssinsanction val simpTransPolicy = OptionWrapper(params.hasCompAndSimp, Module(new EnqPolicy)) 7728607074Ssinsanction val compTransPolicy = OptionWrapper(params.hasCompAndSimp, Module(new EnqPolicy)) 785db4956bSzhanglyGit 795db4956bSzhanglyGit //Wire 80aa2bcc31SzhanglyGit //entries status 815db4956bSzhanglyGit val entries = Wire(Vec(params.numEntries, ValidIO(new EntryBundle))) 82aa2bcc31SzhanglyGit val robIdxVec = Wire(Vec(params.numEntries, new RobPtr)) 835db4956bSzhanglyGit val validVec = Wire(Vec(params.numEntries, Bool())) 845db4956bSzhanglyGit val canIssueVec = Wire(Vec(params.numEntries, Bool())) 855db4956bSzhanglyGit val fuTypeVec = Wire(Vec(params.numEntries, FuType())) 865db4956bSzhanglyGit val isFirstIssueVec = Wire(Vec(params.numEntries, Bool())) 875db4956bSzhanglyGit val issueTimerVec = Wire(Vec(params.numEntries, UInt(2.W))) 8899944b79Ssinsanction val uopIdxVec = OptionWrapper(params.isVecMemIQ, Wire(Vec(params.numEntries, UopIdx()))) 89aa2bcc31SzhanglyGit //src status 90aa2bcc31SzhanglyGit val dataSourceVec = Wire(Vec(params.numEntries, Vec(params.numRegSrc, DataSource()))) 91ec49b127Ssinsanction val loadDependencyVec = Wire(Vec(params.numEntries, Vec(LoadPipelineWidth, UInt(LoadDependencyWidth.W)))) 92aa2bcc31SzhanglyGit val srcWakeUpL1ExuOHVec = OptionWrapper(params.hasIQWakeUp, Wire(Vec(params.numEntries, Vec(params.numRegSrc, ExuVec())))) 93aa2bcc31SzhanglyGit //deq sel 94aa2bcc31SzhanglyGit val deqSelVec = Wire(Vec(params.numEntries, Bool())) 95aa2bcc31SzhanglyGit val issueRespVec = Wire(Vec(params.numEntries, ValidIO(new EntryDeqRespBundle))) 965db4956bSzhanglyGit val deqPortIdxWriteVec = Wire(Vec(params.numEntries, UInt(1.W))) 975db4956bSzhanglyGit val deqPortIdxReadVec = Wire(Vec(params.numEntries, UInt(1.W))) 98aa2bcc31SzhanglyGit //trans sel 9928607074Ssinsanction val othersEntryEnqReadyVec = Wire(Vec(OthersEntryNum, Bool())) 10028607074Ssinsanction val othersEntryEnqVec = Wire(Vec(OthersEntryNum, Valid(new EntryBundle))) 10128607074Ssinsanction val enqEntryTransVec = Wire(Vec(EnqEntryNum, Valid(new EntryBundle))) 10228607074Ssinsanction val simpEntryTransVec = OptionWrapper(params.hasCompAndSimp, Wire(Vec(SimpEntryNum, Valid(new EntryBundle)))) 10328607074Ssinsanction val compEnqVec = OptionWrapper(params.hasCompAndSimp, Wire(Vec(EnqEntryNum, Valid(new EntryBundle)))) 10428607074Ssinsanction 10528607074Ssinsanction val enqCanTrans2Simp = OptionWrapper(params.hasCompAndSimp, Wire(Bool())) 10628607074Ssinsanction val enqCanTrans2Comp = OptionWrapper(params.hasCompAndSimp, Wire(Bool())) 10728607074Ssinsanction val simpCanTrans2Comp = OptionWrapper(params.hasCompAndSimp, Wire(Vec(EnqEntryNum, Bool()))) 10828607074Ssinsanction val simpTransSelVec = OptionWrapper(params.hasCompAndSimp, Wire(Vec(EnqEntryNum, Valid(UInt(SimpEntryNum.W))))) 10928607074Ssinsanction val compTransSelVec = OptionWrapper(params.hasCompAndSimp, Wire(Vec(EnqEntryNum, Valid(UInt(CompEntryNum.W))))) 11028607074Ssinsanction val finalSimpTransSelVec = OptionWrapper(params.hasCompAndSimp, Wire(Vec(EnqEntryNum, UInt(SimpEntryNum.W)))) 11128607074Ssinsanction val finalCompTransSelVec = OptionWrapper(params.hasCompAndSimp, Wire(Vec(EnqEntryNum, UInt(CompEntryNum.W)))) 11228607074Ssinsanction 11328607074Ssinsanction val enqCanTrans2Others = OptionWrapper(params.isAllComp || params.isAllSimp, Wire(Bool())) 11428607074Ssinsanction val othersTransSelVec = OptionWrapper(params.isAllComp || params.isAllSimp, Wire(Vec(EnqEntryNum, Valid(UInt(OthersEntryNum.W))))) 11528607074Ssinsanction val finalOthersTransSelVec = OptionWrapper(params.isAllComp || params.isAllSimp, Wire(Vec(EnqEntryNum, UInt(OthersEntryNum.W)))) 11628607074Ssinsanction 11728607074Ssinsanction val simpEntryEnqReadyVec = othersEntryEnqReadyVec.take(SimpEntryNum) 11828607074Ssinsanction val compEntryEnqReadyVec = othersEntryEnqReadyVec.takeRight(CompEntryNum) 11928607074Ssinsanction val simpEntryEnqVec = othersEntryEnqVec.take(SimpEntryNum) 12028607074Ssinsanction val compEntryEnqVec = othersEntryEnqVec.takeRight(CompEntryNum) 121aa2bcc31SzhanglyGit //debug 122a6938b17Ssinsanction val entryInValidVec = Wire(Vec(params.numEntries, Bool())) 123a6938b17Ssinsanction val entryOutDeqValidVec = Wire(Vec(params.numEntries, Bool())) 124a6938b17Ssinsanction val entryOutTransValidVec = Wire(Vec(params.numEntries, Bool())) 125e3ef3537Ssinsanction val perfLdCancelVec = OptionWrapper(params.hasIQWakeUp, Wire(Vec(params.numEntries, Vec(params.numRegSrc, Bool())))) 126e3ef3537Ssinsanction val perfOg0CancelVec = OptionWrapper(params.hasIQWakeUp, Wire(Vec(params.numEntries, Vec(params.numRegSrc, Bool())))) 127e3ef3537Ssinsanction val perfWakeupByWBVec = Wire(Vec(params.numEntries, Vec(params.numRegSrc, Bool()))) 128e3ef3537Ssinsanction val perfWakeupByIQVec = OptionWrapper(params.hasIQWakeUp, Wire(Vec(params.numEntries, Vec(params.numRegSrc, Vec(params.numWakeupFromIQ, Bool()))))) 129a4d38a63SzhanglyGit //cancel bypass 130eea4a3caSzhanglyGit val cancelBypassVec = Wire(Vec(params.numEntries, Bool())) 1315db4956bSzhanglyGit 1325db4956bSzhanglyGit 1335db4956bSzhanglyGit //enqEntries 1345db4956bSzhanglyGit enqEntries.zipWithIndex.foreach { case (enqEntry, entryIdx) => 135aa2bcc31SzhanglyGit enqEntry.io.commonIn.enq := io.enq(entryIdx) 13628607074Ssinsanction enqEntry.io.commonIn.transSel := (if (params.isAllComp || params.isAllSimp) enqCanTrans2Others.get && othersTransSelVec.get(entryIdx).valid 13728607074Ssinsanction else enqCanTrans2Simp.get && simpTransSelVec.get(entryIdx).valid || enqCanTrans2Comp.get && compTransSelVec.get(entryIdx).valid) 138aa2bcc31SzhanglyGit EntriesConnect(enqEntry.io.commonIn, enqEntry.io.commonOut, entryIdx) 1394fa640e4Ssinsanction enqEntry.io.enqDelayIn1.wakeUpFromWB := RegEnable(io.wakeUpFromWB, io.enq(entryIdx).valid) 1404fa640e4Ssinsanction enqEntry.io.enqDelayIn1.wakeUpFromIQ := RegEnable(io.wakeUpFromIQ, io.enq(entryIdx).valid) 1414fa640e4Ssinsanction enqEntry.io.enqDelayIn1.og0Cancel := RegNext(io.og0Cancel.asUInt) 1424fa640e4Ssinsanction enqEntry.io.enqDelayIn1.ldCancel := RegNext(io.ldCancel) 1434fa640e4Ssinsanction // note: these signals with 2 cycle delay should not be enabled by io.enq.valid 1444fa640e4Ssinsanction enqEntry.io.enqDelayIn2.wakeUpFromWB := DelayN(io.wakeUpFromWB, 2) 1454fa640e4Ssinsanction enqEntry.io.enqDelayIn2.wakeUpFromIQ := DelayN(io.wakeUpFromIQ, 2) 1464fa640e4Ssinsanction enqEntry.io.enqDelayIn2.og0Cancel := DelayN(io.og0Cancel.asUInt, 2) 1474fa640e4Ssinsanction enqEntry.io.enqDelayIn2.ldCancel := DelayN(io.ldCancel, 2) 14828607074Ssinsanction enqEntryTransVec(entryIdx) := enqEntry.io.commonOut.transEntry 1495db4956bSzhanglyGit } 1505db4956bSzhanglyGit //othersEntries 1515db4956bSzhanglyGit othersEntries.zipWithIndex.foreach { case (othersEntry, entryIdx) => 15228607074Ssinsanction othersEntry.io.commonIn.enq := othersEntryEnqVec(entryIdx) 15328607074Ssinsanction othersEntry.io.commonIn.transSel := (if (params.hasCompAndSimp && (entryIdx < SimpEntryNum)) 15428607074Ssinsanction io.simpEntryDeqSelVec.get.zip(simpCanTrans2Comp.get).map(x => x._1(entryIdx) && x._2).reduce(_ | _) 15528607074Ssinsanction else false.B) 156aa2bcc31SzhanglyGit EntriesConnect(othersEntry.io.commonIn, othersEntry.io.commonOut, entryIdx + EnqEntryNum) 15728607074Ssinsanction othersEntryEnqReadyVec(entryIdx) := othersEntry.io.commonOut.enqReady 15828607074Ssinsanction if (params.hasCompAndSimp && (entryIdx < SimpEntryNum)) { 15928607074Ssinsanction simpEntryTransVec.get(entryIdx) := othersEntry.io.commonOut.transEntry 16028607074Ssinsanction } 1615db4956bSzhanglyGit } 1625db4956bSzhanglyGit 1635db4956bSzhanglyGit 1645db4956bSzhanglyGit deqSelVec.zip(deqPortIdxWriteVec).zipWithIndex.foreach { case ((deqSel, deqPortIdxWrite), i) => 165aa2bcc31SzhanglyGit val deqVec = io.deqSelOH.zip(io.deqReady).map(x => x._1.valid && x._1.bits(i) && x._2) 1665db4956bSzhanglyGit deqPortIdxWrite := OHToUInt(deqVec) 1675db4956bSzhanglyGit deqSel := deqVec.reduce(_ | _) 1685db4956bSzhanglyGit } 1695db4956bSzhanglyGit 1705db4956bSzhanglyGit 17128607074Ssinsanction if (params.isAllComp || params.isAllSimp) { 1725db4956bSzhanglyGit //transPolicy 17328607074Ssinsanction othersTransPolicy.get.io.canEnq := othersEntryEnqReadyVec.asUInt 174b43488b9Ssinsanction 175b43488b9Ssinsanction // we only allow all or none of the enq entries transfering to others entries. 17628607074Ssinsanction enqCanTrans2Others.get := PopCount(validVec.take(EnqEntryNum)) <= PopCount(othersEntryEnqReadyVec) 177b43488b9Ssinsanction // othersTransSelVec(i) is the target others entry for enq entry [i]. 178b43488b9Ssinsanction // note that dispatch does not guarantee the validity of enq entries with low index. 179b43488b9Ssinsanction // that means in some cases enq entry [0] is invalid while enq entry [1] is valid. 180b43488b9Ssinsanction // in this case, enq entry [1] should use result [0] of TransPolicy. 18128607074Ssinsanction othersTransSelVec.get(0).valid := othersTransPolicy.get.io.enqSelOHVec(0).valid && validVec(0) 18228607074Ssinsanction othersTransSelVec.get(0).bits := othersTransPolicy.get.io.enqSelOHVec(0).bits 1838321ef33Ssinsanction if (params.numEnq == 2) { 18428607074Ssinsanction othersTransSelVec.get(1).valid := Mux(!validVec(0), othersTransPolicy.get.io.enqSelOHVec(0).valid, othersTransPolicy.get.io.enqSelOHVec(1).valid) 18528607074Ssinsanction othersTransSelVec.get(1).bits := Mux(!validVec(0), othersTransPolicy.get.io.enqSelOHVec(0).bits, othersTransPolicy.get.io.enqSelOHVec(1).bits) 1868321ef33Ssinsanction } 1878321ef33Ssinsanction 18828607074Ssinsanction finalOthersTransSelVec.get.zip(othersTransSelVec.get).zipWithIndex.foreach { case ((finalOH, selOH), enqIdx) => 18928607074Ssinsanction finalOH := Fill(OthersEntryNum, enqCanTrans2Others.get && selOH.valid) & selOH.bits 1905db4956bSzhanglyGit } 1915db4956bSzhanglyGit 19228607074Ssinsanction //othersEntryEnq 19328607074Ssinsanction othersEntryEnqVec.zipWithIndex.foreach { case (othersEntryEnq, othersIdx) => 19428607074Ssinsanction val othersEnqOH = finalOthersTransSelVec.get.map(_(othersIdx)) 19528607074Ssinsanction if (othersEnqOH.size == 1) 19628607074Ssinsanction othersEntryEnq := Mux(othersEnqOH.head, enqEntryTransVec.head, 0.U.asTypeOf(enqEntryTransVec.head)) 19728607074Ssinsanction else 19828607074Ssinsanction othersEntryEnq := Mux1H(othersEnqOH, enqEntryTransVec) 1995db4956bSzhanglyGit } 20028607074Ssinsanction } 20128607074Ssinsanction else { 20228607074Ssinsanction //transPolicy 20328607074Ssinsanction simpTransPolicy.get.io.canEnq := VecInit(simpEntryEnqReadyVec).asUInt 20428607074Ssinsanction compTransPolicy.get.io.canEnq := VecInit(validVec.takeRight(CompEntryNum).map(!_)).asUInt 20528607074Ssinsanction 206b43488b9Ssinsanction // we only allow all or none of the enq entries transfering to comp/simp entries. 207b43488b9Ssinsanction // when all of simp entries are empty and comp entries are enough, transfer to comp entries. 208b43488b9Ssinsanction // otherwise, transfer to simp entries. 20928607074Ssinsanction enqCanTrans2Comp.get := PopCount(validVec.take(EnqEntryNum)) <= PopCount(validVec.takeRight(CompEntryNum).map(!_)) && !validVec.drop(EnqEntryNum).take(SimpEntryNum).reduce(_ || _) 21028607074Ssinsanction enqCanTrans2Simp.get := !enqCanTrans2Comp.get && PopCount(validVec.take(EnqEntryNum)) <= PopCount(simpEntryEnqReadyVec) 21128607074Ssinsanction simpCanTrans2Comp.get.zipWithIndex.foreach { case (canTrans, idx) => 21228607074Ssinsanction canTrans := !enqCanTrans2Comp.get && PopCount(validVec.takeRight(CompEntryNum).map(!_)) >= (idx + 1).U 21328607074Ssinsanction } 21428607074Ssinsanction 215b43488b9Ssinsanction // simp/compTransSelVec(i) is the target simp/comp entry for enq entry [i]. 216b43488b9Ssinsanction // note that dispatch does not guarantee the validity of enq entries with low index. 217b43488b9Ssinsanction // that means in some cases enq entry [0] is invalid while enq entry [1] is valid. 218b43488b9Ssinsanction // in this case, enq entry [1] should use result [0] of TransPolicy. 21928607074Ssinsanction simpTransSelVec.get(0).valid := simpTransPolicy.get.io.enqSelOHVec(0).valid && validVec(0) 22028607074Ssinsanction simpTransSelVec.get(0).bits := simpTransPolicy.get.io.enqSelOHVec(0).bits 22128607074Ssinsanction compTransSelVec.get(0).valid := compTransPolicy.get.io.enqSelOHVec(0).valid && validVec(0) 22228607074Ssinsanction compTransSelVec.get(0).bits := compTransPolicy.get.io.enqSelOHVec(0).bits 22328607074Ssinsanction if (params.numEnq == 2) { 22428607074Ssinsanction simpTransSelVec.get(1).valid := Mux(!validVec(0), simpTransPolicy.get.io.enqSelOHVec(0).valid, simpTransPolicy.get.io.enqSelOHVec(1).valid) 22528607074Ssinsanction simpTransSelVec.get(1).bits := Mux(!validVec(0), simpTransPolicy.get.io.enqSelOHVec(0).bits, simpTransPolicy.get.io.enqSelOHVec(1).bits) 22628607074Ssinsanction compTransSelVec.get(1).valid := Mux(!validVec(0), compTransPolicy.get.io.enqSelOHVec(0).valid, compTransPolicy.get.io.enqSelOHVec(1).valid) 22728607074Ssinsanction compTransSelVec.get(1).bits := Mux(!validVec(0), compTransPolicy.get.io.enqSelOHVec(0).bits, compTransPolicy.get.io.enqSelOHVec(1).bits) 22828607074Ssinsanction } 22928607074Ssinsanction 23028607074Ssinsanction finalSimpTransSelVec.get.zip(simpTransSelVec.get).zipWithIndex.foreach { case ((finalOH, selOH), enqIdx) => 23128607074Ssinsanction finalOH := Fill(SimpEntryNum, enqCanTrans2Simp.get && selOH.valid) & selOH.bits 23228607074Ssinsanction } 23328607074Ssinsanction finalCompTransSelVec.get.zip(compTransSelVec.get).zip(compTransPolicy.get.io.enqSelOHVec).zipWithIndex.foreach { 23428607074Ssinsanction case (((finalOH, selOH), origSelOH), enqIdx) => 23528607074Ssinsanction finalOH := Mux(enqCanTrans2Comp.get, Fill(CompEntryNum, selOH.valid) & selOH.bits, Fill(CompEntryNum, origSelOH.valid) & origSelOH.bits) 23628607074Ssinsanction } 23728607074Ssinsanction 23828607074Ssinsanction //othersEntryEnq 23928607074Ssinsanction simpEntryEnqVec.zipWithIndex.foreach { case (simpEntryEnq, simpIdx) => 24028607074Ssinsanction val simpEnqOH = finalSimpTransSelVec.get.map(_(simpIdx)) 24128607074Ssinsanction // shit Mux1H directly returns in(0) if the seq has only 1 elements 24228607074Ssinsanction if (simpEnqOH.size == 1) 24328607074Ssinsanction simpEntryEnq := Mux(simpEnqOH.head, enqEntryTransVec.head, 0.U.asTypeOf(enqEntryTransVec.head)) 24428607074Ssinsanction else 24528607074Ssinsanction simpEntryEnq := Mux1H(simpEnqOH, enqEntryTransVec) 24628607074Ssinsanction } 24728607074Ssinsanction 24828607074Ssinsanction compEnqVec.get.zip(enqEntryTransVec).zip(io.simpEntryDeqSelVec.get).foreach { case ((compEnq, enqEntry), deqSel) => 24928607074Ssinsanction compEnq := Mux(enqCanTrans2Comp.get, enqEntry, Mux1H(deqSel, simpEntryTransVec.get)) 25028607074Ssinsanction } 25128607074Ssinsanction compEntryEnqVec.zipWithIndex.foreach { case (compEntryEnq, compIdx) => 25228607074Ssinsanction val compEnqOH = finalCompTransSelVec.get.map(_(compIdx)) 25328607074Ssinsanction // shit Mux1H directly returns in(0) if the seq has only 1 elements 25428607074Ssinsanction if (compEnqOH.size == 1) 25528607074Ssinsanction compEntryEnq := Mux(compEnqOH.head, compEnqVec.get.head, 0.U.asTypeOf(compEnqVec.get.head)) 25628607074Ssinsanction else 25728607074Ssinsanction compEntryEnq := Mux1H(compEnqOH, compEnqVec.get) 25828607074Ssinsanction } 25928607074Ssinsanction 26028607074Ssinsanction assert(PopCount(simpEntryEnqVec.map(_.valid)) <= params.numEnq.U, "the number of simpEntryEnq is more than numEnq\n") 26128607074Ssinsanction assert(PopCount(compEntryEnqVec.map(_.valid)) <= params.numEnq.U, "the number of compEntryEnq is more than numEnq\n") 26228607074Ssinsanction } 26328607074Ssinsanction 2648d081717Sszw_kaixin if(backendParams.debugEn) { 26528607074Ssinsanction dontTouch(othersEntryEnqVec) 2668d081717Sszw_kaixin } 2675db4956bSzhanglyGit 2685db4956bSzhanglyGit //issueRespVec 269887f9c3dSzhanglinjuan if (params.isVecMemIQ) { 270887f9c3dSzhanglinjuan // vector memory IQ 271887f9c3dSzhanglinjuan issueRespVec.zip(robIdxVec).zip(uopIdxVec.get).foreach { case ((issueResp, robIdx), uopIdx) => 272f7890d3cSXuan Hu val hitRespsVec = VecInit(memEtyResps.map(x => 273aa2bcc31SzhanglyGit x.valid && x.bits.robIdx === robIdx && x.bits.uopIdx.get === uopIdx 274f7890d3cSXuan Hu ).toSeq) 275887f9c3dSzhanglinjuan issueResp.valid := hitRespsVec.reduce(_ | _) 276f7890d3cSXuan Hu issueResp.bits := Mux1H(hitRespsVec, memEtyResps.map(_.bits).toSeq) 277887f9c3dSzhanglinjuan } 278887f9c3dSzhanglinjuan } else if (params.isMemAddrIQ) { 279887f9c3dSzhanglinjuan // scalar memory IQ 2805db4956bSzhanglyGit issueRespVec.zip(robIdxVec).foreach { case (issueResp, robIdx) => 281c838dea1SXuan Hu val hitRespsVec = VecInit(memEtyResps.map(x => x.valid && (x.bits.robIdx === robIdx)).toSeq) 2825db4956bSzhanglyGit issueResp.valid := hitRespsVec.reduce(_ | _) 283c838dea1SXuan Hu issueResp.bits := Mux1H(hitRespsVec, memEtyResps.map(_.bits).toSeq) 2845db4956bSzhanglyGit } 2855db4956bSzhanglyGit } 2865db4956bSzhanglyGit else { 2875db4956bSzhanglyGit issueRespVec.zip(issueTimerVec).zip(deqPortIdxReadVec).foreach { case ((issueResp, issueTimer), deqPortIdx) => 2885db4956bSzhanglyGit val Resp = resps(issueTimer)(deqPortIdx) 2895db4956bSzhanglyGit issueResp := Resp 2905db4956bSzhanglyGit } 2915db4956bSzhanglyGit } 2925db4956bSzhanglyGit 29340283787Ssinsanction //deq 29428607074Ssinsanction val enqEntryOldest = Wire(Vec(params.numDeq, ValidIO(new EntryBundle))) 29528607074Ssinsanction val simpEntryOldest = OptionWrapper(params.hasCompAndSimp, Wire(Vec(params.numDeq, ValidIO(new EntryBundle)))) 29628607074Ssinsanction val compEntryOldest = OptionWrapper(params.hasCompAndSimp, Wire(Vec(params.numDeq, ValidIO(new EntryBundle)))) 29728607074Ssinsanction val othersEntryOldest = OptionWrapper(params.isAllComp || params.isAllSimp, Wire(Vec(params.numDeq, ValidIO(new EntryBundle)))) 29828607074Ssinsanction val enqEntryOldestCancel = Wire(Vec(params.numDeq, Bool())) 29928607074Ssinsanction val simpEntryOldestCancel = OptionWrapper(params.hasCompAndSimp, Wire(Vec(params.numDeq, Bool()))) 30028607074Ssinsanction val compEntryOldestCancel = OptionWrapper(params.hasCompAndSimp, Wire(Vec(params.numDeq, Bool()))) 30128607074Ssinsanction val othersEntryOldestCancel = OptionWrapper(params.isAllComp || params.isAllSimp, Wire(Vec(params.numDeq, Bool()))) 30228607074Ssinsanction 30328607074Ssinsanction io.enqEntryOldestSel.zipWithIndex.map { case (sel, deqIdx) => 30428607074Ssinsanction enqEntryOldest(deqIdx) := Mux1H(sel.bits, entries.take(EnqEntryNum)) 305eea4a3caSzhanglyGit enqEntryOldestCancel(deqIdx) := Mux1H(sel.bits, cancelBypassVec.take(EnqEntryNum)) 30640283787Ssinsanction } 30728607074Ssinsanction 30828607074Ssinsanction if (params.isAllComp || params.isAllSimp) { 30928607074Ssinsanction io.othersEntryOldestSel.get.zipWithIndex.map { case (sel, deqIdx) => 31028607074Ssinsanction othersEntryOldest.get(deqIdx) := Mux1H(sel.bits, entries.drop(EnqEntryNum)) 311eea4a3caSzhanglyGit othersEntryOldestCancel.get(deqIdx) := Mux1H(sel.bits, cancelBypassVec.drop(EnqEntryNum)) 312af4bd265SzhanglyGit } 31340283787Ssinsanction } 31428607074Ssinsanction else { 31528607074Ssinsanction io.simpEntryOldestSel.get.zipWithIndex.map { case (sel, deqIdx) => 31628607074Ssinsanction simpEntryOldest.get(deqIdx) := Mux1H(sel.bits, entries.drop(EnqEntryNum).take(SimpEntryNum)) 317eea4a3caSzhanglyGit simpEntryOldestCancel.get(deqIdx) := Mux1H(sel.bits, cancelBypassVec.drop(EnqEntryNum).take(SimpEntryNum)) 31828607074Ssinsanction } 31928607074Ssinsanction io.compEntryOldestSel.get.zipWithIndex.map { case (sel, deqIdx) => 32028607074Ssinsanction compEntryOldest.get(deqIdx) := Mux1H(sel.bits, entries.drop(EnqEntryNum).takeRight(CompEntryNum)) 321eea4a3caSzhanglyGit compEntryOldestCancel.get(deqIdx) := Mux1H(sel.bits, cancelBypassVec.drop(EnqEntryNum).takeRight(CompEntryNum)) 32228607074Ssinsanction } 323af4bd265SzhanglyGit } 324cf4a131aSsinsanction 325cf4a131aSsinsanction if (params.deqFuSame) { 326cf4a131aSsinsanction val subDeqPolicyEntryVec = Wire(Vec(params.numDeq, ValidIO(new EntryBundle))) 327cf4a131aSsinsanction val subDeqPolicyValidVec = Wire(Vec(params.numDeq, Bool())) 328a4d38a63SzhanglyGit val subDeqPolicyCancelBypassVec = Wire(Vec(params.numDeq, Bool())) 329cf4a131aSsinsanction 330aa2bcc31SzhanglyGit subDeqPolicyValidVec(0) := PopCount(io.subDeqRequest.get(0)) >= 1.U 331aa2bcc31SzhanglyGit subDeqPolicyValidVec(1) := PopCount(io.subDeqRequest.get(0)) >= 2.U 33228607074Ssinsanction 33328607074Ssinsanction if (params.isAllComp || params.isAllSimp) { 33428607074Ssinsanction subDeqPolicyEntryVec(0) := PriorityMux(io.subDeqRequest.get(0), entries) 33528607074Ssinsanction subDeqPolicyEntryVec(1) := PriorityMux(Reverse(io.subDeqRequest.get(0)), entries.reverse) 336eea4a3caSzhanglyGit subDeqPolicyCancelBypassVec(0) := PriorityMux(io.subDeqRequest.get(0), cancelBypassVec) 337eea4a3caSzhanglyGit subDeqPolicyCancelBypassVec(1) := PriorityMux(Reverse(io.subDeqRequest.get(0)), cancelBypassVec.reverse) 338cf4a131aSsinsanction 33928607074Ssinsanction io.deqEntry(0) := Mux(io.othersEntryOldestSel.get(0).valid, othersEntryOldest.get(0), subDeqPolicyEntryVec(1)) 340aa2bcc31SzhanglyGit io.deqEntry(1) := subDeqPolicyEntryVec(0) 34128607074Ssinsanction io.cancelDeqVec(0) := Mux(io.othersEntryOldestSel.get(0).valid, othersEntryOldestCancel.get(0), subDeqPolicyCancelBypassVec(1)) 342a4d38a63SzhanglyGit io.cancelDeqVec(1) := subDeqPolicyCancelBypassVec(0) 34328607074Ssinsanction } 34428607074Ssinsanction else { 34528607074Ssinsanction subDeqPolicyEntryVec(0) := PriorityMux(Reverse(io.subDeqRequest.get(0)), entries.reverse) 34628607074Ssinsanction subDeqPolicyEntryVec(1) := PriorityMux(io.subDeqRequest.get(0), entries) 347eea4a3caSzhanglyGit subDeqPolicyCancelBypassVec(0) := PriorityMux(Reverse(io.subDeqRequest.get(0)), cancelBypassVec.reverse) 348eea4a3caSzhanglyGit subDeqPolicyCancelBypassVec(1) := PriorityMux(io.subDeqRequest.get(0), cancelBypassVec) 34928607074Ssinsanction 35028607074Ssinsanction io.deqEntry(0) := Mux(io.compEntryOldestSel.get(0).valid, 35128607074Ssinsanction compEntryOldest.get(0), 35228607074Ssinsanction Mux(io.simpEntryOldestSel.get(0).valid, simpEntryOldest.get(0), subDeqPolicyEntryVec(1))) 35328607074Ssinsanction io.deqEntry(1) := subDeqPolicyEntryVec(0) 35428607074Ssinsanction io.cancelDeqVec(0) := Mux(io.compEntryOldestSel.get(0).valid, 35528607074Ssinsanction compEntryOldestCancel.get(0), 35628607074Ssinsanction Mux(io.simpEntryOldestSel.get(0).valid, simpEntryOldestCancel.get(0), subDeqPolicyCancelBypassVec(1))) 35728607074Ssinsanction io.cancelDeqVec(1) := subDeqPolicyCancelBypassVec(0) 35828607074Ssinsanction } 359cf4a131aSsinsanction 360cf4a131aSsinsanction when (subDeqPolicyValidVec(0)) { 361aa2bcc31SzhanglyGit assert(Mux1H(io.subDeqSelOH.get(0), entries).bits.status.robIdx === subDeqPolicyEntryVec(0).bits.status.robIdx, "subDeqSelOH(0) is not the same\n") 36240283787Ssinsanction } 363cf4a131aSsinsanction when (subDeqPolicyValidVec(1)) { 364aa2bcc31SzhanglyGit assert(Mux1H(io.subDeqSelOH.get(1), entries).bits.status.robIdx === subDeqPolicyEntryVec(1).bits.status.robIdx, "subDeqSelOH(1) is not the same\n") 365f7f73727Ssinsanction } 366f7f73727Ssinsanction } 367f7f73727Ssinsanction else { 36828607074Ssinsanction if (params.isAllComp || params.isAllSimp) { 36928607074Ssinsanction io.othersEntryOldestSel.get.zipWithIndex.foreach { case (sel, i) => 37028607074Ssinsanction io.deqEntry(i) := Mux(sel.valid, othersEntryOldest.get(i), enqEntryOldest(i)) 37128607074Ssinsanction io.cancelDeqVec(i) := Mux(sel.valid, othersEntryOldestCancel.get(i), enqEntryOldestCancel(i)) 37228607074Ssinsanction } 37328607074Ssinsanction } 37428607074Ssinsanction else { 37528607074Ssinsanction io.compEntryOldestSel.get.zip(io.simpEntryOldestSel.get).zipWithIndex.foreach { case ((compSel, simpSel), i) => 37628607074Ssinsanction io.deqEntry(i) := Mux(compSel.valid, 37728607074Ssinsanction compEntryOldest.get(i), 37828607074Ssinsanction Mux(simpSel.valid, simpEntryOldest.get(i), enqEntryOldest(i))) 37928607074Ssinsanction io.cancelDeqVec(i) := Mux(compSel.valid, 38028607074Ssinsanction compEntryOldestCancel.get(i), 38128607074Ssinsanction Mux(simpSel.valid, simpEntryOldestCancel.get(i), enqEntryOldestCancel(i))) 38228607074Ssinsanction } 383af4bd265SzhanglyGit } 384af4bd265SzhanglyGit } 385af4bd265SzhanglyGit 3865db4956bSzhanglyGit io.valid := validVec.asUInt 3875db4956bSzhanglyGit io.canIssue := canIssueVec.asUInt 3885db4956bSzhanglyGit io.fuType := fuTypeVec 3895db4956bSzhanglyGit io.dataSources := dataSourceVec 390aa2bcc31SzhanglyGit io.srcWakeUpL1ExuOH.foreach(_ := srcWakeUpL1ExuOHVec.get.map(x => VecInit(x.map(_.asUInt)))) 391eea4a3caSzhanglyGit io.loadDependency := loadDependencyVec 392aa2bcc31SzhanglyGit io.isFirstIssue.zipWithIndex.foreach{ case (isFirstIssue, deqIdx) => 393aa2bcc31SzhanglyGit isFirstIssue := io.deqSelOH(deqIdx).valid && Mux1H(io.deqSelOH(deqIdx).bits, isFirstIssueVec) 3948d081717Sszw_kaixin } 39528607074Ssinsanction io.simpEntryEnqSelVec.foreach(_ := finalSimpTransSelVec.get.zip(enqEntryTransVec).map(x => x._1 & Fill(SimpEntryNum, x._2.valid))) 39628607074Ssinsanction io.compEntryEnqSelVec.foreach(_ := finalCompTransSelVec.get.zip(compEnqVec.get).map(x => x._1 & Fill(CompEntryNum, x._2.valid))) 39728607074Ssinsanction io.othersEntryEnqSelVec.foreach(_ := finalOthersTransSelVec.get.zip(enqEntryTransVec).map(x => x._1 & Fill(OthersEntryNum, x._2.valid))) 398aa2bcc31SzhanglyGit io.robIdx.foreach(_ := robIdxVec) 399aa2bcc31SzhanglyGit io.uopIdx.foreach(_ := uopIdxVec.get) 400aa2bcc31SzhanglyGit 4017e471bf8SXuan Hu 402aa2bcc31SzhanglyGit def EntriesConnect(in: CommonInBundle, out: CommonOutBundle, entryIdx: Int) = { 403aa2bcc31SzhanglyGit in.flush := io.flush 404aa2bcc31SzhanglyGit in.wakeUpFromWB := io.wakeUpFromWB 405aa2bcc31SzhanglyGit in.wakeUpFromIQ := io.wakeUpFromIQ 406b6279fc6SZiyue Zhang in.vlIsZero := io.vlIsZero 407b6279fc6SZiyue Zhang in.vlIsVlmax := io.vlIsVlmax 408aa2bcc31SzhanglyGit in.og0Cancel := io.og0Cancel 409aa2bcc31SzhanglyGit in.og1Cancel := io.og1Cancel 410aa2bcc31SzhanglyGit in.ldCancel := io.ldCancel 411aa2bcc31SzhanglyGit in.deqSel := deqSelVec(entryIdx) 412aa2bcc31SzhanglyGit in.deqPortIdxWrite := deqPortIdxWriteVec(entryIdx) 413aa2bcc31SzhanglyGit in.issueResp := issueRespVec(entryIdx) 414aa2bcc31SzhanglyGit if (params.isVecMemIQ) { 415aa2bcc31SzhanglyGit in.fromLsq.get.sqDeqPtr := io.vecMemIn.get.sqDeqPtr 416aa2bcc31SzhanglyGit in.fromLsq.get.lqDeqPtr := io.vecMemIn.get.lqDeqPtr 417aa2bcc31SzhanglyGit } 418aa2bcc31SzhanglyGit validVec(entryIdx) := out.valid 419aa2bcc31SzhanglyGit canIssueVec(entryIdx) := out.canIssue 420aa2bcc31SzhanglyGit fuTypeVec(entryIdx) := out.fuType 421aa2bcc31SzhanglyGit robIdxVec(entryIdx) := out.robIdx 422aa2bcc31SzhanglyGit dataSourceVec(entryIdx) := out.dataSource 423aa2bcc31SzhanglyGit isFirstIssueVec(entryIdx) := out.isFirstIssue 424aa2bcc31SzhanglyGit entries(entryIdx) := out.entry 425aa2bcc31SzhanglyGit deqPortIdxReadVec(entryIdx) := out.deqPortIdxRead 426aa2bcc31SzhanglyGit issueTimerVec(entryIdx) := out.issueTimerRead 427eea4a3caSzhanglyGit loadDependencyVec(entryIdx) := out.entry.bits.status.mergedLoadDependency 428ec49b127Ssinsanction cancelBypassVec(entryIdx) := out.cancelBypass 429aa2bcc31SzhanglyGit if (params.hasIQWakeUp) { 430aa2bcc31SzhanglyGit srcWakeUpL1ExuOHVec.get(entryIdx) := out.srcWakeUpL1ExuOH.get 431aa2bcc31SzhanglyGit } 432aa2bcc31SzhanglyGit if (params.isVecMemIQ) { 433aa2bcc31SzhanglyGit uopIdxVec.get(entryIdx) := out.uopIdx.get 434aa2bcc31SzhanglyGit } 435a6938b17Ssinsanction entryInValidVec(entryIdx) := out.entryInValid 436a6938b17Ssinsanction entryOutDeqValidVec(entryIdx) := out.entryOutDeqValid 437a6938b17Ssinsanction entryOutTransValidVec(entryIdx) := out.entryOutTransValid 438e3ef3537Ssinsanction perfWakeupByWBVec(entryIdx) := out.perfWakeupByWB 439e3ef3537Ssinsanction if (params.hasIQWakeUp) { 440e3ef3537Ssinsanction perfLdCancelVec.get(entryIdx) := out.perfLdCancel.get 441e3ef3537Ssinsanction perfOg0CancelVec.get(entryIdx) := out.perfOg0Cancel.get 442e3ef3537Ssinsanction perfWakeupByIQVec.get(entryIdx) := out.perfWakeupByIQ.get 443aa2bcc31SzhanglyGit } 444aa2bcc31SzhanglyGit } 445a6938b17Ssinsanction 446*25df626eSgood-circle io.vecLdIn.foreach(dontTouch(_)) 447a6938b17Ssinsanction 448a6938b17Ssinsanction // entries perf counter 449a6938b17Ssinsanction // enq 450a6938b17Ssinsanction for (i <- 0 until params.numEnq) { 451a6938b17Ssinsanction XSPerfAccumulate(s"enqEntry_${i}_in_cnt", entryInValidVec(i)) 452a6938b17Ssinsanction XSPerfAccumulate(s"enqEntry_${i}_out_deq_cnt", entryOutDeqValidVec(i)) 453a6938b17Ssinsanction XSPerfAccumulate(s"enqEntry_${i}_out_trans_cnt", entryOutTransValidVec(i)) 454a6938b17Ssinsanction } 455a6938b17Ssinsanction // simple 456a6938b17Ssinsanction for (i <- 0 until params.numSimp) { 457a6938b17Ssinsanction XSPerfAccumulate(s"simpEntry_${i}_in_cnt", entryInValidVec(i + params.numEnq)) 458a6938b17Ssinsanction XSPerfAccumulate(s"simpEntry_${i}_out_deq_cnt", entryOutDeqValidVec(i + params.numEnq)) 459a6938b17Ssinsanction XSPerfAccumulate(s"simpEntry_${i}_out_trans_cnt", entryOutTransValidVec(i + params.numEnq)) 460a6938b17Ssinsanction } 461a6938b17Ssinsanction // complex 462a6938b17Ssinsanction for (i <- 0 until params.numComp) { 463a6938b17Ssinsanction XSPerfAccumulate(s"compEntry_${i}_in_cnt", entryInValidVec(i + params.numEnq + params.numSimp)) 464a6938b17Ssinsanction XSPerfAccumulate(s"compEntry_${i}_out_deq_cnt", entryOutDeqValidVec(i + params.numEnq + params.numSimp)) 465a6938b17Ssinsanction XSPerfAccumulate(s"compEntry_${i}_out_trans_cnt", entryOutTransValidVec(i + params.numEnq + params.numSimp)) 466a6938b17Ssinsanction } 467a6938b17Ssinsanction // total 468a6938b17Ssinsanction XSPerfAccumulate(s"enqEntry_all_in_cnt", PopCount(entryInValidVec.take(params.numEnq))) 469a6938b17Ssinsanction XSPerfAccumulate(s"enqEntry_all_out_deq_cnt", PopCount(entryOutDeqValidVec.take(params.numEnq))) 470a6938b17Ssinsanction XSPerfAccumulate(s"enqEntry_all_out_trans_cnt", PopCount(entryOutTransValidVec.take(params.numEnq))) 471e3ef3537Ssinsanction for (srcIdx <- 0 until params.numRegSrc) { 472e3ef3537Ssinsanction XSPerfAccumulate(s"enqEntry_all_wakeup_wb_src${srcIdx}_cnt", PopCount(perfWakeupByWBVec.take(params.numEnq).map(_(srcIdx)))) 473d280e426Slewislzh if (params.hasIQWakeUp) { 474e3ef3537Ssinsanction XSPerfAccumulate(s"enqEntry_all_ldCancel_src${srcIdx}_cnt", PopCount(perfLdCancelVec.get.take(params.numEnq).map(_(srcIdx)))) 475e3ef3537Ssinsanction XSPerfAccumulate(s"enqEntry_all_og0Cancel_src${srcIdx}_cnt", PopCount(perfOg0CancelVec.get.take(params.numEnq).map(_(srcIdx)))) 476e3ef3537Ssinsanction for (iqIdx <- 0 until params.numWakeupFromIQ) { 477e3ef3537Ssinsanction XSPerfAccumulate(s"enqEntry_all_wakeup_iq_from_exu${params.wakeUpSourceExuIdx(iqIdx)}_src${srcIdx}_cnt", PopCount(perfWakeupByIQVec.get.take(params.numEnq).map(_(srcIdx)(iqIdx)))) 478e3ef3537Ssinsanction } 479e3ef3537Ssinsanction } 480d280e426Slewislzh } 481a6938b17Ssinsanction 482a6938b17Ssinsanction XSPerfAccumulate(s"othersEntry_all_in_cnt", PopCount(entryInValidVec.drop(params.numEnq))) 483a6938b17Ssinsanction XSPerfAccumulate(s"othersEntry_all_out_deq_cnt", PopCount(entryOutDeqValidVec.drop(params.numEnq))) 484a6938b17Ssinsanction XSPerfAccumulate(s"othersEntry_all_out_trans_cnt", PopCount(entryOutTransValidVec.drop(params.numEnq))) 4857e471bf8SXuan Hu 486e3ef3537Ssinsanction for (srcIdx <- 0 until params.numRegSrc) { 487e3ef3537Ssinsanction XSPerfAccumulate(s"othersEntry_all_wakeup_wb_src${srcIdx}_cnt", PopCount(perfWakeupByWBVec.drop(params.numEnq).map(_(srcIdx)))) 488d280e426Slewislzh if (params.hasIQWakeUp) { 489e3ef3537Ssinsanction XSPerfAccumulate(s"othersEntry_all_ldCancel_src${srcIdx}_cnt", PopCount(perfLdCancelVec.get.drop(params.numEnq).map(_(srcIdx)))) 490e3ef3537Ssinsanction XSPerfAccumulate(s"othersEntry_all_og0Cancel_src${srcIdx}_cnt", PopCount(perfOg0CancelVec.get.drop(params.numEnq).map(_(srcIdx)))) 491e3ef3537Ssinsanction for (iqIdx <- 0 until params.numWakeupFromIQ) { 492e3ef3537Ssinsanction XSPerfAccumulate(s"othersEntry_all_wakeup_iq_from_exu${params.wakeUpSourceExuIdx(iqIdx)}_src${srcIdx}_cnt", PopCount(perfWakeupByIQVec.get.drop(params.numEnq).map(_(srcIdx)(iqIdx)))) 493e3ef3537Ssinsanction } 494e3ef3537Ssinsanction } 495e3ef3537Ssinsanction } 496e3ef3537Ssinsanction 497e3ef3537Ssinsanction for (t <- FuType.functionNameMap.keys) { 498e3ef3537Ssinsanction val fuName = FuType.functionNameMap(t) 499e3ef3537Ssinsanction if (params.getFuCfgs.map(_.fuType == t).reduce(_ | _) && params.getFuCfgs.size > 1) { 500e3ef3537Ssinsanction for (srcIdx <- 0 until params.numRegSrc) { 501e3ef3537Ssinsanction XSPerfAccumulate(s"allEntry_futype_${fuName}_wakeup_wb_src${srcIdx}_cnt", PopCount(perfWakeupByWBVec.zip(fuTypeVec).map{ case(x, fu) => x(srcIdx) && fu(t.id) })) 502e3ef3537Ssinsanction if (params.hasIQWakeUp) { 503e3ef3537Ssinsanction XSPerfAccumulate(s"allEntry_futype_${fuName}_ldCancel_src${srcIdx}_cnt", PopCount(perfLdCancelVec.get.zip(fuTypeVec).map{ case(x, fu) => x(srcIdx) && fu(t.id) })) 504e3ef3537Ssinsanction XSPerfAccumulate(s"allEntry_futype_${fuName}_og0Cancel_src${srcIdx}_cnt", PopCount(perfOg0CancelVec.get.zip(fuTypeVec).map{ case(x, fu) => x(srcIdx) && fu(t.id) })) 505e3ef3537Ssinsanction for (iqIdx <- 0 until params.numWakeupFromIQ) { 506e3ef3537Ssinsanction 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) })) 507e3ef3537Ssinsanction } 508e3ef3537Ssinsanction } 509e3ef3537Ssinsanction } 510e3ef3537Ssinsanction } 511d280e426Slewislzh } 512aa2bcc31SzhanglyGit} 513aa2bcc31SzhanglyGit 514aa2bcc31SzhanglyGitclass EntriesIO(implicit p: Parameters, params: IssueBlockParams) extends XSBundle { 515aa2bcc31SzhanglyGit val flush = Flipped(ValidIO(new Redirect)) 516aa2bcc31SzhanglyGit //enq 517aa2bcc31SzhanglyGit val enq = Vec(params.numEnq, Flipped(ValidIO(new EntryBundle))) 518aa2bcc31SzhanglyGit val og0Resp = Vec(params.numDeq, Flipped(ValidIO(new EntryDeqRespBundle))) 519aa2bcc31SzhanglyGit val og1Resp = Vec(params.numDeq, Flipped(ValidIO(new EntryDeqRespBundle))) 520c38df446SzhanglyGit val og2Resp = OptionWrapper(params.inVfSchd, Vec(params.numDeq, Flipped(ValidIO(new EntryDeqRespBundle)))) 521aa2bcc31SzhanglyGit //deq sel 522aa2bcc31SzhanglyGit val deqReady = Vec(params.numDeq, Input(Bool())) 523aa2bcc31SzhanglyGit val deqSelOH = Vec(params.numDeq, Flipped(ValidIO(UInt(params.numEntries.W)))) 524aa2bcc31SzhanglyGit val enqEntryOldestSel = Vec(params.numDeq, Flipped(ValidIO(UInt(params.numEnq.W)))) 52528607074Ssinsanction val simpEntryOldestSel = OptionWrapper(params.hasCompAndSimp, Vec(params.numDeq, Flipped(ValidIO(UInt(params.numSimp.W))))) 52628607074Ssinsanction val compEntryOldestSel = OptionWrapper(params.hasCompAndSimp, Vec(params.numDeq, Flipped(ValidIO(UInt(params.numComp.W))))) 52728607074Ssinsanction val othersEntryOldestSel= OptionWrapper(params.isAllComp || params.isAllSimp, Vec(params.numDeq, Flipped(ValidIO(UInt((params.numEntries - params.numEnq).W))))) 528aa2bcc31SzhanglyGit val subDeqRequest = OptionWrapper(params.deqFuSame, Vec(params.numDeq, Input(UInt(params.numEntries.W)))) 529aa2bcc31SzhanglyGit val subDeqSelOH = OptionWrapper(params.deqFuSame, Vec(params.numDeq, Input(UInt(params.numEntries.W)))) 530aa2bcc31SzhanglyGit // wakeup 531aa2bcc31SzhanglyGit val wakeUpFromWB: MixedVec[ValidIO[IssueQueueWBWakeUpBundle]] = Flipped(params.genWBWakeUpSinkValidBundle) 532aa2bcc31SzhanglyGit val wakeUpFromIQ: MixedVec[ValidIO[IssueQueueIQWakeUpBundle]] = Flipped(params.genIQWakeUpSinkValidBundle) 533b6279fc6SZiyue Zhang val vlIsZero = Input(Bool()) 534b6279fc6SZiyue Zhang val vlIsVlmax = Input(Bool()) 535aa2bcc31SzhanglyGit val og0Cancel = Input(ExuOH(backendParams.numExu)) 536aa2bcc31SzhanglyGit val og1Cancel = Input(ExuOH(backendParams.numExu)) 537aa2bcc31SzhanglyGit val ldCancel = Vec(backendParams.LdExuCnt, Flipped(new LoadCancelIO)) 538aa2bcc31SzhanglyGit //entries status 539aa2bcc31SzhanglyGit val valid = Output(UInt(params.numEntries.W)) 540aa2bcc31SzhanglyGit val canIssue = Output(UInt(params.numEntries.W)) 541aa2bcc31SzhanglyGit val fuType = Vec(params.numEntries, Output(FuType())) 542aa2bcc31SzhanglyGit val dataSources = Vec(params.numEntries, Vec(params.numRegSrc, Output(DataSource()))) 543ec49b127Ssinsanction val loadDependency = Vec(params.numEntries, Vec(LoadPipelineWidth, UInt(LoadDependencyWidth.W))) 544aa2bcc31SzhanglyGit val srcWakeUpL1ExuOH = OptionWrapper(params.hasIQWakeUp, Vec(params.numEntries, Vec(params.numRegSrc, Output(ExuOH())))) 545aa2bcc31SzhanglyGit //deq status 546aa2bcc31SzhanglyGit val isFirstIssue = Vec(params.numDeq, Output(Bool())) 547aa2bcc31SzhanglyGit val deqEntry = Vec(params.numDeq, ValidIO(new EntryBundle)) 548aa2bcc31SzhanglyGit val cancelDeqVec = Vec(params.numDeq, Output(Bool())) 549e07131b2Ssinsanction 550e07131b2Ssinsanction // load/hybird only 551e07131b2Ssinsanction val fromLoad = OptionWrapper(params.isLdAddrIQ || params.isHyAddrIQ, new Bundle { 552e07131b2Ssinsanction val finalIssueResp = Vec(params.numDeq, Flipped(ValidIO(new EntryDeqRespBundle))) 553e07131b2Ssinsanction val memAddrIssueResp = Vec(params.numDeq, Flipped(ValidIO(new EntryDeqRespBundle))) 554e07131b2Ssinsanction }) 555aa2bcc31SzhanglyGit // mem only 556e07131b2Ssinsanction val fromMem = OptionWrapper(params.isMemAddrIQ, new Bundle { 557aa2bcc31SzhanglyGit val slowResp = Vec(params.numDeq, Flipped(ValidIO(new EntryDeqRespBundle))) 558d3372210SzhanglyGit val fastResp = Vec(params.numDeq, Flipped(ValidIO(new EntryDeqRespBundle))) 559e07131b2Ssinsanction }) 56099944b79Ssinsanction // vec mem only 561aa2bcc31SzhanglyGit val vecMemIn = OptionWrapper(params.isVecMemIQ, new Bundle { 562aa2bcc31SzhanglyGit val sqDeqPtr = Input(new SqPtr) 563aa2bcc31SzhanglyGit val lqDeqPtr = Input(new LqPtr) 564aa2bcc31SzhanglyGit }) 5657e471bf8SXuan Hu val vecLdIn = OptionWrapper(params.isVecLduIQ, new Bundle { 5667e471bf8SXuan Hu val resp = Vec(params.numDeq, Flipped(ValidIO(new EntryDeqRespBundle))) 5677e471bf8SXuan Hu }) 568aa2bcc31SzhanglyGit val robIdx = OptionWrapper(params.isVecMemIQ, Output(Vec(params.numEntries, new RobPtr))) 569aa2bcc31SzhanglyGit val uopIdx = OptionWrapper(params.isVecMemIQ, Output(Vec(params.numEntries, UopIdx()))) 570aa2bcc31SzhanglyGit 57128607074Ssinsanction // trans 57228607074Ssinsanction val simpEntryDeqSelVec = OptionWrapper(params.hasCompAndSimp, Vec(params.numEnq, Input(UInt(params.numSimp.W)))) 57328607074Ssinsanction val simpEntryEnqSelVec = OptionWrapper(params.hasCompAndSimp, Vec(params.numEnq, Output(UInt(params.numSimp.W)))) 57428607074Ssinsanction val compEntryEnqSelVec = OptionWrapper(params.hasCompAndSimp, Vec(params.numEnq, Output(UInt(params.numComp.W)))) 57528607074Ssinsanction val othersEntryEnqSelVec = OptionWrapper(params.isAllComp || params.isAllSimp, Vec(params.numEnq, Output(UInt((params.numEntries - params.numEnq).W)))) 576aa2bcc31SzhanglyGit 577aa2bcc31SzhanglyGit def wakeup = wakeUpFromWB ++ wakeUpFromIQ 5785db4956bSzhanglyGit} 579