1package xiangshan.backend.datapath 2 3import chisel3._ 4 5class DataSource extends Bundle { 6 val value = UInt(3.W) 7 8 def readReg: Bool = value(2) 9 10 def readRegOH: Bool = value === DataSource.reg 11 12 def readAnotherReg: Bool = value === DataSource.anotherReg 13 14 def readZero: Bool = value === DataSource.zero 15 16 def readForward: Bool = value === DataSource.forward 17 18 def readBypass: Bool = value === DataSource.bypass 19 20 def readImm: Bool = value === DataSource.imm 21 22} 23 24object DataSource { 25 def apply() = new DataSource 26 27 def reg: UInt = "b100".U 28 29 def anotherReg: UInt = "b101".U 30 31 // read int preg addr is 0 32 def zero: UInt = "b000".U 33 34 def forward: UInt = "b001".U 35 36 def bypass: UInt = "b010".U 37 38 def imm: UInt = "b011".U 39 40} 41 42