xref: /XiangShan/src/main/scala/xiangshan/backend/datapath/DataSource.scala (revision 2d875144688c4876d32d2f9496a2caa51e83dfad)
1c0be7f33SXuan Hupackage xiangshan.backend.datapath
2c0be7f33SXuan Hu
3c0be7f33SXuan Huimport chisel3._
4c0be7f33SXuan Hu
5c0be7f33SXuan Huclass DataSource extends Bundle {
64fa640e4Ssinsanction  val value = UInt(4.W)
7c0be7f33SXuan Hu
84fa640e4Ssinsanction  def readReg: Bool = value(3)
9c0be7f33SXuan Hu
10712a039eSxiaofeibao-xjtu  def readRegOH: Bool = value === DataSource.reg
11712a039eSxiaofeibao-xjtu
12*2d875144Ssinsanction  def readRegCache: Bool = value === DataSource.regcache
13*2d875144Ssinsanction
14f8e432b7Sxiaofeibao  def readV0: Bool = value === DataSource.v0
15c4fc226aSxiaofeibao-xjtu
160dbae67aSxiaofeibao-xjtu  def readZero: Bool = value === DataSource.zero
17c0be7f33SXuan Hu
180dbae67aSxiaofeibao-xjtu  def readForward: Bool = value === DataSource.forward
190dbae67aSxiaofeibao-xjtu
200dbae67aSxiaofeibao-xjtu  def readBypass: Bool = value === DataSource.bypass
210dbae67aSxiaofeibao-xjtu
224fa640e4Ssinsanction  def readBypass2: Bool = value === DataSource.bypass2
234fa640e4Ssinsanction
240dbae67aSxiaofeibao-xjtu  def readImm: Bool = value === DataSource.imm
250dbae67aSxiaofeibao-xjtu
26c0be7f33SXuan Hu}
27c0be7f33SXuan Hu
28c0be7f33SXuan Huobject DataSource {
29c0be7f33SXuan Hu  def apply() = new DataSource
30c0be7f33SXuan Hu
314fa640e4Ssinsanction  def reg: UInt = "b1000".U
32c0be7f33SXuan Hu
33*2d875144Ssinsanction  def regcache: UInt = "b0110".U
34*2d875144Ssinsanction
35*2d875144Ssinsanction  def v0: UInt = "b0101".U
36c4fc226aSxiaofeibao-xjtu
370dbae67aSxiaofeibao-xjtu  // read int preg addr is 0
384fa640e4Ssinsanction  def zero: UInt = "b0000".U
39c0be7f33SXuan Hu
404fa640e4Ssinsanction  def forward: UInt = "b0001".U
41c0be7f33SXuan Hu
424fa640e4Ssinsanction  def bypass: UInt = "b0010".U
430dbae67aSxiaofeibao-xjtu
444fa640e4Ssinsanction  def bypass2: UInt = "b0011".U
454fa640e4Ssinsanction
464fa640e4Ssinsanction  def imm: UInt = "b0100".U
47c0be7f33SXuan Hu
48c0be7f33SXuan Hu}
49c0be7f33SXuan Hu
50