forked from Yehowshua/RiscV-Formal
90 lines
2.1 KiB
Haskell
90 lines
2.1 KiB
Haskell
|
{-# LANGUAGE DataKinds #-}
|
||
|
{-# LANGUAGE NumericUnderscores #-}
|
||
|
|
||
|
module Isa.Forms(
|
||
|
FUNCT7, RS2, RS1, FUNCT3, RD, OPCODE,
|
||
|
IMM12, IMM13, IMM20, IMM21,
|
||
|
|
||
|
RTypeFields(..), ITypeFields(..), STypeFields(..),
|
||
|
BTypeFields(..), UTypeFields(..), JTypeFields(..),
|
||
|
|
||
|
Opcode(..)
|
||
|
) where
|
||
|
import Clash.Prelude
|
||
|
import Types(Mem, Addr, Insn)
|
||
|
|
||
|
type FUNCT7 = Unsigned 7
|
||
|
type RS2 = Unsigned 5
|
||
|
type RS1 = Unsigned 5
|
||
|
type FUNCT3 = Unsigned 3
|
||
|
type RD = Unsigned 5
|
||
|
type OPCODE = Unsigned 7
|
||
|
|
||
|
type IMM12 = Unsigned 12
|
||
|
type IMM13 = Unsigned 13
|
||
|
type IMM20 = Unsigned 20
|
||
|
type IMM21 = Unsigned 21
|
||
|
|
||
|
data RTypeFields = RTypeFields OPCODE RD FUNCT3 RS1 RS2 FUNCT7 deriving (Generic, Show, Eq, NFDataX)
|
||
|
data ITypeFields = ITypeFields OPCODE RD FUNCT3 RS1 IMM12 deriving (Generic, Show, Eq, NFDataX)
|
||
|
data STypeFields = STypeFields OPCODE FUNCT3 RS1 RS2 IMM12 deriving (Generic, Show, Eq, NFDataX)
|
||
|
data BTypeFields = BTypeFields OPCODE FUNCT3 RS1 RS2 IMM13 deriving (Generic, Show, Eq, NFDataX)
|
||
|
data UTypeFields = UTypeFields OPCODE RD IMM20 deriving (Generic, Show, Eq, NFDataX)
|
||
|
data JTypeFields = JTypeFields OPCODE 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
|
||
|
|
||
|
| Unimplemented
|
||
|
deriving (Generic, Show, Eq, NFDataX)
|