1aa2bcc31SzhanglyGitpackage xiangshan.backend.issue 2aa2bcc31SzhanglyGit 3aa2bcc31SzhanglyGitimport org.chipsalliance.cde.config.Parameters 4aa2bcc31SzhanglyGitimport chisel3._ 5aa2bcc31SzhanglyGitimport chisel3.util._ 6ac90e54aSxiaofeibao-xjtuimport ujson.IndexedValue.True 7bb2f3f51STang Haojinimport utils.MathUtils 8bb2f3f51STang Haojinimport utility.{HasCircularQueuePtrHelper, XSError} 9aa2bcc31SzhanglyGitimport xiangshan._ 10aa2bcc31SzhanglyGitimport xiangshan.backend.Bundles._ 11aa2bcc31SzhanglyGitimport xiangshan.backend.datapath.DataSource 12aa2bcc31SzhanglyGitimport xiangshan.backend.fu.FuType 136dbb4e08SXuan Huimport xiangshan.backend.fu.vector.Bundles.NumLsElem 14aa2bcc31SzhanglyGitimport xiangshan.backend.rob.RobPtr 156dbb4e08SXuan Huimport xiangshan.mem.{LqPtr, MemWaitUpdateReq, SqPtr} 16aa2bcc31SzhanglyGit 17aa2bcc31SzhanglyGitobject EntryBundles extends HasCircularQueuePtrHelper { 18aa2bcc31SzhanglyGit 19aa2bcc31SzhanglyGit class Status(implicit p: Parameters, params: IssueBlockParams) extends XSBundle { 20aa2bcc31SzhanglyGit //basic status 21aa2bcc31SzhanglyGit val robIdx = new RobPtr 22aa2bcc31SzhanglyGit val fuType = IQFuType() 23aa2bcc31SzhanglyGit //src status 24aa2bcc31SzhanglyGit val srcStatus = Vec(params.numRegSrc, new SrcStatus) 25aa2bcc31SzhanglyGit //issue status 26aa2bcc31SzhanglyGit val blocked = Bool() 27aa2bcc31SzhanglyGit val issued = Bool() 28aa2bcc31SzhanglyGit val firstIssue = Bool() 29aa2bcc31SzhanglyGit val issueTimer = UInt(2.W) 30aa2bcc31SzhanglyGit val deqPortIdx = UInt(1.W) 31aa2bcc31SzhanglyGit //vector mem status 32bb2f3f51STang Haojin val vecMem = Option.when(params.isVecMemIQ)(new StatusVecMemPart) 33aa2bcc31SzhanglyGit 34aa2bcc31SzhanglyGit def srcReady: Bool = { 35aa2bcc31SzhanglyGit VecInit(srcStatus.map(_.srcState).map(SrcState.isReady)).asUInt.andR 36aa2bcc31SzhanglyGit } 37aa2bcc31SzhanglyGit 38aa2bcc31SzhanglyGit def canIssue: Bool = { 39aa2bcc31SzhanglyGit srcReady && !issued && !blocked 40aa2bcc31SzhanglyGit } 41aa2bcc31SzhanglyGit 42eea4a3caSzhanglyGit def mergedLoadDependency: Vec[UInt] = { 43eea4a3caSzhanglyGit srcStatus.map(_.srcLoadDependency).reduce({ 44aa2bcc31SzhanglyGit case (l: Vec[UInt], r: Vec[UInt]) => VecInit(l.zip(r).map(x => x._1 | x._2)) 45eea4a3caSzhanglyGit }: (Vec[UInt], Vec[UInt]) => Vec[UInt]) 46aa2bcc31SzhanglyGit } 47aa2bcc31SzhanglyGit } 48aa2bcc31SzhanglyGit 49aa2bcc31SzhanglyGit class SrcStatus(implicit p: Parameters, params: IssueBlockParams) extends XSBundle { 50aa2bcc31SzhanglyGit val psrc = UInt(params.rdPregIdxWidth.W) 51aa2bcc31SzhanglyGit val srcType = SrcType() 52aa2bcc31SzhanglyGit val srcState = SrcState() 53aa2bcc31SzhanglyGit val dataSources = DataSource() 54ec49b127Ssinsanction val srcLoadDependency = Vec(LoadPipelineWidth, UInt(LoadDependencyWidth.W)) 55bb2f3f51STang Haojin val srcWakeUpL1ExuOH = Option.when(params.hasIQWakeUp)(ExuVec()) 564c2a845dSsinsanction //reg cache 574c2a845dSsinsanction val useRegCache = Option.when(params.needReadRegCache)(Bool()) 584c2a845dSsinsanction val regCacheIdx = Option.when(params.needReadRegCache)(UInt(RegCacheIdxWidth.W)) 59aa2bcc31SzhanglyGit } 60aa2bcc31SzhanglyGit 61aa2bcc31SzhanglyGit class StatusVecMemPart(implicit p:Parameters, params: IssueBlockParams) extends Bundle { 62aa2bcc31SzhanglyGit val sqIdx = new SqPtr 63aa2bcc31SzhanglyGit val lqIdx = new LqPtr 646dbb4e08SXuan Hu val numLsElem = NumLsElem() 65aa2bcc31SzhanglyGit } 66aa2bcc31SzhanglyGit 6742b6cdf9Ssinsanction class EntryDeqRespBundle(implicit p: Parameters, val params: IssueBlockParams) extends XSBundle { 68aa2bcc31SzhanglyGit val robIdx = new RobPtr 69f08a822fSzhanglyGit val resp = RespType() 70aa2bcc31SzhanglyGit val fuType = FuType() 71bb2f3f51STang Haojin val uopIdx = Option.when(params.isVecMemIQ)(Output(UopIdx())) 72bb2f3f51STang Haojin val sqIdx = Option.when(params.needFeedBackSqIdx)(new SqPtr()) 73bb2f3f51STang Haojin val lqIdx = Option.when(params.needFeedBackLqIdx)(new LqPtr()) 74aa2bcc31SzhanglyGit } 75aa2bcc31SzhanglyGit 76f08a822fSzhanglyGit object RespType { 77f08a822fSzhanglyGit def apply() = UInt(2.W) 78f08a822fSzhanglyGit 79f08a822fSzhanglyGit def isBlocked(resp: UInt) = { 80f08a822fSzhanglyGit resp === block 81f08a822fSzhanglyGit } 82f08a822fSzhanglyGit 83f08a822fSzhanglyGit def succeed(resp: UInt) = { 84f08a822fSzhanglyGit resp === success 85f08a822fSzhanglyGit } 86f08a822fSzhanglyGit 87f08a822fSzhanglyGit val block = "b00".U 88f08a822fSzhanglyGit val uncertain = "b01".U 89f08a822fSzhanglyGit val success = "b11".U 90f08a822fSzhanglyGit } 91f08a822fSzhanglyGit 92aa2bcc31SzhanglyGit class EntryBundle(implicit p: Parameters, params: IssueBlockParams) extends XSBundle { 93aa2bcc31SzhanglyGit val status = new Status() 94bb2f3f51STang Haojin val imm = Option.when(params.needImm)(UInt((params.deqImmTypesMaxLen).W)) 95aa2bcc31SzhanglyGit val payload = new DynInst() 96aa2bcc31SzhanglyGit } 97aa2bcc31SzhanglyGit 98aa2bcc31SzhanglyGit class CommonInBundle(implicit p: Parameters, params: IssueBlockParams) extends XSBundle { 99aa2bcc31SzhanglyGit val flush = Flipped(ValidIO(new Redirect)) 100aa2bcc31SzhanglyGit val enq = Flipped(ValidIO(new EntryBundle)) 101aa2bcc31SzhanglyGit //wakeup 102aa2bcc31SzhanglyGit val wakeUpFromWB: MixedVec[ValidIO[IssueQueueWBWakeUpBundle]] = Flipped(params.genWBWakeUpSinkValidBundle) 103aa2bcc31SzhanglyGit val wakeUpFromIQ: MixedVec[ValidIO[IssueQueueIQWakeUpBundle]] = Flipped(params.genIQWakeUpSinkValidBundle) 104b6279fc6SZiyue Zhang // vl 105d88d4328SZiyue Zhang val vlFromIntIsZero = Input(Bool()) 106d88d4328SZiyue Zhang val vlFromIntIsVlmax = Input(Bool()) 107d88d4328SZiyue Zhang val vlFromVfIsZero = Input(Bool()) 108d88d4328SZiyue Zhang val vlFromVfIsVlmax = Input(Bool()) 109aa2bcc31SzhanglyGit //cancel 110be9ff987Ssinsanction val og0Cancel = Input(ExuVec()) 111be9ff987Ssinsanction val og1Cancel = Input(ExuVec()) 112aa2bcc31SzhanglyGit val ldCancel = Vec(backendParams.LdExuCnt, Flipped(new LoadCancelIO)) 113aa2bcc31SzhanglyGit //deq sel 114aa2bcc31SzhanglyGit val deqSel = Input(Bool()) 115aa2bcc31SzhanglyGit val deqPortIdxWrite = Input(UInt(1.W)) 116aa2bcc31SzhanglyGit val issueResp = Flipped(ValidIO(new EntryDeqRespBundle)) 117aa2bcc31SzhanglyGit //trans sel 118aa2bcc31SzhanglyGit val transSel = Input(Bool()) 119aa2bcc31SzhanglyGit // vector mem only 120bb2f3f51STang Haojin val fromLsq = Option.when(params.isVecMemIQ)(new Bundle { 121aa2bcc31SzhanglyGit val sqDeqPtr = Input(new SqPtr) 122aa2bcc31SzhanglyGit val lqDeqPtr = Input(new LqPtr) 123aa2bcc31SzhanglyGit }) 124aa2bcc31SzhanglyGit } 125aa2bcc31SzhanglyGit 126aa2bcc31SzhanglyGit class CommonOutBundle(implicit p: Parameters, params: IssueBlockParams) extends XSBundle { 127aa2bcc31SzhanglyGit //status 128aa2bcc31SzhanglyGit val valid = Output(Bool()) 129c0beb497Sxiaofeibao val issued = Output(Bool()) 130aa2bcc31SzhanglyGit val canIssue = Output(Bool()) 131aa2bcc31SzhanglyGit val fuType = Output(FuType()) 132aa2bcc31SzhanglyGit val robIdx = Output(new RobPtr) 133bb2f3f51STang Haojin val uopIdx = Option.when(params.isVecMemIQ)(Output(UopIdx())) 134aa2bcc31SzhanglyGit //src 135aa2bcc31SzhanglyGit val dataSource = Vec(params.numRegSrc, Output(DataSource())) 136bb2f3f51STang Haojin val srcWakeUpL1ExuOH = Option.when(params.hasIQWakeUp)(Vec(params.numRegSrc, Output(ExuVec()))) 137aa2bcc31SzhanglyGit //deq 138aa2bcc31SzhanglyGit val isFirstIssue = Output(Bool()) 139aa2bcc31SzhanglyGit val entry = ValidIO(new EntryBundle) 140ec49b127Ssinsanction val cancelBypass = Output(Bool()) 141aa2bcc31SzhanglyGit val deqPortIdxRead = Output(UInt(1.W)) 142aa2bcc31SzhanglyGit val issueTimerRead = Output(UInt(2.W)) 143397c0f33Ssinsanction //trans 144397c0f33Ssinsanction val enqReady = Output(Bool()) 145397c0f33Ssinsanction val transEntry = ValidIO(new EntryBundle) 146aa2bcc31SzhanglyGit // debug 147a6938b17Ssinsanction val entryInValid = Output(Bool()) 148a6938b17Ssinsanction val entryOutDeqValid = Output(Bool()) 149a6938b17Ssinsanction val entryOutTransValid = Output(Bool()) 150bb2f3f51STang Haojin val perfLdCancel = Option.when(params.hasIQWakeUp)(Output(Vec(params.numRegSrc, Bool()))) 151bb2f3f51STang Haojin val perfOg0Cancel = Option.when(params.hasIQWakeUp)(Output(Vec(params.numRegSrc, Bool()))) 152e3ef3537Ssinsanction val perfWakeupByWB = Output(Vec(params.numRegSrc, Bool())) 153bb2f3f51STang Haojin val perfWakeupByIQ = Option.when(params.hasIQWakeUp)(Output(Vec(params.numRegSrc, Vec(params.numWakeupFromIQ, Bool())))) 154aa2bcc31SzhanglyGit } 155aa2bcc31SzhanglyGit 156aa2bcc31SzhanglyGit class CommonWireBundle(implicit p: Parameters, params: IssueBlockParams) extends XSBundle { 157aa2bcc31SzhanglyGit val validRegNext = Bool() 158aa2bcc31SzhanglyGit val flushed = Bool() 159aa2bcc31SzhanglyGit val clear = Bool() 160aa2bcc31SzhanglyGit val canIssue = Bool() 161aa2bcc31SzhanglyGit val enqReady = Bool() 162aa2bcc31SzhanglyGit val deqSuccess = Bool() 163aa2bcc31SzhanglyGit val srcWakeupByWB = Vec(params.numRegSrc, Bool()) 164d88d4328SZiyue Zhang val vlWakeupByIntWb = Bool() 165d88d4328SZiyue Zhang val vlWakeupByVfWb = Bool() 166eea4a3caSzhanglyGit val srcCancelVec = Vec(params.numRegSrc, Bool()) 167eea4a3caSzhanglyGit val srcLoadCancelVec = Vec(params.numRegSrc, Bool()) 168*e311c278Ssinsanction val srcLoadTransCancelVec = Vec(params.numRegSrc, Bool()) 169ec49b127Ssinsanction val srcLoadDependencyNext = Vec(params.numRegSrc, Vec(LoadPipelineWidth, UInt(LoadDependencyWidth.W))) 170aa2bcc31SzhanglyGit } 171aa2bcc31SzhanglyGit 1720dfdb52aSzhanglyGit def CommonWireConnect(common: CommonWireBundle, hasIQWakeup: Option[CommonIQWakeupBundle], validReg: Bool, status: Status, commonIn: CommonInBundle, isEnq: Boolean)(implicit p: Parameters, params: IssueBlockParams) = { 173aa2bcc31SzhanglyGit val hasIQWakeupGet = hasIQWakeup.getOrElse(0.U.asTypeOf(new CommonIQWakeupBundle)) 1740dfdb52aSzhanglyGit common.flushed := status.robIdx.needFlush(commonIn.flush) 175ac90e54aSxiaofeibao-xjtu common.deqSuccess := (if (params.isVecMemIQ) status.issued else true.B) && 176ac90e54aSxiaofeibao-xjtu commonIn.issueResp.valid && RespType.succeed(commonIn.issueResp.bits.resp) && !common.srcLoadCancelVec.asUInt.orR 1778dd32220Ssinsanction common.srcWakeupByWB := commonIn.wakeUpFromWB.map{ bundle => 1788dd32220Ssinsanction val psrcSrcTypeVec = status.srcStatus.map(_.psrc) zip status.srcStatus.map(_.srcType) 1798dd32220Ssinsanction if (params.numRegSrc == 5) { 1808dd32220Ssinsanction bundle.bits.wakeUp(psrcSrcTypeVec.take(3), bundle.valid) :+ 1818dd32220Ssinsanction bundle.bits.wakeUpV0(psrcSrcTypeVec(3), bundle.valid) :+ 1828dd32220Ssinsanction bundle.bits.wakeUpVl(psrcSrcTypeVec(4), bundle.valid) 1838dd32220Ssinsanction } 1848dd32220Ssinsanction else 1858dd32220Ssinsanction bundle.bits.wakeUp(psrcSrcTypeVec, bundle.valid) 1868dd32220Ssinsanction }.transpose.map(x => VecInit(x.toSeq).asUInt.orR).toSeq 187a4d38a63SzhanglyGit common.canIssue := validReg && status.canIssue 188ff671587Sxiaofeibao common.enqReady := !validReg || commonIn.transSel 18928607074Ssinsanction common.clear := common.flushed || common.deqSuccess || commonIn.transSel 190*e311c278Ssinsanction common.srcCancelVec.zip(hasIQWakeupGet.srcWakeupByIQWithoutCancel).zipWithIndex.foreach { case ((srcCancel, wakeUpByIQVec), srcIdx) => 191*e311c278Ssinsanction common.srcLoadTransCancelVec(srcIdx) := (if(params.hasIQWakeUp) Mux1H(wakeUpByIQVec, hasIQWakeupGet.wakeupLoadDependencyByIQVec.map(dep => LoadShouldCancel(Some(dep), commonIn.ldCancel))) else false.B) 192*e311c278Ssinsanction common.srcLoadCancelVec(srcIdx) := LoadShouldCancel(Some(status.srcStatus(srcIdx).srcLoadDependency), commonIn.ldCancel) 193*e311c278Ssinsanction srcCancel := common.srcLoadTransCancelVec(srcIdx) || common.srcLoadCancelVec(srcIdx) 194eea4a3caSzhanglyGit } 195ec49b127Ssinsanction common.srcLoadDependencyNext.zip(status.srcStatus.map(_.srcLoadDependency)).foreach { case (ldsNext, lds) => 196ec49b127Ssinsanction ldsNext.zip(lds).foreach{ case (ldNext, ld) => ldNext := ld << 1 } 197eea4a3caSzhanglyGit } 198aa2bcc31SzhanglyGit if(isEnq) { 199aa2bcc31SzhanglyGit common.validRegNext := Mux(commonIn.enq.valid && common.enqReady, true.B, Mux(common.clear, false.B, validReg)) 200aa2bcc31SzhanglyGit } else { 20128607074Ssinsanction common.validRegNext := Mux(commonIn.enq.valid, true.B, Mux(common.clear, false.B, validReg)) 202aa2bcc31SzhanglyGit } 203b6279fc6SZiyue Zhang if (params.numRegSrc == 5) { 204b6279fc6SZiyue Zhang // only when numRegSrc == 5 need vl 205d88d4328SZiyue Zhang val wakeUpFromVl = VecInit(commonIn.wakeUpFromWB.map{ bundle => 206d88d4328SZiyue Zhang val psrcSrcTypeVec = status.srcStatus.map(_.psrc) zip status.srcStatus.map(_.srcType) 207d88d4328SZiyue Zhang bundle.bits.wakeUpVl(psrcSrcTypeVec(4), bundle.valid) 208d88d4328SZiyue Zhang }) 209d88d4328SZiyue Zhang var numVecWb = params.backendParam.getVfWBExeGroup.size 210d88d4328SZiyue Zhang var numV0Wb = params.backendParam.getV0WBExeGroup.size 211d88d4328SZiyue Zhang // int wb is first bit of vlwb, which is after vfwb and v0wb 212d88d4328SZiyue Zhang common.vlWakeupByIntWb := wakeUpFromVl(numVecWb + numV0Wb) 213d88d4328SZiyue Zhang // vf wb is second bit of wb 214d88d4328SZiyue Zhang common.vlWakeupByVfWb := wakeUpFromVl(numVecWb + numV0Wb + 1) 215b6279fc6SZiyue Zhang } else { 216d88d4328SZiyue Zhang common.vlWakeupByIntWb := false.B 217d88d4328SZiyue Zhang common.vlWakeupByVfWb := false.B 218b6279fc6SZiyue Zhang } 219aa2bcc31SzhanglyGit } 220aa2bcc31SzhanglyGit 221aa2bcc31SzhanglyGit class CommonIQWakeupBundle(implicit p: Parameters, params: IssueBlockParams) extends XSBundle { 222aa2bcc31SzhanglyGit val srcWakeupByIQ = Vec(params.numRegSrc, Vec(params.numWakeupFromIQ, Bool())) 223aa2bcc31SzhanglyGit val srcWakeupByIQWithoutCancel = Vec(params.numRegSrc, Vec(params.numWakeupFromIQ, Bool())) 224aa2bcc31SzhanglyGit val srcWakeupByIQButCancel = Vec(params.numRegSrc, Vec(params.numWakeupFromIQ, Bool())) 225ec49b127Ssinsanction val srcWakeupL1ExuOH = Vec(params.numRegSrc, ExuVec()) 226ec49b127Ssinsanction val wakeupLoadDependencyByIQVec = Vec(params.numWakeupFromIQ, Vec(LoadPipelineWidth, UInt(LoadDependencyWidth.W))) 227ec49b127Ssinsanction val shiftedWakeupLoadDependencyByIQVec = Vec(params.numWakeupFromIQ, Vec(LoadPipelineWidth, UInt(LoadDependencyWidth.W))) 228aa2bcc31SzhanglyGit val canIssueBypass = Bool() 229aa2bcc31SzhanglyGit } 230aa2bcc31SzhanglyGit 231aa2bcc31SzhanglyGit def CommonIQWakeupConnect(common: CommonWireBundle, hasIQWakeupGet: CommonIQWakeupBundle, validReg: Bool, status: Status, commonIn: CommonInBundle, isEnq: Boolean)(implicit p: Parameters, params: IssueBlockParams) = { 2328dd32220Ssinsanction val wakeupVec: Seq[Seq[Bool]] = commonIn.wakeUpFromIQ.map{(bundle: ValidIO[IssueQueueIQWakeUpBundle]) => 2338dd32220Ssinsanction val psrcSrcTypeVec = status.srcStatus.map(_.psrc) zip status.srcStatus.map(_.srcType) 2348dd32220Ssinsanction if (params.numRegSrc == 5) { 2358dd32220Ssinsanction bundle.bits.wakeUpFromIQ(psrcSrcTypeVec.take(3)) :+ 2368dd32220Ssinsanction bundle.bits.wakeUpV0FromIQ(psrcSrcTypeVec(3)) :+ 2378dd32220Ssinsanction bundle.bits.wakeUpVlFromIQ(psrcSrcTypeVec(4)) 2388dd32220Ssinsanction } 2398dd32220Ssinsanction else 2408dd32220Ssinsanction bundle.bits.wakeUpFromIQ(psrcSrcTypeVec) 2418dd32220Ssinsanction }.toSeq.transpose 242aa2bcc31SzhanglyGit val cancelSel = params.wakeUpSourceExuIdx.zip(commonIn.wakeUpFromIQ).map { case (x, y) => commonIn.og0Cancel(x) && y.bits.is0Lat } 243aa2bcc31SzhanglyGit 244aa2bcc31SzhanglyGit hasIQWakeupGet.srcWakeupByIQ := wakeupVec.map(x => VecInit(x.zip(cancelSel).map { case (wakeup, cancel) => wakeup && !cancel })) 245aa2bcc31SzhanglyGit hasIQWakeupGet.srcWakeupByIQButCancel := wakeupVec.map(x => VecInit(x.zip(cancelSel).map { case (wakeup, cancel) => wakeup && cancel })) 246aa2bcc31SzhanglyGit hasIQWakeupGet.srcWakeupByIQWithoutCancel := wakeupVec.map(x => VecInit(x)) 247aa2bcc31SzhanglyGit hasIQWakeupGet.wakeupLoadDependencyByIQVec := commonIn.wakeUpFromIQ.map(_.bits.loadDependency).toSeq 248ec49b127Ssinsanction hasIQWakeupGet.srcWakeupL1ExuOH.zip(status.srcStatus.map(_.srcWakeUpL1ExuOH.get)).foreach { 249aa2bcc31SzhanglyGit case (exuOH, regExuOH) => 250aa2bcc31SzhanglyGit exuOH := 0.U.asTypeOf(exuOH) 251aa2bcc31SzhanglyGit params.wakeUpSourceExuIdx.foreach(x => exuOH(x) := regExuOH(x)) 252aa2bcc31SzhanglyGit } 253aa2bcc31SzhanglyGit hasIQWakeupGet.canIssueBypass := validReg && !status.issued && !status.blocked && 254aa2bcc31SzhanglyGit VecInit(status.srcStatus.map(_.srcState).zip(hasIQWakeupGet.srcWakeupByIQWithoutCancel).zipWithIndex.map { case ((state, wakeupVec), srcIdx) => 255a4d38a63SzhanglyGit wakeupVec.asUInt.orR | state 256aa2bcc31SzhanglyGit }).asUInt.andR 257aa2bcc31SzhanglyGit } 258aa2bcc31SzhanglyGit 259aa2bcc31SzhanglyGit 260aa2bcc31SzhanglyGit def ShiftLoadDependency(hasIQWakeupGet: CommonIQWakeupBundle)(implicit p: Parameters, params: IssueBlockParams) = { 261aa2bcc31SzhanglyGit hasIQWakeupGet.shiftedWakeupLoadDependencyByIQVec 262aa2bcc31SzhanglyGit .zip(hasIQWakeupGet.wakeupLoadDependencyByIQVec) 263aa2bcc31SzhanglyGit .zip(params.wakeUpInExuSources.map(_.name)).foreach { 264aa2bcc31SzhanglyGit case ((deps, originalDeps), name) => deps.zip(originalDeps).zipWithIndex.foreach { 265aa2bcc31SzhanglyGit case ((dep, originalDep), deqPortIdx) => 26680c686d5SzhanglyGit if (params.backendParam.getLdExuIdx(params.backendParam.allExuParams.find(_.name == name).get) == deqPortIdx) 267d2fb0dcdSzhanglyGit dep := 1.U 268aa2bcc31SzhanglyGit else 269aa2bcc31SzhanglyGit dep := originalDep << 1 270aa2bcc31SzhanglyGit } 271aa2bcc31SzhanglyGit } 272aa2bcc31SzhanglyGit } 273aa2bcc31SzhanglyGit 2742734c4a6Sxiao feibao def wakeUpByVf(OH: Vec[Bool])(implicit p: Parameters): Bool = { 2752734c4a6Sxiao feibao val allExuParams = p(XSCoreParamsKey).backendParams.allExuParams 2762734c4a6Sxiao feibao OH.zip(allExuParams).map{case (oh,e) => 2772734c4a6Sxiao feibao if (e.isVfExeUnit) oh else false.B 2782734c4a6Sxiao feibao }.reduce(_ || _) 279aa2bcc31SzhanglyGit } 280aa2bcc31SzhanglyGit 281*e311c278Ssinsanction def EntryRegCommonConnect(common: CommonWireBundle, hasIQWakeup: Option[CommonIQWakeupBundle], validReg: Bool, entryUpdate: EntryBundle, entryReg: EntryBundle, status: Status, commonIn: CommonInBundle, isEnq: Boolean, isComp: Boolean)(implicit p: Parameters, params: IssueBlockParams) = { 282aa2bcc31SzhanglyGit val hasIQWakeupGet = hasIQWakeup.getOrElse(0.U.asTypeOf(new CommonIQWakeupBundle)) 283*e311c278Ssinsanction val cancelBypassVec = Wire(Vec(params.numRegSrc, Bool())) 284*e311c278Ssinsanction val srcCancelByLoad = common.srcLoadCancelVec.asUInt.orR 285f08a822fSzhanglyGit val respIssueFail = commonIn.issueResp.valid && RespType.isBlocked(commonIn.issueResp.bits.resp) 286397c0f33Ssinsanction entryUpdate.status.robIdx := status.robIdx 287397c0f33Ssinsanction entryUpdate.status.fuType := IQFuType.readFuType(status.fuType, params.getFuCfgs.map(_.fuType)) 288397c0f33Ssinsanction entryUpdate.status.srcStatus.zip(status.srcStatus).zipWithIndex.foreach { case ((srcStatusNext, srcStatus), srcIdx) => 289*e311c278Ssinsanction val srcLoadCancel = common.srcLoadCancelVec(srcIdx) 290*e311c278Ssinsanction val loadTransCancel = common.srcLoadTransCancelVec(srcIdx) 291*e311c278Ssinsanction val wakeupByWB = common.srcWakeupByWB(srcIdx) 292*e311c278Ssinsanction val wakeupByIQ = hasIQWakeupGet.srcWakeupByIQ(srcIdx).asUInt.orR && !loadTransCancel 293aa2bcc31SzhanglyGit val wakeupByIQOH = hasIQWakeupGet.srcWakeupByIQ(srcIdx) 294*e311c278Ssinsanction val wakeupByMemIQ = wakeupByIQOH.zip(commonIn.wakeUpFromIQ).filter(_._2.bits.params.isMemExeUnit).map(_._1).fold(false.B)(_ || _) 295*e311c278Ssinsanction cancelBypassVec(srcIdx) := (if (isComp) Mux(hasIQWakeupGet.srcWakeupByIQWithoutCancel(srcIdx).asUInt.orR, loadTransCancel, srcLoadCancel) 296*e311c278Ssinsanction else srcLoadCancel) 297b6279fc6SZiyue Zhang 298b6279fc6SZiyue Zhang val ignoreOldVd = Wire(Bool()) 299d88d4328SZiyue Zhang val vlWakeUpByIntWb = common.vlWakeupByIntWb 300d88d4328SZiyue Zhang val vlWakeUpByVfWb = common.vlWakeupByVfWb 301b6279fc6SZiyue Zhang val isDependOldvd = entryReg.payload.vpu.isDependOldvd 302d8ceb649SZiyue Zhang val isWritePartVd = entryReg.payload.vpu.isWritePartVd 303b6279fc6SZiyue Zhang val vta = entryReg.payload.vpu.vta 304b6279fc6SZiyue Zhang val vma = entryReg.payload.vpu.vma 305b6279fc6SZiyue Zhang val vm = entryReg.payload.vpu.vm 306d88d4328SZiyue Zhang val vlFromIntIsZero = commonIn.vlFromIntIsZero 307d88d4328SZiyue Zhang val vlFromIntIsVlmax = commonIn.vlFromIntIsVlmax 308d88d4328SZiyue Zhang val vlFromVfIsZero = commonIn.vlFromVfIsZero 309d88d4328SZiyue Zhang val vlFromVfIsVlmax = commonIn.vlFromVfIsVlmax 310d88d4328SZiyue Zhang val vlIsVlmax = (vlFromIntIsVlmax && vlWakeUpByIntWb) || (vlFromVfIsVlmax && vlWakeUpByVfWb) 311d88d4328SZiyue Zhang val vlIsNonZero = (!vlFromIntIsZero && vlWakeUpByIntWb) || (!vlFromVfIsZero && vlWakeUpByVfWb) 312d8ceb649SZiyue Zhang val ignoreTail = vlIsVlmax && (vm =/= 0.U || vma) && !isWritePartVd 313d88d4328SZiyue Zhang val ignoreWhole = (vm =/= 0.U || vma) && vta 314cc991b08SZiyue Zhang val srcIsVec = SrcType.isVp(srcStatus.srcType) 315b6279fc6SZiyue Zhang if (params.numVfSrc > 0 && srcIdx == 2) { 316b6279fc6SZiyue Zhang /** 317b6279fc6SZiyue Zhang * the src store the old vd, update it when vl is write back 318b6279fc6SZiyue Zhang * 1. when the instruction depend on old vd, we cannot set the srctype to imm, we will update the method of uop split to avoid this situation soon 319b6279fc6SZiyue Zhang * 2. when vl = 0, we cannot set the srctype to imm because the vd keep the old value 320b6279fc6SZiyue Zhang * 3. when vl = vlmax, we can set srctype to imm when vta is not set 321b6279fc6SZiyue Zhang */ 322575665baSXuan Hu ignoreOldVd := !VlduType.isFof(entryReg.payload.fuOpType) && srcIsVec && vlIsNonZero && !isDependOldvd && (ignoreTail || ignoreWhole) 323b6279fc6SZiyue Zhang } else { 324b6279fc6SZiyue Zhang ignoreOldVd := false.B 325b6279fc6SZiyue Zhang } 326b6279fc6SZiyue Zhang 327aa2bcc31SzhanglyGit srcStatusNext.psrc := srcStatus.psrc 328b6279fc6SZiyue Zhang srcStatusNext.srcType := Mux(ignoreOldVd, SrcType.no, srcStatus.srcType) 329*e311c278Ssinsanction srcStatusNext.srcState := srcStatus.srcState & !srcLoadCancel | wakeupByWB | wakeupByIQ | ignoreOldVd 3304fa640e4Ssinsanction srcStatusNext.dataSources.value := (if (params.inVfSchd && params.readVfRf && params.hasIQWakeUp) { 331c4cabf18Ssinsanction // Vf / Mem -> Vf 332c4cabf18Ssinsanction MuxCase(srcStatus.dataSources.value, Seq( 333*e311c278Ssinsanction ignoreOldVd -> DataSource.imm, 334*e311c278Ssinsanction (wakeupByIQ && wakeupByMemIQ) -> DataSource.bypass2, 335*e311c278Ssinsanction (wakeupByIQ && !wakeupByMemIQ) -> DataSource.bypass, 336c4cabf18Ssinsanction srcStatus.dataSources.readBypass -> DataSource.bypass2, 337c4cabf18Ssinsanction srcStatus.dataSources.readBypass2 -> DataSource.reg, 338aa2bcc31SzhanglyGit )) 3394fa640e4Ssinsanction } 340a75d561cSsinsanction else if (params.inMemSchd && params.readVfRf && params.hasIQWakeUp) { 341c4cabf18Ssinsanction // Vf / Int -> Mem 342c4cabf18Ssinsanction MuxCase(srcStatus.dataSources.value, Seq( 343c4cabf18Ssinsanction wakeupByIQ -> DataSource.bypass, 3442734c4a6Sxiao feibao (srcStatus.dataSources.readBypass && wakeUpByVf(srcStatus.srcWakeUpL1ExuOH.get)) -> DataSource.bypass2, 3452734c4a6Sxiao feibao (srcStatus.dataSources.readBypass && !wakeUpByVf(srcStatus.srcWakeUpL1ExuOH.get)) -> DataSource.reg, 346c4cabf18Ssinsanction srcStatus.dataSources.readBypass2 -> DataSource.reg, 347c4cabf18Ssinsanction )) 348a75d561cSsinsanction } 349c4cabf18Ssinsanction else { 350c4cabf18Ssinsanction MuxCase(srcStatus.dataSources.value, Seq( 351*e311c278Ssinsanction ignoreOldVd -> DataSource.imm, 352c4cabf18Ssinsanction wakeupByIQ -> DataSource.bypass, 353c4cabf18Ssinsanction srcStatus.dataSources.readBypass -> DataSource.reg, 354c4cabf18Ssinsanction )) 355c4cabf18Ssinsanction }) 356aa2bcc31SzhanglyGit if(params.hasIQWakeUp) { 357ec49b127Ssinsanction ExuOHGen(srcStatusNext.srcWakeUpL1ExuOH.get, wakeupByIQOH, hasIQWakeupGet.srcWakeupL1ExuOH(srcIdx)) 358ec49b127Ssinsanction srcStatusNext.srcLoadDependency := Mux(wakeupByIQ, 359aa2bcc31SzhanglyGit Mux1H(wakeupByIQOH, hasIQWakeupGet.shiftedWakeupLoadDependencyByIQVec), 360ec49b127Ssinsanction common.srcLoadDependencyNext(srcIdx)) 361eea4a3caSzhanglyGit } else { 362ec49b127Ssinsanction srcStatusNext.srcLoadDependency := common.srcLoadDependencyNext(srcIdx) 363aa2bcc31SzhanglyGit } 3644c2a845dSsinsanction 3654c2a845dSsinsanction if (params.needReadRegCache) { 3664c2a845dSsinsanction val wakeupSrcExuWriteRC = wakeupByIQOH.zip(commonIn.wakeUpFromIQ).filter(_._2.bits.params.needWriteRegCache) 367de4e991cSsinsanction val wakeupRC = wakeupSrcExuWriteRC.map(_._1).fold(false.B)(_ || _) && SrcType.isXp(srcStatus.srcType) 3684c2a845dSsinsanction val wakeupRCIdx = Mux1H(wakeupSrcExuWriteRC.map(_._1), wakeupSrcExuWriteRC.map(_._2.bits.rcDest.get)) 3694c2a845dSsinsanction val replaceRC = wakeupSrcExuWriteRC.map(x => x._2.bits.rfWen && x._2.bits.rcDest.get === srcStatus.regCacheIdx.get).fold(false.B)(_ || _) 3704c2a845dSsinsanction 371*e311c278Ssinsanction srcStatusNext.useRegCache.get := srcStatus.useRegCache.get && !(srcLoadCancel || replaceRC) || wakeupRC 3724c2a845dSsinsanction srcStatusNext.regCacheIdx.get := Mux(wakeupRC, wakeupRCIdx, srcStatus.regCacheIdx.get) 3734c2a845dSsinsanction } 374aa2bcc31SzhanglyGit } 375397c0f33Ssinsanction entryUpdate.status.blocked := false.B 376397c0f33Ssinsanction entryUpdate.status.issued := MuxCase(status.issued, Seq( 377*e311c278Ssinsanction (commonIn.deqSel && !cancelBypassVec.asUInt.orR) -> true.B, 378*e311c278Ssinsanction (srcCancelByLoad || respIssueFail) -> false.B, 379aa2bcc31SzhanglyGit )) 380397c0f33Ssinsanction entryUpdate.status.firstIssue := commonIn.deqSel || status.firstIssue 381dd40a82bSsinsanction entryUpdate.status.issueTimer := Mux(commonIn.deqSel, 0.U, Mux(status.issued, Mux(status.issueTimer === "b11".U, status.issueTimer, status.issueTimer + 1.U), "b11".U)) 382397c0f33Ssinsanction entryUpdate.status.deqPortIdx := Mux(commonIn.deqSel, commonIn.deqPortIdxWrite, Mux(status.issued, status.deqPortIdx, 0.U)) 383397c0f33Ssinsanction entryUpdate.imm.foreach(_ := entryReg.imm.get) 384397c0f33Ssinsanction entryUpdate.payload := entryReg.payload 385397c0f33Ssinsanction if (params.isVecMemIQ) { 386397c0f33Ssinsanction entryUpdate.status.vecMem.get := entryReg.status.vecMem.get 387397c0f33Ssinsanction } 388aa2bcc31SzhanglyGit } 389aa2bcc31SzhanglyGit 390df26db8aSsinsanction def CommonOutConnect(commonOut: CommonOutBundle, common: CommonWireBundle, hasIQWakeup: Option[CommonIQWakeupBundle], validReg: Bool, entryUpdate: EntryBundle, entryReg: EntryBundle, status: Status, commonIn: CommonInBundle, isEnq: Boolean, isComp: Boolean)(implicit p: Parameters, params: IssueBlockParams) = { 391aa2bcc31SzhanglyGit val hasIQWakeupGet = hasIQWakeup.getOrElse(0.U.asTypeOf(new CommonIQWakeupBundle)) 392aa2bcc31SzhanglyGit commonOut.valid := validReg 393c0beb497Sxiaofeibao commonOut.issued := entryReg.status.issued 394df26db8aSsinsanction commonOut.canIssue := (if (isComp) (common.canIssue || hasIQWakeupGet.canIssueBypass) && !common.flushed 395df26db8aSsinsanction else common.canIssue && !common.flushed) 396aa2bcc31SzhanglyGit commonOut.fuType := IQFuType.readFuType(status.fuType, params.getFuCfgs.map(_.fuType)).asUInt 397aa2bcc31SzhanglyGit commonOut.robIdx := status.robIdx 398aa2bcc31SzhanglyGit commonOut.dataSource.zipWithIndex.foreach{ case (dataSourceOut, srcIdx) => 399de111a36Ssinsanction val wakeupByIQWithoutCancel = hasIQWakeupGet.srcWakeupByIQWithoutCancel(srcIdx).asUInt.orR 400de111a36Ssinsanction val wakeupByIQWithoutCancelOH = hasIQWakeupGet.srcWakeupByIQWithoutCancel(srcIdx) 401de111a36Ssinsanction val isWakeupByMemIQ = wakeupByIQWithoutCancelOH.zip(commonIn.wakeUpFromIQ).filter(_._2.bits.params.isMemExeUnit).map(_._1).fold(false.B)(_ || _) 4024c2a845dSsinsanction val useRegCache = status.srcStatus(srcIdx).useRegCache.getOrElse(false.B) && status.srcStatus(srcIdx).dataSources.readReg 403ec49b127Ssinsanction dataSourceOut.value := (if (isComp) 404ec49b127Ssinsanction if (params.inVfSchd && params.readVfRf && params.hasWakeupFromMem) { 405ec49b127Ssinsanction MuxCase(status.srcStatus(srcIdx).dataSources.value, Seq( 406ec49b127Ssinsanction (wakeupByIQWithoutCancel && !isWakeupByMemIQ) -> DataSource.forward, 407ec49b127Ssinsanction (wakeupByIQWithoutCancel && isWakeupByMemIQ) -> DataSource.bypass, 408ec49b127Ssinsanction )) 409ec49b127Ssinsanction } else { 410ec49b127Ssinsanction MuxCase(status.srcStatus(srcIdx).dataSources.value, Seq( 411ec49b127Ssinsanction wakeupByIQWithoutCancel -> DataSource.forward, 4124c2a845dSsinsanction useRegCache -> DataSource.regcache, 413ec49b127Ssinsanction )) 414ec49b127Ssinsanction } 4154c2a845dSsinsanction else { 4164c2a845dSsinsanction MuxCase(status.srcStatus(srcIdx).dataSources.value, Seq( 4174c2a845dSsinsanction useRegCache -> DataSource.regcache, 4184c2a845dSsinsanction )) 4194c2a845dSsinsanction }) 420aa2bcc31SzhanglyGit } 421aa2bcc31SzhanglyGit commonOut.isFirstIssue := !status.firstIssue 422aa2bcc31SzhanglyGit commonOut.entry.valid := validReg 423aa2bcc31SzhanglyGit commonOut.entry.bits := entryReg 424aa2bcc31SzhanglyGit if(isEnq) { 425aa2bcc31SzhanglyGit commonOut.entry.bits.status := status 426aa2bcc31SzhanglyGit } 427aa2bcc31SzhanglyGit commonOut.issueTimerRead := status.issueTimer 428aa2bcc31SzhanglyGit commonOut.deqPortIdxRead := status.deqPortIdx 429ec49b127Ssinsanction 430ec49b127Ssinsanction if(params.hasIQWakeUp) { 431ec49b127Ssinsanction commonOut.srcWakeUpL1ExuOH.get.zipWithIndex.foreach{ case (exuOHOut, srcIdx) => 432ec49b127Ssinsanction val wakeupByIQWithoutCancelOH = hasIQWakeupGet.srcWakeupByIQWithoutCancel(srcIdx) 433ec49b127Ssinsanction if (isComp) 434ec49b127Ssinsanction ExuOHGen(exuOHOut, wakeupByIQWithoutCancelOH, hasIQWakeupGet.srcWakeupL1ExuOH(srcIdx)) 435ec49b127Ssinsanction else 436ec49b127Ssinsanction ExuOHGen(exuOHOut, 0.U.asTypeOf(wakeupByIQWithoutCancelOH), hasIQWakeupGet.srcWakeupL1ExuOH(srcIdx)) 437ec49b127Ssinsanction } 438ec49b127Ssinsanction } 439ec49b127Ssinsanction 440ec49b127Ssinsanction val srcLoadDependencyOut = Wire(chiselTypeOf(common.srcLoadDependencyNext)) 441aa2bcc31SzhanglyGit if(params.hasIQWakeUp) { 442ec49b127Ssinsanction val wakeupSrcLoadDependencyNext = hasIQWakeupGet.srcWakeupByIQWithoutCancel.map(x => Mux1H(x, hasIQWakeupGet.shiftedWakeupLoadDependencyByIQVec)) 443ec49b127Ssinsanction srcLoadDependencyOut.zipWithIndex.foreach { case (ldOut, srcIdx) => 444ec49b127Ssinsanction ldOut := (if (isComp) Mux(hasIQWakeupGet.srcWakeupByIQWithoutCancel(srcIdx).asUInt.orR, 445ec49b127Ssinsanction wakeupSrcLoadDependencyNext(srcIdx), 446ec49b127Ssinsanction common.srcLoadDependencyNext(srcIdx)) 447ec49b127Ssinsanction else common.srcLoadDependencyNext(srcIdx)) 448ec49b127Ssinsanction } 449eea4a3caSzhanglyGit } else { 450ec49b127Ssinsanction srcLoadDependencyOut := common.srcLoadDependencyNext 451eea4a3caSzhanglyGit } 452*e311c278Ssinsanction commonOut.cancelBypass := VecInit(hasIQWakeupGet.srcWakeupByIQWithoutCancel.zipWithIndex.map{ case (wakeupVec, srcIdx) => 453*e311c278Ssinsanction if (isComp) Mux(wakeupVec.asUInt.orR, common.srcLoadTransCancelVec(srcIdx), common.srcLoadCancelVec(srcIdx)) 454*e311c278Ssinsanction else common.srcLoadCancelVec(srcIdx) 455*e311c278Ssinsanction }).asUInt.orR 456ec49b127Ssinsanction commonOut.entry.bits.status.srcStatus.map(_.srcLoadDependency).zipWithIndex.foreach { case (ldOut, srcIdx) => 457ec49b127Ssinsanction ldOut := srcLoadDependencyOut(srcIdx) 458eea4a3caSzhanglyGit } 459ec49b127Ssinsanction 460397c0f33Ssinsanction commonOut.enqReady := common.enqReady 461c0beb497Sxiaofeibao commonOut.transEntry.valid := validReg && !common.flushed && !status.issued 462397c0f33Ssinsanction commonOut.transEntry.bits := entryUpdate 463a6938b17Ssinsanction // debug 464a6938b17Ssinsanction commonOut.entryInValid := commonIn.enq.valid 465a6938b17Ssinsanction commonOut.entryOutDeqValid := validReg && (common.flushed || common.deqSuccess) 466a6938b17Ssinsanction commonOut.entryOutTransValid := validReg && commonIn.transSel && !(common.flushed || common.deqSuccess) 467e3ef3537Ssinsanction commonOut.perfWakeupByWB := common.srcWakeupByWB.zip(status.srcStatus).map{ case (w, s) => w && SrcState.isBusy(s.srcState) && validReg } 468e3ef3537Ssinsanction if (params.hasIQWakeUp) { 469ec49b127Ssinsanction commonOut.perfLdCancel.get := common.srcCancelVec.map(_ && validReg) 470e3ef3537Ssinsanction commonOut.perfOg0Cancel.get := hasIQWakeupGet.srcWakeupByIQButCancel.map(_.asUInt.orR && validReg) 471e3ef3537Ssinsanction commonOut.perfWakeupByIQ.get := hasIQWakeupGet.srcWakeupByIQ.map(x => VecInit(x.map(_ && validReg))) 472e3ef3537Ssinsanction } 473e3ef3537Ssinsanction // vecMem 474aa2bcc31SzhanglyGit if (params.isVecMemIQ) { 47599944b79Ssinsanction commonOut.uopIdx.get := entryReg.payload.uopIdx 476aa2bcc31SzhanglyGit } 477aa2bcc31SzhanglyGit } 478aa2bcc31SzhanglyGit 479e07131b2Ssinsanction def EntryVecMemConnect(commonIn: CommonInBundle, common: CommonWireBundle, validReg: Bool, entryReg: EntryBundle, entryRegNext: EntryBundle, entryUpdate: EntryBundle)(implicit p: Parameters, params: IssueBlockParams) = { 48099944b79Ssinsanction val fromLsq = commonIn.fromLsq.get 48199944b79Ssinsanction val vecMemStatus = entryReg.status.vecMem.get 48299944b79Ssinsanction val vecMemStatusUpdate = entryUpdate.status.vecMem.get 48399944b79Ssinsanction vecMemStatusUpdate := vecMemStatus 48499944b79Ssinsanction 485b0480352SZiyue Zhang val isFirstLoad = entryReg.status.vecMem.get.lqIdx === fromLsq.lqDeqPtr 486b0480352SZiyue Zhang 487b0480352SZiyue Zhang val isVleff = entryReg.payload.vpu.isVleff 488e07131b2Ssinsanction // update blocked 489b0480352SZiyue Zhang entryUpdate.status.blocked := !isFirstLoad && isVleff 49099944b79Ssinsanction } 49199944b79Ssinsanction 492ec49b127Ssinsanction def ExuOHGen(exuOH: Vec[Bool], wakeupByIQOH: Vec[Bool], regSrcExuOH: Vec[Bool])(implicit p: Parameters, params: IssueBlockParams) = { 493ae0295f4STang Haojin val origExuOH = Wire(chiselTypeOf(exuOH)) 494aa2bcc31SzhanglyGit when(wakeupByIQOH.asUInt.orR) { 495aa2bcc31SzhanglyGit origExuOH := Mux1H(wakeupByIQOH, params.wakeUpSourceExuIdx.map(x => MathUtils.IntToOH(x).U(p(XSCoreParamsKey).backendParams.numExu.W)).toSeq).asBools 496aa2bcc31SzhanglyGit }.otherwise { 497aa2bcc31SzhanglyGit origExuOH := regSrcExuOH 498aa2bcc31SzhanglyGit } 499aa2bcc31SzhanglyGit exuOH := 0.U.asTypeOf(exuOH) 500aa2bcc31SzhanglyGit params.wakeUpSourceExuIdx.foreach(x => exuOH(x) := origExuOH(x)) 501aa2bcc31SzhanglyGit } 502aa2bcc31SzhanglyGit 503aa2bcc31SzhanglyGit object IQFuType { 504aa2bcc31SzhanglyGit def num = FuType.num 505aa2bcc31SzhanglyGit 506aa2bcc31SzhanglyGit def apply() = Vec(num, Bool()) 507aa2bcc31SzhanglyGit 508aa2bcc31SzhanglyGit def readFuType(fuType: Vec[Bool], fus: Seq[FuType.OHType]): Vec[Bool] = { 509ae0295f4STang Haojin val res = WireDefault(0.U.asTypeOf(fuType)) 510aa2bcc31SzhanglyGit fus.foreach(x => res(x.id) := fuType(x.id)) 511aa2bcc31SzhanglyGit res 512aa2bcc31SzhanglyGit } 513aa2bcc31SzhanglyGit } 5144fa640e4Ssinsanction 5154fa640e4Ssinsanction class EnqDelayInBundle(implicit p: Parameters, params: IssueBlockParams) extends XSBundle { 5164fa640e4Ssinsanction //wakeup 5174fa640e4Ssinsanction val wakeUpFromWB: MixedVec[ValidIO[IssueQueueWBWakeUpBundle]] = Flipped(params.genWBWakeUpSinkValidBundle) 5184fa640e4Ssinsanction val wakeUpFromIQ: MixedVec[ValidIO[IssueQueueIQWakeUpBundle]] = Flipped(params.genIQWakeUpSinkValidBundle) 5194fa640e4Ssinsanction //cancel 52091f31488Sxiaofeibao-xjtu val srcLoadDependency = Input(Vec(params.numRegSrc, Vec(LoadPipelineWidth, UInt(LoadDependencyWidth.W)))) 521be9ff987Ssinsanction val og0Cancel = Input(ExuVec()) 5224fa640e4Ssinsanction val ldCancel = Vec(backendParams.LdExuCnt, Flipped(new LoadCancelIO)) 5234fa640e4Ssinsanction } 5244fa640e4Ssinsanction 5254fa640e4Ssinsanction class EnqDelayOutBundle(implicit p: Parameters, params: IssueBlockParams) extends XSBundle { 5264fa640e4Ssinsanction val srcWakeUpByWB: Vec[UInt] = Vec(params.numRegSrc, SrcState()) 5274fa640e4Ssinsanction val srcWakeUpByIQ: Vec[UInt] = Vec(params.numRegSrc, SrcState()) 5284fa640e4Ssinsanction val srcWakeUpByIQVec: Vec[Vec[Bool]] = Vec(params.numRegSrc, Vec(params.numWakeupFromIQ, Bool())) 52991f31488Sxiaofeibao-xjtu val srcCancelByLoad: Vec[Bool] = Vec(params.numRegSrc, Bool()) 530ec49b127Ssinsanction val shiftedWakeupLoadDependencyByIQVec: Vec[Vec[UInt]] = Vec(params.numWakeupFromIQ, Vec(LoadPipelineWidth, UInt(LoadDependencyWidth.W))) 5314fa640e4Ssinsanction } 5324fa640e4Ssinsanction 5334fa640e4Ssinsanction def EnqDelayWakeupConnect(enqDelayIn: EnqDelayInBundle, enqDelayOut: EnqDelayOutBundle, status: Status, delay: Int)(implicit p: Parameters, params: IssueBlockParams) = { 5344fa640e4Ssinsanction enqDelayOut.srcWakeUpByWB.zipWithIndex.foreach { case (wakeup, i) => 5358dd32220Ssinsanction wakeup := enqDelayIn.wakeUpFromWB.map{ x => 5368dd32220Ssinsanction if (i == 3) 5378dd32220Ssinsanction x.bits.wakeUpV0((status.srcStatus(i).psrc, status.srcStatus(i).srcType), x.valid) 5388dd32220Ssinsanction else if (i == 4) 5398dd32220Ssinsanction x.bits.wakeUpVl((status.srcStatus(i).psrc, status.srcStatus(i).srcType), x.valid) 5408dd32220Ssinsanction else 5418dd32220Ssinsanction x.bits.wakeUp(Seq((status.srcStatus(i).psrc, status.srcStatus(i).srcType)), x.valid).head 5428dd32220Ssinsanction }.reduce(_ || _) 5434fa640e4Ssinsanction } 5444fa640e4Ssinsanction 5454fa640e4Ssinsanction if (params.hasIQWakeUp) { 5468dd32220Ssinsanction val wakeupVec: IndexedSeq[IndexedSeq[Bool]] = enqDelayIn.wakeUpFromIQ.map{ x => 5478dd32220Ssinsanction val psrcSrcTypeVec = status.srcStatus.map(_.psrc) zip status.srcStatus.map(_.srcType) 5488dd32220Ssinsanction if (params.numRegSrc == 5) { 5498dd32220Ssinsanction x.bits.wakeUpFromIQ(psrcSrcTypeVec.take(3)) :+ 5508dd32220Ssinsanction x.bits.wakeUpV0FromIQ(psrcSrcTypeVec(3)) :+ 5518dd32220Ssinsanction x.bits.wakeUpVlFromIQ(psrcSrcTypeVec(4)) 5528dd32220Ssinsanction } 5538dd32220Ssinsanction else 5548dd32220Ssinsanction x.bits.wakeUpFromIQ(psrcSrcTypeVec) 5558dd32220Ssinsanction }.toIndexedSeq.transpose 5564fa640e4Ssinsanction val cancelSel = params.wakeUpSourceExuIdx.zip(enqDelayIn.wakeUpFromIQ).map{ case (x, y) => enqDelayIn.og0Cancel(x) && y.bits.is0Lat} 5574fa640e4Ssinsanction enqDelayOut.srcWakeUpByIQVec := wakeupVec.map(x => VecInit(x.zip(cancelSel).map { case (wakeup, cancel) => wakeup && !cancel })) 5584fa640e4Ssinsanction } else { 5594fa640e4Ssinsanction enqDelayOut.srcWakeUpByIQVec := 0.U.asTypeOf(enqDelayOut.srcWakeUpByIQVec) 5604fa640e4Ssinsanction } 5614fa640e4Ssinsanction 5624fa640e4Ssinsanction if (params.hasIQWakeUp) { 5634fa640e4Ssinsanction enqDelayOut.srcWakeUpByIQ.zipWithIndex.foreach { case (wakeup, i) => 5644fa640e4Ssinsanction val ldTransCancel = Mux1H(enqDelayOut.srcWakeUpByIQVec(i), enqDelayIn.wakeUpFromIQ.map(_.bits.loadDependency).map(dp => LoadShouldCancel(Some(dp), enqDelayIn.ldCancel)).toSeq) 5654fa640e4Ssinsanction wakeup := enqDelayOut.srcWakeUpByIQVec(i).asUInt.orR && !ldTransCancel 5664fa640e4Ssinsanction } 56791f31488Sxiaofeibao-xjtu enqDelayOut.srcCancelByLoad.zipWithIndex.foreach { case (ldCancel, i) => 56891f31488Sxiaofeibao-xjtu ldCancel := LoadShouldCancel(Some(enqDelayIn.srcLoadDependency(i)), enqDelayIn.ldCancel) 56991f31488Sxiaofeibao-xjtu } 5704fa640e4Ssinsanction } else { 5714fa640e4Ssinsanction enqDelayOut.srcWakeUpByIQ := 0.U.asTypeOf(enqDelayOut.srcWakeUpByIQ) 57291f31488Sxiaofeibao-xjtu enqDelayOut.srcCancelByLoad := 0.U.asTypeOf(enqDelayOut.srcCancelByLoad) 5734fa640e4Ssinsanction } 5744fa640e4Ssinsanction 5754fa640e4Ssinsanction enqDelayOut.shiftedWakeupLoadDependencyByIQVec.zip(enqDelayIn.wakeUpFromIQ.map(_.bits.loadDependency)) 5764fa640e4Ssinsanction .zip(params.wakeUpInExuSources.map(_.name)).foreach { case ((dps, ldps), name) => 5774fa640e4Ssinsanction dps.zip(ldps).zipWithIndex.foreach { case ((dp, ldp), deqPortIdx) => 5784fa640e4Ssinsanction if (params.backendParam.getLdExuIdx(params.backendParam.allExuParams.find(_.name == name).get) == deqPortIdx) 579ec49b127Ssinsanction dp := 1.U << (delay - 1) 5804fa640e4Ssinsanction else 5814fa640e4Ssinsanction dp := ldp << delay 5824fa640e4Ssinsanction } 5834fa640e4Ssinsanction } 5844fa640e4Ssinsanction } 585aa2bcc31SzhanglyGit} 586