1import chisel3._ 2import chisel3.util._ 3 4package object xiangshan { 5 object SrcType { 6 def reg = "b00".U 7 def pc = "b01".U 8 def imm = "b01".U 9 def fp = "b10".U 10 11 def isReg(srcType: UInt) = srcType===reg 12 def isPc(srcType: UInt) = srcType===pc 13 def isImm(srcType: UInt) = srcType===imm 14 def isFp(srcType: UInt) = srcType===fp 15 def isPcImm(srcType: UInt) = isPc(srcType) || isImm(srcType) 16 def isRegFp(srcType: UInt) = isReg(srcType) || isFp(srcType) 17 18 def apply() = UInt(2.W) 19 } 20 21 object SrcState { 22 def busy = "b00".U 23 def rdy = "b01".U 24 def specRdy = "b10".U // speculative ready, for future use 25 def apply() = UInt(2.W) 26 } 27 28 object FuType extends HasXSParameter { 29 def num = exuParameters.NRFuType 30 31 def jmp = "b0000".U 32 def i2f = "b0001".U 33 def csr = "b0010".U 34 def alu = "b0011".U 35 def mul = "b0100".U 36 def div = "b0101".U 37 38 def fmac = "b1000".U 39 def fmisc = "b1001".U 40 def fDivSqrt = "b1010".U 41 42 def ldu = "b1100".U 43 def stu = "b1101".U 44 45 def apply() = UInt(log2Up(num).W) 46 47 def isIntExu(fuType: UInt) = !fuType(3) 48 def isFpExu(fuType: UInt) = fuType(3, 2) === "b10".U 49 def isMemExu(fuType: UInt) = fuType(3, 2) === "b11".U 50 51 val functionNameMap = Map( 52 jmp.litValue() -> "jmp", 53 i2f.litValue() -> "int to float", 54 csr.litValue() -> "csr", 55 alu.litValue() -> "alu", 56 mul.litValue() -> "mul", 57 div.litValue() -> "div", 58 fmac.litValue() -> "fmac", 59 fmisc.litValue() -> "fmisc", 60 fDivSqrt.litValue() -> "fdiv/fsqrt", 61 ldu.litValue() -> "load", 62 stu.litValue() -> "store" 63 ) 64 65 } 66 67 object FuOpType extends HasXSParameter { 68 def apply() = UInt(exuParameters.FuOpWidth.W) 69 } 70 71 object BTBtype { 72 def B = "b00".U // branch 73 def J = "b01".U // jump 74 def I = "b10".U // indirect 75 def R = "b11".U // return 76 77 def apply() = UInt(2.W) 78 } 79} 80