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