xref: /XiangShan/src/main/scala/xiangshan/backend/datapath/DataSource.scala (revision 039cdc35f5f3b68b6295ec5ace90f22a77322e02)
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 readV0: Bool = value === DataSource.v0
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 readBypass2: Bool = value === DataSource.bypass2
21
22  def readImm: Bool = value === DataSource.imm
23
24}
25
26object DataSource {
27  def apply() = new DataSource
28
29  def reg: UInt = "b1000".U
30
31  def v0: UInt = "b1001".U
32
33  // read int preg addr is 0
34  def zero: UInt = "b0000".U
35
36  def forward: UInt = "b0001".U
37
38  def bypass: UInt = "b0010".U
39
40  def bypass2: UInt = "b0011".U
41
42  def imm: UInt = "b0100".U
43
44}
45
46