{-# LANGUAGE DataKinds #-} {-# LANGUAGE NumericUnderscores #-} module DecodeTypes( FUNCT7, RS2, RS1, FUNCT3, RD, OPCODE, IMM12, IMM13, IMM20, IMM21, RTypeFields(..), ITypeFields(..), STypeFields(..), BTypeFields(..), UTypeFields(..), JTypeFields(..), Opcode(..) ) where import Clash.Prelude import RegFiles(RegFileIdx, RegVal) type FUNCT7 = Unsigned 7 type RS2 = RegVal type RS1 = RegVal type RD = RegFileIdx type FUNCT3 = Unsigned 3 type OPCODE = Unsigned 7 type IMM12 = Unsigned 12 type IMM13 = Unsigned 13 type IMM20 = Unsigned 20 type IMM21 = Unsigned 21 data RTypeFields = RTypeFields RD FUNCT3 RS1 RS2 FUNCT7 deriving (Generic, Show, Eq, NFDataX) data ITypeFields = ITypeFields RD FUNCT3 RS1 IMM12 deriving (Generic, Show, Eq, NFDataX) data STypeFields = STypeFields FUNCT3 RS1 RS2 IMM12 deriving (Generic, Show, Eq, NFDataX) data BTypeFields = BTypeFields FUNCT3 RS1 RS2 IMM13 deriving (Generic, Show, Eq, NFDataX) data UTypeFields = UTypeFields RD IMM20 deriving (Generic, Show, Eq, NFDataX) data JTypeFields = JTypeFields RD IMM21 deriving (Generic, Show, Eq, NFDataX) data Opcode = -- R-Type ADD RTypeFields | SUB RTypeFields | XOR RTypeFields | OR RTypeFields | AND RTypeFields | SLL RTypeFields | SRL RTypeFields | SRA RTypeFields | SLT RTypeFields | SLTU RTypeFields -- I-Type | ADDI ITypeFields | XORI ITypeFields | ORI ITypeFields | ANDI ITypeFields | SLLI ITypeFields | SRLI ITypeFields | SRAI ITypeFields | SLTI ITypeFields | SLTIU ITypeFields | LB ITypeFields | LH ITypeFields | LW ITypeFields | LBU ITypeFields | LHU ITypeFields | ECALL ITypeFields | EBREAK ITypeFields -- S-Type | SB STypeFields | SH STypeFields | SW STypeFields -- B-Type | BEQ BTypeFields | BNE BTypeFields | BLT BTypeFields | BGE BTypeFields | BLTU BTypeFields | BGEU BTypeFields -- J-Type | JAL JTypeFields | JALR ITypeFields -- U-Type | LUI UTypeFields | AUIPC UTypeFields deriving (Generic, Show, Eq, NFDataX)