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