1package xiangshan.backend 2 3import chipsalliance.rocketchip.config.Parameters 4import chisel3._ 5import chisel3.util.BitPat.bitPatToUInt 6import chisel3.util._ 7import utils.OptionWrapper 8import xiangshan._ 9import xiangshan.backend.datapath.DataConfig._ 10import xiangshan.backend.datapath.DataSource 11import xiangshan.backend.datapath.WbConfig.WbConfig 12import xiangshan.backend.decode.{ImmUnion, XDecode} 13import xiangshan.backend.exu.ExeUnitParams 14import xiangshan.backend.fu.FuType 15import xiangshan.backend.fu.fpu.Bundles.Frm 16import xiangshan.backend.fu.vector.Bundles.{Category, Nf, VConfig, VLmul, VSew, VType, Vl, Vxrm} 17import xiangshan.backend.issue.{IssueBlockParams, IssueQueueDeqRespBundle, IssueQueueJumpBundle, SchedulerType, StatusArrayDeqRespBundle} 18import xiangshan.backend.regfile.{RfReadPortWithConfig, RfWritePortWithConfig} 19import xiangshan.backend.rob.RobPtr 20import xiangshan.frontend._ 21import xiangshan.mem.{LqPtr, SqPtr} 22 23object Bundles { 24 25 // frontend -> backend 26 class StaticInst(implicit p: Parameters) extends XSBundle { 27 val instr = UInt(32.W) 28 val pc = UInt(VAddrBits.W) 29 val foldpc = UInt(MemPredPCWidth.W) 30 val exceptionVec = ExceptionVec() 31 val trigger = new TriggerCf 32 val preDecodeInfo = new PreDecodeInfo 33 val pred_taken = Bool() 34 val crossPageIPFFix = Bool() 35 val ftqPtr = new FtqPtr 36 val ftqOffset = UInt(log2Up(PredictWidth).W) 37 38 def connectCtrlFlow(source: CtrlFlow): Unit = { 39 this.instr := source.instr 40 this.pc := source.pc 41 this.foldpc := source.foldpc 42 this.exceptionVec := source.exceptionVec 43 this.trigger := source.trigger 44 this.preDecodeInfo := source.pd 45 this.pred_taken := source.pred_taken 46 this.crossPageIPFFix := source.crossPageIPFFix 47 this.ftqPtr := source.ftqPtr 48 this.ftqOffset := source.ftqOffset 49 } 50 } 51 52 // StaticInst --[Decode]--> DecodedInst 53 class DecodedInst(implicit p: Parameters) extends XSBundle { 54 def numSrc = backendParams.numSrc 55 // passed from StaticInst 56 val instr = UInt(32.W) 57 val pc = UInt(VAddrBits.W) 58 val foldpc = UInt(MemPredPCWidth.W) 59 val exceptionVec = ExceptionVec() 60 val trigger = new TriggerCf 61 val preDecodeInfo = new PreDecodeInfo 62 val pred_taken = Bool() 63 val crossPageIPFFix = Bool() 64 val ftqPtr = new FtqPtr 65 val ftqOffset = UInt(log2Up(PredictWidth).W) 66 // decoded 67 val srcType = Vec(numSrc, SrcType()) 68 val lsrc = Vec(numSrc, UInt(6.W)) 69 val ldest = UInt(6.W) 70 val fuType = FuType() 71 val fuOpType = FuOpType() 72 val rfWen = Bool() 73 val fpWen = Bool() 74 val vecWen = Bool() 75 val isXSTrap = Bool() 76 val waitForward = Bool() // no speculate execution 77 val blockBackward = Bool() 78 val flushPipe = Bool() // This inst will flush all the pipe when commit, like exception but can commit 79 val selImm = SelImm() 80 val imm = UInt(ImmUnion.maxLen.W) 81 val fpu = new FPUCtrlSignals 82 val vpu = new VPUCtrlSignals 83 val isMove = Bool() 84 val uopIdx = UInt(5.W) 85 val uopSplitType = UopSplitType() 86 val isVset = Bool() 87 val firstUop = Bool() 88 val lastUop = Bool() 89 val numUops = UInt(log2Up(MaxUopSize).W) // rob need this 90 val commitType = CommitType() // Todo: remove it 91 92 private def allSignals = srcType.take(3) ++ Seq(fuType, fuOpType, rfWen, fpWen, vecWen, 93 isXSTrap, waitForward, blockBackward, flushPipe, uopSplitType, selImm) 94 95 def decode(inst: UInt, table: Iterable[(BitPat, List[BitPat])]): DecodedInst = { 96 val decoder: Seq[UInt] = ListLookup( 97 inst, XDecode.decodeDefault.map(bitPatToUInt), 98 table.map{ case (pat, pats) => (pat, pats.map(bitPatToUInt)) }.toArray 99 ) 100 allSignals zip decoder foreach { case (s, d) => s := d } 101 this 102 } 103 104 def isSoftPrefetch: Bool = { 105 fuType === FuType.alu.U && fuOpType === ALUOpType.or && selImm === SelImm.IMM_I && ldest === 0.U 106 } 107 108 def connectStaticInst(source: StaticInst): Unit = { 109 for ((name, data) <- this.elements) { 110 if (source.elements.contains(name)) { 111 data := source.elements(name) 112 } 113 } 114 } 115 } 116 117 // DecodedInst --[Rename]--> DynInst 118 class DynInst(implicit p: Parameters) extends XSBundle { 119 def numSrc = backendParams.numSrc 120 // passed from StaticInst 121 val instr = UInt(32.W) 122 val pc = UInt(VAddrBits.W) 123 val foldpc = UInt(MemPredPCWidth.W) 124 val exceptionVec = ExceptionVec() 125 val trigger = new TriggerCf 126 val preDecodeInfo = new PreDecodeInfo 127 val pred_taken = Bool() 128 val crossPageIPFFix = Bool() 129 val ftqPtr = new FtqPtr 130 val ftqOffset = UInt(log2Up(PredictWidth).W) 131 // passed from DecodedInst 132 val srcType = Vec(numSrc, SrcType()) 133 val lsrc = Vec(numSrc, UInt(6.W)) 134 val ldest = UInt(6.W) 135 val fuType = FuType() 136 val fuOpType = FuOpType() 137 val rfWen = Bool() 138 val fpWen = Bool() 139 val vecWen = Bool() 140 val isXSTrap = Bool() 141 val waitForward = Bool() // no speculate execution 142 val blockBackward = Bool() 143 val flushPipe = Bool() // This inst will flush all the pipe when commit, like exception but can commit 144 val selImm = SelImm() 145 val imm = UInt(XLEN.W) // Todo: check if it need minimized 146 val fpu = new FPUCtrlSignals 147 val vpu = new VPUCtrlSignals 148 val isMove = Bool() 149 val uopIdx = UInt(5.W) 150 val isVset = Bool() 151 val firstUop = Bool() 152 val lastUop = Bool() 153 val numUops = UInt(log2Up(MaxUopSize).W) // rob need this 154 val commitType = CommitType() 155 // rename 156 val srcState = Vec(numSrc, SrcState()) 157 val psrc = Vec(numSrc, UInt(PhyRegIdxWidth.W)) 158 val pdest = UInt(PhyRegIdxWidth.W) 159 val oldPdest = UInt(PhyRegIdxWidth.W) 160 val robIdx = new RobPtr 161 162 val eliminatedMove = Bool() 163 val debugInfo = new PerfDebugInfo 164 val storeSetHit = Bool() // inst has been allocated an store set 165 val waitForRobIdx = new RobPtr // store set predicted previous store robIdx 166 // Load wait is needed 167 // load inst will not be executed until former store (predicted by mdp) addr calcuated 168 val loadWaitBit = Bool() 169 // If (loadWaitBit && loadWaitStrict), strict load wait is needed 170 // load inst will not be executed until ALL former store addr calcuated 171 val loadWaitStrict = Bool() 172 val ssid = UInt(SSIDWidth.W) 173 // Todo 174 val lqIdx = new LqPtr 175 val sqIdx = new SqPtr 176 // debug module 177 val singleStep = Bool() 178 // schedule 179 val replayInst = Bool() 180 181 def isLUI: Bool = this.fuType === FuType.alu.U && this.selImm === SelImm.IMM_U 182 def isWFI: Bool = this.fuType === FuType.csr.U && fuOpType === CSROpType.wfi 183 184 def isSvinvalBegin(flush: Bool) = FuType.isFence(fuType) && fuOpType === FenceOpType.nofence && !flush 185 def isSvinval(flush: Bool) = FuType.isFence(fuType) && fuOpType === FenceOpType.sfence && !flush 186 def isSvinvalEnd(flush: Bool) = FuType.isFence(fuType) && fuOpType === FenceOpType.nofence && flush 187 188 def srcIsReady: Vec[Bool] = { 189 VecInit(this.srcType.zip(this.srcState).map { 190 case (t, s) => SrcType.isNotReg(t) || SrcState.isReady(s) 191 }) 192 } 193 194 def clearExceptions( 195 exceptionBits: Seq[Int] = Seq(), 196 flushPipe : Boolean = false, 197 replayInst : Boolean = false 198 ): DynInst = { 199 this.exceptionVec.zipWithIndex.filterNot(x => exceptionBits.contains(x._2)).foreach(_._1 := false.B) 200 if (!flushPipe) { this.flushPipe := false.B } 201 if (!replayInst) { this.replayInst := false.B } 202 this 203 } 204 205 def needWriteRf: Bool = (rfWen && ldest =/= 0.U) || fpWen || vecWen 206 } 207 208 trait BundleSource { 209 var wakeupSource = "undefined" 210 var idx = 0 211 } 212 213 /** 214 * 215 * @param pregIdxWidth index width of preg 216 * @param exuIndices exu indices of wakeup bundle 217 */ 218 sealed abstract class IssueQueueWakeUpBaseBundle(pregIdxWidth: Int, val exuIndices: Seq[Int]) extends Bundle { 219 val rfWen = Bool() 220 val fpWen = Bool() 221 val vecWen = Bool() 222 val pdest = UInt(pregIdxWidth.W) 223 224 /** 225 * @param successor Seq[(psrc, srcType)] 226 * @return Seq[if wakeup psrc] 227 */ 228 def wakeUp(successor: Seq[(UInt, UInt)], valid: Bool): Seq[Bool] = { 229 successor.map { case (thatPsrc, srcType) => 230 val pdestMatch = pdest === thatPsrc 231 pdestMatch && ( 232 SrcType.isFp(srcType) && this.fpWen || 233 SrcType.isXp(srcType) && this.rfWen || 234 SrcType.isVp(srcType) && this.vecWen 235 ) && valid 236 } 237 } 238 239 def hasOnlyOneSource: Boolean = exuIndices.size == 1 240 241 def hasMultiSources: Boolean = exuIndices.size > 1 242 243 def isWBWakeUp = this.isInstanceOf[IssueQueueWBWakeUpBundle] 244 245 def isIQWakeUp = this.isInstanceOf[IssueQueueIQWakeUpBundle] 246 247 def exuIdx: Int = { 248 require(hasOnlyOneSource) 249 this.exuIndices.head 250 } 251 } 252 253 class IssueQueueWBWakeUpBundle(exuIndices: Seq[Int], backendParams: BackendParams) extends IssueQueueWakeUpBaseBundle(backendParams.pregIdxWidth, exuIndices) { 254 255 } 256 257 class IssueQueueIQWakeUpBundle(exuIdx: Int, backendParams: BackendParams) extends IssueQueueWakeUpBaseBundle(backendParams.pregIdxWidth, Seq(exuIdx)) { 258 def fromExuInput(exuInput: ExuInput, l2ExuVecs: Vec[Vec[Bool]]): Unit = { 259 this.rfWen := exuInput.rfWen.getOrElse(false.B) 260 this.fpWen := exuInput.fpWen.getOrElse(false.B) 261 this.vecWen := exuInput.vecWen.getOrElse(false.B) 262 this.pdest := exuInput.pdest 263 } 264 265 def fromExuInput(exuInput: ExuInput): Unit = { 266 this.rfWen := exuInput.rfWen.getOrElse(false.B) 267 this.fpWen := exuInput.fpWen.getOrElse(false.B) 268 this.vecWen := exuInput.vecWen.getOrElse(false.B) 269 this.pdest := exuInput.pdest 270 } 271 } 272 273 class VPUCtrlSignals(implicit p: Parameters) extends XSBundle { 274 // vtype 275 val vill = Bool() 276 val vma = Bool() // 1: agnostic, 0: undisturbed 277 val vta = Bool() // 1: agnostic, 0: undisturbed 278 val vsew = VSew() 279 val vlmul = VLmul() // 1/8~8 --> -3~3 280 281 val vm = Bool() // 0: need v0.t 282 val vstart = Vl() 283 284 // float rounding mode 285 val frm = Frm() 286 // vector fix int rounding mode 287 val vxrm = Vxrm() 288 // vector uop index, exclude other non-vector uop 289 val vuopIdx = UopIdx() 290 // maybe used if data dependancy 291 val vmask = UInt(MaskSrcData().dataWidth.W) 292 val vl = Vl() 293 294 // vector load/store 295 val nf = Nf() 296 297 val needScalaSrc = Bool() 298 val permImmTruncate = Bool() // opivi 299 300 val isReverse = Bool() // vrsub, vrdiv 301 val isExt = Bool() 302 val isNarrow = Bool() 303 val isDstMask = Bool() // vvm, vvvm, mmm 304 val isMove = Bool() // vmv.s.x, vmv.v.v, vmv.v.x, vmv.v.i 305 306 def vtype: VType = { 307 val res = Wire(VType()) 308 res.illegal := this.vill 309 res.vma := this.vma 310 res.vta := this.vta 311 res.vsew := this.vsew 312 res.vlmul := this.vlmul 313 res 314 } 315 316 def vconfig: VConfig = { 317 val res = Wire(VConfig()) 318 res.vtype := this.vtype 319 res.vl := this.vl 320 res 321 } 322 } 323 324 // DynInst --[IssueQueue]--> DataPath 325 class IssueQueueIssueBundle( 326 iqParams: IssueBlockParams, 327 exuParams: ExeUnitParams, 328 addrWidth: Int, 329 vaddrBits: Int 330 )(implicit 331 p: Parameters 332 ) extends Bundle { 333 private val rfReadDataCfgSet: Seq[Set[DataConfig]] = exuParams.getRfReadDataCfgSet 334 335 val rf: MixedVec[MixedVec[RfReadPortWithConfig]] = Flipped(MixedVec( 336 rfReadDataCfgSet.map((set: Set[DataConfig]) => 337 MixedVec(set.map((x: DataConfig) => new RfReadPortWithConfig(x, addrWidth)).toSeq) 338 ) 339 )) 340 341 val srcType = Vec(exuParams.numRegSrc, SrcType()) // used to select imm or reg data 342 val immType = SelImm() // used to select imm extractor 343 val common = new ExuInput(exuParams) 344 val jmp = if (exuParams.needPc) Some(Flipped(new IssueQueueJumpBundle)) else None 345 val addrOH = UInt(iqParams.numEntries.W) 346 347 def exuIdx = exuParams.exuIdx 348 def getSource: SchedulerType = exuParams.getWBSource 349 def getIntWbBusyBundle = common.rfWen.toSeq 350 def getVfWbBusyBundle = common.getVfWen.toSeq 351 def getIntRfReadBundle: Seq[RfReadPortWithConfig] = rf.flatten.filter(_.readInt) 352 def getVfRfReadBundle: Seq[RfReadPortWithConfig] = rf.flatten.filter(_.readVf) 353 } 354 355 class OGRespBundle(implicit p:Parameters, params: IssueBlockParams) extends XSBundle { 356 val issueQueueParams = this.params 357 val og0resp = Valid(new StatusArrayDeqRespBundle) 358 val og1resp = Valid(new StatusArrayDeqRespBundle) 359 } 360 361 class fuBusyRespBundle(implicit p: Parameters, params: IssueBlockParams) extends Bundle { 362 val respType = RSFeedbackType() // update credit if needs replay 363 val rfWen = Bool() // TODO: use params to identify IntWB/VfWB 364 val fuType = FuType() 365 } 366 367 class WbFuBusyTableWriteBundle(val params: ExeUnitParams)(implicit p: Parameters) extends XSBundle { 368 private val intCertainLat = params.intLatencyCertain 369 private val vfCertainLat = params.vfLatencyCertain 370 private val intLat = params.intLatencyValMax 371 private val vfLat = params.vfLatencyValMax 372 373 val intWbBusyTable = OptionWrapper(intCertainLat, UInt((intLat + 1).W)) 374 val vfWbBusyTable = OptionWrapper(vfCertainLat, UInt((vfLat + 1).W)) 375 val intDeqRespSet = OptionWrapper(intCertainLat, UInt((intLat + 1).W)) 376 val vfDeqRespSet = OptionWrapper(vfCertainLat, UInt((vfLat + 1).W)) 377 } 378 379 class WbFuBusyTableReadBundle(val params: ExeUnitParams)(implicit p: Parameters) extends XSBundle { 380 private val intCertainLat = params.intLatencyCertain 381 private val vfCertainLat = params.vfLatencyCertain 382 private val intLat = params.intLatencyValMax 383 private val vfLat = params.vfLatencyValMax 384 385 val intWbBusyTable = OptionWrapper(intCertainLat, UInt((intLat + 1).W)) 386 val vfWbBusyTable = OptionWrapper(vfCertainLat, UInt((vfLat + 1).W)) 387 } 388 389 class WbConflictBundle(val params: ExeUnitParams)(implicit p: Parameters) extends XSBundle { 390 private val intCertainLat = params.intLatencyCertain 391 private val vfCertainLat = params.vfLatencyCertain 392 393 val intConflict = OptionWrapper(intCertainLat, Bool()) 394 val vfConflict = OptionWrapper(vfCertainLat, Bool()) 395 } 396 397 // DataPath --[ExuInput]--> Exu 398 class ExuInput(val params: ExeUnitParams)(implicit p: Parameters) extends XSBundle { 399 val fuType = FuType() 400 val fuOpType = FuOpType() 401 val src = Vec(params.numRegSrc, UInt(params.dataBitsMax.W)) 402 val imm = UInt(XLEN.W) 403 val robIdx = new RobPtr 404 val iqIdx = UInt(log2Up(MemIQSizeMax).W)// Only used by store yet 405 val isFirstIssue = Bool() // Only used by store yet 406 val pdest = UInt(params.wbPregIdxWidth.W) 407 val rfWen = if (params.writeIntRf) Some(Bool()) else None 408 val fpWen = if (params.writeFpRf) Some(Bool()) else None 409 val vecWen = if (params.writeVecRf) Some(Bool()) else None 410 val fpu = if (params.needFPUCtrl) Some(new FPUCtrlSignals) else None 411 val vpu = if (params.needVPUCtrl) Some(new VPUCtrlSignals) else None 412 val flushPipe = if (params.flushPipe) Some(Bool()) else None 413 val pc = if (params.needPc) Some(UInt(VAddrData().dataWidth.W)) else None 414 val jalrTarget = if (params.hasJmpFu) Some(UInt(VAddrData().dataWidth.W)) else None 415 val preDecode = if (params.hasPredecode) Some(new PreDecodeInfo) else None 416 val ftqIdx = if (params.needPc || params.replayInst) 417 Some(new FtqPtr) else None 418 val ftqOffset = if (params.needPc || params.replayInst) 419 Some(UInt(log2Up(PredictWidth).W)) else None 420 val predictInfo = if (params.hasPredecode) Some(new Bundle { 421 val target = UInt(VAddrData().dataWidth.W) 422 val taken = Bool() 423 }) else None 424 val sqIdx = if (params.hasMemAddrFu || params.hasStdFu) Some(new SqPtr) else None 425 val lqIdx = if (params.hasMemAddrFu) Some(new LqPtr) else None 426 val dataSources = Vec(params.numRegSrc, DataSource()) 427 val l1ExuVec = OptionWrapper(params.isIQWakeUpSink, Vec(params.numRegSrc, ExuVec())) 428 val srcTimer = OptionWrapper(params.isIQWakeUpSink, Vec(params.numRegSrc, UInt(3.W))) 429 430 def exuIdx = this.params.exuIdx 431 432 def needCancel(og0CancelVec: Vec[Bool], og1CancelVec: Vec[Bool]) : Bool = { 433 if (params.isIQWakeUpSink) { 434 require( 435 og0CancelVec.size == l1ExuVec.get.head.size, 436 s"cancelVecSize: {og0: ${og0CancelVec.size}, og1: ${og1CancelVec.size}}" 437 ) 438 val l1Cancel: Bool = l1ExuVec.get.zip(srcTimer.get).map { 439 case(exuOH: Vec[Bool], srcTimer: UInt) => 440 (exuOH.asUInt & og0CancelVec.asUInt).orR && srcTimer === 1.U 441 }.reduce(_ | _) 442 l1Cancel 443 } else { 444 false.B 445 } 446 } 447 448 def getVfWen = { 449 if (params.writeFpRf) this.fpWen 450 else if(params.writeVecRf) this.vecWen 451 else None 452 } 453 454 def fromIssueBundle(source: IssueQueueIssueBundle): Unit = { 455 // src is assigned to rfReadData 456 this.fuType := source.common.fuType 457 this.fuOpType := source.common.fuOpType 458 this.imm := source.common.imm 459 this.robIdx := source.common.robIdx 460 this.pdest := source.common.pdest 461 this.isFirstIssue := source.common.isFirstIssue // Only used by mem debug log 462 this.iqIdx := source.common.iqIdx // Only used by mem feedback 463 this.dataSources := source.common.dataSources 464 this.rfWen .foreach(_ := source.common.rfWen.get) 465 this.fpWen .foreach(_ := source.common.fpWen.get) 466 this.vecWen .foreach(_ := source.common.vecWen.get) 467 this.fpu .foreach(_ := source.common.fpu.get) 468 this.vpu .foreach(_ := source.common.vpu.get) 469 this.flushPipe .foreach(_ := source.common.flushPipe.get) 470 this.pc .foreach(_ := source.jmp.get.pc) 471 this.jalrTarget .foreach(_ := source.jmp.get.target) 472 this.preDecode .foreach(_ := source.common.preDecode.get) 473 this.ftqIdx .foreach(_ := source.common.ftqIdx.get) 474 this.ftqOffset .foreach(_ := source.common.ftqOffset.get) 475 this.predictInfo .foreach(_ := source.common.predictInfo.get) 476 this.lqIdx .foreach(_ := source.common.lqIdx.get) 477 this.sqIdx .foreach(_ := source.common.sqIdx.get) 478 this.l1ExuVec .foreach(_ := source.common.l1ExuVec.get) 479 this.srcTimer .foreach(_ := source.common.srcTimer.get) 480 } 481 } 482 483 // ExuInput --[FuncUnit]--> ExuOutput 484 class ExuOutput( 485 val params: ExeUnitParams, 486 )(implicit 487 val p: Parameters 488 ) extends Bundle with BundleSource with HasXSParameter { 489 val data = UInt(params.dataBitsMax.W) 490 val pdest = UInt(params.wbPregIdxWidth.W) 491 val robIdx = new RobPtr 492 val intWen = if (params.writeIntRf) Some(Bool()) else None 493 val fpWen = if (params.writeFpRf) Some(Bool()) else None 494 val vecWen = if (params.writeVecRf) Some(Bool()) else None 495 val redirect = if (params.hasRedirect) Some(ValidIO(new Redirect)) else None 496 val fflags = if (params.writeFflags) Some(UInt(5.W)) else None 497 val vxsat = if (params.writeVxsat) Some(Bool()) else None 498 val exceptionVec = if (params.exceptionOut.nonEmpty) Some(ExceptionVec()) else None 499 val flushPipe = if (params.flushPipe) Some(Bool()) else None 500 val replay = if (params.replayInst) Some(Bool()) else None 501 val lqIdx = if (params.hasLoadFu) Some(new LqPtr()) else None 502 val sqIdx = if (params.hasStoreAddrFu || params.hasStdFu) 503 Some(new SqPtr()) else None 504 val ftqIdx = if (params.needPc || params.replayInst) 505 Some(new FtqPtr) else None 506 val ftqOffset = if (params.needPc || params.replayInst) 507 Some(UInt(log2Up(PredictWidth).W)) else None 508 // uop info 509 val predecodeInfo = if(params.hasPredecode) Some(new PreDecodeInfo) else None 510 val debug = new DebugBundle 511 val debugInfo = new PerfDebugInfo 512 } 513 514 // ExuOutput + DynInst --> WriteBackBundle 515 class WriteBackBundle(val params: WbConfig)(implicit p: Parameters) extends Bundle with BundleSource { 516 val rfWen = Bool() 517 val fpWen = Bool() 518 val vecWen = Bool() 519 val pdest = UInt(params.pregIdxWidth.W) 520 val data = UInt(params.dataWidth.W) 521 val robIdx = new RobPtr()(p) 522 val flushPipe = Bool() 523 val replayInst = Bool() 524 val redirect = ValidIO(new Redirect) 525 val fflags = UInt(5.W) 526 val vxsat = Bool() 527 val exceptionVec = ExceptionVec() 528 val debug = new DebugBundle 529 val debugInfo = new PerfDebugInfo 530 531 this.wakeupSource = s"WB(${params.toString})" 532 533 def fromExuOutput(source: ExuOutput) = { 534 this.rfWen := source.intWen.getOrElse(false.B) 535 this.fpWen := source.fpWen.getOrElse(false.B) 536 this.vecWen := source.vecWen.getOrElse(false.B) 537 this.pdest := source.pdest 538 this.data := source.data 539 this.robIdx := source.robIdx 540 this.flushPipe := source.flushPipe.getOrElse(false.B) 541 this.replayInst := source.replay.getOrElse(false.B) 542 this.redirect := source.redirect.getOrElse(0.U.asTypeOf(this.redirect)) 543 this.fflags := source.fflags.getOrElse(0.U.asTypeOf(this.fflags)) 544 this.vxsat := source.vxsat.getOrElse(0.U.asTypeOf(this.vxsat)) 545 this.exceptionVec := source.exceptionVec.getOrElse(0.U.asTypeOf(this.exceptionVec)) 546 this.debug := source.debug 547 this.debugInfo := source.debugInfo 548 } 549 550 def asIntRfWriteBundle(fire: Bool): RfWritePortWithConfig = { 551 val rfWrite = Wire(Output(new RfWritePortWithConfig(this.params.dataCfg, this.params.pregIdxWidth))) 552 rfWrite.wen := this.rfWen && fire 553 rfWrite.addr := this.pdest 554 rfWrite.data := this.data 555 rfWrite.intWen := this.rfWen 556 rfWrite.fpWen := false.B 557 rfWrite.vecWen := false.B 558 rfWrite 559 } 560 561 def asVfRfWriteBundle(fire: Bool): RfWritePortWithConfig = { 562 val rfWrite = Wire(Output(new RfWritePortWithConfig(this.params.dataCfg, this.params.pregIdxWidth))) 563 rfWrite.wen := (this.fpWen || this.vecWen) && fire 564 rfWrite.addr := this.pdest 565 rfWrite.data := this.data 566 rfWrite.intWen := false.B 567 rfWrite.fpWen := this.fpWen 568 rfWrite.vecWen := this.vecWen 569 rfWrite 570 } 571 } 572 573 // ExuOutput --> ExuBypassBundle --[DataPath]-->ExuInput 574 // / 575 // [IssueQueue]--> ExuInput -- 576 class ExuBypassBundle( 577 val params: ExeUnitParams, 578 )(implicit 579 val p: Parameters 580 ) extends Bundle { 581 val data = UInt(params.dataBitsMax.W) 582 val pdest = UInt(params.wbPregIdxWidth.W) 583 } 584 585 class ExceptionInfo extends Bundle { 586 val pc = UInt(VAddrData().dataWidth.W) 587 val instr = UInt(32.W) 588 val commitType = CommitType() 589 val exceptionVec = ExceptionVec() 590 val singleStep = Bool() 591 val crossPageIPFFix = Bool() 592 val isInterrupt = Bool() 593 } 594 595 object UopIdx { 596 def apply()(implicit p: Parameters): UInt = UInt(log2Up(p(XSCoreParamsKey).MaxUopSize + 1).W) 597 } 598 599 object FuLatency { 600 def apply(): UInt = UInt(width.W) 601 602 def width = 4 // 0~15 // Todo: assosiate it with FuConfig 603 } 604 605 object ExuVec { 606 def apply(exuNum: Int): Vec[Bool] = Vec(exuNum, Bool()) 607 608 def apply()(implicit p: Parameters): Vec[Bool] = Vec(width, Bool()) 609 610 def width(implicit p: Parameters): Int = p(XSCoreParamsKey).backendParams.numExu 611 } 612 613 class MemExuInput(isVector: Boolean = false)(implicit p: Parameters) extends XSBundle { 614 val uop = new DynInst 615 val src = if (isVector) Vec(5, UInt(VLEN.W)) else Vec(3, UInt(XLEN.W)) 616 val iqIdx = UInt(log2Up(MemIQSizeMax).W) 617 val isFirstIssue = Bool() 618 } 619 620 class MemExuOutput(isVector: Boolean = false)(implicit p: Parameters) extends XSBundle { 621 val uop = new DynInst 622 val data = if (isVector) UInt(VLEN.W) else UInt(XLEN.W) 623 val debug = new DebugBundle 624 } 625 626 class MemMicroOpRbExt(implicit p: Parameters) extends XSBundle { 627 val uop = new DynInst 628 val flag = UInt(1.W) 629 } 630} 631