FloatBlock.scala 2.4 KB
Newer Older
1 2 3 4 5
package xiangshan.backend

import chisel3._
import chisel3.util._
import xiangshan._
6 7
import xiangshan.backend.regfile.Regfile
import xiangshan.backend.exu._
Y
Yinan Xu 已提交
8
import xiangshan.backend.issue.ReservationStationNew
9 10 11 12 13 14 15 16 17 18 19 20 21


class FpBlockToCtrlIO extends XSBundle {
  // TODO: should not be FpExuCnt
  val wbIntRegs = Vec(exuParameters.FpExuCnt, Flipped(ValidIO(new ExuOutput)))
  val wbFpRegs = Vec(exuParameters.FpExuCnt, Flipped(ValidIO(new ExuOutput)))
  val numExist = Vec(exuParameters.FpExuCnt, Output(UInt(log2Ceil(IssQueSize).W)))
}

class FloatBlock extends XSModule {
  val io = IO(new Bundle {
    val fromCtrlBlock = Flipped(new CtrlToFpBlockIO)
    val toCtrlBlock = new FpBlockToCtrlIO
Y
Yinan Xu 已提交
22 23 24
    // TODO: ramdonly set 5
    val writebackData = Vec(5, Input(UInt(XLEN.W)))
    val extraListenPorts = Vec(5, Flipped(DecoupledIO(new ExuOutput)))
25 26
  })

27 28 29 30 31 32 33 34 35 36 37 38 39
  // floating-point regfile
  val regfile = Module(new Regfile(
    numReadPorts = NRFpReadPorts,
    numWirtePorts = NRFpWritePorts,
    hasZero = false
  ))

  val fmacExeUnits = Array.tabulate(exuParameters.FmacCnt)(_ => Module(new FmacExeUnit))
  val fmiscExeUnits = Array.tabulate(exuParameters.FmiscCnt)(_ => Module(new FmiscExeUnit))
  val exeUnits = fmacExeUnits ++ fmiscExeUnits
  val exuConfigs = exeUnits.map(_.config)

  // generate reservation stations
Y
Yinan Xu 已提交
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
  val exeWbReqs = exeUnits.map(_.io.out)
  val writebackData = exuConfigs.zip(exeWbReqs).filter(x => x._1.hasCertainLatency && x._1.writeIntRf).map(_._2.bits.data)
  val extraListenPorts = exuConfigs.zip(exeWbReqs).filter(x => x._1.hasUncertainlatency && x._1.writeIntRf).map(_._2)

  val rsConfigs = Seq(5, 5, 5, 5, -1, -1)
  val reservationStations = exuConfigs.zipWithIndex.map({ case (cfg, i) =>
    val rs = Module(new ReservationStationNew(cfg, 5, 4, fixedDelay = rsConfigs(i), feedback = true))

    rs.io.redirect <> io.fromCtrlBlock.redirect
    rs.io.numExist <> io.toCtrlBlock.numExist(i)
    rs.io.enqCtrl <> io.fromCtrlBlock.enqIqCtrl(i)
    rs.io.enqData <> io.fromCtrlBlock.enqIqData(i)

    rs.io.writeBackedData <> writebackData ++ io.writebackData
    for((x, y) <- rs.io.extraListenPorts.zip(extraListenPorts ++ io.extraListenPorts)){
      x.valid := y.fire()
      x.bits := y.bits
    }

    exeUnits(i).io.in <> rs.io.deq
    exeUnits(i).io.redirect <> io.fromCtrlBlock.redirect
    rs.io.tlbFeedback := DontCare

    rs.suggestName(s"rs_${cfg.name}")
    rs
  })
66 67 68

  // connect writeback
  // val wbArbiter = 
69 70

}