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 213 fpDebugReadData.foreach(_ := vfDebugRead 214 .get._2 215 .slice(0, 32) 216 .map(_(63, 0)) 217 ) // fp only used [63, 0] 218 vecDebugReadData.foreach(_ := vfDebugRead 219 .get._2 220 .slice(32, 64) 221 .map(x => Seq(x(63, 0), x(127, 64))).flatten 222 ) 223 224 io.debugVconfig := vfDebugRead.get._2(64)(63, 0) 225 226 IntRegFile("IntRegFile", intSchdParams.numPregs, intRfRaddr, intRfRdata, intRfWen, intRfWaddr, intRfWdata, 227 debugReadAddr = intDebugRead.map(_._1), 228 debugReadData = intDebugRead.map(_._2)) 229 VfRegFile("VfRegFile", vfSchdParams.numPregs, vfRfSplitNum, vfRfRaddr, vfRfRdata, vfRfWen, vfRfWaddr, vfRfWdata, 230 debugReadAddr = vfDebugRead.map(_._1), 231 debugReadData = vfDebugRead.map(_._2)) 232 233 intRfWaddr := io.fromIntWb.map(_.addr) 234 intRfWdata := io.fromIntWb.map(_.data) 235 intRfWen := io.fromIntWb.map(_.wen) 236 237 intRFReadArbiter.io.out.map(_.bits.addr).zip(intRfRaddr).foreach{ case(source, sink) => sink := source } 238 239 vfRfWaddr := io.fromVfWb.map(_.addr) 240 vfRfWdata := io.fromVfWb.map(_.data) 241 vfRfWen.foreach(_.zip(io.fromVfWb.map(_.wen)).foreach { case (wenSink, wenSource) => wenSink := wenSource } )// Todo: support fp multi-write 242 243 vfRFReadArbiter.io.out.map(_.bits.addr).zip(vfRfRaddr).foreach{ case(source, sink) => sink := source } 244 vfRfRaddr(VCONFIG_PORT) := io.vconfigReadPort.addr 245 io.vconfigReadPort.data := vfRfRdata(VCONFIG_PORT) 246 247 intDebugRead.foreach { case (addr, _) => 248 addr := io.debugIntRat 249 } 250 251 vfDebugRead.foreach { case (addr, _) => 252 addr := io.debugFpRat ++ io.debugVecRat :+ io.debugVconfigRat 253 } 254 println(s"[DataPath] " + 255 s"has intDebugRead: ${intDebugRead.nonEmpty}, " + 256 s"has vfDebugRead: ${vfDebugRead.nonEmpty}") 257 258 val s1_addrOHs = Reg(MixedVec( 259 fromIQ.map(x => MixedVec(x.map(_.bits.addrOH.cloneType))) 260 )) 261 val s1_toExuValid: MixedVec[MixedVec[Bool]] = Reg(MixedVec( 262 toExu.map(x => MixedVec(x.map(_.valid.cloneType))) 263 )) 264 val s1_toExuData: MixedVec[MixedVec[ExuInput]] = Reg(MixedVec(toExu.map(x => MixedVec(x.map(_.bits.cloneType))))) 265 val s1_toExuReady = Wire(MixedVec(toExu.map(x => MixedVec(x.map(_.ready.cloneType))))) // Todo 266 val s1_srcType: MixedVec[MixedVec[Vec[UInt]]] = MixedVecInit(fromIQ.map(x => MixedVecInit(x.map(xx => RegEnable(xx.bits.srcType, xx.fire))))) 267 268 val s1_intPregRData: MixedVec[MixedVec[Vec[UInt]]] = Wire(MixedVec(toExu.map(x => MixedVec(x.map(_.bits.src.cloneType))))) 269 val s1_vfPregRData: MixedVec[MixedVec[Vec[UInt]]] = Wire(MixedVec(toExu.map(x => MixedVec(x.map(_.bits.src.cloneType))))) 270 271 val rfrPortConfigs = schdParams.map(_.issueBlockParams).flatten.map(_.exuBlockParams.map(_.rfrPortConfigs)) 272 273 println(s"[DataPath] s1_intPregRData.flatten.flatten.size: ${s1_intPregRData.flatten.flatten.size}, intRfRdata.size: ${intRfRdata.size}") 274 s1_intPregRData.foreach(_.foreach(_.foreach(_ := 0.U))) 275 s1_intPregRData.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[IntRD]) else x).flatten 278 assert(iuRdata.size == realIuCfg.size, "iuRdata.size != realIuCfg.size") 279 iuRdata.zip(realIuCfg) 280 .filter { case (_, rfrPortConfig) => rfrPortConfig.isInstanceOf[IntRD] } 281 .foreach { case (sink, cfg) => sink := intRfRdata(cfg.port) } 282 } 283 } 284 285 println(s"[DataPath] s1_vfPregRData.flatten.flatten.size: ${s1_vfPregRData.flatten.flatten.size}, vfRfRdata.size: ${vfRfRdata.size}") 286 s1_vfPregRData.foreach(_.foreach(_.foreach(_ := 0.U))) 287 s1_vfPregRData.zip(rfrPortConfigs).foreach{ case(iqRdata, iqCfg) => 288 iqRdata.zip(iqCfg).foreach{ case(iuRdata, iuCfg) => 289 val realIuCfg = iuCfg.map(x => if(x.size > 1) x.filter(_.isInstanceOf[VfRD]) else x).flatten 290 assert(iuRdata.size == realIuCfg.size, "iuRdata.size != realIuCfg.size") 291 iuRdata.zip(realIuCfg) 292 .filter { case (_, rfrPortConfig) => rfrPortConfig.isInstanceOf[VfRD] } 293 .foreach { case (sink, cfg) => sink := vfRfRdata(cfg.port) } 294 } 295 } 296 297 // var intRfRdataIdx = 0 298// var vfRfRdataIdx = 0 299// for (iqIdx <- toExu.indices) { 300// for (exuIdx <- toExu(iqIdx).indices) { 301// for (srcIdx <- toExu(iqIdx)(exuIdx).bits.src.indices) { 302// val readDataCfgSet = toExu(iqIdx)(exuIdx).bits.params.getSrcDataType(srcIdx) 303// // need read int reg 304// if (readDataCfgSet.intersect(IntRegSrcDataSet).nonEmpty) { 305// println(s"[DataPath] (iqIdx, exuIdx, srcIdx): ($iqIdx, $exuIdx, $srcIdx)") 306// s1_intPregRData(iqIdx)(exuIdx)(srcIdx) := intRfRdata(intRfRdataIdx) 307// } else { 308// // better for debug, should never assigned to other bundles 309// s1_intPregRData(iqIdx)(exuIdx)(srcIdx) := "hdead_beef_dead_beef".U 310// } 311// // need read vf reg 312// if (readDataCfgSet.intersect(VfRegSrcDataSet).nonEmpty) { 313// s1_vfPregRData(iqIdx)(exuIdx)(srcIdx) := vfRfRdata(vfRfRdataIdx) 314// vfRfRdataIdx += 1 315// } else { 316// // better for debug, should never assigned to other bundles 317// s1_vfPregRData(iqIdx)(exuIdx)(srcIdx) := "hdead_beef_dead_beef_dead_beef_dead_beef".U 318// } 319// } 320// } 321// } 322// 323// println(s"[DataPath] assigned RegFile Rdata: int(${intRfRdataIdx}), vf(${vfRfRdataIdx})") 324 325 for (i <- fromIQ.indices) { 326 for (j <- fromIQ(i).indices) { 327 // IQ(s0) --[Ctrl]--> s1Reg ---------- begin 328 // refs 329 val s1_valid = s1_toExuValid(i)(j) 330 val s1_ready = s1_toExuReady(i)(j) 331 val s1_data = s1_toExuData(i)(j) 332 val s1_addrOH = s1_addrOHs(i)(j) 333 val s0 = fromIQ(i)(j) // s0 334 val block = intBlocks(i)(j) || vfBlocks(i)(j) 335 val s1_flush = s0.bits.common.robIdx.needFlush(Seq(io.flush, RegNextWithEnable(io.flush))) 336 when (s0.fire && !s1_flush && !block) { 337 s1_valid := s0.valid 338 s1_data.fromIssueBundle(s0.bits) // no src data here 339 s1_addrOH := s0.bits.addrOH 340 }.otherwise { 341 s1_valid := false.B 342 } 343 344 s0.ready := (s1_ready || !s1_valid) && !block 345 // IQ(s0) --[Ctrl]--> s1Reg ---------- end 346 347 // IQ(s0) --[Data]--> s1Reg ---------- begin 348 // imm extract 349 when (s0.fire && !s1_flush && !block) { 350 if (s1_data.params.immType.nonEmpty && s1_data.src.size > 1) { 351 // rs1 is always int reg, rs2 may be imm 352 when(SrcType.isImm(s0.bits.srcType(1))) { 353 s1_data.src(1) := ImmExtractor( 354 s0.bits.common.imm, 355 s0.bits.immType, 356 s1_data.DataBits, 357 s1_data.params.immType.map(_.litValue) 358 ) 359 } 360 } 361 if (s1_data.params.hasJmpFu) { 362 when(SrcType.isPc(s0.bits.srcType(0))) { 363 s1_data.src(0) := SignExt(s0.bits.jmp.get.pc, XLEN) 364 } 365 } 366 } 367 // IQ(s0) --[Data]--> s1Reg ---------- end 368 } 369 } 370 371 private val fromIQFire = fromIQ.map(_.map(_.fire)) 372 private val toExuFire = toExu.map(_.map(_.fire)) 373 toIQs.zipWithIndex.foreach { 374 case(toIQ, iqIdx) => 375 toIQ.zipWithIndex.foreach { 376 case (toIU, iuIdx) => 377 // IU: issue unit 378 val og0resp = toIU.og0resp 379 og0resp.valid := fromIQ(iqIdx)(iuIdx).valid && (!fromIQFire(iqIdx)(iuIdx)) 380 og0resp.bits.respType := RSFeedbackType.rfArbitFail 381 og0resp.bits.success := false.B 382 og0resp.bits.addrOH := fromIQ(iqIdx)(iuIdx).bits.addrOH 383 384 val og1resp = toIU.og1resp 385 og1resp.valid := s1_toExuValid(iqIdx)(iuIdx) 386 og1resp.bits.respType := Mux(toExuFire(iqIdx)(iuIdx), RSFeedbackType.fuIdle, RSFeedbackType.fuBusy) 387 og1resp.bits.success := false.B 388 og1resp.bits.addrOH := s1_addrOHs(iqIdx)(iuIdx) 389 } 390 } 391 392 for (i <- toExu.indices) { 393 for (j <- toExu(i).indices) { 394 // s1Reg --[Ctrl]--> exu(s1) ---------- begin 395 // refs 396 val sinkData = toExu(i)(j).bits 397 // assign 398 toExu(i)(j).valid := s1_toExuValid(i)(j) 399 s1_toExuReady(i)(j) := toExu(i)(j).ready 400 sinkData := s1_toExuData(i)(j) 401 // s1Reg --[Ctrl]--> exu(s1) ---------- end 402 403 // s1Reg --[Data]--> exu(s1) ---------- begin 404 // data source1: preg read data 405 for (k <- sinkData.src.indices) { 406 val srcDataTypeSet: Set[DataConfig] = sinkData.params.getSrcDataType(k) 407 408 val readRfMap: Seq[(Bool, UInt)] = (Seq(None) :+ 409 (if (s1_intPregRData(i)(j).isDefinedAt(k) && srcDataTypeSet.intersect(IntRegSrcDataSet).nonEmpty) 410 Some(SrcType.isXp(s1_srcType(i)(j)(k)) -> s1_intPregRData(i)(j)(k)) 411 else None) :+ 412 (if (s1_vfPregRData(i)(j).isDefinedAt(k) && srcDataTypeSet.intersect(VfRegSrcDataSet).nonEmpty) 413 Some(SrcType.isVfp(s1_srcType(i)(j)(k))-> s1_vfPregRData(i)(j)(k)) 414 else None) 415 ).filter(_.nonEmpty).map(_.get) 416 if (readRfMap.nonEmpty) 417 sinkData.src(k) := Mux1H(readRfMap) 418 } 419 420 // data source2: extracted imm and pc saved in s1Reg 421 if (sinkData.params.immType.nonEmpty && sinkData.src.size > 1) { 422 when(SrcType.isImm(s1_srcType(i)(j)(1))) { 423 sinkData.src(1) := s1_toExuData(i)(j).src(1) 424 } 425 } 426 if (sinkData.params.hasJmpFu) { 427 when(SrcType.isPc(s1_srcType(i)(j)(0))) { 428 sinkData.src(0) := s1_toExuData(i)(j).src(0) 429 } 430 } 431 // s1Reg --[Data]--> exu(s1) ---------- end 432 } 433 } 434 435 if (env.AlwaysBasicDiff || env.EnableDifftest) { 436 val delayedCnt = 2 437 val difftestArchIntRegState = Module(new DifftestArchIntRegState) 438 difftestArchIntRegState.io.clock := clock 439 difftestArchIntRegState.io.coreid := io.hartId 440 difftestArchIntRegState.io.gpr := DelayN(intDebugRead.get._2, delayedCnt) 441 442 val difftestArchFpRegState = Module(new DifftestArchFpRegState) 443 difftestArchFpRegState.io.clock := clock 444 difftestArchFpRegState.io.coreid := io.hartId 445 difftestArchFpRegState.io.fpr := DelayN(fpDebugReadData.get, delayedCnt) 446 447 val difftestArchVecRegState = Module(new DifftestArchVecRegState) 448 difftestArchVecRegState.io.clock := clock 449 difftestArchVecRegState.io.coreid := io.hartId 450 difftestArchVecRegState.io.vpr := DelayN(vecDebugReadData.get, delayedCnt) 451 } 452} 453 454class DataPathIO()(implicit p: Parameters, params: BackendParams) extends XSBundle { 455 // params 456 private val intSchdParams = params.schdParams(IntScheduler()) 457 private val vfSchdParams = params.schdParams(VfScheduler()) 458 private val memSchdParams = params.schdParams(MemScheduler()) 459 // bundles 460 val hartId = Input(UInt(8.W)) 461 462 val flush: ValidIO[Redirect] = Flipped(ValidIO(new Redirect)) 463 464 val vconfigReadPort = new RfReadPort(XLEN, PhyRegIdxWidth) 465 466 val fromIntIQ: MixedVec[MixedVec[DecoupledIO[IssueQueueIssueBundle]]] = 467 Flipped(MixedVec(intSchdParams.issueBlockParams.map(_.genIssueDecoupledBundle))) 468 469 val fromMemIQ: MixedVec[MixedVec[DecoupledIO[IssueQueueIssueBundle]]] = 470 Flipped(MixedVec(memSchdParams.issueBlockParams.map(_.genIssueDecoupledBundle))) 471 472 val fromVfIQ = Flipped(MixedVec(vfSchdParams.issueBlockParams.map(_.genIssueDecoupledBundle))) 473 474 val toIntIQ = MixedVec(intSchdParams.issueBlockParams.map(_.genOGRespBundle)) 475 476 val toMemIQ = MixedVec(memSchdParams.issueBlockParams.map(_.genOGRespBundle)) 477 478 val toVfIQ = MixedVec(vfSchdParams.issueBlockParams.map(_.genOGRespBundle)) 479 480 val toIntExu: MixedVec[MixedVec[DecoupledIO[ExuInput]]] = intSchdParams.genExuInputBundle 481 482 val toFpExu: MixedVec[MixedVec[DecoupledIO[ExuInput]]] = MixedVec(vfSchdParams.genExuInputBundle) 483 484 val toMemExu: MixedVec[MixedVec[DecoupledIO[ExuInput]]] = memSchdParams.genExuInputBundle 485 486 val fromIntWb: MixedVec[RfWritePortWithConfig] = MixedVec(params.genIntWriteBackBundle) 487 488 val fromVfWb: MixedVec[RfWritePortWithConfig] = MixedVec(params.genVfWriteBackBundle) 489 490 val debugIntRat = Input(Vec(32, UInt(intSchdParams.pregIdxWidth.W))) 491 val debugFpRat = Input(Vec(32, UInt(vfSchdParams.pregIdxWidth.W))) 492 val debugVecRat = Input(Vec(32, UInt(vfSchdParams.pregIdxWidth.W))) 493 val debugVconfigRat = Input(UInt(vfSchdParams.pregIdxWidth.W)) 494 val debugVconfig = Output(UInt(XLEN.W)) 495 496} 497