Files
tatu/src/main/scala/common/Consts.scala
2026-06-26 08:20:25 +00:00

36 lines
914 B
Scala

import chisel3._
import chisel3.util._
object Consts {
val ResetVector = "h80000000".U(64.W)
val OpClassWidth = 4
val OP_NONE = 0.U(OpClassWidth.W)
val OP_ALU = 1.U(OpClassWidth.W)
val OP_BRANCH = 2.U(OpClassWidth.W)
val OP_LOAD = 3.U(OpClassWidth.W)
val OP_STORE = 4.U(OpClassWidth.W)
val OP_SYSTEM = 5.U(OpClassWidth.W)
val OP_FP = 6.U(OpClassWidth.W)
val ALU_ADD = 0.U(5.W)
val ALU_SUB = 1.U(5.W)
val ALU_SLL = 2.U(5.W)
val ALU_SLT = 3.U(5.W)
val ALU_SLTU = 4.U(5.W)
val ALU_XOR = 5.U(5.W)
val ALU_SRL = 6.U(5.W)
val ALU_SRA = 7.U(5.W)
val ALU_OR = 8.U(5.W)
val ALU_AND = 9.U(5.W)
val ALU_MUL = 10.U(5.W)
val ALU_DIV = 11.U(5.W)
val ALU_DIVU = 12.U(5.W)
val ALU_REM = 13.U(5.W)
val ALU_REMU = 14.U(5.W)
val ALU_COPY_B = 15.U(5.W)
def signExtend(value: UInt, from: Int, to: Int = 64): UInt =
Cat(Fill(to - from, value(from - 1)), value(from - 1, 0))
}