1package xiangshan.backend.datapath 2 3import chisel3.util.log2Up 4import xiangshan.backend.datapath.DataConfig._ 5 6object WbConfig { 7 sealed abstract class WbConfig() { 8 val port: Int 9 def dataCfg: DataConfig 10 def numPreg: Int = 0 11 def dataWidth: Int = dataCfg.dataWidth 12 13 def pregIdxWidth = log2Up(numPreg) 14 15 def writeInt = dataCfg == IntData() 16 def writeFp = dataCfg == FpData() 17 def writeVec = dataCfg == VecData() 18 19 override def toString: String = { 20 var res = dataCfg match { 21 case IntData() => "I" 22 case FpData() => "F" 23 case VecData() => "V" 24 case _ => "?" 25 } 26 res += s"($port)" 27 res 28 } 29 } 30 31 sealed abstract class ExuWB extends WbConfig 32 33 sealed abstract class PregWB extends ExuWB { 34 val priority: Int 35 } 36 37 case class IntWB( 38 port : Int = -1, 39 priority: Int = Int.MaxValue, 40 ) extends PregWB { 41 def dataCfg: DataConfig = IntData() 42 override def numPreg: Int = 160 43 } 44 45 case class VfWB( 46 port : Int = -1, 47 priority: Int = Int.MaxValue, 48 ) extends PregWB { 49 def dataCfg: DataConfig = VecData() 50 override def numPreg: Int = 160 51 } 52 53 case class VecWB( 54 port: Int = -1, 55 priority: Int = Int.MaxValue, 56 ) extends PregWB { 57 def dataCfg: DataConfig = VecData() 58 59 override def numPreg: Int = 160 60 } 61 62 case class CtrlWB( 63 port: Int = -1, 64 ) extends WbConfig { 65 val priority: Int = Int.MaxValue 66 override def dataCfg: DataConfig = NoData() 67 } 68 69 // Todo: use it 70 sealed trait WBSource 71 case class WBFromInt() extends WBSource 72 case class WBFromMem() extends WBSource 73 case class WBFromVec() extends WBSource 74 case class WBFromFp() extends WBSource 75} 76 77