xref: /XiangShan/src/main/scala/xiangshan/backend/datapath/DataPath.scala (revision 730cfbc0bf03569aa07dd82ba3fb41eb7413e13c)
1package xiangshan.backend.datapath
2
3import chipsalliance.rocketchip.config.Parameters
4import chisel3._
5import chisel3.util._
6import difftest.{DifftestArchFpRegState, DifftestArchIntRegState, DifftestArchVecRegState}
7import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp}
8import utility._
9import xiangshan._
10import xiangshan.backend.BackendParams
11import xiangshan.backend.datapath.DataConfig._
12import xiangshan.backend.datapath.RdConfig._
13import xiangshan.backend.issue.{ImmExtractor, IntScheduler, MemScheduler, VfScheduler}
14import xiangshan.backend.Bundles._
15import xiangshan.backend.regfile._
16
17class RFArbiterBundle(addrWidth: Int)(implicit p: Parameters) extends XSBundle {
18  val addr = UInt(addrWidth.W)
19}
20
21class RFReadArbiterIO(inPortSize: Int, outPortSize: Int, pregWidth: Int)(implicit p: Parameters) extends XSBundle {
22  val in = Vec(inPortSize, Flipped(DecoupledIO(new RFArbiterBundle(pregWidth))))
23  val out = Vec(outPortSize, Valid(new RFArbiterBundle(pregWidth)))
24  val flush = Flipped(ValidIO(new Redirect))
25}
26
27class RFReadArbiter(isInt: Boolean)(implicit p: Parameters) extends XSModule {
28  val allExuParams = backendParams.allExuParams
29
30  val portConfigs = allExuParams.map(_.rfrPortConfigs.flatten).flatten.filter{
31    rfrPortConfigs =>
32      if(isInt){
33        rfrPortConfigs.isInstanceOf[IntRD]
34      }
35      else{
36        rfrPortConfigs.isInstanceOf[VfRD]
37      }
38  }
39
40  val pregParams = if(isInt) backendParams.intPregParams else backendParams.vfPregParams
41
42  val io = IO(new RFReadArbiterIO(portConfigs.size, backendParams.numRfRead, pregParams.addrWidth))
43  // inGroup[port -> Bundle]
44  val inGroup: Map[Int, IndexedSeq[(DecoupledIO[RFArbiterBundle], RdConfig)]] = io.in.zip(portConfigs).groupBy{ case(port, config) => config.port}
45  // sort by priority
46  val inGroupSorted: Map[Int, IndexedSeq[(DecoupledIO[RFArbiterBundle], RdConfig)]] = inGroup.map{
47    case(key, value) => (key -> value.sortBy{ case(port, config) => config.priority})
48  }
49
50  private val arbiters: Seq[Option[Arbiter[RFArbiterBundle]]] = Seq.tabulate(backendParams.numRfRead) { x => {
51    if (inGroupSorted.contains(x)) {
52      Some(Module(new Arbiter(new RFArbiterBundle(pregParams.addrWidth), inGroupSorted(x).length)))
53    } else {
54      None
55    }
56  }}
57
58  arbiters.zipWithIndex.foreach { case (arb, i) =>
59    if (arb.nonEmpty) {
60      arb.get.io.in.zip(inGroupSorted(i).map(_._1)).foreach { case (arbIn, addrIn) =>
61        arbIn <> addrIn
62      }
63    }
64  }
65
66  io.out.zip(arbiters).foreach { case (addrOut, arb) =>
67    if (arb.nonEmpty) {
68      val arbOut = arb.get.io.out
69      arbOut.ready := true.B
70      addrOut.valid := arbOut.valid
71      addrOut.bits := arbOut.bits
72    } else {
73      addrOut := 0.U.asTypeOf(addrOut)
74    }
75  }
76}
77
78class DataPath(params: BackendParams)(implicit p: Parameters) extends LazyModule {
79  private implicit val dpParams: BackendParams = params
80  lazy val module = new DataPathImp(this)
81}
82
83class DataPathImp(override val wrapper: DataPath)(implicit p: Parameters, params: BackendParams)
84  extends LazyModuleImp(wrapper) with HasXSParameter {
85
86  val io = IO(new DataPathIO())
87
88  private val (fromIntIQ, toIntIQ, toIntExu) = (io.fromIntIQ, io.toIntIQ, io.toIntExu)
89  private val (fromMemIQ, toMemIQ, toMemExu) = (io.fromMemIQ, io.toMemIQ, io.toMemExu)
90  private val (fromVfIQ , toVfIQ , toVfExu ) = (io.fromVfIQ , io.toVfIQ , io.toFpExu)
91
92  println(s"[DataPath] IntIQ(${fromIntIQ.size}), MemIQ(${fromMemIQ.size})")
93  println(s"[DataPath] IntExu(${fromIntIQ.map(_.size).sum}), MemExu(${fromMemIQ.map(_.size).sum})")
94
95  // just refences for convience
96  private val fromIQ = fromIntIQ ++ fromVfIQ ++ fromMemIQ
97
98  private val toIQs = toIntIQ ++ toVfIQ ++ toMemIQ
99
100  private val toExu = toIntExu ++ toVfExu ++ toMemExu
101
102  private val intRFReadArbiter = Module(new RFReadArbiter(true))
103  private val vfRFReadArbiter = Module(new RFReadArbiter(false))
104
105  private val issuePortsIn = fromIQ.flatten
106  private val intBlocks = fromIQ.map{ case iq => Wire(Vec(iq.size, Bool())) }
107  private val intBlocksSeq = intBlocks.flatten
108  private val vfBlocks = fromIQ.map { case iq => Wire(Vec(iq.size, Bool())) }
109  private val vfBlocksSeq = vfBlocks.flatten
110
111  val intReadPortInSize = issuePortsIn.map(issuePortIn => issuePortIn.bits.getIntRfReadBundle.size).scan(0)(_ + _)
112  issuePortsIn.zipWithIndex.foreach{
113    case (issuePortIn, idx) =>
114      val readPortIn = issuePortIn.bits.getIntRfReadBundle
115      val l = intReadPortInSize(idx)
116      val r = intReadPortInSize(idx + 1)
117      val arbiterIn = intRFReadArbiter.io.in.slice(l, r)
118      arbiterIn.zip(readPortIn).foreach{
119        case(sink, source) =>
120          sink.bits.addr := source.addr
121          sink.valid := issuePortIn.valid && SrcType.isXp(source.srcType)
122      }
123      if(r > l){
124        intBlocksSeq(idx) := !arbiterIn.zip(readPortIn).map {
125          case (sink, source) => Mux(SrcType.isXp(source.srcType), sink.ready, true.B)
126        }.reduce(_ & _)
127      }
128      else{
129        intBlocksSeq(idx) := false.B
130      }
131  }
132  intRFReadArbiter.io.flush := io.flush
133
134  val vfReadPortInSize = issuePortsIn.map(issuePortIn => issuePortIn.bits.getFpRfReadBundle.size).scan(0)(_ + _)
135  issuePortsIn.zipWithIndex.foreach {
136    case (issuePortIn, idx) =>
137      val readPortIn = issuePortIn.bits.getFpRfReadBundle
138      val l = vfReadPortInSize(idx)
139      val r = vfReadPortInSize(idx + 1)
140      val arbiterIn = vfRFReadArbiter.io.in.slice(l, r)
141      arbiterIn.zip(readPortIn).foreach {
142        case (sink, source) =>
143          sink.bits.addr := source.addr
144          sink.valid := issuePortIn.valid && SrcType.isVfp(source.srcType)
145      }
146      if (r > l) {
147        vfBlocksSeq(idx) := !arbiterIn.zip(readPortIn).map {
148          case (sink, source) => Mux(SrcType.isVfp(source.srcType), sink.ready, true.B)
149        }.reduce(_ & _)
150      }
151      else {
152        vfBlocksSeq(idx) := false.B
153      }
154  }
155  vfRFReadArbiter.io.flush := io.flush
156
157  private val intSchdParams = params.schdParams(IntScheduler())
158  private val vfSchdParams = params.schdParams(VfScheduler())
159  private val memSchdParams = params.schdParams(MemScheduler())
160
161  private val numIntRfReadByExu = intSchdParams.numIntRfReadByExu + memSchdParams.numIntRfReadByExu
162  private val numVfRfReadByExu = vfSchdParams.numVfRfReadByExu + memSchdParams.numVfRfReadByExu
163  // Todo: limit read port
164  private val numIntR = numIntRfReadByExu
165  private val numVfR = numVfRfReadByExu
166  println(s"[DataPath] RegFile read req needed by Exu: Int(${numIntRfReadByExu}), Vf(${numVfRfReadByExu})")
167  println(s"[DataPath] RegFile read port: Int(${numIntR}), Vf(${numVfR})")
168
169  private val schdParams = params.allSchdParams
170
171  private val intRfRaddr = Wire(Vec(params.numRfRead, UInt(intSchdParams.pregIdxWidth.W)))
172  private val intRfRdata = Wire(Vec(params.numRfRead, UInt(intSchdParams.rfDataWidth.W)))
173  private val intRfWen = Wire(Vec(io.fromIntWb.length, Bool()))
174  private val intRfWaddr = Wire(Vec(io.fromIntWb.length, UInt(intSchdParams.pregIdxWidth.W)))
175  private val intRfWdata = Wire(Vec(io.fromIntWb.length, UInt(intSchdParams.rfDataWidth.W)))
176
177  private val vfRfSplitNum = VLEN / XLEN
178  private val vfRfRaddr = Wire(Vec(params.numRfRead, UInt(vfSchdParams.pregIdxWidth.W)))
179  private val vfRfRdata = Wire(Vec(params.numRfRead, UInt(vfSchdParams.rfDataWidth.W)))
180  private val vfRfWen = Wire(Vec(vfRfSplitNum, Vec(io.fromVfWb.length, Bool())))
181  private val vfRfWaddr = Wire(Vec(io.fromVfWb.length, UInt(vfSchdParams.pregIdxWidth.W)))
182  private val vfRfWdata = Wire(Vec(io.fromVfWb.length, UInt(vfSchdParams.rfDataWidth.W)))
183
184  private val intDebugRead: Option[(Vec[UInt], Vec[UInt])] =
185    if (env.AlwaysBasicDiff || env.EnableDifftest) {
186      Some(Wire(Vec(32, UInt(intSchdParams.pregIdxWidth.W))), Wire(Vec(32, UInt(XLEN.W))))
187    } else { None }
188  private val vfDebugRead: Option[(Vec[UInt], Vec[UInt])] =
189    if (env.AlwaysBasicDiff || env.EnableDifftest) {
190      Some(Wire(Vec(32 + 32, UInt(vfSchdParams.pregIdxWidth.W))), Wire(Vec(32 + 32, UInt(VLEN.W))))
191    } else { None }
192
193  private val fpDebugReadData: Option[Vec[UInt]] =
194    if (env.AlwaysBasicDiff || env.EnableDifftest) {
195      Some(Wire(Vec(32, UInt(XLEN.W))))
196    } else { None }
197  private val vecDebugReadData: Option[Vec[UInt]] =
198    if (env.AlwaysBasicDiff || env.EnableDifftest) {
199      Some(Wire(Vec(64, UInt(64.W)))) // v0 = Cat(Vec(1), Vec(0))
200    } else { None }
201
202  fpDebugReadData.foreach(_ := vfDebugRead
203    .get._2
204    .slice(0, 32)
205    .map(_(63, 0))
206  ) // fp only used [63, 0]
207  vecDebugReadData.foreach(_ := vfDebugRead
208    .get._2
209    .slice(32, 64)
210    .map(x => Seq(x(63, 0), x(127, 64))).flatten
211  )
212
213  IntRegFile("IntRegFile", intSchdParams.numPregs, intRfRaddr, intRfRdata, intRfWen, intRfWaddr, intRfWdata,
214    debugReadAddr = intDebugRead.map(_._1),
215    debugReadData = intDebugRead.map(_._2))
216  VfRegFile("VfRegFile", vfSchdParams.numPregs, vfRfSplitNum, vfRfRaddr, vfRfRdata, vfRfWen, vfRfWaddr, vfRfWdata,
217    debugReadAddr = vfDebugRead.map(_._1),
218    debugReadData = vfDebugRead.map(_._2))
219
220  intRfWaddr := io.fromIntWb.map(_.addr)
221  intRfWdata := io.fromIntWb.map(_.data)
222  intRfWen := io.fromIntWb.map(_.wen)
223
224  intRFReadArbiter.io.out.map(_.bits.addr).zip(intRfRaddr).foreach{ case(source, sink) => sink := source }
225
226  vfRfWaddr := io.fromVfWb.map(_.addr)
227  vfRfWdata := io.fromVfWb.map(_.data)
228  vfRfWen.foreach(_.zip(io.fromVfWb.map(_.wen)).foreach { case (wenSink, wenSource) => wenSink := wenSource } )// Todo: support fp multi-write
229
230  vfRFReadArbiter.io.out.map(_.bits.addr).zip(vfRfRaddr).foreach{ case(source, sink) => sink := source }
231
232  // fromIQFire(i): flattened the i-th deq port fired
233  private val fromIQFire: IndexedSeq[Bool] = fromIQ.flatten.map(_.fire)
234
235  intDebugRead.foreach { case (addr, _) =>
236    addr := io.debugIntRat
237  }
238
239  vfDebugRead.foreach { case (addr, _) =>
240    addr := io.debugFpRat ++ io.debugVecRat
241  }
242  println(s"[DataPath] " +
243    s"has intDebugRead: ${intDebugRead.nonEmpty}, " +
244    s"has vfDebugRead: ${vfDebugRead.nonEmpty}")
245
246  val s1_addrOHs = Reg(MixedVec(
247    fromIQ.map(x => MixedVec(x.map(_.bits.addrOH.cloneType)))
248  ))
249  val s1_toExuValid: MixedVec[MixedVec[Bool]] = Reg(MixedVec(
250    toExu.map(x => MixedVec(x.map(_.valid.cloneType)))
251  ))
252  val s1_toExuData: MixedVec[MixedVec[ExuInput]] = Reg(MixedVec(toExu.map(x => MixedVec(x.map(_.bits.cloneType)))))
253  val s1_toExuReady = Wire(MixedVec(toExu.map(x => MixedVec(x.map(_.ready.cloneType))))) // Todo
254  val s1_srcType: MixedVec[MixedVec[Vec[UInt]]] = MixedVecInit(fromIQ.map(x => MixedVecInit(x.map(xx => RegEnable(xx.bits.srcType, xx.fire)))))
255
256  val s1_intPregRData: MixedVec[MixedVec[Vec[UInt]]] = Wire(MixedVec(toExu.map(x => MixedVec(x.map(_.bits.src.cloneType)))))
257  val s1_vfPregRData: MixedVec[MixedVec[Vec[UInt]]] = Wire(MixedVec(toExu.map(x => MixedVec(x.map(_.bits.src.cloneType)))))
258
259  val rfrPortConfigs = schdParams.map(_.issueBlockParams).flatten.map(_.exuBlockParams.map(_.rfrPortConfigs))
260
261  println(s"[DataPath] s1_intPregRData.flatten.flatten.size: ${s1_intPregRData.flatten.flatten.size}, intRfRdata.size: ${intRfRdata.size}")
262  s1_intPregRData.foreach(_.foreach(_.foreach(_ := 0.U)))
263  s1_intPregRData.zip(rfrPortConfigs).foreach { case (iqRdata, iqCfg) =>
264      iqRdata.zip(iqCfg).foreach { case (iuRdata, iuCfg) =>
265        val realIuCfg = iuCfg.map(x => if(x.size > 1) x.filter(_.isInstanceOf[IntRD]) else x).flatten
266        assert(iuRdata.size == realIuCfg.size, "iuRdata.size != realIuCfg.size")
267        iuRdata.zip(realIuCfg)
268          .filter { case (_, rfrPortConfig) => rfrPortConfig.isInstanceOf[IntRD] }
269          .foreach { case (sink, cfg) => sink := intRfRdata(cfg.port) }
270      }
271  }
272
273  println(s"[DataPath] s1_vfPregRData.flatten.flatten.size: ${s1_vfPregRData.flatten.flatten.size}, vfRfRdata.size: ${vfRfRdata.size}")
274  s1_vfPregRData.foreach(_.foreach(_.foreach(_ := 0.U)))
275  s1_vfPregRData.zip(rfrPortConfigs).foreach{ case(iqRdata, iqCfg) =>
276      iqRdata.zip(iqCfg).foreach{ case(iuRdata, iuCfg) =>
277        val realIuCfg = iuCfg.map(x => if(x.size > 1) x.filter(_.isInstanceOf[VfRD]) else x).flatten
278        assert(iuRdata.size == realIuCfg.size, "iuRdata.size != realIuCfg.size")
279        iuRdata.zip(realIuCfg)
280          .filter { case (_, rfrPortConfig) => rfrPortConfig.isInstanceOf[VfRD] }
281          .foreach { case (sink, cfg) => sink := vfRfRdata(cfg.port) }
282      }
283  }
284
285  //  var intRfRdataIdx = 0
286//  var vfRfRdataIdx = 0
287//  for (iqIdx <- toExu.indices) {
288//    for (exuIdx <- toExu(iqIdx).indices) {
289//      for (srcIdx <- toExu(iqIdx)(exuIdx).bits.src.indices) {
290//        val readDataCfgSet = toExu(iqIdx)(exuIdx).bits.params.getSrcDataType(srcIdx)
291//        // need read int reg
292//        if (readDataCfgSet.intersect(IntRegSrcDataSet).nonEmpty) {
293//          println(s"[DataPath] (iqIdx, exuIdx, srcIdx): ($iqIdx, $exuIdx, $srcIdx)")
294//          s1_intPregRData(iqIdx)(exuIdx)(srcIdx) := intRfRdata(intRfRdataIdx)
295//        } else {
296//          // better for debug, should never assigned to other bundles
297//          s1_intPregRData(iqIdx)(exuIdx)(srcIdx) := "hdead_beef_dead_beef".U
298//        }
299//        // need read vf reg
300//        if (readDataCfgSet.intersect(VfRegSrcDataSet).nonEmpty) {
301//          s1_vfPregRData(iqIdx)(exuIdx)(srcIdx) := vfRfRdata(vfRfRdataIdx)
302//          vfRfRdataIdx += 1
303//        } else {
304//          // better for debug, should never assigned to other bundles
305//          s1_vfPregRData(iqIdx)(exuIdx)(srcIdx) := "hdead_beef_dead_beef_dead_beef_dead_beef".U
306//        }
307//      }
308//    }
309//  }
310//
311//  println(s"[DataPath] assigned RegFile Rdata: int(${intRfRdataIdx}), vf(${vfRfRdataIdx})")
312
313  for (i <- fromIQ.indices) {
314    for (j <- fromIQ(i).indices) {
315      // IQ(s0) --[Ctrl]--> s1Reg ---------- begin
316      // refs
317      val s1_valid = s1_toExuValid(i)(j)
318      val s1_ready = s1_toExuReady(i)(j)
319      val s1_data = s1_toExuData(i)(j)
320      val s1_addrOH = s1_addrOHs(i)(j)
321      val s0 = fromIQ(i)(j) // s0
322      val block = intBlocks(i)(j) || vfBlocks(i)(j)
323      val s1_flush = s0.bits.common.robIdx.needFlush(Seq(io.flush, RegNextWithEnable(io.flush)))
324      when (s0.fire && !s1_flush && !block) {
325        s1_valid := s0.valid
326        s1_data.fromIssueBundle(s0.bits) // no src data here
327        s1_addrOH := s0.bits.addrOH
328      }.otherwise {
329        s1_valid := false.B
330      }
331
332      s0.ready := (s1_ready || !s1_valid) && !block
333      // IQ(s0) --[Ctrl]--> s1Reg ---------- end
334
335      // IQ(s0) --[Data]--> s1Reg ---------- begin
336      // imm extract
337      when (s0.fire && !s1_flush && !block) {
338        if (s1_data.params.immType.nonEmpty && s1_data.src.size > 1) {
339          // rs1 is always int reg, rs2 may be imm
340          when(SrcType.isImm(s0.bits.srcType(1))) {
341            s1_data.src(1) := ImmExtractor(
342              s0.bits.common.imm,
343              s0.bits.immType,
344              s1_data.DataBits,
345              s1_data.params.immType.map(_.litValue)
346            )
347          }
348        }
349        if (s1_data.params.hasJmpFu) {
350          when(SrcType.isPc(s0.bits.srcType(0))) {
351            s1_data.src(0) := SignExt(s0.bits.jmp.get.pc, XLEN)
352          }
353        }
354      }
355      // IQ(s0) --[Data]--> s1Reg ---------- end
356    }
357  }
358
359  private val intFromIQFire = fromIQ.map(_.map(_.fire))
360  private val intToExuFire = toExu.map(_.map(_.fire))
361  toIQs.zipWithIndex.foreach {
362    case(toIQ, iqIdx) =>
363      toIQ.zipWithIndex.foreach {
364        case (toIU, iuIdx) =>
365          // IU: issue unit
366          val og0resp = toIU.og0resp
367          og0resp.valid := fromIQ(iqIdx)(iuIdx).valid
368          og0resp.bits.respType := Mux(intFromIQFire(iqIdx)(iuIdx), RSFeedbackType.rfArbitSuccess, RSFeedbackType.rfArbitFail)
369          og0resp.bits.success := false.B
370          og0resp.bits.addrOH := fromIQ(iqIdx)(iuIdx).bits.addrOH
371
372          val og1resp = toIU.og1resp
373          og1resp.valid := s1_toExuValid(iqIdx)(iuIdx)
374          og1resp.bits.respType := Mux(intToExuFire(iqIdx)(iuIdx), RSFeedbackType.fuIdle, RSFeedbackType.fuBusy)
375          og1resp.bits.success := false.B
376          og1resp.bits.addrOH := s1_addrOHs(iqIdx)(iuIdx)
377      }
378  }
379  for (i <- toExu.indices) {
380    for (j <- toExu(i).indices) {
381      // s1Reg --[Ctrl]--> exu(s1) ---------- begin
382      // refs
383      val sinkData = toExu(i)(j).bits
384      // assign
385      toExu(i)(j).valid := s1_toExuValid(i)(j)
386      s1_toExuReady(i)(j) := toExu(i)(j).ready
387      sinkData := s1_toExuData(i)(j)
388      // s1Reg --[Ctrl]--> exu(s1) ---------- end
389
390      // s1Reg --[Data]--> exu(s1) ---------- begin
391      // data source1: preg read data
392      for (k <- sinkData.src.indices) {
393        val srcDataTypeSet: Set[DataConfig] = sinkData.params.getSrcDataType(k)
394
395        val readRfMap: Seq[(Bool, UInt)] = (Seq(None) :+
396          (if (s1_intPregRData(i)(j).isDefinedAt(k) && srcDataTypeSet.intersect(IntRegSrcDataSet).nonEmpty)
397            Some(SrcType.isXp(s1_srcType(i)(j)(k)) -> s1_intPregRData(i)(j)(k))
398          else None) :+
399          (if (s1_vfPregRData(i)(j).isDefinedAt(k) && srcDataTypeSet.intersect(VfRegSrcDataSet).nonEmpty)
400            Some(SrcType.isVfp(s1_srcType(i)(j)(k))-> s1_vfPregRData(i)(j)(k))
401          else None)
402        ).filter(_.nonEmpty).map(_.get)
403        if (readRfMap.nonEmpty)
404          sinkData.src(k) := Mux1H(readRfMap)
405      }
406
407      // data source2: extracted imm and pc saved in s1Reg
408      if (sinkData.params.immType.nonEmpty && sinkData.src.size > 1) {
409        when(SrcType.isImm(s1_srcType(i)(j)(1))) {
410          sinkData.src(1) := s1_toExuData(i)(j).src(1)
411        }
412      }
413      if (sinkData.params.hasJmpFu) {
414        when(SrcType.isPc(s1_srcType(i)(j)(0))) {
415          sinkData.src(0) := s1_toExuData(i)(j).src(0)
416        }
417      }
418      // s1Reg --[Data]--> exu(s1) ---------- end
419    }
420  }
421
422  if (env.AlwaysBasicDiff || env.EnableDifftest) {
423    val delayedCnt = 2
424    val difftestArchIntRegState = Module(new DifftestArchIntRegState)
425    difftestArchIntRegState.io.clock := clock
426    difftestArchIntRegState.io.coreid := io.hartId
427    difftestArchIntRegState.io.gpr := DelayN(intDebugRead.get._2, delayedCnt)
428
429    val difftestArchFpRegState = Module(new DifftestArchFpRegState)
430    difftestArchFpRegState.io.clock := clock
431    difftestArchFpRegState.io.coreid := io.hartId
432    difftestArchFpRegState.io.fpr := DelayN(fpDebugReadData.get, delayedCnt)
433
434    val difftestArchVecRegState = Module(new DifftestArchVecRegState)
435    difftestArchVecRegState.io.clock := clock
436    difftestArchVecRegState.io.coreid := io.hartId
437    difftestArchVecRegState.io.vpr := DelayN(vecDebugReadData.get, delayedCnt)
438  }
439}
440
441class DataPathIO()(implicit p: Parameters, params: BackendParams) extends XSBundle {
442  // params
443  private val intSchdParams = params.schdParams(IntScheduler())
444  private val vfSchdParams = params.schdParams(VfScheduler())
445  private val memSchdParams = params.schdParams(MemScheduler())
446  // bundles
447  val hartId = Input(UInt(8.W))
448
449  val flush: ValidIO[Redirect] = Flipped(ValidIO(new Redirect))
450
451  val fromIntIQ: MixedVec[MixedVec[DecoupledIO[IssueQueueIssueBundle]]] =
452    Flipped(MixedVec(intSchdParams.issueBlockParams.map(_.genIssueDecoupledBundle)))
453
454  val fromMemIQ: MixedVec[MixedVec[DecoupledIO[IssueQueueIssueBundle]]] =
455    Flipped(MixedVec(memSchdParams.issueBlockParams.map(_.genIssueDecoupledBundle)))
456
457  val fromVfIQ = Flipped(MixedVec(vfSchdParams.issueBlockParams.map(_.genIssueDecoupledBundle)))
458
459  val toIntIQ = MixedVec(intSchdParams.issueBlockParams.map(_.genOGRespBundle))
460
461  val toMemIQ = MixedVec(memSchdParams.issueBlockParams.map(_.genOGRespBundle))
462
463  val toVfIQ = MixedVec(vfSchdParams.issueBlockParams.map(_.genOGRespBundle))
464
465  val toIntExu: MixedVec[MixedVec[DecoupledIO[ExuInput]]] = intSchdParams.genExuInputBundle
466
467  val toFpExu: MixedVec[MixedVec[DecoupledIO[ExuInput]]] = MixedVec(vfSchdParams.genExuInputBundle)
468
469  val toMemExu: MixedVec[MixedVec[DecoupledIO[ExuInput]]] = memSchdParams.genExuInputBundle
470
471  val fromIntWb: MixedVec[RfWritePortWithConfig] = MixedVec(params.genIntWriteBackBundle)
472
473  val fromVfWb: MixedVec[RfWritePortWithConfig] = MixedVec(params.genVfWriteBackBundle)
474
475  val debugIntRat = Input(Vec(32, UInt(intSchdParams.pregIdxWidth.W)))
476  val debugFpRat = Input(Vec(32, UInt(vfSchdParams.pregIdxWidth.W)))
477  val debugVecRat = Input(Vec(32, UInt(vfSchdParams.pregIdxWidth.W)))
478}
479