xref: /XiangShan/src/main/scala/xiangshan/backend/datapath/DataSource.scala (revision c4fc226ad7a2197009ce1afff94b3636f87bb475)
1c0be7f33SXuan Hupackage xiangshan.backend.datapath
2c0be7f33SXuan Hu
3c0be7f33SXuan Huimport chisel3._
4c0be7f33SXuan Hu
5c0be7f33SXuan Huclass DataSource extends Bundle {
60dbae67aSxiaofeibao-xjtu  val value = UInt(3.W)
7c0be7f33SXuan Hu
80dbae67aSxiaofeibao-xjtu  def readReg: Bool = value(2)
9c0be7f33SXuan Hu
10*c4fc226aSxiaofeibao-xjtu  def readAnotherReg: Bool =  value === DataSource.anotherReg
11*c4fc226aSxiaofeibao-xjtu
120dbae67aSxiaofeibao-xjtu  def readZero: Bool = value === DataSource.zero
13c0be7f33SXuan Hu
140dbae67aSxiaofeibao-xjtu  def readForward: Bool = value === DataSource.forward
150dbae67aSxiaofeibao-xjtu
160dbae67aSxiaofeibao-xjtu  def readBypass: Bool = value === DataSource.bypass
170dbae67aSxiaofeibao-xjtu
180dbae67aSxiaofeibao-xjtu  def readImm: Bool = value === DataSource.imm
190dbae67aSxiaofeibao-xjtu
20c0be7f33SXuan Hu}
21c0be7f33SXuan Hu
22c0be7f33SXuan Huobject DataSource {
23c0be7f33SXuan Hu  def apply() = new DataSource
24c0be7f33SXuan Hu
250dbae67aSxiaofeibao-xjtu  def reg: UInt = "b100".U
26c0be7f33SXuan Hu
27*c4fc226aSxiaofeibao-xjtu  def anotherReg: UInt = "b101".U
28*c4fc226aSxiaofeibao-xjtu
290dbae67aSxiaofeibao-xjtu  // read int preg addr is 0
300dbae67aSxiaofeibao-xjtu  def zero: UInt = "b000".U
31c0be7f33SXuan Hu
320dbae67aSxiaofeibao-xjtu  def forward: UInt = "b001".U
33c0be7f33SXuan Hu
340dbae67aSxiaofeibao-xjtu  def bypass: UInt = "b010".U
350dbae67aSxiaofeibao-xjtu
360dbae67aSxiaofeibao-xjtu  def imm: UInt = "b011".U
37c0be7f33SXuan Hu
38c0be7f33SXuan Hu}
39c0be7f33SXuan Hu
40