From 0125e50b024a98a843005a06e09ccc70ab185f04 Mon Sep 17 00:00:00 2001 From: cbezaitis Date: Tue, 17 Oct 2023 16:27:41 +0200 Subject: [PATCH] auipc && ltu bug fix --- src/test/scala/RISCV/Ops.scala | 2 +- src/test/scala/RISCV/VM.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/scala/RISCV/Ops.scala b/src/test/scala/RISCV/Ops.scala index f129986..af7f3d2 100644 --- a/src/test/scala/RISCV/Ops.scala +++ b/src/test/scala/RISCV/Ops.scala @@ -32,7 +32,7 @@ object Ops { case object GE extends Comparison { def run(rs1Val: Int, rs2Val: Int): Boolean = rs1Val >= rs2Val } case object LT extends Comparison { def run(rs1Val: Int, rs2Val: Int): Boolean = rs1Val < rs2Val } case object GEU extends Comparison { def run(rs1Val: Int, rs2Val: Int): Boolean = !(rs1Val `u>` rs2Val) } - case object LTU extends Comparison { def run(rs1Val: Int, rs2Val: Int): Boolean = rs1Val `u>` rs2Val } + case object LTU extends Comparison { def run(rs1Val: Int, rs2Val: Int): Boolean = rs2Val `u>` rs1Val } case class Branch(rs1: Reg, rs2: Reg, dst: Label, comp: Comparison) extends Op with SType object Branch{ diff --git a/src/test/scala/RISCV/VM.scala b/src/test/scala/RISCV/VM.scala index cf597ba..f47b66b 100644 --- a/src/test/scala/RISCV/VM.scala +++ b/src/test/scala/RISCV/VM.scala @@ -89,7 +89,7 @@ case class VM( private def executeAUIPC(op: AUIPC) = { - val (regUpdate, nextRegs) = regs + (op.rd -> (pc.value << 12)) + val (regUpdate, nextRegs) = regs + (op.rd -> (pc.value + (op.imm.value << 12))) val nextVM = this.copy(regs = nextRegs) Right(step(nextVM, regUpdate.toList:_*)) }