CtrlBlock.scala 17.6 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._
L
Lingrui98 已提交
27
import xiangshan.frontend.{FtqRead, HasFtqHelper}
28
import xiangshan.backend.roq.{Roq, RoqCSRIO, RoqLsqIO, RoqPtr}
Y
Yinan Xu 已提交
29
import xiangshan.mem.LsqEnqIO
30

31
class CtrlToIntBlockIO(implicit p: Parameters) extends XSBundle {
32
  val enqIqCtrl = Vec(exuParameters.IntExuCnt, DecoupledIO(new MicroOp))
Y
Yinan Xu 已提交
33
  val readRf = Vec(NRIntReadPorts, Output(UInt(PhyRegIdxWidth.W)))
L
LinJiawei 已提交
34
  val jumpPc = Output(UInt(VAddrBits.W))
L
LinJiawei 已提交
35
  val jalr_target = Output(UInt(VAddrBits.W))
Y
YikeZhou 已提交
36 37
  // 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 已提交
38
  val redirect = ValidIO(new Redirect)
39
  val flush = Output(Bool())
40
  val debug_rat = Vec(32, Output(UInt(PhyRegIdxWidth.W)))
41 42
}

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

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

61
class RedirectGenerator(implicit p: Parameters) extends XSModule
62
  with HasCircularQueuePtrHelper with HasFtqHelper {
L
ljw 已提交
63
  val numRedirect = exuParameters.JmpCnt + exuParameters.AluCnt
L
LinJiawei 已提交
64
  val io = IO(new Bundle() {
L
ljw 已提交
65
    val exuMispredict = Vec(numRedirect, Flipped(ValidIO(new ExuOutput)))
L
ljw 已提交
66
    val loadReplay = Flipped(ValidIO(new Redirect))
67
    val flush = Input(Bool())
L
ljw 已提交
68
    val stage1FtqRead = Vec(numRedirect + 1, new FtqRead)
L
LinJiawei 已提交
69
    val stage2FtqRead = new FtqRead
L
LinJiawei 已提交
70
    val stage2Redirect = ValidIO(new Redirect)
L
LinJiawei 已提交
71
    val stage3Redirect = ValidIO(new Redirect)
72 73
    val memPredUpdate = Output(new MemPredUpdateReq)
    val memPredFtqRead = new FtqRead // read req send form stage 2
L
LinJiawei 已提交
74 75 76 77
  })
  /*
        LoadQueue  Jump  ALU0  ALU1  ALU2  ALU3   exception    Stage1
          |         |      |    |     |     |         |
L
LinJiawei 已提交
78
          |============= reg & compare =====|         |       ========
L
LinJiawei 已提交
79 80 81 82
                            |                         |
                            |                         |
                            |                         |        Stage2
                            |                         |
L
LinJiawei 已提交
83 84 85 86 87 88 89 90
                    redirect (flush backend)          |
                    |                                 |
               === reg ===                            |       ========
                    |                                 |
                    |----- mux (exception first) -----|        Stage3
                            |
                redirect (send to frontend)
   */
L
ljw 已提交
91 92 93 94
  private class Wrapper(val n: Int) extends Bundle {
    val redirect = new Redirect
    val valid = Bool()
    val idx = UInt(log2Up(n).W)
95
  }
96 97 98 99 100 101 102 103
  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 已提交
104 105
  }

L
ljw 已提交
106 107 108 109 110
  for((ptr, redirect) <- io.stage1FtqRead.map(_.ptr).zip(
    io.exuMispredict.map(_.bits.redirect) :+ io.loadReplay.bits
  )){ ptr := redirect.ftqIdx }

  def getRedirect(exuOut: Valid[ExuOutput]): ValidIO[Redirect] = {
L
LinJiawei 已提交
111
    val redirect = Wire(Valid(new Redirect))
L
ljw 已提交
112 113
    redirect.valid := exuOut.valid && exuOut.bits.redirect.cfiUpdate.isMisPred
    redirect.bits := exuOut.bits.redirect
L
LinJiawei 已提交
114
    redirect
L
ljw 已提交
115
  }
L
LinJiawei 已提交
116

L
ljw 已提交
117
  val jumpOut = io.exuMispredict.head
118 119 120 121 122 123
  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)
124

L
LinJiawei 已提交
125
  val s1_jumpTarget = RegEnable(jumpOut.bits.redirect.cfiUpdate.target, jumpOut.valid)
126 127 128 129 130
  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 已提交
131 132

  // stage1 -> stage2
133
  io.stage2Redirect.valid := s1_redirect_valid_reg && !io.flush
L
LinJiawei 已提交
134 135 136 137 138
  io.stage2Redirect.bits := s1_redirect_bits_reg
  io.stage2Redirect.bits.cfiUpdate := DontCare
  // at stage2, we read ftq to get pc
  io.stage2FtqRead.ptr := s1_redirect_bits_reg.ftqIdx

139 140 141
  val s1_isReplay = s1_redirect_onehot(5)
  val s1_isJump = s1_redirect_onehot(0)
  val ftqRead = Mux1H(s1_redirect_onehot, io.stage1FtqRead).entry
L
ljw 已提交
142 143 144 145 146
  val cfiUpdate_pc = Cat(
    ftqRead.ftqPC.head(VAddrBits - s1_redirect_bits_reg.ftqOffset.getWidth - instOffsetBits),
    s1_redirect_bits_reg.ftqOffset,
    0.U(instOffsetBits.W)
  )
147 148
  val real_pc = GetPcByFtq(
    ftqRead.ftqPC, s1_redirect_bits_reg.ftqOffset,
L
ljw 已提交
149 150 151 152 153
    ftqRead.lastPacketPC.valid,
    ftqRead.lastPacketPC.bits
  )
  val brTarget = real_pc + SignExt(ImmUnion.B.toImm32(s1_imm12_reg), XLEN)
  val snpc = real_pc + Mux(s1_pd.isRVC, 2.U, 4.U)
154
  val target = Mux(s1_isReplay,
155
    real_pc, // repaly from itself
L
ljw 已提交
156 157
    Mux(s1_redirect_bits_reg.cfiUpdate.taken,
      Mux(s1_isJump, s1_jumpTarget, brTarget),
L
LinJiawei 已提交
158
      snpc
L
LinJiawei 已提交
159 160
    )
  )
161

162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
  // get pc from ftq
  io.memPredFtqRead.ptr := s1_redirect_bits_reg.stFtqIdx
  // valid only if redirect is caused by load violation
  // store_pc is used to update store set
  val memPredFtqRead = io.memPredFtqRead.entry
  val store_pc = GetPcByFtq(memPredFtqRead.ftqPC, RegNext(s1_redirect_bits_reg).stFtqOffset,
    memPredFtqRead.lastPacketPC.valid,
    memPredFtqRead.lastPacketPC.bits
  )

  // 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

L
ljw 已提交
182

183 184 185 186 187
  val s2_br_mask = RegEnable(ftqRead.br_mask, enable = s1_redirect_valid_reg)
  val s2_sawNotTakenBranch = RegEnable(VecInit((0 until PredictWidth).map{ i =>
      if(i == 0) false.B else Cat(ftqRead.br_mask.take(i)).orR()
    })(s1_redirect_bits_reg.ftqOffset), enable = s1_redirect_valid_reg)
  val s2_hist = RegEnable(ftqRead.hist, enable = s1_redirect_valid_reg)
L
ljw 已提交
188 189 190 191 192 193 194
  val s2_target = RegEnable(target, enable = s1_redirect_valid_reg)
  val s2_pd = RegEnable(s1_pd, enable = s1_redirect_valid_reg)
  val s2_cfiUpdata_pc = RegEnable(cfiUpdate_pc, enable = s1_redirect_valid_reg)
  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)
  val s2_ftqRead = io.stage2FtqRead.entry

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

212 213
class CtrlBlock(implicit p: Parameters) extends XSModule
  with HasCircularQueuePtrHelper with HasFtqHelper {
214 215 216 217 218 219 220 221
  val io = IO(new Bundle {
    val frontend = Flipped(new FrontendToBackendIO)
    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 已提交
222 223 224
    val roqio = new Bundle {
      // to int block
      val toCSR = new RoqCSRIO
225
      val exception = ValidIO(new ExceptionInfo)
Y
Yinan Xu 已提交
226
      // to mem block
227
      val lsq = new RoqLsqIO
Y
Yinan Xu 已提交
228
    }
229
    val csrCtrl = Input(new CustomCSRCtrlIO)
230 231 232 233 234 235 236 237
    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())
      }
    })
238 239 240 241
  })

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

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

L
LinJiawei 已提交
250
  val backendRedirect = redirectGen.io.stage2Redirect
L
LinJiawei 已提交
251
  val frontendRedirect = redirectGen.io.stage3Redirect
252
  val flush = roq.io.flushOut.valid
253
  val flushReg = RegNext(flush)
L
LinJiawei 已提交
254

L
ljw 已提交
255 256 257 258 259 260 261
  val exuRedirect = io.fromIntBlock.exuRedirect.map(x => {
    val valid = x.valid && x.bits.redirectValid
    val killedByOlder = x.bits.uop.roqIdx.needFlush(backendRedirect, flushReg)
    val delayed = Wire(Valid(new ExuOutput))
    delayed.valid := RegNext(valid && !killedByOlder, init = false.B)
    delayed.bits := RegEnable(x.bits, x.valid)
    delayed
L
LinJiawei 已提交
262
  })
L
ljw 已提交
263 264 265 266 267 268
  val loadReplay = Wire(Valid(new Redirect))
  loadReplay.valid := RegNext(io.fromLsBlock.replay.valid &&
    !io.fromLsBlock.replay.bits.roqIdx.needFlush(backendRedirect, flushReg),
    init = false.B
  )
  loadReplay.bits := RegEnable(io.fromLsBlock.replay.bits, io.fromLsBlock.replay.valid)
L
Lingrui98 已提交
269 270 271
  VecInit(io.frontend.fromFtq.ftqRead.tail.dropRight(2)) <> redirectGen.io.stage1FtqRead
  io.frontend.fromFtq.ftqRead.dropRight(1).last <> redirectGen.io.memPredFtqRead
  io.frontend.fromFtq.cfiRead <> redirectGen.io.stage2FtqRead
L
ljw 已提交
272
  redirectGen.io.exuMispredict <> exuRedirect
L
ljw 已提交
273
  redirectGen.io.loadReplay <> loadReplay
274
  redirectGen.io.flush := flushReg
275

L
LinJiawei 已提交
276
  for(i <- 0 until CommitWidth){
L
Lingrui98 已提交
277 278
    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 已提交
279
  }
L
Lingrui98 已提交
280 281 282 283 284 285 286 287
  io.frontend.toFtq.redirect <> backendRedirect
  io.frontend.toFtq.flush := flushReg
  io.frontend.toFtq.flushIdx := RegNext(roq.io.flushOut.bits.ftqIdx)
  io.frontend.toFtq.flushOffset := RegNext(roq.io.flushOut.bits.ftqOffset)
  io.frontend.toFtq.frontendRedirect <> frontendRedirect
  io.frontend.toFtq.exuWriteback <> exuRedirect

  io.frontend.fromFtq.ftqRead.last.ptr := roq.io.flushOut.bits.ftqIdx
288
  val flushPC = GetPcByFtq(
L
Lingrui98 已提交
289
    io.frontend.fromFtq.ftqRead.last.entry.ftqPC,
290
    RegEnable(roq.io.flushOut.bits.ftqOffset, roq.io.flushOut.valid),
L
Lingrui98 已提交
291 292
    io.frontend.fromFtq.ftqRead.last.entry.lastPacketPC.valid,
    io.frontend.fromFtq.ftqRead.last.entry.lastPacketPC.bits
293 294 295
  )

  val flushRedirect = Wire(Valid(new Redirect))
296
  flushRedirect.valid := flushReg
297 298 299
  flushRedirect.bits := DontCare
  flushRedirect.bits.ftqIdx := RegEnable(roq.io.flushOut.bits.ftqIdx, flush)
  flushRedirect.bits.interrupt := true.B
L
LinJiawei 已提交
300 301 302
  flushRedirect.bits.cfiUpdate.target := Mux(io.roqio.toCSR.isXRet || roq.io.exception.valid,
    io.roqio.toCSR.trapTarget,
    flushPC + 4.U // flush pipe
303
  )
L
ljw 已提交
304 305 306
  val flushRedirectReg = Wire(Valid(new Redirect))
  flushRedirectReg.valid := RegNext(flushRedirect.valid, init = false.B)
  flushRedirectReg.bits := RegEnable(flushRedirect.bits, enable = flushRedirect.valid)
L
LinJiawei 已提交
307

L
ljw 已提交
308
  io.frontend.redirect_cfiUpdate := Mux(flushRedirectReg.valid, flushRedirectReg, frontendRedirect)
Y
Yinan Xu 已提交
309

310
  decode.io.in <> io.frontend.cfVec
311
  // currently, we only update wait table when isReplay
312 313 314 315
  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
316 317
  decode.io.csrCtrl := RegNext(io.csrCtrl)

318

L
LinJiawei 已提交
319
  val jumpInst = dispatch.io.enqIQCtrl(0).bits
L
LinJiawei 已提交
320 321
  val ftqOffsetReg = Reg(UInt(log2Up(PredictWidth).W))
  ftqOffsetReg := jumpInst.cf.ftqOffset
L
Lingrui98 已提交
322
  io.frontend.fromFtq.ftqRead(0).ptr := jumpInst.cf.ftqPtr // jump
L
LinJiawei 已提交
323
  io.toIntBlock.jumpPc := GetPcByFtq(
L
Lingrui98 已提交
324 325 326
    io.frontend.fromFtq.ftqRead(0).entry.ftqPC, ftqOffsetReg,
    io.frontend.fromFtq.ftqRead(0).entry.lastPacketPC.valid,
    io.frontend.fromFtq.ftqRead(0).entry.lastPacketPC.bits
L
LinJiawei 已提交
327
  )
L
Lingrui98 已提交
328
  io.toIntBlock.jalr_target := io.frontend.fromFtq.ftqRead(0).entry.target
L
LinJiawei 已提交
329

330 331
  // pipeline between decode and dispatch
  for (i <- 0 until RenameWidth) {
L
LinJiawei 已提交
332
    PipelineConnect(decode.io.out(i), rename.io.in(i), rename.io.in(i).ready,
L
ljw 已提交
333
      flushReg || io.frontend.redirect_cfiUpdate.valid)
334
  }
335

L
LinJiawei 已提交
336
  rename.io.redirect <> backendRedirect
337
  rename.io.flush := flushReg
338 339
  rename.io.roqCommits <> roq.io.commits
  rename.io.out <> dispatch.io.fromRename
340
  rename.io.renameBypass <> dispatch.io.renameBypass
341
  rename.io.dispatchInfo <> dispatch.io.preDpInfo
342
  rename.io.csrCtrl <> RegNext(io.csrCtrl)
343

L
LinJiawei 已提交
344
  dispatch.io.redirect <> backendRedirect
345
  dispatch.io.flush := flushReg
346
  dispatch.io.enqRoq <> roq.io.enq
347
  dispatch.io.enqLsq <> io.toLsBlock.enqLsq
Y
Yinan Xu 已提交
348 349
  dispatch.io.readIntRf <> io.toIntBlock.readRf
  dispatch.io.readFpRf <> io.toFpBlock.readRf
Y
Yinan Xu 已提交
350 351
  dispatch.io.allocPregs.zipWithIndex.foreach { case (preg, i) =>
    intBusyTable.io.allocPregs(i).valid := preg.isInt
352
    fpBusyTable.io.allocPregs(i).valid := preg.isFp
Y
Yinan Xu 已提交
353 354 355
    intBusyTable.io.allocPregs(i).bits := preg.preg
    fpBusyTable.io.allocPregs(i).bits := preg.preg
  }
356
  dispatch.io.numExist <> io.fromIntBlock.numExist ++ io.fromFpBlock.numExist ++ io.fromLsBlock.numExist
Y
Yinan Xu 已提交
357
  dispatch.io.enqIQCtrl <> io.toIntBlock.enqIqCtrl ++ io.toFpBlock.enqIqCtrl ++ io.toLsBlock.enqIqCtrl
358
//  dispatch.io.enqIQData <> io.toIntBlock.enqIqData ++ io.toFpBlock.enqIqData ++ io.toLsBlock.enqIqData
359 360
  dispatch.io.csrCtrl <> io.csrCtrl
  dispatch.io.storeIssue <> io.fromLsBlock.stIn
361

L
LinJiawei 已提交
362

363 364
  fpBusyTable.io.flush := flushReg
  intBusyTable.io.flush := flushReg
Y
Yinan Xu 已提交
365
  for((wb, setPhyRegRdy) <- io.fromIntBlock.wbRegs.zip(intBusyTable.io.wbPregs)){
366
    setPhyRegRdy.valid := wb.valid && wb.bits.uop.ctrl.rfWen
Y
Yinan Xu 已提交
367 368 369 370 371 372
    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 已提交
373 374
  intBusyTable.io.read <> dispatch.io.readIntState
  fpBusyTable.io.read <> dispatch.io.readFpState
Y
Yinan Xu 已提交
375

L
LinJiawei 已提交
376
  roq.io.redirect <> backendRedirect
L
ljw 已提交
377 378 379 380 381
  val exeWbResults = VecInit(io.fromIntBlock.wbRegs ++ io.fromFpBlock.wbRegs ++ io.fromLsBlock.stOut)
  for((roq_wb, wb) <- roq.io.exeWbResults.zip(exeWbResults)) {
    roq_wb.valid := RegNext(wb.valid && !wb.bits.uop.roqIdx.needFlush(backendRedirect, flushReg))
    roq_wb.bits := RegNext(wb.bits)
  }
L
LinJiawei 已提交
382 383 384

  // TODO: is 'backendRedirect' necesscary?
  io.toIntBlock.redirect <> backendRedirect
385
  io.toIntBlock.flush <> flushReg
386
  io.toIntBlock.debug_rat <> rename.io.debug_int_rat
L
LinJiawei 已提交
387
  io.toFpBlock.redirect <> backendRedirect
388
  io.toFpBlock.flush <> flushReg
389
  io.toFpBlock.debug_rat <> rename.io.debug_fp_rat
L
LinJiawei 已提交
390
  io.toLsBlock.redirect <> backendRedirect
391
  io.toLsBlock.flush <> flushReg
392

393 394 395
  dispatch.io.readPortIndex.intIndex <> io.toIntBlock.readPortIndex
  dispatch.io.readPortIndex.fpIndex <> io.toFpBlock.readPortIndex

Y
Yinan Xu 已提交
396 397
  // roq to int block
  io.roqio.toCSR <> roq.io.csr
398
  io.roqio.toCSR.perfinfo.retiredInstr <> RegNext(roq.io.csr.perfinfo.retiredInstr)
399
  io.roqio.exception := roq.io.exception
400
  io.roqio.exception.bits.uop.cf.pc := flushPC
Y
Yinan Xu 已提交
401
  // roq to mem block
402
  io.roqio.lsq <> roq.io.lsq
403 404 405 406 407

  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)
408
}