added needed context and getting ready to implement execute

This commit is contained in:
Yehowshua Immanuel 2025-03-10 22:26:38 -04:00
parent b95b2b962a
commit 69f5cdee6a
7 changed files with 115 additions and 87 deletions

View file

@ -11,22 +11,22 @@ import DecodeTypes(
import Clash.Prelude
import Fetch(FetchResult (Instruction, InstructionException))
import Exceptions(Exception(..))
import Types(Insn)
import Types(Insn, Addr)
import RegFiles(RegVal(..))
import Util((|>))
data DecodeResult = Opcode Opcode
| DecodeException Exception
| InstructionException Exception
data DecodeResult = Opcode {opcode :: Opcode, insnAddr :: Addr}
| DecodeException {exception :: Exception, insnAddr :: Addr}
| InstructionException {exception :: Exception, insnAddr :: Addr}
deriving (Generic, Show, Eq, NFDataX)
decode :: FetchResult -> DecodeResult
decode (Instruction insn) =
decode (Instruction insn addr) =
case insnToOpcode insn of
Just opcode -> Opcode opcode
Nothing -> DecodeException |> IllegalInstruction insn
decode (Fetch.InstructionException exception) =
Decode.InstructionException exception
Just opcode -> Opcode opcode addr
Nothing -> DecodeException (IllegalInstruction insn) addr
decode (Fetch.InstructionException exception addr) =
Decode.InstructionException exception addr
insnToOpcode :: Insn -> Maybe Opcode
insnToOpcode insn =