Skip to content

Commit

Permalink
Added comples test for ADDI
Browse files Browse the repository at this point in the history
  • Loading branch information
mrLSD committed Oct 4, 2019
1 parent 4714eb4 commit d1ea164
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,24 @@ open ISA.RISCV.Decode

[<Fact>]
let ``ADDI to zero`` () =
let instr = 0x00300113L
// Init MachineState
let addr = 0x80000000L
let mstate = MachineState.InitMachineState Map.empty RV32i true
let mstate = mstate.setPC 0x80000000L

// x2 = x0 + 3
let instr = 0x00300113L
let decodedInstr = I.DecodeI instr
Assert.NotEqual(decodedInstr, I.None)
let mstate = ExecuteI.ExecuteI decodedInstr mstate
Assert.Equal(0x80000004L, mstate.PC)

// x3 = x2 + 5
let instr = 0x00510193L
let decodedInstr = I.DecodeI instr
Assert.NotEqual(decodedInstr, I.None)
let mstate = ExecuteI.ExecuteI decodedInstr mstate

Assert.Equal(mstate.getRegister 2, 3L)
Assert.Equal(mstate.getRegister 3, 8L)

Assert.Equal(addr + 8L, mstate.PC)

0 comments on commit d1ea164

Please sign in to comment.