1package xiangshan.backend.datapath 2 3import chisel3._ 4 5class DataSource extends Bundle { 6 val value = UInt(4.W) 7 8 def readReg: Bool = value(3) 9 10 def readRegOH: Bool = value === DataSource.reg 11 12 def readRegCache: Bool = value === DataSource.regcache 13 14 def readV0: Bool = value === DataSource.v0 15 16 def readZero: Bool = value === DataSource.zero 17 18 def readForward: Bool = value === DataSource.forward 19 20 def readBypass: Bool = value === DataSource.bypass 21 22 def readBypass2: Bool = value === DataSource.bypass2 23 24 def readImm: Bool = value === DataSource.imm 25 26} 27 28object DataSource { 29 def apply() = new DataSource 30 31 def reg: UInt = "b1000".U 32 33 def regcache: UInt = "b0110".U 34 35 def v0: UInt = "b0101".U 36 37 // read int preg addr is 0 38 def zero: UInt = "b0000".U 39 40 def forward: UInt = "b0001".U 41 42 def bypass: UInt = "b0010".U 43 44 def bypass2: UInt = "b0011".U 45 46 def imm: UInt = "b0100".U 47 48} 49 50