fixed execution of R type instructions
This commit is contained in:
parent
7066df0936
commit
4428f7f196
3 changed files with 5 additions and 15 deletions
|
@ -61,15 +61,15 @@ execute (Opcode opcode addr) = case opcode of
|
|||
SLL (RTypeFields rd _ rs1 rs2 _) ->
|
||||
let val1 = extractRegVal rs1
|
||||
val2 = extractRegVal rs2
|
||||
in WriteBackGPR rd (val1 `shiftL` fromIntegral (val2 .&. 0x3F))
|
||||
in WriteBackGPR rd (val1 `shiftL` fromIntegral val2)
|
||||
SRL (RTypeFields rd _ rs1 rs2 _) ->
|
||||
let val1 = extractRegVal rs1
|
||||
val2 = extractRegVal rs2
|
||||
in WriteBackGPR rd (val1 `shiftR` fromIntegral (val2 .&. 0x3F))
|
||||
in WriteBackGPR rd (val1 `shiftR` fromIntegral val2)
|
||||
SRA (RTypeFields rd _ rs1 rs2 _) ->
|
||||
let val1 = unpack (pack (extractRegVal rs1) :: BitVector 64) :: Signed 64
|
||||
val2 = extractRegVal rs2
|
||||
in WriteBackGPR rd (bitCoerce (val1 `shiftR` fromIntegral (val2 .&. 0x3F)))
|
||||
in WriteBackGPR rd (bitCoerce (val1 `shiftR` fromIntegral val2))
|
||||
SLT (RTypeFields rd _ rs1 rs2 _) ->
|
||||
let val1 = unpack (pack (extractRegVal rs1) :: BitVector 64) :: Signed 64
|
||||
val2 = unpack (pack (extractRegVal rs2) :: BitVector 64) :: Signed 64
|
||||
|
@ -209,4 +209,4 @@ execute (Opcode opcode addr) = case opcode of
|
|||
in if rd /= 0 then WriteBackGPR rd (addr + 4) else Jump (addr + offset)
|
||||
|
||||
execute (Decode.DecodeException e addr) = Execute.DecodeException e addr
|
||||
execute (Decode.InstructionException e addr) = Execute.InstructionException e addr
|
||||
execute (Decode.InstructionException e addr) = Execute.InstructionException e addr
|
||||
|
|
Reference in a new issue