CtrlBlock.scala 17.0 KB
Newer Older
L
Lemover 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/***************************************************************************************
* Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences
*
* XiangShan is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*          http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
*
* See the Mulan PSL v2 for more details.
***************************************************************************************/

16 17
package xiangshan.backend

18
import chipsalliance.rocketchip.config.Parameters
19 20
import chisel3._
import chisel3.util._
Y
Yinan Xu 已提交
21
import utils._
22
import xiangshan._
23
import xiangshan.backend.decode.{DecodeStage, ImmUnion}
L
LinJiawei 已提交
24
import xiangshan.backend.rename.{BusyTable, Rename}
25 26
import xiangshan.backend.dispatch.Dispatch
import xiangshan.backend.exu._
Z
zoujr 已提交
27
import xiangshan.frontend.{FtqRead, FtqToCtrlIO, FtqPtr, CfiInfoToCtrl}
28
import xiangshan.backend.roq.{Roq, RoqCSRIO, RoqLsqIO, RoqPtr}
Y
Yinan Xu 已提交
29
import xiangshan.mem.LsqEnqIO
30

31

32
class CtrlToIntBlockIO(implicit p: Parameters) extends XSBundle {
33
  val enqIqCtrl = Vec(exuParameters.IntExuCnt, DecoupledIO(new MicroOp))
Y
Yinan Xu 已提交
34
  val readRf = Vec(NRIntReadPorts, Output(UInt(PhyRegIdxWidth.W)))
L
LinJiawei 已提交
35
  val jumpPc = Output(UInt(VAddrBits.W))
L
LinJiawei 已提交
36
  val jalr_target = Output(UInt(VAddrBits.W))
Y
YikeZhou 已提交
37 38
  // int block only uses port 0~7
  val readPortIndex = Vec(exuParameters.IntExuCnt, Output(UInt(log2Ceil(8 / 2).W))) // TODO parameterize 8 here
Y
Yinan Xu 已提交
39
  val redirect = ValidIO(new Redirect)
40
  val flush = Output(Bool())
41
  val debug_rat = Vec(32, Output(UInt(PhyRegIdxWidth.W)))
42 43
}

44
class CtrlToFpBlockIO(implicit p: Parameters) extends XSBundle {
45
  val enqIqCtrl = Vec(exuParameters.FpExuCnt, DecoupledIO(new MicroOp))
Y
Yinan Xu 已提交
46
  val readRf = Vec(NRFpReadPorts, Output(UInt(PhyRegIdxWidth.W)))
Y
YikeZhou 已提交
47 48
  // fp block uses port 0~11
  val readPortIndex = Vec(exuParameters.FpExuCnt, Output(UInt(log2Ceil((NRFpReadPorts - exuParameters.StuCnt) / 3).W)))
Y
Yinan Xu 已提交
49
  val redirect = ValidIO(new Redirect)
50
  val flush = Output(Bool())
51
  val debug_rat = Vec(32, Output(UInt(PhyRegIdxWidth.W)))
52 53
}

54
class CtrlToLsBlockIO(implicit p: Parameters) extends XSBundle {
55
  val enqIqCtrl = Vec(exuParameters.LsExuCnt, DecoupledIO(new MicroOp))
Y
Yinan Xu 已提交
56
  val enqLsq = Flipped(new LsqEnqIO)
57
  val memPredUpdate = Vec(StorePipelineWidth, Input(new MemPredUpdateReq))
Y
Yinan Xu 已提交
58
  val redirect = ValidIO(new Redirect)
59
  val flush = Output(Bool())
60 61
}

62 63 64 65 66 67 68 69 70 71 72 73 74
class CtrlToFtqIO(implicit p: Parameters) extends XSBundle {
  val roq_commits = Vec(CommitWidth, Valid(new RoqCommitInfo))
  val stage2Redirect = Valid(new Redirect)
  val roqFlush = Valid(new Bundle {
    val ftqIdx = Output(new FtqPtr)
    val ftqOffset = Output(UInt(log2Up(PredictWidth).W))
  })

  val exuWriteback = Vec(exuParameters.JmpCnt + exuParameters.AluCnt, Valid(new ExuOutput))
  val loadReplay = Valid(new Redirect)
  val stage3Redirect = ValidIO(new Redirect)
}

75
class RedirectGenerator(implicit p: Parameters) extends XSModule
76
  with HasCircularQueuePtrHelper {
L
ljw 已提交
77
  val numRedirect = exuParameters.JmpCnt + exuParameters.AluCnt
L
LinJiawei 已提交
78
  val io = IO(new Bundle() {
L
ljw 已提交
79
    val exuMispredict = Vec(numRedirect, Flipped(ValidIO(new ExuOutput)))
L
ljw 已提交
80
    val loadReplay = Flipped(ValidIO(new Redirect))
81
    val flush = Input(Bool())
Z
zoujr 已提交
82 83
    val stage1PcRead = Vec(numRedirect+1, new FtqRead(UInt(VAddrBits.W)))
    val stage1CfiRead = Vec(numRedirect+1, new FtqRead(new CfiInfoToCtrl))
L
LinJiawei 已提交
84
    val stage2Redirect = ValidIO(new Redirect)
L
LinJiawei 已提交
85
    val stage3Redirect = ValidIO(new Redirect)
86
    val memPredUpdate = Output(new MemPredUpdateReq)
Z
zoujr 已提交
87
    val memPredPcRead = new FtqRead(UInt(VAddrBits.W)) // read req send form stage 2
L
LinJiawei 已提交
88 89 90 91
  })
  /*
        LoadQueue  Jump  ALU0  ALU1  ALU2  ALU3   exception    Stage1
          |         |      |    |     |     |         |
L
LinJiawei 已提交
92
          |============= reg & compare =====|         |       ========
L
LinJiawei 已提交
93 94 95 96
                            |                         |
                            |                         |
                            |                         |        Stage2
                            |                         |
L
LinJiawei 已提交
97 98 99 100 101 102 103 104
                    redirect (flush backend)          |
                    |                                 |
               === reg ===                            |       ========
                    |                                 |
                    |----- mux (exception first) -----|        Stage3
                            |
                redirect (send to frontend)
   */
L
ljw 已提交
105 106 107 108
  private class Wrapper(val n: Int) extends Bundle {
    val redirect = new Redirect
    val valid = Bool()
    val idx = UInt(log2Up(n).W)
109
  }
110 111 112 113 114 115 116 117
  def selectOldestRedirect(xs: Seq[Valid[Redirect]]): Vec[Bool] = {
    val compareVec = (0 until xs.length).map(i => (0 until i).map(j => isAfter(xs(j).bits.roqIdx, xs(i).bits.roqIdx)))
    val resultOnehot = VecInit((0 until xs.length).map(i => Cat((0 until xs.length).map(j =>
      (if (j < i) !xs(j).valid || compareVec(i)(j)
      else if (j == i) xs(i).valid
      else !xs(j).valid || !compareVec(j)(i))
    )).andR))
    resultOnehot
L
LinJiawei 已提交
118 119
  }

120 121 122 123 124
  val redirects = io.exuMispredict.map(_.bits.redirect) :+ io.loadReplay.bits
  val stage1FtqReadPcs = 
    (io.stage1PcRead zip redirects).map{ case (r: FtqRead[UInt], redirect: Redirect) => 
      r(redirect.ftqIdx, redirect.ftqOffset)
    }
L
ljw 已提交
125 126

  def getRedirect(exuOut: Valid[ExuOutput]): ValidIO[Redirect] = {
L
LinJiawei 已提交
127
    val redirect = Wire(Valid(new Redirect))
L
ljw 已提交
128 129
    redirect.valid := exuOut.valid && exuOut.bits.redirect.cfiUpdate.isMisPred
    redirect.bits := exuOut.bits.redirect
L
LinJiawei 已提交
130
    redirect
L
ljw 已提交
131
  }
L
LinJiawei 已提交
132

L
ljw 已提交
133
  val jumpOut = io.exuMispredict.head
134 135 136 137 138 139
  val allRedirect = VecInit(io.exuMispredict.map(x => getRedirect(x)) :+ io.loadReplay)
  val oldestOneHot = selectOldestRedirect(allRedirect)
  val needFlushVec = VecInit(allRedirect.map(_.bits.roqIdx.needFlush(io.stage2Redirect, io.flush)))
  val oldestValid = VecInit(oldestOneHot.zip(needFlushVec).map{ case (v, f) => v && !f }).asUInt.orR
  val oldestExuOutput = Mux1H((0 until 5).map(oldestOneHot), io.exuMispredict)
  val oldestRedirect = Mux1H(oldestOneHot, allRedirect)
140

L
LinJiawei 已提交
141
  val s1_jumpTarget = RegEnable(jumpOut.bits.redirect.cfiUpdate.target, jumpOut.valid)
142 143 144 145 146
  val s1_imm12_reg = RegNext(oldestExuOutput.bits.uop.ctrl.imm(11, 0))
  val s1_pd = RegNext(oldestExuOutput.bits.uop.cf.pd)
  val s1_redirect_bits_reg = RegNext(oldestRedirect.bits)
  val s1_redirect_valid_reg = RegNext(oldestValid)
  val s1_redirect_onehot = RegNext(oldestOneHot)
L
LinJiawei 已提交
147 148

  // stage1 -> stage2
149
  io.stage2Redirect.valid := s1_redirect_valid_reg && !io.flush
L
LinJiawei 已提交
150 151 152
  io.stage2Redirect.bits := s1_redirect_bits_reg
  io.stage2Redirect.bits.cfiUpdate := DontCare

153 154
  val s1_isReplay = s1_redirect_onehot(5)
  val s1_isJump = s1_redirect_onehot(0)
155 156
  val cfiRead = Mux1H(s1_redirect_onehot, io.stage1CfiRead)
  val real_pc = Mux1H(s1_redirect_onehot, stage1FtqReadPcs)
L
ljw 已提交
157 158
  val brTarget = real_pc + SignExt(ImmUnion.B.toImm32(s1_imm12_reg), XLEN)
  val snpc = real_pc + Mux(s1_pd.isRVC, 2.U, 4.U)
159
  val target = Mux(s1_isReplay,
160
    real_pc, // repaly from itself
L
ljw 已提交
161 162
    Mux(s1_redirect_bits_reg.cfiUpdate.taken,
      Mux(s1_isJump, s1_jumpTarget, brTarget),
L
LinJiawei 已提交
163
      snpc
L
LinJiawei 已提交
164 165
    )
  )
166

167 168 169
  // get pc from ftq
  // valid only if redirect is caused by load violation
  // store_pc is used to update store set
170
  val store_pc = io.memPredPcRead(s1_redirect_bits_reg.stFtqIdx, s1_redirect_bits_reg.stFtqOffset)
171 172 173 174 175 176 177 178 179 180

  // update load violation predictor if load violation redirect triggered
  io.memPredUpdate.valid := RegNext(s1_isReplay && s1_redirect_valid_reg, init = false.B)
  // update wait table
  io.memPredUpdate.waddr := RegNext(XORFold(real_pc(VAddrBits-1, 1), MemPredPCWidth))
  io.memPredUpdate.wdata := true.B
  // update store set
  io.memPredUpdate.ldpc := RegNext(XORFold(real_pc(VAddrBits-1, 1), MemPredPCWidth))
  // store pc is ready 1 cycle after s1_isReplay is judged
  io.memPredUpdate.stpc := XORFold(store_pc(VAddrBits-1, 1), MemPredPCWidth)
181

182
  val s2_br_mask = RegEnable(cfiRead.data.br_mask, enable = s1_redirect_valid_reg)
183
  val s2_sawNotTakenBranch = RegEnable(VecInit((0 until PredictWidth).map{ i =>
184
      if(i == 0) false.B else Cat(cfiRead.data.br_mask.take(i)).orR()
185
    })(s1_redirect_bits_reg.ftqOffset), enable = s1_redirect_valid_reg)
186
  val s2_hist = RegEnable(cfiRead.data.hist, enable = s1_redirect_valid_reg)
L
ljw 已提交
187 188
  val s2_target = RegEnable(target, enable = s1_redirect_valid_reg)
  val s2_pd = RegEnable(s1_pd, enable = s1_redirect_valid_reg)
189
  val s2_pc = RegEnable(real_pc, enable = s1_redirect_valid_reg)
L
ljw 已提交
190 191 192
  val s2_redirect_bits_reg = RegEnable(s1_redirect_bits_reg, enable = s1_redirect_valid_reg)
  val s2_redirect_valid_reg = RegNext(s1_redirect_valid_reg && !io.flush, init = false.B)

L
LinJiawei 已提交
193 194 195
  io.stage3Redirect.valid := s2_redirect_valid_reg
  io.stage3Redirect.bits := s2_redirect_bits_reg
  val stage3CfiUpdate = io.stage3Redirect.bits.cfiUpdate
196
  stage3CfiUpdate.pc := s2_pc
L
LinJiawei 已提交
197
  stage3CfiUpdate.pd := s2_pd
198 199 200 201
  // stage3CfiUpdate.rasSp := s2_ftqRead.rasSp
  // stage3CfiUpdate.rasEntry := s2_ftqRead.rasTop
  // stage3CfiUpdate.predHist := s2_ftqRead.predHist
  // stage3CfiUpdate.specCnt := s2_ftqRead.specCnt
202
  stage3CfiUpdate.hist := s2_hist
L
LinJiawei 已提交
203
  stage3CfiUpdate.predTaken := s2_redirect_bits_reg.cfiUpdate.predTaken
204
  stage3CfiUpdate.sawNotTakenBranch := s2_sawNotTakenBranch
L
ljw 已提交
205
  stage3CfiUpdate.target := s2_target
L
LinJiawei 已提交
206 207
  stage3CfiUpdate.taken := s2_redirect_bits_reg.cfiUpdate.taken
  stage3CfiUpdate.isMisPred := s2_redirect_bits_reg.cfiUpdate.isMisPred
L
LinJiawei 已提交
208 209
}

210
class CtrlBlock(implicit p: Parameters) extends XSModule
211
  with HasCircularQueuePtrHelper {
212
  val io = IO(new Bundle {
213
    val frontend = Flipped(new FrontendToCtrlIO)
214 215 216 217 218 219
    val fromIntBlock = Flipped(new IntBlockToCtrlIO)
    val fromFpBlock = Flipped(new FpBlockToCtrlIO)
    val fromLsBlock = Flipped(new LsBlockToCtrlIO)
    val toIntBlock = new CtrlToIntBlockIO
    val toFpBlock = new CtrlToFpBlockIO
    val toLsBlock = new CtrlToLsBlockIO
Y
Yinan Xu 已提交
220 221 222
    val roqio = new Bundle {
      // to int block
      val toCSR = new RoqCSRIO
223
      val exception = ValidIO(new ExceptionInfo)
Y
Yinan Xu 已提交
224
      // to mem block
225
      val lsq = new RoqLsqIO
Y
Yinan Xu 已提交
226
    }
227
    val csrCtrl = Input(new CustomCSRCtrlIO)
228 229 230 231 232 233 234 235
    val perfInfo = Output(new Bundle{
      val ctrlInfo = new Bundle {
        val roqFull   = Input(Bool())
        val intdqFull = Input(Bool())
        val fpdqFull  = Input(Bool())
        val lsdqFull  = Input(Bool())
      }
    })
236 237 238 239
  })

  val decode = Module(new DecodeStage)
  val rename = Module(new Rename)
240
  val dispatch = Module(new Dispatch)
Y
Yinan Xu 已提交
241 242
  val intBusyTable = Module(new BusyTable(NRIntReadPorts, NRIntWritePorts))
  val fpBusyTable = Module(new BusyTable(NRFpReadPorts, NRFpWritePorts))
L
LinJiawei 已提交
243
  val redirectGen = Module(new RedirectGenerator)
244

L
LinJiawei 已提交
245
  val roqWbSize = NRIntWritePorts + NRFpWritePorts + exuParameters.StuCnt
246
  val roq = Module(new Roq(roqWbSize))
247

248 249
  val stage2Redirect = redirectGen.io.stage2Redirect
  val stage3Redirect = redirectGen.io.stage3Redirect
250
  val flush = roq.io.flushOut.valid
251
  val flushReg = RegNext(flush)
L
LinJiawei 已提交
252

L
ljw 已提交
253 254
  val exuRedirect = io.fromIntBlock.exuRedirect.map(x => {
    val valid = x.valid && x.bits.redirectValid
255
    val killedByOlder = x.bits.uop.roqIdx.needFlush(stage2Redirect, flushReg)
L
ljw 已提交
256 257 258 259
    val delayed = Wire(Valid(new ExuOutput))
    delayed.valid := RegNext(valid && !killedByOlder, init = false.B)
    delayed.bits := RegEnable(x.bits, x.valid)
    delayed
L
LinJiawei 已提交
260
  })
L
ljw 已提交
261 262
  val loadReplay = Wire(Valid(new Redirect))
  loadReplay.valid := RegNext(io.fromLsBlock.replay.valid &&
263
    !io.fromLsBlock.replay.bits.roqIdx.needFlush(stage2Redirect, flushReg),
L
ljw 已提交
264 265 266
    init = false.B
  )
  loadReplay.bits := RegEnable(io.fromLsBlock.replay.bits, io.fromLsBlock.replay.valid)
267 268
  io.frontend.fromFtq.getRedirectPcRead <> redirectGen.io.stage1PcRead
  io.frontend.fromFtq.getMemPredPcRead <> redirectGen.io.memPredPcRead
L
ljw 已提交
269
  redirectGen.io.exuMispredict <> exuRedirect
L
ljw 已提交
270
  redirectGen.io.loadReplay <> loadReplay
271
  redirectGen.io.flush := flushReg
272

L
LinJiawei 已提交
273
  for(i <- 0 until CommitWidth){
L
Lingrui98 已提交
274 275
    io.frontend.toFtq.roq_commits(i).valid := roq.io.commits.valid(i) && !roq.io.commits.isWalk
    io.frontend.toFtq.roq_commits(i).bits := roq.io.commits.info(i)
L
LinJiawei 已提交
276
  }
277 278 279
  io.frontend.toFtq.stage2Redirect <> stage2Redirect
  io.frontend.toFtq.roqFlush <> RegNext(roq.io.flushOut)
  io.frontend.toFtq.stage3Redirect <> stage3Redirect
L
Lingrui98 已提交
280
  io.frontend.toFtq.exuWriteback <> exuRedirect
281
  io.frontend.toFtq.loadReplay <> loadReplay
L
Lingrui98 已提交
282

283 284
  val roqPcRead = io.frontend.fromFtq.getRoqFlushPcRead
  val flushPC = roqPcRead(roq.io.flushOut.bits.ftqIdx, roq.io.flushOut.bits.ftqOffset)
285 286

  val flushRedirect = Wire(Valid(new Redirect))
287
  flushRedirect.valid := flushReg
288 289 290
  flushRedirect.bits := DontCare
  flushRedirect.bits.ftqIdx := RegEnable(roq.io.flushOut.bits.ftqIdx, flush)
  flushRedirect.bits.interrupt := true.B
L
LinJiawei 已提交
291 292 293
  flushRedirect.bits.cfiUpdate.target := Mux(io.roqio.toCSR.isXRet || roq.io.exception.valid,
    io.roqio.toCSR.trapTarget,
    flushPC + 4.U // flush pipe
294
  )
L
ljw 已提交
295 296 297
  val flushRedirectReg = Wire(Valid(new Redirect))
  flushRedirectReg.valid := RegNext(flushRedirect.valid, init = false.B)
  flushRedirectReg.bits := RegEnable(flushRedirect.bits, enable = flushRedirect.valid)
L
LinJiawei 已提交
298

299
  io.frontend.redirect_cfiUpdate := Mux(flushRedirectReg.valid, flushRedirectReg, stage3Redirect)
Y
Yinan Xu 已提交
300

301
  decode.io.in <> io.frontend.cfVec
302
  // currently, we only update wait table when isReplay
303 304 305 306
  decode.io.memPredUpdate(0) <> RegNext(redirectGen.io.memPredUpdate)
  decode.io.memPredUpdate(1) := DontCare
  decode.io.memPredUpdate(1).valid := false.B
  // decode.io.memPredUpdate <> io.toLsBlock.memPredUpdate
307 308
  decode.io.csrCtrl := RegNext(io.csrCtrl)

309

L
LinJiawei 已提交
310
  val jumpInst = dispatch.io.enqIQCtrl(0).bits
311 312 313 314
  val jumpPcRead = io.frontend.fromFtq.getJumpPcRead
  io.toIntBlock.jumpPc := jumpPcRead(jumpInst.cf.ftqPtr, jumpInst.cf.ftqOffset)
  val jumpTargetRead = io.frontend.fromFtq.target_read
  io.toIntBlock.jalr_target := jumpTargetRead(jumpInst.cf.ftqPtr, jumpInst.cf.ftqOffset)
L
LinJiawei 已提交
315

316 317
  // pipeline between decode and dispatch
  for (i <- 0 until RenameWidth) {
L
LinJiawei 已提交
318
    PipelineConnect(decode.io.out(i), rename.io.in(i), rename.io.in(i).ready,
L
ljw 已提交
319
      flushReg || io.frontend.redirect_cfiUpdate.valid)
320
  }
321

322
  rename.io.redirect <> stage2Redirect
323
  rename.io.flush := flushReg
324 325
  rename.io.roqCommits <> roq.io.commits
  rename.io.out <> dispatch.io.fromRename
326
  rename.io.renameBypass <> dispatch.io.renameBypass
327
  rename.io.dispatchInfo <> dispatch.io.preDpInfo
328
  rename.io.csrCtrl <> RegNext(io.csrCtrl)
329

330
  dispatch.io.redirect <> stage2Redirect
331
  dispatch.io.flush := flushReg
332
  dispatch.io.enqRoq <> roq.io.enq
333
  dispatch.io.enqLsq <> io.toLsBlock.enqLsq
Y
Yinan Xu 已提交
334 335
  dispatch.io.readIntRf <> io.toIntBlock.readRf
  dispatch.io.readFpRf <> io.toFpBlock.readRf
Y
Yinan Xu 已提交
336 337
  dispatch.io.allocPregs.zipWithIndex.foreach { case (preg, i) =>
    intBusyTable.io.allocPregs(i).valid := preg.isInt
338
    fpBusyTable.io.allocPregs(i).valid := preg.isFp
Y
Yinan Xu 已提交
339 340 341
    intBusyTable.io.allocPregs(i).bits := preg.preg
    fpBusyTable.io.allocPregs(i).bits := preg.preg
  }
342
  dispatch.io.numExist <> io.fromIntBlock.numExist ++ io.fromFpBlock.numExist ++ io.fromLsBlock.numExist
Y
Yinan Xu 已提交
343
  dispatch.io.enqIQCtrl <> io.toIntBlock.enqIqCtrl ++ io.toFpBlock.enqIqCtrl ++ io.toLsBlock.enqIqCtrl
344
//  dispatch.io.enqIQData <> io.toIntBlock.enqIqData ++ io.toFpBlock.enqIqData ++ io.toLsBlock.enqIqData
345 346
  dispatch.io.csrCtrl <> io.csrCtrl
  dispatch.io.storeIssue <> io.fromLsBlock.stIn
347

L
LinJiawei 已提交
348

349 350
  fpBusyTable.io.flush := flushReg
  intBusyTable.io.flush := flushReg
Y
Yinan Xu 已提交
351
  for((wb, setPhyRegRdy) <- io.fromIntBlock.wbRegs.zip(intBusyTable.io.wbPregs)){
352
    setPhyRegRdy.valid := wb.valid && wb.bits.uop.ctrl.rfWen
Y
Yinan Xu 已提交
353 354 355 356 357 358
    setPhyRegRdy.bits := wb.bits.uop.pdest
  }
  for((wb, setPhyRegRdy) <- io.fromFpBlock.wbRegs.zip(fpBusyTable.io.wbPregs)){
    setPhyRegRdy.valid := wb.valid && wb.bits.uop.ctrl.fpWen
    setPhyRegRdy.bits := wb.bits.uop.pdest
  }
Y
Yinan Xu 已提交
359 360
  intBusyTable.io.read <> dispatch.io.readIntState
  fpBusyTable.io.read <> dispatch.io.readFpState
Y
Yinan Xu 已提交
361

362
  roq.io.redirect <> stage2Redirect
L
ljw 已提交
363 364
  val exeWbResults = VecInit(io.fromIntBlock.wbRegs ++ io.fromFpBlock.wbRegs ++ io.fromLsBlock.stOut)
  for((roq_wb, wb) <- roq.io.exeWbResults.zip(exeWbResults)) {
365
    roq_wb.valid := RegNext(wb.valid && !wb.bits.uop.roqIdx.needFlush(stage2Redirect, flushReg))
L
ljw 已提交
366 367
    roq_wb.bits := RegNext(wb.bits)
  }
L
LinJiawei 已提交
368

369 370
  // TODO: is 'stage2Redirect' necesscary?
  io.toIntBlock.redirect <> stage2Redirect
371
  io.toIntBlock.flush <> flushReg
372
  io.toIntBlock.debug_rat <> rename.io.debug_int_rat
373
  io.toFpBlock.redirect <> stage2Redirect
374
  io.toFpBlock.flush <> flushReg
375
  io.toFpBlock.debug_rat <> rename.io.debug_fp_rat
376
  io.toLsBlock.redirect <> stage2Redirect
377
  io.toLsBlock.flush <> flushReg
378

379 380 381
  dispatch.io.readPortIndex.intIndex <> io.toIntBlock.readPortIndex
  dispatch.io.readPortIndex.fpIndex <> io.toFpBlock.readPortIndex

Y
Yinan Xu 已提交
382 383
  // roq to int block
  io.roqio.toCSR <> roq.io.csr
384
  io.roqio.toCSR.perfinfo.retiredInstr <> RegNext(roq.io.csr.perfinfo.retiredInstr)
385
  io.roqio.exception := roq.io.exception
386
  io.roqio.exception.bits.uop.cf.pc := flushPC
Y
Yinan Xu 已提交
387
  // roq to mem block
388
  io.roqio.lsq <> roq.io.lsq
389 390 391 392 393

  io.perfInfo.ctrlInfo.roqFull := RegNext(roq.io.roqFull)
  io.perfInfo.ctrlInfo.intdqFull := RegNext(dispatch.io.ctrlInfo.intdqFull)
  io.perfInfo.ctrlInfo.fpdqFull := RegNext(dispatch.io.ctrlInfo.fpdqFull)
  io.perfInfo.ctrlInfo.lsdqFull := RegNext(dispatch.io.ctrlInfo.lsdqFull)
394
}