xref: /XiangShan/src/main/scala/xiangshan/backend/issue/OthersEntry.scala (revision 99ce5576f0ecce1b5045b7bc0dbbb2debd934fbb)
15db4956bSzhanglyGitpackage xiangshan.backend.issue
25db4956bSzhanglyGit
383ba63b3SXuan Huimport org.chipsalliance.cde.config.Parameters
45db4956bSzhanglyGitimport chisel3._
55db4956bSzhanglyGitimport chisel3.util._
64243aa09SsinceforYyimport utility.{HasCircularQueuePtrHelper, GatedValidRegNext}
75db4956bSzhanglyGitimport utils.{MathUtils, OptionWrapper}
85db4956bSzhanglyGitimport xiangshan._
95db4956bSzhanglyGitimport xiangshan.backend.Bundles._
105db4956bSzhanglyGitimport xiangshan.backend.fu.FuType
115db4956bSzhanglyGitimport xiangshan.backend.datapath.DataSource
125db4956bSzhanglyGitimport xiangshan.backend.rob.RobPtr
13aa2bcc31SzhanglyGitimport xiangshan.backend.issue.EntryBundles._
149e12e8edScz4eimport xiangshan.mem.{SqPtr, LqPtr}
15*99ce5576Scz4eimport xiangshan.mem.Bundles.MemWaitUpdateReqBundle
165db4956bSzhanglyGit
175db4956bSzhanglyGit
185db4956bSzhanglyGitclass OthersEntryIO(implicit p: Parameters, params: IssueBlockParams) extends XSBundle {
195db4956bSzhanglyGit  //input
20aa2bcc31SzhanglyGit  val commonIn        = new CommonInBundle
215db4956bSzhanglyGit  //output
22aa2bcc31SzhanglyGit  val commonOut       = new CommonOutBundle
235db4956bSzhanglyGit
24aa2bcc31SzhanglyGit  def wakeup          = commonIn.wakeUpFromWB ++ commonIn.wakeUpFromIQ
255db4956bSzhanglyGit}
265db4956bSzhanglyGit
27df26db8aSsinsanctionclass OthersEntry(isComp: Boolean)(implicit p: Parameters, params: IssueBlockParams) extends XSModule {
285db4956bSzhanglyGit  val io = IO(new OthersEntryIO)
295db4956bSzhanglyGit
30aa2bcc31SzhanglyGit  val common          = Wire(new CommonWireBundle)
31397c0f33Ssinsanction  val entryUpdate     = Wire(new EntryBundle)
325db4956bSzhanglyGit  val entryRegNext    = Wire(new EntryBundle)
33aa2bcc31SzhanglyGit  val hasWakeupIQ     = OptionWrapper(params.hasIQWakeUp, Wire(new CommonIQWakeupBundle))
345db4956bSzhanglyGit
355db4956bSzhanglyGit  //Reg
364243aa09SsinceforYy  val validReg = GatedValidRegNext(common.validRegNext, false.B)
3756db494fSxiaofeibao-xjtu  val entryReg = RegNext(entryRegNext)
385db4956bSzhanglyGit
395db4956bSzhanglyGit  //Wire
400dfdb52aSzhanglyGit  CommonWireConnect(common, hasWakeupIQ, validReg, entryReg.status, io.commonIn, false)
415db4956bSzhanglyGit
425db4956bSzhanglyGit  if (params.hasIQWakeUp) {
43aa2bcc31SzhanglyGit    ShiftLoadDependency(hasWakeupIQ.get)
44aa2bcc31SzhanglyGit    CommonIQWakeupConnect(common, hasWakeupIQ.get, validReg, entryReg.status, io.commonIn, false)
455db4956bSzhanglyGit  }
465db4956bSzhanglyGit
4728607074Ssinsanction  when(io.commonIn.enq.valid) {
48c0beb497Sxiaofeibao    assert(common.enqReady, s"${params.getIQName}'s OthersEntry is not ready when enq is valid\n")
4928607074Ssinsanction  }
5028607074Ssinsanction
5128607074Ssinsanction  when(io.commonIn.enq.valid) {
52aa2bcc31SzhanglyGit    entryRegNext := io.commonIn.enq.bits
535db4956bSzhanglyGit  }.otherwise {
54397c0f33Ssinsanction    entryRegNext := entryUpdate
555db4956bSzhanglyGit  }
56e08589a5Ssinsanction
57e311c278Ssinsanction  EntryRegCommonConnect(common, hasWakeupIQ, validReg, entryUpdate, entryReg, entryReg.status, io.commonIn, false, isComp)
58397c0f33Ssinsanction
59e08589a5Ssinsanction  //output
60df26db8aSsinsanction  CommonOutConnect(io.commonOut, common, hasWakeupIQ, validReg, entryUpdate, entryReg, entryReg.status, io.commonIn, false, isComp)
615db4956bSzhanglyGit}
625db4956bSzhanglyGit
63e07131b2Ssinsanctionclass OthersEntryVecMem(isComp: Boolean)(implicit p: Parameters, params: IssueBlockParams) extends OthersEntry(isComp)
642d270511Ssinsanction  with HasCircularQueuePtrHelper {
652d270511Ssinsanction
66e07131b2Ssinsanction  require(params.isVecMemIQ, "OthersEntryVecMem can only be instance of VecMem IQ")
672d270511Ssinsanction
68e07131b2Ssinsanction  EntryVecMemConnect(io.commonIn, common, validReg, entryReg, entryRegNext, entryUpdate)
692d270511Ssinsanction}
702d270511Ssinsanction
715db4956bSzhanglyGitobject OthersEntry {
72df26db8aSsinsanction  def apply(isComp: Boolean)(implicit p: Parameters, iqParams: IssueBlockParams): OthersEntry = {
735db4956bSzhanglyGit    iqParams.schdType match {
74df26db8aSsinsanction      case IntScheduler() => new OthersEntry(isComp)
7560f0c5aeSxiaofeibao      case FpScheduler()  => new OthersEntry(isComp)
765db4956bSzhanglyGit      case MemScheduler() =>
77e07131b2Ssinsanction        if (iqParams.isVecMemIQ) new OthersEntryVecMem(isComp)
78df26db8aSsinsanction        else new OthersEntry(isComp)
79df26db8aSsinsanction      case VfScheduler() => new OthersEntry(isComp)
805db4956bSzhanglyGit      case _ => null
815db4956bSzhanglyGit    }
825db4956bSzhanglyGit  }
835db4956bSzhanglyGit}
84